home / skills / upstash / context7 / context7-cli

context7-cli skill

/skills/context7-cli

This skill helps you fetch up-to-date library docs, manage AI coding skills, and configure Context7 MCP for streamlined coding workflows.

npx playbooks add skill upstash/context7 --skill context7-cli

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
2.9 KB
---
name: context7-cli
description: Use the ctx7 CLI to fetch library documentation, manage AI coding skills, and configure Context7 MCP. Activate when the user mentions "ctx7" or "context7", needs current docs for any library, wants to install/search/generate skills, or needs to set up Context7 for their AI coding agent.
---

# ctx7 CLI

The Context7 CLI does three things: fetches up-to-date library documentation, manages AI coding skills, and sets up Context7 MCP for your editor.

Make sure the CLI is up to date before running commands:

```bash
npm install -g ctx7@latest
```

Or run directly without installing:

```bash
npx ctx7@latest <command>
```

## What this skill covers

- **[Documentation](references/docs.md)** — Fetch current docs for any library. Use when writing code, verifying API signatures, or when training data may be outdated.
- **[Skills management](references/skills.md)** — Install, search, suggest, list, remove, and generate AI coding skills.
- **[Setup](references/setup.md)** — Configure Context7 MCP for Claude Code / Cursor / OpenCode.

## Quick Reference

```bash
# Documentation
ctx7 library <name> <query>           # Step 1: resolve library ID
ctx7 docs <libraryId> <query>         # Step 2: fetch docs

# Skills
ctx7 skills install /owner/repo       # Install from a repo (interactive)
ctx7 skills install /owner/repo name  # Install a specific skill
ctx7 skills search <keywords>         # Search the registry
ctx7 skills suggest                   # Auto-suggest based on project deps
ctx7 skills list                      # List installed skills
ctx7 skills remove <name>             # Uninstall a skill
ctx7 skills generate                  # Generate a custom skill with AI (requires login)

# Setup
ctx7 setup                            # Configure Context7 MCP (interactive)
ctx7 login                            # Log in for higher rate limits + skill generation
ctx7 whoami                           # Check current login status
```

## Authentication

```bash
ctx7 login               # Opens browser for OAuth
ctx7 login --no-browser  # Prints URL instead of opening browser
ctx7 logout              # Clear stored tokens
ctx7 whoami              # Show current login status (name + email)
```

Most commands work without login. Exceptions: `skills generate` always requires it; `ctx7 setup` requires it unless `--api-key` or `--oauth` is passed. Login also unlocks higher rate limits on docs commands.

Set an API key via environment variable to skip interactive login entirely:

```bash
export CONTEXT7_API_KEY=your_key
```

## Common Mistakes

- Library IDs require a `/` prefix — `/facebook/react` not `facebook/react`
- Always run `ctx7 library` first — `ctx7 docs react "hooks"` will fail without a valid ID
- Repository format for skills is `/owner/repo` — e.g., `ctx7 skills install /anthropics/skills`
- `skills generate` requires login — run `ctx7 login` first

Overview

This skill provides a command-line interface for fetching up-to-date library documentation, managing AI coding skills, and configuring the Context7 MCP for code editors. It centralizes tasks you need when writing code against libraries with possibly stale training data and when installing or generating AI-powered coding capabilities. Use it to keep documentation current, manage a skills registry, and set up Context7 in your editor.

How this skill works

The CLI resolves library identities, fetches live docs, and returns precise API signatures and examples. It also lets you search, install, list, remove, suggest, and generate AI coding skills (generation requires login). Finally, an interactive setup flow configures Context7 MCP for supported editors and services, with non-interactive options via API key or flags.

When to use it

  • You need current documentation or API signatures for a library that may be newer than the model's training data.
  • You want to search, install, or remove AI coding skills from the Context7 registry.
  • You want to auto-suggest relevant skills based on your project's dependencies.
  • You need to configure Context7 MCP for Claude Code, Cursor, OpenCode, or similar editors.
  • You want to generate a custom skill using AI (requires authentication).

Best practices

  • Run npm install -g ctx7@latest or use npx ctx7@latest to ensure the CLI is up to date.
  • Always run ctx7 library <name> to resolve the library ID (it requires a leading slash like /owner/name).
  • Set CONTEXT7_API_KEY in your environment for non-interactive workflows and higher rate limits.
  • Log in with ctx7 login before running commands that require authentication, especially skills generate.
  • Use the interactive ctx7 setup for editor integration, or pass --api-key/--oauth for automated CI setups.

Example use cases

  • Fetch documentation: resolve a library ID then fetch docs for a specific function or topic in your editor workflow.
  • Install skills: add community skills from a GitHub repo using ctx7 skills install /owner/repo.
  • Generate a custom skill: run ctx7 skills generate after logging in to produce a tailored coding assistant for your repo.
  • Project onboarding: run ctx7 skills suggest to automatically recommend skills based on package.json or other deps.
  • Editor integration: run ctx7 setup to configure Context7 MCP for an AI code editor, enabling live docs and skills.

FAQ

Do I always need to log in to use ctx7?

No. Most commands work without login, but skills generate always requires login and setup may require authentication unless you provide --api-key or --oauth.

Why did ctx7 docs fail for a library name?

You must first resolve the library ID with ctx7 library <name>, and the ID requires a leading slash (for example /facebook/react).