Communitygithub.com

文件查詢 (Context7)

透過 Context7 MCP 即時查閱最新的函式庫與框架文件,取代訓練資料。適用於設定問題、API 參考、程式碼範例,或當使用者提到特定框架(如 React、Next.js、Prisma)時。

文件查詢 (Context7) 是什麼?

此技能讓 AI 代理能無縫整合 Context7 的 MCP 伺服器,擷取最新的函式庫與框架文件,確保回應基於最新資訊,而非可能有時效性的訓練資料。使用者只要在問題中提及特定函式庫或框架(例如 Next.js、Prisma、Supabase),代理就會透過 `resolve-library-id` 工具解析其對應的 Context7 庫 ID,然後使用 `query-docs` 工具擷取相關文件片段與程式碼範例。此技能特別適用於設定指南、API 參考查詢以及依賴特定函式庫實作方式的程式碼生成任務。它遵循逐步工作流程,首先解析庫 ID,然後根據名稱匹配、基準分數與來源聲譽選取最佳結果,最後擷取文件並將其整合到回應中。為避免濫用,每次詢問呼叫 MCP 工具的次數限制為三次;若不確定,代理應說明不確定性,並依據現有最佳資訊回應。此技能支援所有已設定 Context7 MCP 的開發工具(如 Claude Code、Cursor、Codex),並強調使用精確查詢、留意版本、優先選用官方來源,以及從所有查詢中移除敏感性資料等最佳實務。

相容平台✓Claude Code✓Codex CLI✓Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/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 與問題,擷取文件與程式碼片段。在呼叫 query-docs 之前,務必先呼叫 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: "How do I set up Next.js middleware?"。
  2. 從結果中,根據名稱和基準分數選取最佳比對結果(例如 /vercel/next.js)。
  3. 呼叫 query-docs,設定 libraryId: "/vercel/next.js",query: "How do I set up Next.js middleware?"。
  4. 使用回傳的片段和文字回答;如果相關,可從文件中附上一個簡潔的 middleware.ts 範例。

範例:Prisma 查詢

  1. 呼叫 resolve-library-id,設定 libraryName: "Prisma",query: "How do I query with relations?"。
  2. 選取官方的 Prisma 庫 ID(例如 /prisma/prisma)。
  3. 使用該 libraryId 和查詢內容呼叫 query-docs。
  4. 回傳 Prisma Client 的模式(例如 include 或 select),並附上來自文件的簡短程式碼片段。

範例:Supabase 驗證方法

  1. 呼叫 resolve-library-id,設定 libraryName: "Supabase",query: "What are the auth methods?"。
  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/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

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.

相關技能