cursor-handbook / architecture
Cursor rule31 starsChanged 3 months agoMITView on GitHub
Token optimization rules to reduce AI costs by 30%+
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 repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/architecture/core-principles.mdcCursor rule
- .cursor/rules/architecture/dependency-management.mdcCursor rule
- .cursor/rules/backend/api-design.mdcCursor rule
- .cursor/rules/backend/code-organization.mdcCursor rule
- .cursor/rules/backend/error-handling.mdcCursor rule
- .cursor/rules/backend/handler-patterns.mdcCursor rule
- .cursor/rules/backend/nodejs.mdcCursor rule
- .cursor/rules/backend/typescript.mdcCursor rule
- .cursor/rules/cloud/containerization.mdcCursor rule
- .cursor/rules/cloud/infrastructure.mdcCursor rule
- .cursor/rules/cloud/serverless.mdcCursor rule
- .cursor/rules/database/migration-rules.mdcCursor rule
- .cursor/rules/database/query-patterns.mdcCursor rule
- .cursor/rules/database/schema-design.mdcCursor rule
- .cursor/rules/devops/ci-cd.mdcCursor rule
- .cursor/rules/devops/documentation-standards.mdcCursor rule
- .cursor/rules/devops/monitoring.mdcCursor rule
- .cursor/rules/frontend/accessibility.mdcCursor rule
- .cursor/rules/frontend/component-patterns.mdcCursor rule
- .cursor/rules/frontend/performance.mdcCursor rule
- .cursor/rules/frontend/state-management.mdcCursor rule
- .cursor/rules/main-rules.mdcCursor rule
- .cursor/rules/security/guardrails.mdcCursor rule
- .cursor/rules/security/secrets-rules.mdcCursor rule
- .cursor/rules/security/security-compliance.mdcCursor rule
- .cursor/rules/testing/integration-testing.mdcCursor rule
- .cursor/rules/testing/mock-patterns.mdcCursor rule
- .cursor/rules/testing/testing-standards.mdcCursor rule
The file
Show its rules and text
We split this token-efficiency.mdc into the rules it gives an agent
18 rules. About 0 are common, 16 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈16
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Use layered context to minimize token consumption:
- Very specific: line 27
Use read_lints tool instead of running lint commands
- Very specific: line 28
Run {{CONFIG.testing.typeCheckCommand}} (~10K tokens) instead of full tests
- Distinctive: line 29
Run tests for a single file instead of the entire suite
- Distinctive: line 30
Read only the specific functions/sections needed, not entire files
- Distinctive: line 33
Summaries over verbose: Use bullet points, not paragraphs
- Distinctive: line 36
No redundant context: Don't repeat information the user already provided
- Distinctive: line 37
Structured responses: Use headers, lists, and tables
- Distinctive: line 38
Code blocks: Only show relevant sections, not entire files
- Distinctive: line 41
Read only the files directly related to the task
- Distinctive: line 42
Start with type definitions and interfaces
- Distinctive: line 43
Read implementation files only when needed
- Distinctive: line 44
Never read generated files (dist/, build/, coverage/)
- Distinctive: line 45
Use file search tools to find specific symbols instead of reading entire files
- Distinctive: line 48
When asked to "review" code, focus on: bugs, security issues, performance — skip style
- Distinctive: line 49
When asked to "implement", show the minimal diff — not the entire file
- Distinctive: line 50
When asked to "explain", use a layered approach: summary first, details on request
- Distinctive: line 51
When asked to "test", create tests for the specific function — not the entire module
≈ “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: "Token optimization rules to reduce AI costs by 30%+"
alwaysApply: true
---
# Token Efficiency Rules
## Context Layering Strategy
Use layered context to minimize token consumption:
| Layer | Token Budget | What to Include |
|-------|-------------|-----------------|
| Immediate | {{CONFIG.cursor.tokenOptimization.contextLayers.immediate}} | Current file, direct dependencies |
| Relevant | {{CONFIG.cursor.tokenOptimization.contextLayers.relevant}} | Related modules, shared types |
| Extended | {{CONFIG.cursor.tokenOptimization.contextLayers.extended}} | Broader codebase patterns |
| Reference | {{CONFIG.cursor.tokenOptimization.contextLayers.reference}} | Documentation, examples |
## Expensive Operations — REQUIRE CONFIRMATION
### Operations that MUST require user confirmation:
1. **Full test suite** (`{{CONFIG.testing.testCommand}}`) — estimated 100K+ tokens
2. **Full lint** (`{{CONFIG.testing.lintCommand}}`) — estimated 50K+ tokens
3. **Full build** — estimated 75K+ tokens
4. **Reading 10+ files** — estimated 50K+ tokens
### Preferred alternatives:
- Use `read_lints` tool instead of running lint commands
- Run `{{CONFIG.testing.typeCheckCommand}}` (~10K tokens) instead of full tests
- Run tests for a **single file** instead of the entire suite
- Read only the specific functions/sections needed, not entire files
## Output Guidelines
- **Summaries over verbose**: Use bullet points, not paragraphs
- **Diff format**: Show only changed lines when editing files
- **Max 3 sentences** for explanations unless user asks for more
- **No redundant context**: Don't repeat information the user already provided
- **Structured responses**: Use headers, lists, and tables
- **Code blocks**: Only show relevant sections, not entire files
## File Reading Strategy
1. Read only the files directly related to the task
2. Start with type definitions and interfaces
3. Read implementation files only when needed
4. Never read generated files (dist/, build/, coverage/)
5. Use file search tools to find specific symbols instead of reading entire files
## Token-Saving Patterns
- When asked to "review" code, focus on: bugs, security issues, performance — skip style
- When asked to "implement", show the minimal diff — not the entire file
- When asked to "explain", use a layered approach: summary first, details on request
- When asked to "test", create tests for the specific function — not the entire module
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.

