context7-docs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Context7 Documentation Lookup

Context7 文档查询

Retrieve current documentation and code examples from Context7 using the
resolve-library-id
and
query-docs
tools that ship with this extension.
使用此扩展附带的
resolve-library-id
和
query-docs
工具,从 Context7 获取当前文档和代码示例。

When to use

何时使用

Reach for these tools whenever a question involves a specific library, framework, SDK, CLI tool, or cloud service. Examples:
  • "How do I configure caching in Next.js 16?"
  • "What's the syntax for Prisma's
    findMany
    with relations?"
  • "Show me a working Tailwind v4 install for a Vite app."
  • "How do I rate-limit with
    @upstash/ratelimit
    ?"
只要问题涉及特定的 library、framework、SDK、CLI tool 或 cloud service,都应使用这些工具。例如:
  • “如何在 Next.js 16 中配置缓存?”
  • “Prisma 的
    findMany
    如何使用关联关系?”
  • “为 Vite app 提供一个可用的 Tailwind v4 安装示例。”
  • “如何使用
    @upstash/ratelimit
    实施速率限制?”

Workflow

工作流程

  1. Resolve the library ID. Call
    resolve-library-id
    with the library name and what to look up in the library's documentation. The tool returns matching libraries with their Context7 IDs (
    /org/project
    format), descriptions, snippet counts, and quality scores. Pick the best match — prioritize official sources, name match, and high benchmark scores.
  2. Query the docs. Call
    query-docs
    with the chosen library ID and what to look up in the library's documentation, scoped to a single concept — if the question spans multiple distinct concepts, make a separate call per concept with the same library ID, unless the question is about how the concepts interact. The tool returns documentation snippets and code examples.
  3. Answer. Cite the library ID you used and quote code examples verbatim when relevant.
If the user supplies a library ID in
/org/project
or
/org/project/version
format directly, skip step 1 and call
query-docs
immediately.
  1. 解析 library ID。 使用 library 名称以及要在该 library 文档中查找的内容,调用
    resolve-library-id
    。该工具会返回匹配的 library 及其 Context7 ID(
    /org/project
    格式)、描述、代码片段数量和质量分数。选择最匹配的项——优先考虑官方来源、名称匹配度高且基准分数较高的项目。
  2. 查询文档。 使用选定的 library ID 以及要在该 library 文档中查找的内容,调用
    query-docs
    ,并将查询范围限定为单一概念——如果问题涉及多个不同概念,请使用同一个 library ID 为每个概念分别调用一次,除非问题涉及这些概念之间的交互。该工具会返回文档片段和代码示例。
  3. 回答。 引用你使用的 library ID,并在相关时逐字引用代码示例。
如果用户直接提供了
/org/project
或
/org/project/version
格式的 library ID,请跳过第 1 步,立即调用
query-docs
。

Constraints

约束

  • Do not call either tool more than 3 times per question.
  • Do not pass API keys, passwords, credentials, personal data, or proprietary code as the
    query
    argument — it is sent to the Context7 API.
  • Authentication uses the
    CONTEXT7_API_KEY
    environment variable. Get a key at https://context7.com/dashboard if requests fail with an auth error.
  • 每个问题中,任一工具的调用次数均不得超过 3 次。
  • 不要将 API key、密码、凭据、个人数据或专有代码作为
    query
    参数传入——这些内容会被发送到 Context7 API。
  • 身份验证使用
    CONTEXT7_API_KEY
    环境变量。如果请求因身份验证错误而失败,请前往 https://context7.com/dashboard 获取 key。