Skip to content
Agentmart
Submit a tool

harness-diet

Measure and shrink the always-loaded context of a Claude Code harness (CLAUDE.md + rules without paths frontmatter) back under budget — migrate narrative to…

Skill by sangrokjung

IndexedMIT★ 863
Write a review

Chalk Labs

Need help deploying harness-diet?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/sangrokjung-harness-diet

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Measure and shrink the always-loaded context of a Claude Code harness (CLAUDE.md + rules without paths frontmatter) back under budget — migrate narrative to reference files, convert rules to path-scoped or skill-triggered loading, and verify zero governance loss with deterministic preservation checks. Use on "harness diet", "context diet", "rules diet", "CLAUDE.md too long", "always-load budget", "trim my rules", "context bloat", "하네스 다이어트", "룰 다이어트", "컨텍스트 다이어트", "always-load 줄여줘". Not for one-off prose editing or project docs cleanup.

Use cases: writing, finance, agent-building

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found
Runs as
Python package

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/harness-diet

What's inside

Skill name
harness-diet
Description
Measure and shrink the always-loaded context of a Claude Code harness (CLAUDE.md + rules without paths frontmatter) back under budget — migrate narrative to reference files, convert rules to path-scoped or skill-triggered loading, and verify zero governance loss with deterministic preservation checks. Use on "harness diet", "context diet", "rules diet", "CLAUDE.md too long", "always-load budget", "trim my rules", "context bloat", "하네스 다이어트", "룰 다이어트", "컨텍스트 다이어트", "always-load 줄여줘". Not for one-off prose editing or project docs cleanup.
License
MIT
Metadata
phase: v1 · category: harness-maintenance
Instructions
117 lines in SKILL.md · view on GitHub

Before installing

  • Ships executable scripts

Files (5)

  • SKILL.md
  • rules-budget-guard.sh · hooks/
  • methodology.md · references/
  • harness_diet_audit.py · scripts/
  • preservation_check.py · scripts/

SKILL.md (first lines)

# harness-diet — put your always-loaded context back under budget

> A harness gains weight automatically (every incident note, every boss directive, every fix lands
> as another paragraph in an always-loaded rule) but only loses weight when someone runs a diet.
> Field measurement on a mature harness: growth-to-reduction commit ratio of ~60:1, natural growth
> of ~70KB/month, and adherence degrading as the pile grows. Anthropic's guidance is blunt:
> *"target under 200 lines per CLAUDE.md file. Longer files consume more context and reduce
> adherence"*, and rules without `paths` frontmatter load *"with the same priority as CLAUDE.md"*
> — every session, every token ([memory docs](https://docs.claude.com/en/docs/claude-code/memory)).

**Result you should expect**: one field run took a harness from 146KB always-loaded (143% of
budget) to 100.6KB (98%) with **zero governance loss** — every killswitch, decision table,
trigger keyword, and canonical command verified present after the diet.

## Budgets (defaults — override via flags)

| Metric | Budget | Why |
|---|---|---|
| CLAUDE.md | < 200 lines | Anthropic official guidance |
| Per always-loaded rule file | 8,192 B | Keeps any single rule scannable; forces narrative out |
| Total always-loaded rules | 102,400 B | Attention-budget ceiling; beyond this, adherence drops |

> **Bundled script paths**: commands below use `$HOME/.claude/skills/harness-diet/…` (the
> `install.sh` layout). For marketplace (`/plugin install`) installs, resolve under
> `${CLAUDE_PLUGIN_ROOT}/skills/harness-diet/…` instead. The scripts are stdlib-only Python;
> if unavailable, perform the step manually from the described contract.

## Phase 0 — Measure

```bash
DIET="$HOME/.claude/skills/harness-diet"   # or "${CLAUDE_PLUGIN_ROOT}/skills/harness-diet"
python3 "$DIET/scripts/harness_diet_audit.py"            # human summary
python3 "$DIET/scripts/harness_diet_audit.py" --json     # machine output
python3 "$DIET/scripts/harness_diet_audit.py" --strict   # exit 2 if over budget (CI/ratchet)
```

Auto-discovers `./.claude/rules`, `~/.claude/rules`, and CLAUDE.md files at project/user level.
A rule is **always-loaded** iff its YAML frontmatter has no `paths:` key.

## Phase 1 — Classify every always-loaded rule

Walk the list from largest to smallest and pick one bucket per file:

1. **Keep always-loaded** — cross-cutting behavior needed in *every* session (tone, security
   boundaries, routing indexes). Diet the body (Phase 2) but keep the load class.
2. **Path-scope** — the rule only matters when specific files are touched. Add `paths:` globs.
   ⚠ Path scoping fires on *file access*, never on spoken keywords. A rule triggered by what the
   user *says* cannot be path-scoped. ⚠ No literal brackets in globs (`[locale]` parses as a
   character class and silently never matches).
3. **Convert to skill / hook-injected** — task-specific procedure? Official guidance: *"use
   skills instead"*. Best case: the rule's real trigger is already a deterministic hook — have
   the hook inject "Read <rule> first" into context and drop the always-load.
4. **Migrate narrative to reference** — the default for oversized keepers (Phase 2).

## Phase 2 — Migrate (block-level, never prose compression)

For each oversized file:

1. **Extract a preservation manifest first** (before touching anything):
   ```bash
   python3 "$DIET/scripts/preservation_check.py" extract rules/big-rule.md > /tmp/big-rule.manifest.json
   ```
2. **Append** the outgoing blocks to `references/<name>-ref.md` (or your repo's reference dir),
   verbatim under a dated section header. Append *before* rewriting the rule body, and commit
   both together — a slimmed body pushed without its reference content is a content hole for
   every mirror that pulls in between.
3. **Rewrite the rule body**: keep the verdict skeleton (what to do / never do), leave a one-line
   pointer to the reference for the "why" and the war stories.

**Must stay in the body** (never migrate): CRITICAL/IMPORTANT banners and their verdicts,
decision tables, trigger keywords and agent names (they are a routing index, not prose),
killswitch env vars, canonical command lines, IDs and threshold values.

**Migrate aggressively**: incident narratives, measurement history, duplicated explanations of
the same point, long example blocks, anything already present in the reference file.

## Phase 3 — Verify (two lenses, fresh checker)

1. **Loss lens (deterministic)**:
   ```bash
   python3 "$DIET/scripts/preservation_check.py" verify rules/big-rule.md /tmp/big-rule.manifest.json
   ```
   Exit 2 = something load-bearing got migrated. Restore it before proceeding. Review the
   manifest by hand first — prune entries that were *intended* to move.
2. **Efficacy lens**: re-run the audit; recompute the total; confirm the savings are real
   (reference files are lazily `Read`, not `@`-imported — check the rule bodies contain no
   `@path` imports of the reference, or the "savings" still load at launch).
3. **Fresh checker**: hand the diff to an independent reviewer that didn't write it (pairs with
   the `review-loop` skill). Diets fail quietly: a plausible-looking slim body missing one
   qualifier is exactly what the maker cannot see.

## Phase 4 — Guard (keep it off)

A diet without a guard regrows. Ship-with options in `$DIET/hooks/`:

- `rules-budget-guard.sh` — PostToolUse (`Edit|Write`) advisory: the moment a rule edit pushes a
  file past budget, the editing session gets a context note telling it to migrate, not append.
  Non-blocking by design — a blocking pre-commit gate silently stalls auto-commit pipelines.
- Re-run `--strict` weekly (cron, session-start dispatcher, or CI) and surface the report only
  when over budget.

## Anti-patterns (each one cost a real harness a failed round)

| Anti-pattern | Why it fails |
|---|---|
| Prose compression ("tighten the wording") | Trigger keywords, guru names, stage names *are* the routing index. A compression pass that saved 12% destroyed 70% of routing signals and was fully reverted. Move blocks; don't rewrite sentences. |
| Dedup toward a private file | If rules are distributed to a team but `~/.claude/CLAUDE.md` is one person's, "delete from rules, it's already in CLAUDE.md" deletes it from every teammate's context. Dedup toward the *shared* surface. |
| Slim body committed, reference append not | Mirrors pull a body full of dangling pointers. Commit both in one change. |
| Trusting the maker's "everything preserved" claim | Extract the manifest before the edit and verify after. Field run: the maker claimed "6 bullets kept verbatim"; the deterministic check found two qualifiers gone. |
| Treating one diet as the fix | Growth is automatic; reduction is manual. Without the guard, one measured harness regrew from 145KB toward its 220KB peak within weeks. |

## References

- `references/methodology.md` — budget rationale, growth mechanics, byte-accounting worksheet,
  verification lens design, worked field results.

From sangrokjung/claude-forge, MIT.

More from sangrokjung/claude-forge

Signals

Stars
863
Forks
184
Open issues
22
Last commit (this folder)
Aug 25, 2026 (2 months ago)
Last release
Aug 25, 2026 (2 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from sangrokjung

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get harness-diet running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying harness-diet?

CallGet help
Cite this page

harness-diet skill. Agent Mart. https://agentmart.dev/skills/sangrokjung-harness-diet (last updated 2026-10-24)