agentleFS
penkatypenkaty/lean-context/SKILL.md

lean-context

Skill1 starsChanged 24 days agoMITView on GitHub

Keep coding-agent sessions cheap on large, multi-repo projects. Use when setting up or auditing a project for Claude Code (CLAUDE.md, project map, settings, tools), when sessions start with a large context, or before long multi-day tasks.

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. 0 are common, 12 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 12

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create PROJECT_MAP.md at the project root (template in templates/).

    line 12
  2. Distinctive:

    Put a short "how to read cheaply" block at the top (see the template) and a never-open list for bulky folders.

    line 16
  3. Very specific:

    Keep it complete automatically: python scripts/mapcheck.py --install-hook warns on every commit when a file is missing from the map or a …

    line 17
  4. Distinctive:

    When the agent adds, moves or removes a file, it fixes the map row in the same turn.

    line 19
  5. Distinctive:

    Start every source file, config and script with a header comment saying what it is and when to use it.

    line 28
  6. Distinctive:

    Prefer a code-graph or symbol-search tool for "where is this used" over opening files.

    line 30
  7. Distinctive:

    Never list whole trees. Provide a tree command that skips bulk folders.

    line 31
  8. Distinctive:

    Every tool and MCP server definition costs context in every session, used or not.

    line 34
  9. Distinctive:

    Keep findings in a small knowledge base with a find step (even a TSV plus grep).

    line 46
  10. Distinctive:

    No sub-agents or side sessions unless the user asks.

    line 51
  11. Distinctive:

    Start a fresh session and note the context size before any prompt.

    line 56
  12. Distinctive:

    Check CLAUDE.md size and contents.

    line 58
  13. Very specific:

    Create or update PROJECT_MAP.md.

    line 59
  14. Distinctive:

    Add header comments to the most-opened files.

    line 60
  15. Distinctive:

    Start a fresh session again and compare the context size.

    line 62

“Common” is measured: kept by at least 6 in 10 of the 7 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

Lean context

Goal: the agent should start small, find any file in one or two steps, and never read or load what the task does not need. Every token the agent spends finding things is a token not spent on the work.

1. Index the library: one project map

Create PROJECT_MAP.md at the project root (template in templates/). One row per doc, config, source folder and tool: the path in backticks, one line on what it is, and when to open it.

  • Pointers only, never facts (values, states, rules). Facts live in the files the map points to, so the map cannot go stale against them.
  • Put a short "how to read cheaply" block at the top (see the template) and a never-open list for bulky folders.
  • Keep it complete automatically: python scripts/mapcheck.py --install-hook warns on every commit when a file is missing from the map or a row points to nothing.
  • When the agent adds, moves or removes a file, it fixes the map row in the same turn.

2. Keep the always-loaded context tiny

  • CLAUDE.md: rules only (safety, git, where things are). Aim for a few KB. Point to the map; do not copy it.
  • STATUS.md (template): current state in at most 40 lines, rewritten at the end of each session, read at the start only when the task is not self-contained.
  • Decision log and change log are newest-first: read the top (about 60 lines) or grep. Never whole.

3. Find before you read

  • Start every source file, config and script with a header comment saying what it is and when to use it. The agent reads the header, greps, then reads a line range.
  • Prefer a code-graph or symbol-search tool for "where is this used" over opening files.
  • Never list whole trees. Provide a tree command that skips bulk folders.

4. Tool diet

Every tool and MCP server definition costs context in every session, used or not.

  • Deny tools the project never uses in .claude/settings.local.json (example in templates/).
  • Enable only the MCP servers this project needs; prefer per-project .mcp.json over global ones.
  • Hard-deny reads of bulky generated folders (decompiler projects, caches, build output, backups).
  • Desktop-app integrations add their own tools: for long technical work a terminal or editor session can start much smaller.

5. Expensive output goes to disk

Wrap heavy commands (decompilers, whole-tree linters, big logs, API dumps) with scripts/cached.py: the full output is written once to .cache/cmd/, the agent sees the path and the first lines, then greps the file. Re-runs are free.

6. Never learn the same thing twice

Keep findings in a small knowledge base with a find step (even a TSV plus grep). Rule for the agent: look it up before researching, record what it learned in the same turn.

7. Session habits

  • One task per session; clear between unrelated tasks; end each session by rewriting STATUS.md.
  • No sub-agents or side sessions unless the user asks. When parallel work is worth it: one coordinator, at most two workers, each with a written brief naming the only files it may write. Cheaper models for mechanical work.
  • Measure: note the context size at session start before and after each change, and keep what pays.

Audit checklist (run on an existing project)

  1. Start a fresh session and note the context size before any prompt.
  2. List loaded tools and MCP servers; deny what the project does not use.
  3. Check CLAUDE.md size and contents; move facts out, keep rules and pointers.
  4. Create or update PROJECT_MAP.md; run mapcheck until it is clean; install the hook.
  5. Add header comments to the most-opened files; add a never-open list.
  6. Wrap the heaviest commands with cached.py.
  7. Start a fresh session again and compare the context size.

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.