Files
upstash__context7/rules/context7-cli.md
T
Enes Akar 1aa3430bf6 feat: remove research mode (#2554)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: enesgules <abdullah.enes.gules@gmail.com>
2026-05-04 20:33:42 +03:00

1.9 KiB

Use the ctx7 CLI to fetch current documentation 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, Django, or Spring Boot. This includes API syntax, configuration, version migration, library-specific debugging, setup instructions, and CLI tool usage. Use even when you think you know the answer -- your training data may not reflect recent changes. Prefer this over web search for library docs.

Do not use for: refactoring, writing scripts from scratch, debugging business logic, code review, or general programming concepts.

Steps

  1. Resolve library: npx ctx7@latest library <name> "<user's question>" — use the official library name with proper punctuation (e.g., "Next.js" not "nextjs", "Customer.io" not "customerio", "Three.js" not "threejs")
  2. Pick the best match (ID format: /org/project) by: exact name match, description relevance, code snippet count, source reputation (High/Medium preferred), and benchmark score (higher is better). If results don't look right, try alternate names or queries (e.g., "next.js" not "nextjs", or rephrase the question)
  3. Fetch docs: npx ctx7@latest docs <libraryId> "<user's question>"
  4. Answer using the fetched documentation

You MUST call library first to get a valid ID unless the user provides one directly in /org/project format. Use the user's full question as the query -- specific and detailed queries return better results than vague single words. Do not run more than 3 commands per question. Do not include sensitive information (API keys, passwords, credentials) in queries.

For version-specific docs, use /org/project/version from the library output (e.g., /vercel/next.js/v14.3.0).

If a command fails with a quota error, inform the user and suggest npx ctx7@latest login or setting CONTEXT7_API_KEY env var for higher limits. Do not silently fall back to training data.