agentleFS
edilsonvilarinhoedilsonvilarinho/usage-monitor/.claude/skills/usage-monitor-token-cleanup/SKILL.md

usage-monitor-token-cleanup

Skill19 starsChanged 50 days agoMITView on GitHub

Measure the context this repo loads every session (CLAUDE.md, memory, skills), report evidence-backed cleanup candidates with estimated savings, and apply only what the user approves. Use to save tokens, trim context, clean up memory or shrink CLAUDE.md.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    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:

    Measure: Run the read-only script and keep its output as the baseline:

    line 25
  2. Distinctive:

    Analyze: Every finding carries the evidence that justifies it (line numbers, command output, file names).

    line 31
  3. Very specific:

    Do not commit: Commit only when the user asks, through usage-monitor-commit-push.

    line 60
  4. Distinctive:

    Never edit production code, tests, or build files.

    line 64
  5. Distinctive:

    Never shorten a rule without the user approving that specific item.

    line 65
  6. Distinctive:

    Never "summarize" a decision in a way that loses its reason without moving the reason somewhere.

    line 66
  7. Very specific:

    Never delete a memory whose issues you did not check with gh.

    line 67
  8. Distinctive:

    If a finding is a judgment call (e.g.

    line 68

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill 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
SKILL.md

Usage Monitor Token Cleanup

Measure first, propose with evidence, ask item by item, apply only what was approved, measure again. Nothing is changed before the user picks it.

Targets

TargetLoadedPath
Project instructionsevery sessionCLAUDE.md
Global instructionsevery session~/.claude/CLAUDE.md
Memory indexevery session~/.claude/projects/<project-key>/memory/MEMORY.md
Memory fileson demandsame folder, *.md
Skill descriptionsevery session.claude/skills/*/SKILL.md frontmatter
Skill bodieswhen invoked.claude/skills/*/SKILL.md

<project-key> is the absolute repo path with :, \ and / replaced by -.

Workflow

  1. Measure. Run the read-only script and keep its output as the baseline:
    powershell -NoProfile -ExecutionPolicy Bypass -File .claude\skills\usage-monitor-token-cleanup\scripts\measure_context.ps1
    Tokens are chars / 3.5 — label them as an estimate everywhere; this is not the tokenizer's count.
  2. Analyze. Every finding carries the evidence that justifies it (line numbers, command output, file names). No evidence, no finding.
    • Project CLAUDE.md — it dominates the budget. For each heavy section or first-level bullet the script lists:
      • Narrative that is history, not rule: measurements, "a primeira versão", dated incidents, run ids, how a bug was found. Candidate action: move it to the plan in docs/planos/ that already covers the subject (the script lists linked plans) or to a new docs/<area>.md, and leave in CLAUDE.md the rule in 1–3 lines plus the link. The why must survive in the destination — moving is allowed, deleting a decision is not.
      • Duplication: the same rule stated in two sections, or restating docs/design-system/ / server/README.md. Candidate action: keep one owner, link from the other.
      • Rules the tests already enforce (e.g. ArchitectureRulesTest) can be shortened to the rule plus the test name, never removed.
    • Memory:
      • Broken pointers and orphan files (script output).
      • project_* memories citing issues: run gh issue view N --json state,title for each; a memory whose issues are all closed and whose pending work is done is a candidate for deletion.
      • Memories that duplicate CLAUDE.md, the repo, or git history (the memory rules say not to store those).
      • Memories naming a file, function or flag: Grep for it; if it no longer exists, the memory is stale.
    • Global CLAUDE.md: rules redundant with the project file, or conflicting with it. Report conflicts; never resolve them silently — the global file is the user's personal instruction set.
    • Skills: descriptions over ~300 chars (paid every session), and bodies that repeat CLAUDE.md instead of pointing to it.
  3. Report. One table, sorted by estimated savings:

    #TargetFindingEvidenceEst. tokens savedProposed actionReversible?

    Reversibility: repo files are reversible through git; memory and ~/.claude/CLAUDE.md live outside git and are not.

  4. Ask. Use AskUserQuestion with multiSelect: true, one option per finding (batch in groups of up to 4 options per question, up to 4 questions per call). Before offering to delete or rewrite anything outside git, show its full current content in the report so the user decides on what they actually read.
  5. Apply only the approved items.
    • Repo files: Edit, preserving line endings (CLAUDE.md is CRLF in the working copy).
    • Memory: delete the file and its line in MEMORY.md; when merging, update the surviving file and remove the other pointer.
    • Anything not selected stays untouched, including items the user did not answer.
  6. Measure again with the same script and report before/after per target.
  7. Do not commit. Commit only when the user asks, through usage-monitor-commit-push. Content moved from CLAUDE.md to docs/ goes in the same commit as the removal, so no decision exists in neither place.

Guardrails

  • Never edit production code, tests, or build files.
  • Never shorten a rule without the user approving that specific item.
  • Never "summarize" a decision in a way that loses its reason without moving the reason somewhere.
  • Never delete a memory whose issues you did not check with gh.
  • If a finding is a judgment call (e.g. whether a passage is rule or history), say so in the Evidence column.

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.