devcontext / rules
Cursor rule49 starsChanged 18 months agoMITView on GitHub
Require using Context7 or Web Search to review library documentation before implementation
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- .cursor/rules/020-tasks-workflow.mdcCursor rule
- .cursor/rules/200-cursor-rules.mdcCursor rule
The file
Show its rules and text
We split this 010-documentation-context.mdc into the rules it gives an agent
14 rules. About 0 are common, 14 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
No exceptions - even for commonly known libraries like React, Express, or Lodash
- Distinctive: line 41
Do not rely on previously cached knowledge for current implementations
- Distinctive: line 42
Never make assumptions about library interfaces, verify with current documentation
- Distinctive: line 60
Always check current API version compatibility
- Distinctive: line 62
Verify required dependencies and peer dependencies
- Distinctive: line 133
All transitive dependencies must be documented
- Distinctive: line 153
If Context7 cannot provide documentation or returns insufficient information, the agent MUST use the web search tool
- Distinctive: line 154
Always search for the most recent documentation as of mid-2025
- Distinctive: line 155
Verify the library version against the latest available release
- Distinctive: line 200
Search queries MUST include:
- Distinctive: line 206
Verify information from at least 2-3 reputable sources when possible
- Distinctive: line 207
Consider official documentation, GitHub repositories, and trusted developer resources
- Distinctive: line 211
When using web search, compile information from multiple sources
- Distinctive: line 214
Document any discrepancies found between sources
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Require using Context7 or Web Search to review library documentation before implementation
globs: **/*
alwaysApply: true
---
# 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**
```javascript
// ✅ 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**
```javascript
// ✅ 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**
```javascript
// ✅ 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**
```javascript
// ✅ 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**
- All transitive dependencies must be documented
- Version compatibility must be verified
- Properly handle conflicting dependencies
- **Update Implementation After Documentation Review**
```javascript
// ✅ DO: Update existing code based on documentation
// If reviewing code that uses libraries without proper documentation:
// 1. Retrieve documentation for used libraries
// 2. Verify existing implementation against documentation
// 3. Correct any discrepancies found
// ❌ DON'T: Assume existing implementation is correct
// ❌ DON'T: Skip verification of existing library usage
```
- **MUST Use Web Search When Documentation Is Unavailable**
- If Context7 cannot provide documentation or returns insufficient information, the agent MUST use the web search tool
- Always search for the most recent documentation as of mid-2025
- Verify the library version against the latest available release
```javascript
// ✅ DO: Fallback to web search when Context7 fails
try {
// First attempt to use Context7
const libraryIdResponse =
(await mcp_context7_resolve-library-id({
libraryName: "some-library",
});
const docsResponse =
(await mcp_context7_get-library-docs({
context7CompatibleLibraryID: libraryIdResponse.libraryId,
});
// Check if documentation is insufficient
if (!docsResponse.content || docsResponse.content.length < 100) {
throw new Error("Insufficient documentation");
}
} catch (error) {
// If Context7 fails or returns insufficient docs, use web search
const webResults = await web_search({
search_term: "some-library latest documentation api reference mid 2025",
explanation: "Context7 documentation was unavailable or insufficient",
});
// Analyze multiple search results to get comprehensive information
const latestDocs = webResults.filter(
(result) =>
result.includes("documentation") ||
result.includes("api reference") ||
result.includes("guide")
);
// Use these web results to guide implementation
}
// ❌ DON'T: Skip web search when Context7 fails
// ❌ DON'T: Proceed with implementation without documentation
// ❌ DON'T: Use outdated web search results (verify they're current as of mid-2025)
```
- **Web Search Requirements**
- Search queries MUST include:
- Library name
- "latest documentation" or "api reference"
- Version information (if known)
- "mid 2025" to get the most recent documentation
- Multiple searches may be needed to gather comprehensive information
- Verify information from at least 2-3 reputable sources when possible
- Consider official documentation, GitHub repositories, and trusted developer resources
- **Synthesize Documentation From Multiple Sources**
- When using web search, compile information from multiple sources
- Prioritize official documentation sources
- Cross-reference information to ensure accuracy
- Document any discrepancies found between sources
```javascript
// ✅ DO: Synthesize documentation from multiple sources
const webResults = [
await web_search({
search_term: "library-name official documentation mid 2025",
explanation: "Finding official documentation",
}),
await web_search({
search_term: "library-name GitHub README api reference mid 2025",
explanation: "Finding GitHub documentation",
}),
await web_search({
search_term: "library-name latest tutorial examples mid 2025",
explanation: "Finding practical examples",
}),
];
// Analyze and synthesize the results
// Extract API details, examples, and best practices
// Document any conflicting information
// ❌ DON'T: Rely on a single search result
// ❌ DON'T: Skip verification across multiple sources
```
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

