Context7 is a platform that injects up-to-date library documentation straight into your AI coding assistant's context, eliminating code suggestions based on outdated APIs. The ctx7 CLI runs with npx ctx7 (no install required) and connects to Claude Code, Cursor, or OpenCode using a single ctx7 setup command.
What is Context7 and why does it matter?
When you use AI coding tools, you often get code based on old APIs: wrong function signatures, changed import paths, or outdated examples. This is because LLMs are trained on data with a cutoff date. They don't know about recent changes, like updates in Next.js, or deprecated APIs.
Context7 solves this by indexing docs for 9,000+ libraries and serving them to your AI assistant in real time. When you ask your coding agent a question, Context7 fetches current, version-specific docs and injects them into the context window before the model generates its response.
The result: your AI coding tool produces code that matches today's APIs.
The ctx7 CLI provides:
- Direct library docs fetch in your terminal
- AI coding skills management (prompt files that enhance your agent)
- Context7 MCP server configuration for Claude Code, Cursor, or OpenCode
đź’ˇ If you're building API integrations, Apidog handles API testing: send, organize, and automate API requests for free. Use Context7 to keep your AI assistant up to date, Apidog to verify your API calls.
Installing ctx7
Requirement: Node.js 18+ (node --version to check).
Run without installing
Try ctx7 instantly using npx:
npx ctx7 --help
npx ctx7 library react
This downloads the latest version each run—good for occasional use.
Install globally
For regular use, install globally:
npm install -g ctx7
ctx7 --version
Now you can use ctx7 directly without npx.
Setting up Context7 for your AI coding agent
The ctx7 setup command connects Context7 to your AI coding environment. It authenticates via OAuth, generates an API key, and writes the config.
Interactive setup
ctx7 setup
This prompts for your agent and preferred mode (CLI + Skills vs. MCP). To skip prompts:
ctx7 setup --yes
Target a specific agent
ctx7 setup --claude # Claude Code (~/.claude/skills or MCP config)
ctx7 setup --cursor # Cursor (~/.cursor/skills or MCP config)
ctx7 setup --opencode # OpenCode
Use an existing API key
If you have a Context7 API key from context7.com/dashboard:
ctx7 setup --api-key YOUR_API_KEY
Project-level vs. global setup
Global is default. For project-only config:
ctx7 setup --project
Two modes: CLI + Skills vs. MCP
CLI + Skills mode: Installs a SKILL.md file so your AI agent runs ctx7 commands for docs—no MCP server needed.
ctx7 setup --cli --claude # Installs skill to ~/.claude/skills
ctx7 setup --cli --cursor # Installs skill to ~/.cursor/skills
ctx7 setup --cli --universal # Installs to ~/.config/agents/skills
MCP Server mode: Registers Context7 as a Model Context Protocol server. Documentation fetching is automatic and invisible.
Sample MCP config:
{
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
Or add to Claude Code via CLI:
claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
Authentication
ctx7 login # OAuth browser login
ctx7 whoami # Check your login
ctx7 logout # Remove credentials
You can also set the API key as an environment variable:
export CONTEXT7_API_KEY=your_key_here
Login is only needed for skill generation and some setup. Basic docs lookup works without it.
Telemetry
Context7 collects anonymous usage data by default. To disable:
export CTX7_TELEMETRY_DISABLED=1
Fetching library documentation from the terminal
ctx7 is a standalone docs lookup tool, even without an AI agent.
Resolve a library name
ctx7 library react
ctx7 library nextjs "app router setup"
ctx7 library prisma "database relations"
ctx7 library express --json
Returns the library's canonical ID and metadata (snippet count, reputation, version).
Example output for ctx7 library nextjs:
Library: /vercel/next.js
Snippets: 4,820
Reputation: high
Version: 15.2.0
Fetch documentation
With a library ID, use:
ctx7 docs /facebook/react "useEffect cleanup"
ctx7 docs /vercel/next.js "middleware authentication"
ctx7 docs /prisma/prisma "one-to-many relations"
ctx7 docs /facebook/react "hooks" --json
This returns documentation snippets for your query from the current version. Outputs can be piped to files or tools.
Skip ctx7 library if you know the library ID.
Managing AI coding skills
Skills are SKILL.md files granting your AI agent special instructions or knowledge.
Context7 hosts a registry of community skills. You can search, install, generate, and remove skills.
Search for skills
ctx7 skills search pdf
ctx7 skills search "stripe payments"
ctx7 skills search "react testing"
Install a skill
ctx7 skills install /anthropics/skills pdf
ctx7 skills install /anthropics/skills pdf --cursor # For Cursor
ctx7 skills install /anthropics/skills pdf --claude # For Claude Code
Install globally (all projects):
ctx7 skills install /anthropics/skills pdf --global
Get suggestions based on your project
ctx7 skills suggest
Scans your project, detects libraries/frameworks, and recommends relevant skills.
List installed skills
ctx7 skills list # All
ctx7 skills list --claude # Claude Code only
ctx7 skills list --cursor # Cursor only
Remove a skill
ctx7 skills remove pdf
Generate a custom skill with AI
With a paid account, generate a custom skill:
ctx7 login
ctx7 skills generate
The CLI guides you: pick a library, describe the skill, and it generates a tailored SKILL.md.
Skills are portable. The SKILL.md format follows the Agent Skills standard—compatible across Claude Code, Cursor, VS Code Copilot, OpenCode, and more.
Free: 6 skill generations/week. Pro: 10/week.
Shorthand aliases:
| Full command | Alias |
|---|---|
ctx7 skills install |
ctx7 si |
ctx7 skills search |
ctx7 ss |
ctx7 skills generate |
ctx7 skills gen or ctx7 skills g
|
Using Context7 in your AI prompts
Once set up, use Context7 in your daily workflow:
The "use context7" pattern
In MCP mode, add "use context7" to prompts:
Create a Next.js middleware that checks JWT in cookies and redirects unauthenticated users to /login. use context7
Set up a Prisma schema with user and post models and a one-to-many relation. use context7
How do I configure the App Router layout in Next.js 15? use context7
The agent fetches current docs automatically.
Reference a specific library
To target certain libraries:
Implement Supabase authentication in a Next.js app.
use library /supabase/supabase for Supabase and /vercel/next.js for Next.js routing.
Auto-invoke without typing "use context7"
Add a rule to your agent to always fetch docs automatically.
For Claude Code, add to CLAUDE.md:
Always use Context7 MCP tools when generating code that uses third-party libraries.
Resolve the library ID and fetch current docs before writing any implementation.
Do this without waiting for me to ask.
For Cursor, add to Settings > Rules for AI:
When writing code that uses external libraries or frameworks, always invoke
Context7 to fetch current documentation before generating the implementation.
Pair it with Apidog for complete API confidence
Context7 ensures your AI assistant has current library docs. But to verify your API integrations, use Apidog. It's a free API client for sending requests, inspecting responses, setting up environments, and automating tests.
Workflow example:
- Building a Next.js app with a third-party API: Use Context7 for current Next.js docs in your AI assistant; use Apidog to test the API, verify responses, and check payloads.
- Integrating a new HTTP API library: Context7 provides up-to-date SDK docs; Apidog lets you test endpoints directly.
- Debugging an integration: Send requests from Apidog to isolate issues between your code and the API.
Set up environments in Apidog with API keys as variables, switch between dev/prod, and run test assertions. Context7 + Apidog means current docs and verified API behavior.
Pricing and rate limits
The ctx7 CLI is free. Rate limits and features depend on your Context7 plan:
| Plan | Price | API calls/month | Rate limit | Private repos |
|---|---|---|---|---|
| Free | $0 | 1,000 | 60 req/hour | No |
| Pro | $7/seat/mo | 5,000/seat | 60/hour/seat | Yes ($15/1M tokens to parse) |
| Enterprise | Custom | 5,000/seat | Custom | Yes ($25/1M tokens) |
Free tier notes:
- After the monthly limit, get 20 bonus API calls/day until reset
- Private repo access: Pro or higher
- Skill generation: 6/week (Free), 10/week (Pro)
- Pro: max 20 members
Limitation: Context7 routes all queries via Upstash servers. No offline mode. In offline environments, it won't work. Large doc responses may use significant LLM context window space.
Get a free API key at context7.com/dashboard. The API key gives higher rate limits.
FAQ
Does Context7 send my code to its servers?
No. Only the library name and query text are sent. Your codebase and conversation stay with your LLM provider.
What libraries does Context7 support?
9,000+ public libraries and frameworks. Search at context7.com or submit new ones via /add-library.
How current is the documentation?
Libraries are re-indexed regularly. Very recent releases may lag by a few days. For most libraries, docs are current with the latest release.
Does it work without an API key?
Yes, but with lower rate limits. Register at context7.com and set CONTEXT7_API_KEY for better throughput.
Which editors and agents does it support?
Claude Code, Cursor, OpenCode, VS Code Copilot, Windsurf, Claude Desktop, and any client supporting MCP or Agent Skills.
What's the difference between CLI + Skills mode and MCP mode?
-
CLI + Skills: A skill file tells your agent to run
ctx7commands for docs. - MCP mode: The agent calls Context7's tools natively via MCP. No explicit "use context7" prompt needed.
Can I use ctx7 without an AI agent?
Yes. ctx7 library and ctx7 docs work as standalone terminal commands.
Top comments (0)