Skip to content

Up-to-date library docs — Context7 + a routing skill

Scorecard question: Where does your agent get up-to-date library docs? Max-score answer (3 pts): Context7 + a skill that decides “library lookup vs general programming”.

Why this matters in 2026 (model training cutoffs vs weekly library updates)

Section titled “Why this matters in 2026 (model training cutoffs vs weekly library updates)”

The single biggest source of wasted turns in 2026 is still the same as it was in 2024: the model writes code against an API that no longer exists. React 19 dropped the implicit forwardRef pattern. Next.js 15 made params and searchParams async. Tailwind 4 reshuffled the config from tailwind.config.js into CSS-native @theme blocks. Drizzle’s relational queries API renamed half its methods between 0.30 and 0.36. Cloudflare Workers added a dozen new bindings since the last Claude/GPT/Gemini training cutoff. None of these changes are visible to a model whose training data ends nine months before you ask it the question — so it confidently writes code that uses the old API, you paste it in, it doesn’t compile, and you burn three turns finding out why.

The fix is not “use a smarter model”. The fix is to wire your agent into a source of current library documentation so it can look up the API surface that exists today, not the one that existed at training cutoff. That’s what Context7 does, and it’s why Q20 separates the developers who still wait 6–12 months for the next training cutoff from the developers whose agents are already reading the docs that shipped last Tuesday. Library APIs change weekly. Models hallucinate APIs that don’t exist. Context7 closes the gap.

The reason Q20 separates a 2-point answer (“I sometimes use Context7”) from a 3-point answer (“Context7 + a routing skill”) is that installing Context7 is only half the win. The other half is making sure the agent actually invokes it whenever a library question shows up — without you having to type “use context7” at the end of every prompt. That’s what the routing skill is for. Together, Context7 + skill turns “look up the current API of this library” from a thing you have to remember into a thing your agent does on its own.

A max-score Q20 setup has both halves wired in. The first half is Context7 MCP installed and authenticated, addressable at https://mcp.context7.com/mcp, visible in claude mcp list (and the equivalent for Codex / Cursor). The second half is a routing skill — a SKILL.md file with a description that triggers whenever the user mentions a specific library, framework, SDK, or version, and instructs the agent to call Context7 first before writing code against that library. The skill lives in ~/.claude/skills/library-lookup/ (mirrored to .cursor/skills/ and ~/.agents/skills/) and its description is specific enough that the model invokes it without you typing the word “context7” in the prompt.

In practice this looks like the following pattern. You ask the agent something like “set up a Drizzle query that joins users to subscriptions and filters by active status”. You don’t say “use context7”. You don’t say “look up the docs”. You just describe the task. The routing skill fires because the prompt mentions a library name and a non-trivial API surface. The skill instructs the agent to call resolve-library-id for Drizzle, then get-library-docs for the relational queries section, then write the code against that docs payload — not against its memory of how Drizzle worked at training time. The result is code that uses the current relational-queries API, references current method names, and compiles on the first try. No “use context7” suffix, no hallucinated method names, no three-turn correction loop.

A 2-point setup has Context7 installed but no routing skill — so it works when you remember to invoke it, and doesn’t when you don’t. A 1-point setup has no Context7 and falls back to whatever the model remembers from training, padded with the occasional WebFetch of a docs page when the user pastes a URL. A 0-point setup is “I just trust the model” — which in 2026 means you’re paying the hallucination tax on every library question. Max score requires both pieces wired so the lookup is automatic, not opt-in.

By May 2026 Context7 has consolidated as the default solution to the stale-docs problem across the entire agent ecosystem. It’s the #1 server on MCP.Directory by views (~2x the #2 entry), the install command appears in nearly every “best MCP setup for Claude Code / Codex / Cursor” roundup published in the last six months, and most major IDE-level agents now ship it as a one-click install option. The competitive landscape exists — Nia Oracle reports a slightly lower hallucination rate on bleeding-edge features (52.1% vs Context7’s 63.4% on the most cutting-edge unreleased APIs), and Mintlify auto-hosts an MCP per docs site for vendors who publish on Mintlify — but Context7’s combination of broad coverage (9,000+ libraries indexed), continuous freshness (new versions typically indexed within days of release), and zero-config install has made it the default pick.

Context7 MCP (free + paid tiers, library coverage)

Section titled “Context7 MCP (free + paid tiers, library coverage)”

Context7 is a remote MCP server hosted at https://mcp.context7.com/mcp. It indexes documentation for over 9,000 libraries, frameworks, and SDKs — React, Vue, Svelte, Next.js, Nuxt, Astro, Tailwind, Vite, Rollup, Prisma, Drizzle, Kysely, tRPC, Hono, Express, Fastify, Cloudflare Workers, Vercel SDKs, AWS SDK, Stripe, Supabase, Convex, the list goes on. The index is continuously updated: when a library releases a new version with documentation changes, Context7 typically picks it up within days, and for high-traffic libraries (React, Next.js, Tailwind) the lag is often hours.

The free tier covers most individual usage with rate limits that are generous enough for normal developer workflow. Paid tiers raise the rate limits and add features like organization-level usage analytics and priority indexing for libraries you submit. For most developers, “free tier + install and forget” is the right move; you’ll know if you need to upgrade when you hit a rate limit, and even then the upgrade is cheap relative to the time saved on hallucination cleanup.

How it works (resolve-library-id → get-library-docs)

Section titled “How it works (resolve-library-id → get-library-docs)”

Context7 exposes two tools to the agent. The first, resolve-library-id, takes a library name in natural language (“Drizzle ORM”, “Next.js”, “Tailwind 4”) and returns a canonical Context7 ID that identifies the library and version. The second, get-library-docs, takes that ID plus an optional topic parameter (e.g. “relational queries”, “app router”, “middleware”) and an optional tokens budget, and returns the relevant documentation chunks plus code examples for that topic.

The two-step pattern is deliberate. resolve-library-id is cheap and disambiguates between similarly-named libraries — “Next.js” vs “next” (the npm test runner), “Drizzle” the ORM vs “drizzle” (a Three.js helper). get-library-docs is the expensive call (it pulls actual docs content), and the topic filter is what keeps it from over-fetching: instead of dumping the entire Next.js docs into context, the agent asks for the specific section it needs (“App Router data fetching” or “Server Actions”) and gets a focused payload. A well-routed Context7 call returns 5–15 KB of relevant docs, not 500 KB of “every page on the site”.

The naive alternative to Context7 is “tell the agent to WebFetch the docs page”. This sometimes works — for a vendor with clean HTML docs and a stable URL, WebFetch can return the right content — but it has three problems that Context7 solves. First, retrieval quality: the agent has to guess the docs URL, which fails for vendors whose docs live under non-obvious paths (Cloudflare moves things around, Vercel rebrands every few months, smaller libraries have docs on GitHub READMEs that change format). Second, signal-to-noise: a docs page often includes nav, ads, marketing copy, and other libraries’ cross-links — Context7 strips that down to the actual API content. Third, version awareness: WebFetch returns whatever URL it’s pointed at; Context7 knows about library versions and can return docs for the specific version the user is on (or the latest stable, if version isn’t specified).

WebSearch is even worse for this use case — it returns a list of links to docs, blog posts, Stack Overflow answers, and AI-generated summary sites of varying quality. The agent then has to pick one, WebFetch it, and parse it. Context7 collapses that whole chain into a single tool call that returns curated, version-aware, API-focused content. Use WebFetch and WebSearch for things Context7 doesn’t cover (one-off blog posts, RFCs, GitHub issues); use Context7 for everything that has a canonical docs site.

Authoring a routing skill (description that auto-triggers on library mentions)

Section titled “Authoring a routing skill (description that auto-triggers on library mentions)”

The routing skill is the bridge between “Context7 is installed” and “Context7 actually gets called when it should”. It’s a SKILL.md in ~/.claude/skills/library-lookup/ whose description is specific and slightly pushy — listing the kinds of prompts where Context7 should fire — and whose body tells the agent the actual workflow: call resolve-library-id first, then get-library-docs with a targeted topic, then write code against the returned payload.

The description is the entire game. Recall from Q8 that the model only sees the name and description of every skill at session boot — the body is only loaded when the description matches a request. So your description must list the trigger conditions explicitly: “whenever the user mentions a specific library, framework, SDK, or version”, “whenever the user asks for the current API of a library”, “whenever the user pastes code that imports from a third-party package and asks the agent to extend or refactor it”. A vague description like “Helps with documentation” will never fire. A specific one like “Triggers whenever the user mentions a JavaScript/TypeScript library, framework, ORM, or SDK by name — Drizzle, Next.js, Tailwind, React, Hono, tRPC, etc. — to fetch current docs from Context7 before generating code” fires reliably.

  1. Install Context7 MCP. Run:

    Terminal window
    claude mcp add --transport http context7 https://mcp.context7.com/mcp

    The free tier is fine to start; you can sign up for an API key later if you hit rate limits. Confirm with claude mcp listcontext7 should appear. For Codex CLI: codex mcp add --transport http context7 https://mcp.context7.com/mcp. For Cursor: add via the MCP panel with the same URL.

  2. Test Context7 in a session. Open a new agent session and ask something like “look up the current API for Drizzle’s db.query relational queries — I want to see the actual method signatures”. The agent should call resolve-library-id then get-library-docs and return current docs content. If it doesn’t fire on its own, you don’t have the routing skill yet — that’s fine, move to the next step.

  3. Create the routing skill directory. Run:

    Terminal window
    mkdir -p ~/.claude/skills/library-lookup

    For cross-tool sharing, also create ~/.cursor/skills/ and ~/.agents/skills/ and symlink the same folder into both: ln -s ~/.claude/skills/library-lookup ~/.cursor/skills/library-lookup and similar for ~/.agents/skills/.

  4. Write the SKILL.md. Create ~/.claude/skills/library-lookup/SKILL.md:

    ---
    name: library-lookup
    description: Triggers whenever the user mentions a JavaScript/TypeScript/Python library, framework, ORM, SDK, or CLI tool by name — including React, Next.js, Astro, Tailwind, Drizzle, Prisma, Hono, tRPC, Cloudflare Workers, Vercel AI SDK, Stripe SDK, Polar SDK, Supabase, Convex, FastAPI, Django, etc. Use whenever the user asks for current API surface, migration steps between versions, or "how do I X with library Y". Always call Context7 (resolve-library-id → get-library-docs) BEFORE generating code that uses the library, and quote the returned docs in your response so the user can verify.
    version: 1.0.0
    ---
    # Library lookup routing
    ## When to use
    Fire this skill whenever ANY of the following are true:
    - The user mentions a specific library, framework, SDK, ORM, or CLI tool by name.
    - The user asks "how do I X with Y" where Y is a third-party package.
    - The user pastes code that imports from a third-party package and asks to extend or refactor it.
    - The user asks about migration between versions of a library.
    - The user asks for the current API surface of any package.
    Do NOT fire for: refactoring without library questions, debugging business logic, code review, or general programming concepts.
    ## Steps
    1. Identify the library name(s) from the user's prompt.
    2. Call `resolve-library-id` with the library name to get the canonical Context7 ID.
    3. Call `get-library-docs` with that ID and a focused `topic` parameter that matches what the user actually asked about (e.g. "relational queries", "App Router", "middleware"). Keep `tokens` modest (5000–10000) unless the user asked for exhaustive coverage.
    4. Write code against the returned docs payload, not against your training memory.
    5. In your response, briefly quote the relevant method signature or config block from the docs so the user can sanity-check.
    ## Gotchas
    - Do NOT over-fetch. A `get-library-docs` call with no `topic` filter can return hundreds of KB of irrelevant content and waste the user's context budget. Always scope by `topic`.
    - Do NOT fall back to model memory if Context7 returns nothing useful. Instead, try a different `topic` phrasing, or surface the gap to the user ("Context7 didn't return current docs for X — want me to WebFetch the official docs page instead?").
    - Do NOT trigger on generic mentions ("I love TypeScript", "JavaScript is fun"). Trigger only when the prompt is asking about a specific *named library or framework*.
  5. Test the skill fires automatically. Open a fresh agent session and describe a task that should trigger it — without saying “use context7” or naming the skill. Example: “Help me set up a Hono route that streams a response from an async generator.” Watch the transcript: did the agent load the library-lookup skill and call resolve-library-id + get-library-docs for Hono? If yes, you’re done. If no, the description was too generic — add more specific trigger phrases (more library names, more verb patterns like “set up a”, “how do I”, “configure”) and try again.

  6. Commit the skill to version control. Add ~/.claude/skills/library-lookup/ to a personal dotfiles repo (or a team skills/ repo if multiple developers should inherit the same routing). Skills are infrastructure; treat them like config, not like throwaway files.

  7. Iterate on every miss. Every time you notice the agent wrote code against a stale API (deprecated React pattern, old Drizzle method name, removed Tailwind utility), open the transcript, find the prompt that should have triggered the skill, and check why it didn’t. Usually the description is missing the relevant verb pattern or library name — add it, save, retry. Over a few weeks the skill converges to a description that fires reliably across your real workflow.

  • Over-fetching docs. Calling get-library-docs with no topic filter dumps the entire library docs into context — 100–500 KB for a large framework like Next.js. This eats your context budget and slows every subsequent turn in the session. The skill’s ## Steps section should explicitly tell the agent to scope by topic with a tight tokens budget (5,000–10,000), and only widen the scope if the user asks for exhaustive coverage.
  • No routing trigger. Installing Context7 without a routing skill means the agent only invokes it when the user explicitly types “use context7” at the end of a prompt. Most of the time the user forgets, and the agent silently falls back to training memory. The whole point of the skill is to remove the burden of remembering — if your description is too generic to fire on its own, you’ve installed half the solution.
  • Fallback to model memory when Context7 returns nothing useful. Sometimes Context7 doesn’t have docs for a library, or returns docs that don’t answer the specific question. The wrong move is to silently fall back to whatever the model remembers from training (which is exactly what you were trying to avoid). The right move is to surface the gap: “Context7 returned no docs for this — want me to WebFetch the official docs page instead?” The skill’s ## Gotchas block should call this out explicitly.
  • Over-triggering on generic mentions. A description that fires on any mention of “TypeScript” or “JavaScript” will fire on prompts that don’t actually need a library lookup — burning a turn on a useless resolve-library-id call for “javascript”. The description should specify named libraries, frameworks, SDKs — not generic language mentions.
  • Mistaking WebFetch for Context7. A “library docs” workflow that uses WebFetch of the docs URL instead of Context7 is fragile: the agent has to guess the URL, parses HTML that includes nav and ads, and gets no version awareness. Use WebFetch only for one-off pages Context7 doesn’t cover (RFCs, GitHub issues, individual blog posts) — not as the primary docs source.
  • Skipping the trio entry. If your Q10 trio doesn’t already include Context7, your Q20 max-score is incompatible with your Q10 — fix Q10 first by adding Context7 to your three essential MCPs. Q20 is a downstream consequence of having Context7 installed; you can’t max Q20 without first maxing the Context7 slot in Q10.
  • claude mcp list (and Codex / Cursor equivalents) shows context7 with endpoint https://mcp.context7.com/mcp.
  • ~/.claude/skills/library-lookup/SKILL.md exists (and is symlinked or copied into ~/.cursor/skills/ and ~/.agents/skills/).
  • The skill’s description lists specific trigger conditions — library names, verb patterns, prompt shapes — not a generic one-liner.
  • In a recent agent transcript, you can point to at least one line where the agent loaded library-lookup and called resolve-library-id + get-library-docs without you typing “use context7” anywhere in the prompt.
  • The get-library-docs call had a focused topic parameter and a modest tokens budget — not a blank topic that dumped the whole library into context.
  • The skill is in version control (personal dotfiles or team skills/ repo), not just sitting in ~/.claude/skills/ waiting to be lost on the next machine move.
  • You haven’t hand-typed “use context7” at the end of a prompt in the last week — the routing skill has made it unnecessary.