agentleFS
girijashankarjgirijashankarj/cursor-handbook/.cursor/rules/architecture/token-efficiency.mdc

cursor-handbook / architecture

Cursor rule31 starsChanged 3 months agoMITView on GitHub

Token optimization rules to reduce AI costs by 30%+

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
  1. Distinctive:

    Use layered context to minimize token consumption:

    line 9
  2. Very specific:

    Use read_lints tool instead of running lint commands

    line 27
  3. Very specific:

    Run {{CONFIG.testing.typeCheckCommand}} (~10K tokens) instead of full tests

    line 28
  4. Distinctive:

    Run tests for a single file instead of the entire suite

    line 29
  5. Distinctive:

    Read only the specific functions/sections needed, not entire files

    line 30
  6. Distinctive:

    Summaries over verbose: Use bullet points, not paragraphs

    line 33
  7. Distinctive:

    No redundant context: Don't repeat information the user already provided

    line 36
  8. Distinctive:

    Structured responses: Use headers, lists, and tables

    line 37
  9. Distinctive:

    Code blocks: Only show relevant sections, not entire files

    line 38
  10. Distinctive:

    Read only the files directly related to the task

    line 41
  11. Distinctive:

    Start with type definitions and interfaces

    line 42
  12. Distinctive:

    Read implementation files only when needed

    line 43
  13. Distinctive:

    Never read generated files (dist/, build/, coverage/)

    line 44
  14. Distinctive:

    Use file search tools to find specific symbols instead of reading entire files

    line 45
  15. Distinctive:

    When asked to "review" code, focus on: bugs, security issues, performance — skip style

    line 48
  16. Distinctive:

    When asked to "implement", show the minimal diff — not the entire file

    line 49
  17. Distinctive:

    When asked to "explain", use a layered approach: summary first, details on request

    line 50
  18. Distinctive:

    When asked to "test", create tests for the specific function — not the entire module

    line 51

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
token-efficiency.mdc
---
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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.