Context7 is a platform that injects up-to-date library documentation directly into your AI coding assistant's context, so it stops generating code based on stale training data. The CLI (ctx7) runs with npx ctx7 (no install required) and connects to Claude Code, Cursor, or OpenCode with a single ctx7 setup command.
What is Context7 and why does it matter?
Here's a problem every developer who uses AI coding tools has run into: you ask your assistant to write code using a library you know well, and it gives you something that looks right but uses APIs that don't exist anymore. The function signatures are wrong. The import paths changed two major versions ago. The example works in the docs for version 12, but you're on version 15.
This happens because LLMs are trained on data with a cutoff date. They don't know what changed last month. They don't know that Next.js 15 reworked how layouts work, or that a library you rely on deprecated half its API surface since the training snapshot.
Context7 solves this. It's a platform built by Upstash that indexes documentation for over 9,000 libraries and serves it to your AI assistant in real time. When you ask your coding agent a question, Context7 fetches the current, version-specific docs and puts them in the context window before the model generates its response.
The result: your AI coding tool stops hallucinating APIs and starts producing code that matches what the library actually does today.
The ctx7 CLI is the command-line interface for Context7. It does three things:
- Fetch library docs directly in your terminal
- Manage AI coding skills (reusable prompt files that enhance your agent)
- Configure the Context7 MCP server for Claude Code, Cursor, or OpenCode
Installing ctx7
The only requirement is Node.js 18 or later. Check your version with node --version.
Run without installing
The fastest way to try ctx7 is with npx:
npx ctx7 --help
npx ctx7 library react
This pulls the latest version each time you run it. Fine for occasional use.
Install globally
For regular use, install globally:
npm install -g ctx7
ctx7 --version
After that, every ctx7 command runs locally without the npx overhead.
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 to the right place.
Interactive setup
ctx7 setup
This prompts you to choose your agent and your preferred mode (CLI + Skills vs. MCP). If you want to skip the 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 already have a Context7 API key from context7.com/dashboard:
ctx7 setup --api-key YOUR_API_KEY
Project-level vs. global setup
By default, ctx7 setup installs globally. To configure just for the current project:
ctx7 setup --project
Two modes: CLI + Skills vs. MCP
CLI + Skills mode installs a SKILL.md file that tells your AI agent to fetch docs by running ctx7 CLI commands. Your agent reads the skill instructions and autonomously runs ctx7 library and ctx7 docs when it needs library documentation. No MCP server required.
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. Your agent calls resolve-library-id and query-docs tools natively without running any CLI commands. The documentation fetching is invisible.
For MCP mode, the config looks like this (add to your editor's MCP settings):
{
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
Or add it to Claude Code via the 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 # Confirm who you're logged in as
ctx7 logout # Remove stored credentials
You can also set the API key as an environment variable:
export CONTEXT7_API_KEY=your_key_here
Login is only required for skill generation and certain setup flows. Basic documentation lookups work without it.
Telemetry
Context7 collects anonymous usage data by default. Disable it:
export CTX7_TELEMETRY_DISABLED=1
Fetching library documentation from the terminal
Even without an AI agent in the loop, ctx7 is useful as a standalone docs lookup tool. Two commands do the heavy lifting.
Resolve a library name
ctx7 library react
ctx7 library nextjs "app router setup"
ctx7 library prisma "database relations"
ctx7 library express --json # JSON output
This searches the Context7 index and returns the library's canonical ID, along with metadata: snippet count, source reputation, benchmark scores, and version identifiers.
Example output for ctx7 library nextjs:
Library: /vercel/next.js
Snippets: 4,820
Reputation: high
Version: 15.2.0
Fetch documentation
Once you have a library ID, pass it to ctx7 docs along with a topic query:
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
The output is documentation snippets relevant to your query, pulled from the current version of the library. You can pipe this output into a file or into another tool.
If you already know the library ID, you can skip ctx7 library and go straight to ctx7 docs.
Managing AI coding skills
Skills are SKILL.md files that give your AI agent specialized knowledge or behavior. Think of them as tiny instruction manuals your agent reads before tackling a specific type of task.
Context7 hosts a registry of community-contributed skills. You can search it, install skills into your agent environment, generate custom ones, and remove what you don't need.
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 # Install for Cursor specifically
ctx7 skills install /anthropics/skills pdf --claude # Install for Claude Code
When you install globally (--global), the skill is available across all your projects:
ctx7 skills install /anthropics/skills pdf --global
Get suggestions based on your project
ctx7 skills suggest scans your project directory, detects the libraries and frameworks you're using, and recommends relevant skills:
ctx7 skills suggest
This works well when you start a new project and want to seed your agent with relevant knowledge upfront.
List installed skills
ctx7 skills list # All installed skills
ctx7 skills list --claude # Only skills installed for Claude Code
ctx7 skills list --cursor # Only Cursor skills
Remove a skill
ctx7 skills remove pdf
Generate a custom skill with AI
This is the most powerful feature. With a paid account, you can generate a custom skill from any library in the Context7 index:
ctx7 login
ctx7 skills generate
The CLI walks you through an interactive prompt: pick a library, describe what you want the skill to teach your agent, and Context7 generates a SKILL.md file tailored to that library's current docs.
Generated skills are portable. The SKILL.md format follows the Agent Skills standard, which means a skill you generate for Claude Code works unchanged in Cursor, VS Code Copilot, OpenCode, and any other Agent Skills-compatible tool.
Free accounts get 6 skill generations per week. Pro accounts get 10.
Shorthand aliases for faster typing:
| 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 Context7 is set up, you have a few ways to use it in your daily coding workflow.
The "use context7" pattern
In MCP mode, append "use context7" to any prompt where you want current documentation:
Create a Next.js middleware that checks for a valid 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 calls Context7's resolve-library-id and query-docs tools automatically, fetches the current docs, and uses them to ground its response.
Reference a specific library
If your prompt involves multiple libraries and you want Context7 to focus on one:
Implement Supabase authentication in a Next.js app.
use library /supabase/supabase for Supabase and /vercel/next.js for Next.js routing.
This skips the library-matching step and goes straight to the docs.
Auto-invoke without typing "use context7"
Add a rule to your AI agent so it fetches docs automatically whenever it touches library code. In Claude Code, add to your 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.
In 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 keeps your AI assistant's library knowledge current. But accurate docs are only half the picture. When you're building an API integration, you also need to verify that your actual HTTP calls work the way you expect.
Apidog covers that. It's a free API client where you can send requests, inspect responses, set up environments, and automate test suites. It handles everything from ad-hoc endpoint exploration to repeatable integration tests.
Here's how they complement each other in a real workflow:
You're building a Next.js app that calls a third-party API. Context7 gives your AI agent current Next.js docs so its code suggestions are correct. Apidog lets you test the third-party API directly, verify the response structure, and confirm that the payloads your code sends match what the API expects.
You're integrating a new library that has its own HTTP API. Context7 gives your agent the library's current SDK docs. Apidog lets you test the raw API endpoints to understand the behavior at the HTTP level before you write any application code.
You're debugging an integration. You can send the exact request your code constructs in Apidog, inspect the raw response, and isolate whether the problem is in your request logic or the API's behavior.
Set up an environment in Apidog with your API keys stored as variables, switch between dev and production with one click, and run test assertions on every response. Context7 + Apidog gives you both current docs and verified API behavior.
Pricing and rate limits
The ctx7 CLI is free to use. Rate limits and feature access 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:
- When you hit the monthly limit, you get 20 bonus API calls per day until the month resets
- Private repository access requires Pro or higher
- Skill generation: 6/week on Free, 10/week on Pro
- Pro supports a maximum of 20 members
Important limitation: Context7 routes all queries through Upstash's servers. There's no offline mode. If you're in an environment without internet access, the tool won't work. Documentation responses can also be large, which eats into your LLM's context window. On complex projects with many library queries, this adds up.
Get a free API key at context7.com/dashboard. The API key gives you higher rate limits than unauthenticated requests.
FAQ
Does Context7 send my code to its servers?
No. Only the library name and query text are sent to Context7's servers, not your code, conversation history, or any sensitive data. Your codebase stays with your LLM provider.
What libraries does Context7 support?
The index covers over 9,000 public libraries and frameworks. You can search the index at context7.com to check if a specific library is available. New libraries can be submitted via /add-library in the Context7 interface.
How current is the documentation?
Libraries are re-indexed periodically. Very recent releases (within the past few days) may not be available yet. For stable libraries, the docs are typically up to date with the latest release.
Does it work without an API key?
Basic usage works without an API key but at lower rate limits. For regular use, register at context7.com and set CONTEXT7_API_KEY to get better throughput.
Which editors and agents does it support?
Context7 works with Claude Code, Cursor, OpenCode, VS Code Copilot, Windsurf, Claude Desktop, and any other client that supports MCP or the Agent Skills standard.
What's the difference between CLI + Skills mode and MCP mode?
In CLI + Skills mode, a skill file tells your agent to run ctx7 commands explicitly when it needs docs. In MCP mode, your agent calls Context7's tools natively through the MCP protocol. MCP mode is more transparent to the user and doesn't require any explicit "use context7" prompting once configured.
Can I use ctx7 without an AI coding agent?
Yes. ctx7 library and ctx7 docs work as standalone terminal commands. You can look up library documentation directly without any AI agent involved.



