Context7 Cli

作者 upstashfeef1b2f6078無授權條款62K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Use the ctx7 CLI to fetch library documentation and configure Context7 MCP. Activate when the user mentions "ctx7" or "context7", needs current docs for any library, or needs to set up Context7 for their AI coding agent.

AI 產生的概覽

透過 ctx7 CLI 取得最新的函式庫文件,並為 AI 程式編輯器設定 Context7 MCP。

功能
這個技能說明如何使用 ctx7 命令列工具解析函式庫 ID,並取得該函式庫的最新文件。它也介紹如何為 Claude Code、Cursor 和 OpenCode 等編輯器設定 Context7 MCP,以及登入、登出和狀態查詢等驗證指令。這是僅含說明的技能,附帶兩份參考文件,分別介紹文件查詢和設定。
適用情境
當使用者提到 ctx7 或 Context7、需要某個函式庫的最新文件,或希望在其 AI 程式代理中設定 Context7 MCP 時使用。它也適用於核對 API 簽章,或訓練資料可能過時的情況。
執行需求
需要 ctx7 CLI,可透過 npm 全域安裝或使用 npx 直接執行,因此需要 Node.js、npm 和網路存取。選用的 Context7 API 金鑰或 OAuth 登入可取得更高速率限制;setup 指令需要登入,除非傳入 API 金鑰或 OAuth 參數。這個技能不附帶指令碼。

ctx7 CLI

The Context7 CLI does two things: fetches up-to-date library documentation and sets up Context7 MCP for your editor.

Make sure the CLI is up to date before running commands:

bash
npm install -g ctx7@latest

Or run directly without installing:

bash
npx ctx7@latest <command>

What this skill covers

  • Documentation [blocked] — Fetch current docs for any library. Use when writing code, verifying API signatures, or when training data may be outdated.
  • Setup [blocked] — Configure Context7 MCP for Claude Code / Cursor / OpenCode.

Quick Reference

bash
# Documentationctx7 library <name> <query>           # Step 1: resolve library IDctx7 docs <libraryId> <query>         # Step 2: fetch docs
# Setupctx7 setup                            # Configure Context7 MCP (interactive)ctx7 login                            # Log in for higher rate limitsctx7 whoami                           # Check current login status

Authentication

bash
ctx7 login               # Opens browser for OAuthctx7 login --no-browser  # Prints URL instead of opening browserctx7 logout              # Clear stored tokensctx7 whoami              # Show current login status (name + email)

Most commands work without login. Exception: ctx7 setup requires it unless --api-key or --oauth is passed. Login also unlocks higher rate limits on docs commands.

Set an API key via environment variable to skip interactive login entirely:

bash
export CONTEXT7_API_KEY=your_key

Common Mistakes

  • Library IDs require a / prefix — /facebook/react not facebook/react
  • Always run ctx7 library first — ctx7 docs react "hooks" will fail without a valid ID

來源與署名

來源:upstash/context7位於skills/context7-cli提交feef1b2

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架