← LeaderboardThe Skill Leaderboard

context-audit

Report-only audit of the always-loaded context (CLAUDE.md, AGENTS.md, GEMINI.md, .cursorrules, skill descriptions). Use when sessions feel slow or sloppy, after adding skills or rules, or monthly. Finds duplicate rules, stale lines, sections that should become skills, and skills with no when-to-use description, ranked by tokens saved.

Published by huytieu ↗huytieu/COG-second-brain

Try your first task

A source-grounded starter task has not been verified for this skill yet.

SKILL.md

name: context-auditdescription: Report-only audit of the always-loaded context (CLAUDE.md, AGENTS.md, GEMINI.md, .cursorrules, skill descriptions). Use when sessions feel slow or sloppy, after adding skills or rules, or monthly. Finds duplicate rules, stale lines, sections that should become skills, and skills with no when-to-use description, ranked by tokens saved.roles: [all]integrations: []

COG Context Audit Skill

Purpose

Every line in an always-loaded file costs tokens in every session, and a long file also dilutes the rules that matter. This skill measures that cost, reads the files, and reports what to cut, move or fix. It never changes the files it audits. The user decides what to apply.

Ideas credited to garrytan/gbrain (a report-only context audit skill) and garrytan/gstack (a published per-skill context bill). The text and checks here are original.

When to Invoke

  • /context-audit
  • "Audit my context", "why is my CLAUDE.md so long", "what costs the most tokens"
  • After adding or editing a skill, or after a rule was added to an always-loaded file
  • Default cadence: monthly, or when scripts/context-bill.py --check fails

Report-Only Contract

  • Read any file in the vault. Write exactly one file: the report in 01-daily/.
  • Never edit, move, rename or delete CLAUDE.md, AGENTS.md, GEMINI.md, .cursorrules, a skill, or any file named in a finding.
  • Every finding is a proposal with the exact file, line range and a suggested action. The user applies it, or asks for a separate edit run.
  • Token figures are estimates (characters divided by 4). Say so in the report.

Pre-Flight Check

  1. Run date '+%Y-%m-%d %H:%M' with Bash for the real date. Use it in the report name and header.
  2. Confirm scripts/context-bill.py exists. If it does not, count characters with wc -c and divide by 4 for each file and skill, and say in the report that the bill script was missing.
  3. Check 01-daily/ exists. Create nothing else.

Steps

1. Run the bill

python3 scripts/context-bill.py --format json

Keep the JSON in working memory. It gives tokens for each instruction file, the skill catalog, and each skill body. Copy the headline numbers into the report: always-loaded total, the largest three always-loaded items, and the five largest skill bodies.

2. Read the always-loaded files

Read every instruction file the bill listed, in full: CLAUDE.md, AGENTS.md, GEMINI.md, .cursorrules, and .agents/rules/*.md when present. Read the description line of every skill (the bill output names the paths). Do not read skill bodies unless a finding needs one.

3. Find redundant rules

A rule is redundant when the same instruction appears in more than one place that one session loads.

  • Compare section headings and imperative sentences across the instruction files. Match on meaning even when the wording differs.
  • Compare each rule with the skill that also states it. A rule that a skill owns should live in the skill, with a one-line pointer in the always-loaded file.
  • Separate two cases. The same rule in CLAUDE.md and AGENTS.md is a mirror for different hosts: one host loads one file, so the saving is small. Mark it cross-host mirror and rank it low. The same rule twice in one file, or in a file plus a skill description, costs tokens every session. Rank it high.
  • Estimated saving: tokens of every copy except the one to keep.

4. Find stale lines

A line is stale when it names something that no longer exists. Check mechanically, cheapest first.

  • Paths in backticks: run test -e <path>. A path with a placeholder such as YYYY or <name> is a pattern, so skip it.
  • Skill and command names after a slash, such as /example: run test -f .claude/skills/<name>/SKILL.md. Also accept a name defined under .claude/commands/ when that folder exists.
  • Scripts and tools: run test -e on the script path. For a CLI name, run command -v <name> and mark a miss unverifiable when the tool is optional.
  • Counts such as "43 skills": compare with ls .claude/skills | wc -l.
  • Never report a line stale on memory alone. Each stale finding quotes the line and shows the failed check.
  • Estimated saving: tokens of the stale line or paragraph.

5. Find sections that should load on demand

A section belongs in a skill or a reference file when it fits three tests:

  1. It is longer than about 40 lines or 500 estimated tokens.
  2. It applies to one kind of task, such as release notes, a code review, or one integration.
  3. A session that does not do that task never needs it.

Propose a target: a new skill with a description that says when to use it, or a file under an existing skill's references/ folder. In the always-loaded file, the section shrinks to one pointer line. Estimated saving: section tokens minus about 30 for the pointer.

6. Find skills that do not say when to use them

Read each skill description. Flag it when it:

  • has no trigger, meaning it never says when to use the skill ("Use when", "after", "before", a named command, or a named situation);
  • describes internals and omits what the user asks for;
  • runs longer than 400 characters, because every session pays for the extra words.

A flagged description gets a proposed rewrite: one sentence for what the skill does, one for when to use it. A missing trigger saves no tokens, so rank it by routing risk: place it below every finding with a token saving, ordered by skill body size.

7. Rank and write the report

Sort all findings by estimated tokens saved per session, highest first. For a finding in a skill body or a description of a rarely used skill, state the saving per trigger. Put findings with no token saving last.

Report

Write one file: 01-daily/YYYY-MM-DD-context-audit.md. If it exists, add a numeric suffix. Do not overwrite an earlier report.

---
type: context-audit
date: YYYY-MM-DD
estimate: characters / 4
---

# Context audit YYYY-MM-DD

## Headline
One paragraph: always-loaded total in tokens, the largest items, the total estimated saving if every finding is applied.

## Bill
Always-loaded table (item, tokens) and the five largest skill bodies.

## Findings, ranked by tokens saved
| Rank | Kind | Where | Finding | Proposed action | Est. tokens saved |
Kinds: duplicate, stale, move-to-skill, no-trigger.

## Detail
One short block per finding: the quoted lines, the file and line range, the check that failed or the other location that repeats it, and the exact edit proposed.

## Waiting on you
Which findings to apply. Nothing was changed.

End the reply with the report path and the headline saving. State that no audited file changed.

Earn Its Place

A section stays always-loaded only if it changes behavior in most sessions. Test each section with one question: in the last ten sessions, how many would have gone differently without these lines? A rule that applies to a task type moves into the skill for that task. A rule that nothing enforces and nobody noticed missing is a candidate to delete. A safety rule keeps its place on its stated reason even when it rarely fires. When a section has a named owner and a test date, give it one more review cycle before cutting.

Rules

  • Rank by evidence. A finding without a quoted line and a location is dropped.
  • Keep the report short. Cover each finding once. Do not list files that had no findings.
  • Do not rewrite the user's voice in a proposed edit. Propose removal, a pointer line, or a move.
  • If the bill shows the always-loaded layer under a budget the user set, say so and list only the findings that are cheap to apply.