Communitygithub.com

文档查询 (Context7)

通过 Context7 MCP 实时获取库和框架的最新文档,而非依赖训练数据。适用于安装配置问题、API 参考、代码示例或用户提及框架(如 React、Next.js、Prisma)时。

文档查询 (Context7) 是什么?

该技能允许 AI 代理通过 Context7 MCP 服务器实时查询最新的库、框架和 API 文档,从而避免依赖可能过时的训练数据。它通过两个核心工具操作:`resolve-library-id` 用于将库名称和用户查询转换为 Context7 兼容的库 ID(如 `/vercel/next.js`),而 `query-docs` 则根据该 ID 和用户问题获取特定的文档和代码片段。该技能专为需要高准确性和最新信息的开发任务设计,例如配置指引、API 参考和代码生成。它在配置了 Context7 MCP 的平台上可用,如 Claude Code、Cursor 和 Codex。工作流程包括解析库 ID、选择最佳匹配(根据名称、基准分数和版本)、获取文档,然后使用获取到的当前信息回答用户问题。最佳实践包括明确查询、关注版本、优先选择官方来源,以及在发送查询前确保不泄露敏感数据。

兼容平台✓Claude Code✓Codex CLI✓Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/documentation-lookup

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

文档查询 (Context7) 是做什么的?

当用户询问库、框架或 API 时,应通过 Context7 MCP(工具 resolve-library-id 和 query-docs)获取当前文档,而非依赖训练数据。

核心概念

  • Context7: 一个暴露实时文档的 MCP 服务器;在涉及库和 API 时应使用它而非训练数据。
  • resolve-library-id: 根据库名称和查询返回 Context7 兼容的库 ID(例如 /vercel/next.js)。
  • query-docs: 根据给定的库 ID 和问题获取文档和代码片段。始终先调用 resolve-library-id 以获取有效的库 ID。

何时使用

当用户出现以下情况时激活:

  • 询问安装或配置问题(例如“如何配置 Next.js 中间件?”)
  • 请求依赖某个库的代码(“写一个 Prisma 查询来...”)
  • 需要 API 或参考信息(“Supabase 的认证方法有哪些?”)
  • 提到特定框架或库(React、Vue、Svelte、Express、Tailwind、Prisma、Supabase 等)

只要请求依赖于库、框架或 API 的准确、最新行为,就应使用此技能。适用于已配置 Context7 MCP 的各类平台(例如 Claude Code、Cursor、Codex)。

工作原理

第 1 步:解析库 ID

调用 resolve-library-id MCP 工具,参数如下:

  • libraryName: 从用户问题中提取的库或产品名称(例如 Next.js、Prisma、Supabase)。
  • query: 用户的完整问题。这有助于提高结果的相关性排名。

在查询文档之前,必须获取一个 Context7 兼容的库 ID(格式为 /org/project 或 /org/project/version)。没有此步骤得到的有效库 ID,请勿调用 query-docs。

第 2 步:选择最佳匹配

从解析结果中,根据以下条件选择一个结果:

  • 名称匹配: 优先选择与用户需求精确或最接近的匹配。
  • 基准分数: 分数越高表示文档质量越好(100 为最高)。
  • 来源信誉: 尽可能优先选择高或中等信誉的来源。
  • 版本: 如果用户指定了版本(例如“React 19”、“Next.js 15”),则优先选择列出的版本特定库 ID(例如 /org/project/v1.2.0)。

第 3 步:获取文档

调用 query-docs MCP 工具,参数如下:

  • libraryId: 从第 2 步选择的 Context7 库 ID(例如 /vercel/next.js)。
  • query: 用户的特定问题或任务。请具体描述,以获取相关的代码片段。

限制:每次提问时,调用 query-docs(或 resolve-library-id)的次数不得超过 3 次。如果在 3 次调用后答案仍不明确,请说明不确定性,并使用您掌握的最佳信息,而非猜测。

第 4 步:使用文档

  • 使用获取到的当前信息回答用户的问题。
  • 在有用时包含文档中的相关代码示例。
  • 在必要时注明库或版本(例如“在 Next.js 15 中...”)。

示例

示例:Next.js 中间件

  1. 调用 resolve-library-id,参数为 libraryName: "Next.js",query: "如何设置 Next.js 中间件?"。
  2. 根据名称和基准分数从结果中选择最佳匹配(例如 /vercel/next.js)。
  3. 调用 query-docs,参数为 libraryId: "/vercel/next.js",query: "如何设置 Next.js 中间件?"。
  4. 使用返回的片段和文本进行回答;如果相关,包含一个来自文档的最小化 middleware.ts 示例。

示例:Prisma 查询

  1. 调用 resolve-library-id,参数为 libraryName: "Prisma",query: "如何进行关联查询?"。
  2. 选择官方的 Prisma 库 ID(例如 /prisma/prisma)。
  3. 使用该 libraryId 和查询调用 query-docs。
  4. 返回 Prisma Client 模式(例如 include 或 select),并附上来自文档的简短代码片段。

示例:Supabase 认证方法

  1. 调用 resolve-library-id,参数为 libraryName: "Supabase",query: "认证方法有哪些?"。
  2. 选择 Supabase 文档库 ID。
  3. 调用 query-docs;总结认证方法,并从获取的文档中展示最小示例。

最佳实践

  • 具体明确: 尽可能使用用户的完整问题作为查询,以获得更好的相关性。
  • 版本感知: 当用户提及版本时,如果解析步骤中有版本特定的库 ID,请优先使用它们。
  • 优先官方来源: 当存在多个匹配时,优先选择官方或主包而非社区分支。
  • 无敏感数据: 从发送给 Context7 的任何查询中移除 API 密钥、密码、令牌和其他秘密。在将用户问题传递至 resolve-library-id 或 query-docs 之前,应将其视为可能包含机密信息。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相关技能