Check Current Docs First: Stop Agents Using Outdated APIs
Rules that make Claude Code, Cursor, and Codex check your installed versions and current docs before calling any API, cite the version, and flag deprecations.
Added
Add this section to AGENTS.md or CLAUDE.md, or save it as .cursor/rules/current-docs.mdc with alwaysApply: true. Edit every [BRACKETED] part. ## Check the current docs before you use any API Your training data is months or years old, and libraries change. Never write code against a third-party library, SDK, CLI, or hosted API from memory alone. For every one you touch: 1. Find the installed version. Read the lockfile or manifest, not your memory: [package-lock.json / pnpm-lock.yaml / yarn.lock / uv.lock / poetry.lock / requirements.txt / go.mod / Cargo.lock / Gemfile.lock]. If the package is not installed, say so and ask before adding it. 2. Read docs for THAT version, in this order: a. Docs pinned in this repo: [docs/vendor/ or docs/llms/] b. The library's llms.txt or llms-full.txt, or its official docs for the exact major version (use your web or docs tool, e.g. [a docs MCP server like Context7]) c. The installed code itself: type definitions (node_modules/[pkg]/**/*.d.ts), the package source, `go doc`, `[tool] --help` d. The CHANGELOG or migration guide between the version you remember and the installed one If you have no web or docs tool, use (c) and say plainly that online docs were not checked. 3. Never upgrade, downgrade, or add a dependency to make your code fit. If what you need requires another version, stop and tell me: installed version, needed version, breaking changes. 4. Do not invent endpoints, parameters, flags, config keys, or model names. If you cannot verify one, mark it UNVERIFIED in a code comment and in your summary. 5. Deprecated APIs: do not use them in new code. If existing code uses them, list them under "Deprecated APIs found". Do not migrate them unless I ask. 6. Docs beat memory. If docs and the code in this repo disagree, stop and ask: the repo may pin an old version on purpose. 7. Hosted APIs ([Stripe / OpenAI / Supabase / ...]): check the API version or date the repo sends, the SDK version, and current model or endpoint names before changing calls. 8. Prove it compiles against what is installed: run [typecheck/build command, e.g. npm run typecheck]. Type errors against installed types are the fastest outdated-API detector. ## Pinned versions (keep this list current) - [e.g. next@15.x, react@19.x, prisma@6.x, python 3.12, pydantic 2.x] - Known traps: [e.g. "Next.js 15: cookies() and headers() are async, await them" / "Pydantic v2: use model_dump(), not .dict()"] ## Report this in every summary APIs used: - [package@version]: [function or endpoint], checked in [URL or file path] Unverified: [list or "none"] Deprecated APIs found: [list or "none"] --- EXAMPLE summary (filled in) APIs used: - next@15.1.6: cookies() from next/headers (async), checked in node_modules/next/dist/server/request/cookies.d.ts - stripe@17.5.0: checkout.sessions.create with ui_mode "embedded", checked in Stripe API docs for the version pinned in lib/stripe.ts Unverified: none Deprecated APIs found: pages/api/legacy-webhook.ts uses the old body-parser config; not changed.
How to use it
- Click Copy template.
- Paste into ChatGPT, Claude, Grok, Cursor, or your agent framework.
- Replace the [BRACKETED] parts with your details.
FAQ
Why do AI coding agents use outdated or deprecated APIs?
Models learn from code written before their training cutoff, so they confidently write calls for older versions of libraries and APIs. Unless the agent checks the version installed in your project and the docs for that version, it will mix old and new syntax, invent parameters, or use functions that were removed.
What is llms.txt and how does it help coding agents?
llms.txt is a plain-text file many docs sites publish at /llms.txt that links to their docs in an AI-friendly format, sometimes with an llms-full.txt containing the full text. Pointing your agent at it gives it current docs in one fetch instead of relying on memory.
What if my agent has no internet access?
It can still check the truth on disk: the lockfile for exact versions, type definitions and package source for real function signatures, and the package CHANGELOG. You can also save the docs pages you rely on into docs/vendor/ so every session has them.
Will this slow the agent down?
Slightly, on the first use of each library in a session. It's much cheaper than debugging code written for the wrong version. Keep the pinned-versions list and known traps in the rules file so the agent doesn't rediscover them every time.
Get 3 new templates every week
Free. Unsubscribe anytime.Related templates
Minimal Diff Rules: Stop AI Agents Rewriting Unrelated Code
AGENTS.md Starter Template for Claude Code, Codex & Cursor
This Codebase Is Yours: Ownership Rules for Coding Agents
Rules File Drift Check: Is Your AGENTS.md Lying to the Agent?
Browse all Coding & Cursor Rules templates