Context7 injects up-to-date library documentation directly into your AI coding assistant's context, helping it avoid generating code from stale training data. The ctx7 CLI runs with npx ctx7 without installation and connects to Claude Code, Cursor, or OpenCode with a single ctx7 setup command.
What is Context7 and why does it matter?
AI coding assistants can generate code that looks correct but uses APIs that no longer exist:
- Function signatures may be outdated.
- Import paths may have changed.
- Examples may target an older major version.
- Deprecated APIs may still appear in generated code.
This happens because LLMs are trained on data with a cutoff date. They may not know about recent changes, such as a framework changing its layout system or a library deprecating a large part of its API.
Context7 solves this by indexing documentation for more than 9,000 libraries and serving it to your AI assistant in real time. When you ask your coding agent a question, Context7 fetches current, version-specific documentation and adds it to the model's context before it generates a response.
The result is code that is more closely aligned with the APIs and documentation available today.
The ctx7 CLI is Context7's command-line interface. It can:
- Fetch library documentation from your terminal
- Manage AI coding skills, which are reusable prompt files for your agent
- Configure the Context7 MCP server for Claude Code, Cursor, or OpenCode
If you're building API integrations alongside your development work, Apidog handles the API testing side. It's a free client for sending, organizing, and automating API requests. Context7 keeps your AI assistant's knowledge current, while Apidog helps you verify the API calls your application makes.
Install ctx7
The only requirement is Node.js 18 or later. Check your installed version:
node --version
Run without installing
Use npx to try the CLI without installing it globally:
npx ctx7 --help
npx ctx7 library react
npx downloads the latest version when you run the command. This is convenient for occasional use.
Install globally
For regular use, install ctx7 globally:
npm install -g ctx7
ctx7 --version
Global installation lets you run commands locally without the npx download overhead.
Set up Context7 for your AI coding agent
The ctx7 setup command connects Context7 to your AI coding environment. It authenticates through OAuth, generates an API key, and writes the configuration to the appropriate location.
Run the interactive setup
ctx7 setup
The CLI prompts you to select your agent and preferred mode:
- CLI + Skills
- MCP
To accept the default options without prompts:
ctx7 setup --yes
Target a specific agent
Use an agent-specific flag when you already know which environment you want to configure:
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, pass it during setup:
ctx7 setup --api-key YOUR_API_KEY
Configure a project instead of your whole system
By default, ctx7 setup installs configuration globally. To configure only the current project:
ctx7 setup --project
Choose between CLI + Skills and MCP
Context7 supports two setup modes.
CLI + Skills mode
CLI + Skills mode installs a SKILL.md file that instructs your AI agent to fetch documentation by running ctx7 commands.
When the agent needs library documentation, it can run commands such as:
ctx7 library react
ctx7 docs /facebook/react "useEffect cleanup"
No MCP server is required.
Install the skill for a specific agent:
ctx7 setup --cli --claude
ctx7 setup --cli --cursor
ctx7 setup --cli --universal
The universal option installs the skill at:
~/.config/agents/skills
MCP Server mode
MCP mode registers Context7 as a Model Context Protocol server. Your agent can then call resolve-library-id and query-docs natively, without running CLI commands explicitly.
An MCP configuration looks like this:
{
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
You can also add Context7 to Claude Code from the command line:
claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
MCP mode makes documentation fetching less visible in your workflow because the agent calls the tools directly.
Authenticate with Context7
Use these commands to manage your Context7 session:
ctx7 login # OAuth browser login
ctx7 whoami # Confirm your current session
ctx7 logout # Remove stored credentials
You can also provide your API key through an environment variable:
export CONTEXT7_API_KEY=your_key_here
Login is required for skill generation and some setup flows. Basic documentation lookups work without authentication.
Disable telemetry
Context7 collects anonymous usage data by default. To disable it:
export CTX7_TELEMETRY_DISABLED=1
Fetch library documentation from the terminal
You can use ctx7 as a standalone documentation lookup tool, even without an AI coding agent.
Two commands provide the main workflow:
- Resolve a library name.
- Fetch documentation for a topic.
Resolve a library
Search the Context7 index with ctx7 library:
ctx7 library react
ctx7 library nextjs "app router setup"
ctx7 library prisma "database relations"
ctx7 library express --json
The command returns the library's canonical ID and metadata, including snippet count, source reputation, benchmark scores, and version identifiers.
For example:
Library: /vercel/next.js
Snippets: 4,820
Reputation: high
Version: 15.2.0
Fetch documentation
Pass the canonical library ID to ctx7 docs 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 command returns documentation snippets relevant to your query from the current indexed version.
If you already know the library ID, skip the search step and call ctx7 docs directly.
You can also pipe the output into a file or another command for further processing:
ctx7 docs /facebook/react "hooks" --json > react-hooks.json
Manage AI coding skills
Skills are SKILL.md files that give an AI agent specialized knowledge or behavior. Think of them as instruction manuals for a particular task or library.
Context7 provides a registry of community-contributed skills. You can search for skills, install them, generate custom skills, and remove installed skills.
Search for skills
ctx7 skills search pdf
ctx7 skills search "stripe payments"
ctx7 skills search "react testing"
Install a skill
Install a skill for your current environment:
ctx7 skills install /anthropics/skills pdf
Target a specific agent:
ctx7 skills install /anthropics/skills pdf --cursor
ctx7 skills install /anthropics/skills pdf --claude
To make the skill available across all projects, install it globally:
ctx7 skills install /anthropics/skills pdf --global
Get skill suggestions for a project
The suggest command scans your project directory, detects the libraries and frameworks you're using, and recommends relevant skills:
ctx7 skills suggest
This is useful when starting a project and building an initial set of agent instructions.
List installed skills
ctx7 skills list # List all installed skills
ctx7 skills list --claude # List Claude Code skills
ctx7 skills list --cursor # List Cursor skills
Remove a skill
ctx7 skills remove pdf
Generate a custom skill
With a paid account, you can generate a custom skill from a library in the Context7 index:
ctx7 login
ctx7 skills generate
The CLI walks you through an interactive prompt where you select a library and describe what you want the skill to teach your agent. Context7 then generates a SKILL.md file based on the library's current documentation.
Generated skills are portable. The SKILL.md format follows the Agent Skills standard, so a skill generated for Claude Code can also work in Cursor, VS Code Copilot, OpenCode, and other Agent Skills-compatible tools.
Free accounts include 6 skill generations per week. Pro accounts include 10.
Command aliases
Use these aliases for shorter commands:
| Full command | Alias |
|---|---|
ctx7 skills install |
ctx7 si |
ctx7 skills search |
ctx7 ss |
ctx7 skills generate |
ctx7 skills gen or ctx7 skills g
|
Use Context7 in AI prompts
After setting up Context7, you can use it in several ways during development.
Use the use context7 pattern
In MCP mode, append use context7 to prompts where you need 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, fetches the relevant documentation, and uses it to ground the response.
Reference a specific library
When a prompt involves multiple libraries, specify the library IDs explicitly:
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 sends the request directly to the specified documentation sources.
Automatically invoke Context7
You can add an instruction to your AI agent so it fetches documentation automatically whenever it generates code that uses a third-party library.
For Claude Code, add this 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 the equivalent rule under 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 Context7 with Apidog for API confidence
Context7 keeps your AI assistant's library knowledge current, but current documentation is only part of an API integration workflow. You also need to verify that the HTTP requests and responses behave as expected.
Apidog is a free API client for:
- Sending requests
- Inspecting responses
- Managing environments
- Storing API keys as variables
- Running repeatable test suites
- Adding response assertions
A practical workflow looks like this:
- Use Context7 to give your AI agent current documentation for the framework or SDK.
- Use Apidog to call the third-party API directly.
- Inspect the response structure and status codes.
- Compare the tested request with the payload your application generates.
- Add repeatable tests for the integration.
For example, when building a Next.js application that calls a third-party API, Context7 can provide current Next.js documentation so the generated code uses the correct APIs. Apidog lets you test the third-party endpoint directly, verify the response structure, and confirm that your payload matches the API's expectations.
The same approach works when integrating a library with its own HTTP API. Use Context7 to look up the current SDK documentation, then use Apidog to test the raw endpoints and understand their behavior before writing application code.
When debugging an integration, send the exact request your application constructs in Apidog. Inspect the raw response to determine whether the issue is in your request logic or in the API's behavior.
You can also create Apidog environments with API keys stored as variables, switch between development and production values, and run assertions against every response. Context7 provides current documentation, while Apidog helps verify actual 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 repositories |
|---|---|---|---|---|
| Free | $0 | 1,000 | 60 requests/hour | No |
| Pro | $7/seat/month | 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 reaching the monthly limit, you receive 20 bonus API calls per day until the month resets.
- Private repository access requires Pro or higher.
- Skill generation includes 6 generations per week on Free and 10 per week on Pro.
- Pro supports a maximum of 20 members.
One important limitation is that Context7 routes queries through Upstash's servers. It does not provide an offline mode, so it won't work in an environment without internet access.
Documentation responses can also be large and consume part of your LLM's context window. On complex projects with many library queries, this usage can add up.
Get a free API key at context7.com/dashboard. An API key provides 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. Your code, conversation history, and sensitive data are not sent. Your codebase remains with your LLM provider.
What libraries does Context7 support?
The index covers more than 9,000 public libraries and frameworks. Search the index at context7.com to check whether a library is available. New libraries can be submitted through /add-library in the Context7 interface.
How current is the documentation?
Libraries are re-indexed periodically. Very recent releases, including releases from the past few days, may not be available yet. For stable libraries, the documentation is typically up to date with the latest release.
Does it work without an API key?
Basic usage works without an API key, but with lower rate limits. For regular use, register at context7.com and set CONTEXT7_API_KEY for higher throughput.
Which editors and agents does it support?
Context7 works with Claude Code, Cursor, OpenCode, VS Code Copilot, Windsurf, Claude Desktop, and other clients that support 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 documentation.
In MCP mode, your agent calls Context7's tools natively through the MCP protocol. MCP mode is more transparent and does not require an explicit use context7 prompt once configured.
Can I use ctx7 without an AI coding agent?
Yes. The ctx7 library and ctx7 docs commands work as standalone terminal tools, so you can look up library documentation without an AI coding agent.
Additional resources
- Context7 GitHub repository
- Context7 documentation
- CLI documentation
- Plans and pricing
- API key dashboard
- Apidog free API client
Top comments (0)