010-documentation-context

A project rule requiring library documentation to be checked through Context7 or web search before implementation. Context7 is a documentation lookup service for software libraries.

In plain words
What is it for?
It is for enforcing a two-step documentation lookup before using external libraries in code.
Why use it?
It reduces the risk of implementing code against incorrect or outdated library behavior.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/aiurda/devcontext/010-documentation-context
Clone the repo
git clone --depth 1 https://github.com/aiurda/devcontext

Made for: Cursor.

Per session 1,690 This file is loaded in full into every session.
When invoked 1,690 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01690 $0.01690
Opus 5 $0.00845 $0.00845
Sonnet 5 $0.00338 $0.00338
Haiku 4.5 $0.00169 $0.00169

Measured yesterday against content hash 7cc8f6776891, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

010-documentation-context scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/010-documentation-context.mdc · 240 lines

How it starts

The opening of the file, as written. The whole thing — 240 lines — stays where its author put it; the contents beside it link to each section on GitHub.

External Library Documentation Requirements

  • ALWAYS Use Context7 Before Using External Libraries

    • The agent MUST retrieve and review documentation via Context7 before implementing any code that uses an external library
    • This applies to ALL libraries not part of the standard language libraries
    • No exceptions - even for commonly known libraries like React, Express, or Lodash
  • Two-Step Documentation Retrieval Process

    // ✅ DO: ALWAYS follow this exact two-step process
    // Step 1: Resolve the library name to a Context7-compatible ID
    const libraryIdResponse =
      await mcp_context7_resolve-library-id({
        libraryName: "express",
      });
    
    // Step 2: Get the documentation using the resolved ID
    const docsResponse =
      await mcp_context7_get-library-docs({
        context7CompatibleLibraryID: libraryIdResponse.libraryId,
        tokens: 10000, // Adjust based on documentation needs
        topic: "routing", // Optional: focus on specific area
      });
    
    // ❌ DON'T: Skip the resolution step
    // ❌ DON'T: Use hardcoded library IDs
    // ❌ DON'T: Proceed with implementation without review
    
  • Never Skip Documentation Retrieval

    • Documentation MUST be retrieved even for seemingly simple APIs
    • Do not rely on previously cached knowledge for current implementations
    • Never make assumptions about library interfaces, verify with current documentation
  • Document First, Implement Second

    // ✅ DO: Review documentation BEFORE writing implementation code
    // 1. Identify library need
    // 2. Retrieve documentation
    // 3. Review relevant sections
    // 4. THEN implement solution
    
    // ❌ DON'T: Implementation without documentation
    const app = express(); // WRONG - Documentation not retrieved first
    app.get("/", (req, res) => res.send("Hello"));
    
  • Verify API Compatibility

    • Always check current API version compatibility
    • Validate method signatures against retrieved documentation
    • Verify required dependencies and peer dependencies
  • Handle Documentation Response Properly

    // ✅ DO: Properly handle the documentation response
    const docsResponse =
      await mcp_context7_get-library-docs({
        context7CompatibleLibraryID: "vercel/nextjs",
      });
    
    // Extract relevant information
    const sections = docsResponse.content.sections;
    const examples = sections.filter((s) => s.type === "example");
    const apiDocs = sections.filter((s) => s.type === "api");
    
    // Use this for implementation guidance
    // ...
    
    // ❌ DON'T: Ignore retrieved documentation
    // ❌ DON'T: Proceed with implementation based on assumptions
    
  • Required Documentation Review Checklist

    • Core API functions and methods must be verified
    • Method signatures and parameters must be validated
    • Return values and types must be confirmed
    • Required configuration must be identified
    • Common patterns and examples must be analyzed
  • Example Implementation Flow

    // ✅ DO: Follow this implementation flow
    
    // 1. Identify need for external library
    // "I need to implement JWT authentication in Express"
    
    // 2. Resolve library IDs for ALL needed libraries
    const expressLibrary =
      await mcp_context7_resolve-library-id({
        libraryName: "express",
      });
    
    const jwtLibrary =
      await mcp_context7_resolve-library-id({
        libraryName: "jsonwebtoken",
      });
    
    // 3. Retrieve documentation for ALL libraries
    const expressDocs =
      await mcp_context7_get-library-docs({
        context7CompatibleLibraryID: expressLibrary.libraryId,
      });
    
    const jwtDocs =
      await mcp_context7_get-library -
      docs({
        context7CompatibleLibraryID: jwtLibrary.libraryId,
        topic: "authentication",
      });
    
    // 4. Review documentation and extract implementation details
    // 5. Create implementation with proper reference to documentation
    
    // ❌ DON'T: Skip any library in multi-library implementations
    
  • Documentation First for Dependency Resolution

Read the full file on GitHub · 240 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 240 lines · 1,690 tokens per session scan A 7cc8f6776891

Subscribe to this mod's changes

010-documentation-context is a cursor rule published in the GitHub repository aiurda/devcontext (47 stars, last pushed 1y ago), licensed MIT. It adds 1,690 tokens to every session, about $0.0085 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.