agentleFS
peopleforresterpeopleforrester/claude-dotfiles/skills/optimization/strategic-compact/SKILL.md

strategic-compact

Skill3 starsChanged 8 months agoMITView on GitHub

Context window optimization strategies for Claude Code. Covers token budgets, CLAUDE.md sizing, skill organization, tool selection, and techniques for maximizing productive output within context limits. Use when optimizing Claude Code configurations or managing large projects.

40 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use kotlin-testing, ralphinho-rfc-pipeline and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • tpavanipradeepSkill

    kotlin-testing

    Kotlin testing patterns with Kotest, MockK, coroutine testing, property-based testing, and Kover coverage. Follows TDD methodology with idiomatic Kotlin practices.

    Also in 6 projects that use this

  • InfopibeSkill

    ralphinho-rfc-pipeline

    RFC-driven multi-agent DAG execution pattern with quality gates, merge queues, and work unit orchestration.

    Also in 10 projects that use this

  • mryeastcodeSkill

    nuxt4-patterns

    Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.

    Also in 5 projects that use this

  • saxon-ySkill

    configure-ecc

    Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.

    Also in 12 projects that use this

  • InfopibeSkill

    content-hash-cache-pattern

    Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.

    Also in 11 projects that use this

  • mryeastcodeSkill

    santa-method

    Multi-agent adversarial verification with convergence loop. Two independent review agents must both pass before output ships.

    Also in 6 projects that use this

  • +3 more from Infopibe

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 36 edited versions we read keep these.

  • 2

    Distinctive

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

    When a conversation is compacted (summarized to save space):

    line 161
  2. Distinctive:

    Check git status for current change state

    line 165

“Common” is measured: kept by at least 6 in 10 of the 36 edited versions of this file we could read. “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
SKILL.md

Strategic Compact

Techniques for optimizing Claude Code's context window usage.

Context Window Budget

Claude Code loads several sources into context at session start:

SourceTarget BudgetMax Budget
CLAUDE.md (global)500 tokens1,000
CLAUDE.md (project)1,500 tokens2,500
Active skills1,500 per skill3,000
Rules (all loaded)500 per rule1,000
Agent definitions500 per agent1,000
Total passive load< 10,000< 20,000

The remaining context budget is for conversation, code, and tool results.

CLAUDE.md Optimization

Size Guidelines

60-100 lines  → Optimal (loads fast, leaves room for code)
100-150 lines → Acceptable (for complex projects)
150+ lines    → Too large (move details to skills or docs)

What Belongs in CLAUDE.md

✓ Stack and language versions
✓ Build/test/deploy commands
✓ Key directory structure
✓ Critical gotchas (non-obvious behaviors)
✓ Project-specific conventions

What Does NOT Belong in CLAUDE.md

✗ Language tutorials or syntax guides    → Use skills
✗ General best practices                 → Use rules
✗ Long code examples                     → Use skills
✗ Documentation that exists elsewhere    → Link to it
✗ Change history                         → Use CHANGELOG.md

Token-Efficient Writing

# Bad (verbose): 45 tokens
## Testing
To run the tests for this project, you should use the following command
which will discover and execute all test files:
`pytest tests/ -v`

# Good (concise): 12 tokens
## Commands
- **Test**: `pytest tests/ -v`

Skill Organization

When to Create a Skill vs. Inline in CLAUDE.md

SignalLocation
Used in every sessionCLAUDE.md
Used occasionallySkill
Language-specific patternsSkill
Framework-specific patternsSkill
One-time workflowCommand

Skill Loading Strategy

Skills are loaded on demand. Organize so that:

  1. Frequently used skills have clear, searchable names
  2. Related patterns are grouped in one skill (not scattered)
  3. Each skill is self-contained (no cross-skill dependencies)

Tool Budget Management

MCP tools consume context tokens. Fewer active tools = more room for code.

Tool CountImpact
< 10Minimal overhead
10-20Optimal range
20-40Noticeable context cost
40-80Significant — disable unused tools
80+Performance degradation likely

Optimization Steps

  1. Audit — List all configured MCP servers and tools
  2. Measure — Count total tools across all servers
  3. Prune — Disable tools you haven't used in 2+ weeks
  4. Group — Use one multi-purpose tool over many single-purpose ones

Conversation Efficiency

Reduce Round Trips

Bad:  "Read file A" → result → "Read file B" → result → "Now edit both"
Good: "Read file A and file B" → results → "Edit both"

Batch Independent Operations

Launch parallel operations when results don't depend on each other:

✓ Read 3 files simultaneously
✓ Run lint + type-check + test in parallel
✓ Search for pattern across multiple directories at once

Avoid Context Pollution

✗ Pasting entire file contents into chat when a path reference suffices
✗ Asking Claude to "explain this code" without specifying what's unclear
✗ Requesting verbose output when a summary would work

Large Project Strategies

Monorepo Navigation

1. Use Glob to find files by pattern (not ls -R)
2. Use Grep to search content (not reading files sequentially)
3. Delegate exploration to subagents (preserves main context)
4. Focus on one package/module per task

Context Recovery After Compaction

When a conversation is compacted (summarized to save space):

  1. Re-read CLAUDE.md to restore project context
  2. Re-read the specific file(s) you're working on
  3. Check git status for current change state
  4. Continue from the task summary, not from scratch

Checklist

  • CLAUDE.md under 150 lines / 2,000 tokens
  • Token count documented in CLAUDE.md header comment
  • Patterns moved to skills, not inlined in CLAUDE.md
  • MCP tool count under 40 active tools
  • Parallel tool calls used where possible
  • Subagents used for exploration (preserves main context)
  • Rules are concise (under 500 tokens each)

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.