Communitygithub.com

文件查詢 (Context7)

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

文件查詢 (Context7) 是什麼?

此技能讓 AI 助手能夠即時查詢 Context7 MCP 伺服器提供的文件,以獲取各類函式庫、框架和 API 的最新行為資訊,避免依賴可能過時的訓練資料。其核心運作流程包含三個步驟:首先使用 `resolve-library-id` 工具將使用者提到的函式庫名稱(例如 Next.js、Prisma)解析為 Context7 相容的識別碼(格式如 `/org/project`),其次從結果中根據名稱匹配、基準評分、來源信譽和版本等因素選出最佳結果,最後呼叫 `query-docs` 工具搭配使用者的完整問題來取得相關文件與程式碼片段。此技能適用於已配置 Context7 MCP 的開發平台(如 Claude Code、Cursor、Codex),並可有效處理設定配置、API 參考、範例程式碼等依賴準確且最新行為的查詢。為確保效率,每次問題最多僅能呼叫 resolve-library-id 或 query-docs 不超過三次;若結果仍不明確,應如實告知使用者而非自行臆測。

相容平台✓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 相容的函式庫識別碼(例如 /vercel/next.js)。
  • query-docs:針對給定的函式庫識別碼與問題取得文件與程式碼片段。請務必先呼叫 resolve-library-id 以取得有效的函式庫識別碼。

使用時機

在使用者出現以下情況時啟動:

  • 提出安裝或設定相關問題(例如「如何設定 Next.js 中介軟體?」)
  • 請求需要依賴某函式庫的程式碼(「寫一個 Prisma 查詢來……」)
  • 需要 API 或參考資訊(「Supabase 有哪些驗證方法?」)
  • 提及特定的框架或函式庫(React、Vue、Svelte、Express、Tailwind、Prisma、Supabase 等)

當請求依賴於函式庫、框架或 API 的準確且最新行為時,均應使用此技能。適用於所有已配置 Context7 MCP 的平台(例如 Claude Code、Cursor、Codex)。

運作方式

步驟 1:解析函式庫識別碼

使用 resolve-library-id MCP 工具,並提供以下參數:

  • libraryName:從使用者問題中取得的函式庫或產品名稱(例如 Next.js、Prisma、Supabase)。
  • query:使用者的完整問題。這有助於提升結果的相關性排序。

在查詢文件前,必須先取得 Context7 相容的函式庫識別碼(格式為 /org/project 或 /org/project/version)。未經此步驟取得有效識別碼前,不得呼叫 query-docs。

步驟 2:選擇最佳結果

從解析結果中選取一個結果,依據以下條件:

  • 名稱匹配:優先選擇與使用者要求完全或最接近的項目。
  • 基準評分:分數越高表示文件品質越好(滿分 100)。
  • 來源信譽:若有可能,優先選擇信譽為高或中的來源。
  • 版本:若使用者指定了版本(例如「React 19」、「Next.js 15」),則優先選擇列出的版本專用識別碼(例如 /org/project/v1.2.0)。

步驟 3:取得文件

使用 query-docs MCP 工具,並提供以下參數:

  • libraryId:從步驟 2 選取的 Context7 函式庫識別碼(例如 /vercel/next.js)。
  • query:使用者的具體問題或任務。請盡量具體以獲得相關的程式碼片段。

限制:每個問題最多呼叫 query-docs(或 resolve-library-id)三次。若三次後仍無法得到明確答案,請如實告知不確定性,並使用現有最佳資訊解答,切勿自行臆測。

步驟 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 函式庫識別碼(例如 /prisma/prisma)。
  3. 呼叫 query-docs,使用該 libraryId 與查詢。
  4. 回傳 Prisma Client 的模式(例如 include 或 select),並附上文件中的簡短程式碼片段。

範例:Supabase 驗證方法

  1. 呼叫 resolve-library-id,參數為 libraryName: "Supabase",query: "有哪些驗證方法?"。
  2. 選取 Supabase 文件的函式庫識別碼。
  3. 呼叫 query-docs;摘要說明驗證方法,並從取得的文件中展示最小範例。

最佳實踐

  • 具體明確:盡可能使用使用者的完整問題作為查詢,以獲得更好的相關性。
  • 注意版本:當使用者提及版本時,若解析步驟中有版本專用的識別碼,請優先使用。
  • 優先官方來源:若有多個匹配結果,請優先選擇官方或主要套件,而非社群分支。
  • 不傳送敏感資料:在傳送查詢至 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.

相關技能