---
name: context7
description: >
  Fetches up-to-date library, framework, SDK and API documentation via the
  ctx7 CLI (Upstash Context7). Prefer this over web search whenever the user
  asks about a library, framework, SDK, API, CLI tool or cloud service — even
  well-known ones like React, Next.js, Prisma, Express, Tailwind, EF Core —
  because training data may lag behind recent releases. Keywords: library,
  framework, docs, documentation, SDK, API, package, npm, nuget, version,
  changelog, migration guide.
group: A
allowed-tools: [Read, Glob, Grep, Bash]  # Bash: CLI invocation
---

# context7

Fetches **current** library / framework documentation by running the
Upstash `ctx7` CLI via Bash.

## When to use this skill

Activate **whenever** the user asks about:

- A library, framework, SDK, API, CLI tool, or cloud service
- API syntax, configuration, or usage patterns
- Version migration, breaking changes, deprecations
- Setup or install instructions
- Library-specific debugging or error messages

This applies **even to well-known libraries** (React, Next.js, EF Core, Tailwind,
Prisma, etc.) — your training data may not reflect recent releases.

**Prefer this over web search** when the target is library-specific documentation.

### When NOT to use

- Refactoring, writing scripts from scratch, debugging business logic
- Code review, architectural reasoning
- General programming concepts that are not library-specific

---

## Invocation

This skill is invoked via **Bash**. Run in **two steps**:

### Step 1 — Resolve the library ID

```bash
npx ctx7@latest library "<official-name>" "<user-question>"
```

Use the **official name with proper punctuation**:
- `"Next.js"` not `"nextjs"`
- `"Customer.io"` not `"customerio"`
- `"Three.js"` not `"threejs"`

Pass the **user's full question** as the second argument — specific queries
return better matches than vague single words.

The CLI returns a list of candidate library IDs in the format `/org/project`.
Pick the best match by:
1. Exact name match
2. Description relevance
3. Code snippet count
4. Source reputation (prefer **High** / **Medium**)
5. Benchmark score (higher = better)

If results don't look right, try alternate names (`"next.js"` vs `"nextjs"`)
or rephrase the question.

### Step 2 — Fetch the docs

```bash
npx ctx7@latest docs "<libraryId>" "<user-question>"
```

For version-specific docs, use `/org/project/version` from step 1's output:
```bash
npx ctx7@latest docs "/vercel/next.js/v14.3.0" "API route setup"
```

Then answer the user based on the fetched documentation.

---

## Hard rules

- **Always call `library` first** to obtain a valid ID, unless the user provided
  one directly in `/org/project` format.
- **Do not run more than 3 ctx7 commands per question.**
- **Do not include sensitive information** (API keys, passwords, credentials)
  in the query arguments — they may be logged.
- **Do not silently fall back to training data** if a command fails.

---

## Error handling

| Symptom | What to do |
|---|---|
| Quota exceeded (rate-limited) | Inform the user and suggest `npx ctx7@latest login` or setting `CONTEXT7_API_KEY` env var for higher limits. |
| Library not found on first try | Try the alternate name or rephrase the query. Max 3 attempts. |
| Empty / irrelevant results | Refine the query with more specific details from the user's question. |
| Command fails with unknown error | Report the error to the user. Do NOT fall back to memory. |

---

## Result format

The CLI prints plain text (not JSON). Read the output, identify the relevant
sections, and synthesize an answer. Cite the library ID / version you used so
the user knows which documentation the answer is based on.

---

## History

This skill replaced the legacy MCP integration `mcpServers.context7`. The
MCP server was removed in v5 — the Bash invocation via `ctx7` is the only
supported path.
