SuperAPI AI Directory

context7

Coding & development

View repository

Updated 10-15 21:36

About this skill

Context7 - Library Documentation Fetcher

Fetch library documentation directly from the terminal using the ctx7 CLI. Resolve any library by name and query its up-to-date docs without opening a browser.

Execution Environment

Path Type Description
CLI npx ctx7 (no global installation required)
Authentication Most commands require no authentication,ctx7 skills generate requires
API Key Optional:export CONTEXT7_API_KEY=your_key

Workflow

Step 1: Parse library name → Get Library ID

# 基础搜索
npx ctx7 library react
With natural language query (improves relevance)

npx ctx7 library react "How to clean up useEffect with async operations" npx ctx7 library nextjs "How to set up app router with middleware" npx ctx7 library prisma "How to define one-to-many relations"

Output JSON for easy script processing

npx ctx7 library react --json | jq '.[0].id'


返回字段:
- **Library ID** — 格式 `/org/project`,传给 `ctx7 docs`
- **Code Snippets** — 索引的代码示例数量
- **Source Reputation** — High/Medium/Low/Unknown
- **Benchmark Score** — 0-100 质量分

### Step 2: 查询文档

```bash
# 基础查询
npx ctx7 docs /facebook/react "How to clean up useEffect with async operations"
npx ctx7 docs /vercel/next.js "How to add middleware that redirects unauthenticated users"
npx ctx7 docs /prisma/prisma "How to define one-to-many relations with cascade delete"

# 指定版本
npx ctx7 docs /vercel/next.js/v14.3.0-canary.87 "How to set up app router"

# JSON 输出
npx ctx7 docs /facebook/react "How to use hooks for state management" --json

⚠️ Library ID must start with / , and must first be obtained using ctx7 library .

Common Library Reference

Library Library ID Typical Query
React /facebook/react hooks, state management, effects
Next.js /vercel/next.js app router, middleware, API routes
Prisma /prisma/prisma schema, relations, migrations
Vue /vuejs/core composition API, reactivity
Tailwind /tailwindlabs/tailwindcss configuration, plugins
Express /expressjs/express routing, middleware
TypeScript /microsoft/typescript generics, utility types

Skills Management

# 搜索技能
npx ctx7 skills search pdf
npx ctx7 skills search react typescript

# 安装技能
npx ctx7 skills install /anthropics/skills pdf
npx ctx7 skills install /anthropics/skills --all

# 列出已安装
npx ctx7 skills list

# 生成技能(需要认证)
npx ctx7 skills generate

Setup (Configure MCP)

# 交互式配置
npx ctx7 setup

# MCP 模式(IDE 集成)
npx ctx7 setup --mcp --claude
npx ctx7 setup --mcp --cursor

# CLI + Skills 模式(无需 MCP)
npx ctx7 setup --cli --universal

Authentication

# 登录(浏览器 OAuth)
npx ctx7 login
npx ctx7 login --no-browser  # 不打开浏览器

# 检查状态
npx ctx7 whoami

# 退出
npx ctx7 logout

Advanced Usage

# 组合:搜索 + 获取 docs
LIB_ID=$(npx ctx7 library react "hooks" --json | jq -r '.[0].id')
npx ctx7 docs "$LIB_ID" "How to use useContext for global state"

# 管道输出
npx ctx7 docs /facebook/react "useEffect cleanup" | head -50

# 带版本的精确查询
npx ctx7 library nextjs "app router" --json | jq '.[].id' | grep v14

FAQ

Issue Solution
Library ID must start with / First run ctx7 library to get the ID
Irrelevant results Use natural language to describe the specific scenario, avoid single words
Rate limit Log in to unlock higher rate limits
No installation npx ctx7 requires no installation, or npm install -g ctx7

Reference