Stop your agent from hallucinating functions that don't exist
When to use: You're working with Next.js 15, Prisma 5, Drizzle, LangChain 0.3, or any fast-moving library and your agent keeps inventing functions that don't exist.
Prerequisites
- Node 18+ — node -v
- Context7 MCP installed — Paste the config block above into your Claude Desktop / Cursor / Windsurf settings
Flow
-
Name the library explicitlyUsing Context7, pull the latest docs for prisma and show me the right way to do a transaction with nested relation writes.✓ Copied→ Agent calls resolve-library-id then query-docs with a relevant query, not a Wikipedia-style summary
-
Pin to a version if it mattersI'm on [email protected]. Use Context7 to get the App Router streaming docs for that exact version.✓ Copied→ Citation includes the version; code uses file-based conventions, not getServerSideProps
-
Cross-check your own codeRead the imports in src/lib/db.ts, then use Context7 to verify every function I imported actually exists in drizzle-orm 0.30.x.✓ Copied→ Per-import ✓/✗ report with doc links
Outcome: Agent output uses real, current APIs — first try — instead of plausible-looking invented ones.
Pitfalls
- Agent forgets to call Context7 on the second turn — Put 'always use Context7 for library questions' in your system prompt or CLAUDE.md
- Library name ambiguous (e.g. 'supabase') — Let resolve-library-id return matches; pick the specific package (supabase-js vs @supabase/ssr)