find-docs by upstash/context7
npx skills add https://github.com/upstash/context7 --skill find-docs使用 Context7 CLI 检索任何库的最新文档和代码示例。
运行命令前请确保 CLI 已更新至最新版本:
npm install -g ctx7@latest
或者无需安装直接运行:
npx ctx7@latest <command>
两步流程:首先将库名称解析为 ID,然后使用该 ID 查询文档。
# 步骤 1:解析库 ID
ctx7 library <name> <query>
# 步骤 2:查询文档
ctx7 docs <libraryId> <query>
除非用户明确提供了格式为 /org/project 或 /org/project/version 的库 ID,否则你必须首先调用 ctx7 library 来获取有效的库 ID。
重要提示:每个问题运行这些命令不要超过 3 次。如果 3 次尝试后仍未找到所需内容,请使用你得到的最佳结果。
将包/产品名称解析为 Context7 兼容的库 ID,并返回匹配的库。
ctx7 library react "How to clean up useEffect with async operations"
ctx7 library nextjs "How to set up app router with middleware"
ctx7 library prisma "How to define one-to-many relations with cascade delete"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
始终传递 query 参数 —— 这是必需的,并且直接影响结果排名。使用用户的意图来构建查询,这有助于在多个库名称相似时消除歧义。不要在查询中包含任何敏感或机密信息,例如 API 密钥、密码、凭据、个人数据或专有代码。
每个结果包含:
/org/project)/org/project/version。如果用户提到了特定版本,请使用特定版本的库 ID:
# 通用(最新索引版本)
ctx7 docs /vercel/next.js "How to set up app router"
# 特定版本
ctx7 docs /vercel/next.js/v14.3.0-canary.87 "How to set up app router"
可用版本在 ctx7 library 的输出中列出。使用与用户指定版本最接近的匹配项。
检索已解析库的最新文档和代码示例。
ctx7 docs /facebook/react "How to clean up useEffect with async operations"
ctx7 docs /vercel/next.js "How to add authentication middleware to app router"
ctx7 docs /prisma/prisma "How to define one-to-many relations with cascade delete"
查询直接影响结果的质量。请具体并包含相关细节。不要在查询中包含任何敏感或机密信息,例如 API 密钥、密码、凭据、个人数据或专有代码。
| 质量 | 示例 |
|---|---|
| 好 | "How to set up authentication with JWT in Express.js" |
| 好 | "React useEffect cleanup function with async operations" |
| 差 | "auth" |
| 差 | "hooks" |
尽可能使用用户的完整问题作为查询,模糊的单字查询会返回通用结果。
输出包含两种类型的内容:代码片段(带有标题和语言标记的代码块)和信息片段(带有面包屑上下文的解释性文字)。
无需身份验证即可工作。如需更高的速率限制:
# 选项 A:环境变量
export CONTEXT7_API_KEY=your_key
# 选项 B:OAuth 登录
ctx7 login
如果命令因配额错误("Monthly quota reached" 或 "quota exceeded")而失败:
ctx7 login不要默默地回退到训练数据 —— 始终告诉用户为什么没有使用 Context7。
/ 前缀 —— 是 /facebook/react 而不是 facebook/reactctx7 library —— 没有有效 ID 时,ctx7 docs react "hooks" 会失败"React useEffect cleanup function" 而不是 "hooks"每周安装量
385
代码仓库
GitHub 星标数
50.5K
首次出现
14 天前
安全审计
安装于
codex349
opencode339
github-copilot338
cline337
gemini-cli336
amp336
Retrieve current documentation and code examples for any library using the Context7 CLI.
Make sure the CLI is up to date before running commands:
npm install -g ctx7@latest
Or run directly without installing:
npx ctx7@latest <command>
Two-step process: resolve the library name to an ID, then query docs with that ID.
# Step 1: Resolve library ID
ctx7 library <name> <query>
# Step 2: Query documentation
ctx7 docs <libraryId> <query>
You MUST call ctx7 library first to obtain a valid library ID UNLESS the user explicitly provides a library ID in the format /org/project or /org/project/version.
IMPORTANT: Do not run these commands more than 3 times per question. If you cannot find what you need after 3 attempts, use the best result you have.
Resolves a package/product name to a Context7-compatible library ID and returns matching libraries.
ctx7 library react "How to clean up useEffect with async operations"
ctx7 library nextjs "How to set up app router with middleware"
ctx7 library prisma "How to define one-to-many relations with cascade delete"
Always pass a query argument — it is required and directly affects result ranking. Use the user's intent to form the query, which helps disambiguate when multiple libraries share a similar name. Do not include any sensitive or confidential information such as API keys, passwords, credentials, personal data, or proprietary code in your query.
Each result includes:
/org/project)/org/project/version.If the user mentions a specific version, use a version-specific library ID:
# General (latest indexed)
ctx7 docs /vercel/next.js "How to set up app router"
# Version-specific
ctx7 docs /vercel/next.js/v14.3.0-canary.87 "How to set up app router"
The available versions are listed in the ctx7 library output. Use the closest match to what the user specified.
Retrieves up-to-date documentation and code examples for the resolved library.
ctx7 docs /facebook/react "How to clean up useEffect with async operations"
ctx7 docs /vercel/next.js "How to add authentication middleware to app router"
ctx7 docs /prisma/prisma "How to define one-to-many relations with cascade delete"
The query directly affects the quality of results. Be specific and include relevant details. Do not include any sensitive or confidential information such as API keys, passwords, credentials, personal data, or proprietary code in your query.
| Quality | Example |
|---|---|
| Good | "How to set up authentication with JWT in Express.js" |
| Good | "React useEffect cleanup function with async operations" |
| Bad | "auth" |
| Bad | "hooks" |
Use the user's full question as the query when possible, vague one-word queries return generic results.
The output contains two types of content: code snippets (titled, with language-tagged blocks) and info snippets (prose explanations with breadcrumb context).
Works without authentication. For higher rate limits:
# Option A: environment variable
export CONTEXT7_API_KEY=your_key
# Option B: OAuth login
ctx7 login
If a command fails with a quota error ("Monthly quota reached" or "quota exceeded"):
ctx7 loginDo not silently fall back to training data — always tell the user why Context7 was not used.
/ prefix — /facebook/react not facebook/reactctx7 library first — ctx7 docs react "hooks" will fail without a valid ID"React useEffect cleanup function" not "hooks"Weekly Installs
385
Repository
GitHub Stars
50.5K
First Seen
14 days ago
Security Audits
Gen Agent Trust HubFailSocketPassSnykWarn
Installed on
codex349
opencode339
github-copilot338
cline337
gemini-cli336
amp336
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
138,300 周安装