Skip to content

optimise-context

optimise-context

optimisewriteshands-on

Use this when: the always-on context is bloated

Problem it solves — Every always-on token is paid on every session and every AI call. This trims that footprint — duplication, verbosity, volatile data that busts the prompt cache — surfacing each cut for confirm, without ever cutting meaning to save bytes.

Used in workflows: Harness health Check

Optimise context (always-on footprint)

Tokens in the always-on layer compound — they're paid on every session and every AI call. This trims that footprint without losing meaning. On-demand docs matter far less; spend effort where it loads every time.

This skill is the trim/backstop end of static ↔ dynamic placement (glossary): the static-or-dynamic call should be made at add-time (default dynamic, justify static — context as code); this is where we catch what slipped into the always-on layer without earning its slot.

What's always-on (the targets)

  • CLAUDE.md — the authored portion loads every Claude Code session. (The <laravel-boost-guidelines> block is regenerated by boost:updateleave it; flag its size as a known cost, don't edit it.)
  • Every skill's description — the / menu lists them all, so each description is always-on. Bloated descriptions are a real, easily-missed cost.
  • Every agent's description — they load into the Agent tool definition each session, same deal as skill descriptions.
  • Preloaded skills: content — an agent's skills: list injects each skill's full body into every dispatch of that agent (e.g. worktree-builder carries all of fyi-tempo-domain). A recurring per-dispatch cost: weigh the preload against the agent reading it on demand.
  • .claude/rules/code-quality.md is always-on; path-scoped rules load whenever the working set matches.
  • CONTEXT.md / SOUL.mdSOUL.md rides every AI call via PersonalContext; CONTEXT.md is heavy reference.

The lenses — this is the skill

The value is finding bytes that buy nothing — not flattening nuance. Measure first (rough line/token counts of the always-on set; show the heaviest), then:

  • Duplication — one doc restating another (e.g. a CLAUDE.md section paraphrasing CONTEXT.md; PR #125 cut exactly this).
  • Verbosity — prose that a tighter line or a name would carry; what-comments; repeated preamble across skills.
  • Over-long skill descriptions — trim to the trigger essentials (they all load); move detail into the skill body, which is on-demand. Hard ceiling: description + when_to_use clip at 1,536 chars combined — past that it isn't just cost, it's lost routing (#393 sweeps the set).
  • Always-on → on-demand — content that doesn't need to load every time could live in a body/reference the agent reads only when relevant. For a skill whose real trigger is a file area, paths: glob-scoping replaces a fat description doing that job in prose.
  • Removal test — for a CLAUDE.md / rule section, ask: if I delete this, does behaviour change structurally? If yes it's load-bearing control-plane — keep. If not, it's decoration — cut it or move it on-demand. The sharpest test for "does this earn its always-on slot?".
  • Doc-set rationalise — zoom out from lines to whole docs: does each doc (or section) still earn its place, or can it be consolidated / simplified / removed? (This is how HANDOVER.md was retired — unique bits moved to CONTEXT.md/CLAUDE.md, the rest deleted.) If you remove or rename a doc that another doc references, fix those references in the same edit. qa-philosophy hands you the redundant-doc candidates it spots while auditing accuracy; this lens decides their fate.
  • Cache-stability — never interpolate volatile / per-task data (today's date, the current branch, a task id, live counts) into the always-on CLAUDE.md base: a changing prefix busts the prompt cache on every turn, which costs far more than the bytes. Volatile content belongs in on-demand rules or session context, not the stable base. Flag any always-on text that changes between sessions.

Output — surface, then trim

A table: target · file:line · current cost (lines/≈tokens) · the trim · what's preserved. AskUserQuestion which to apply. Never trim unprompted — this is canonical, always-on context; and never cut meaning to save bytes (that's a regression, not an optimisation). Whole-doc removals go through the same confirm gate.

Where it sits

  • The footprint + rationalise counterpart to qa-philosophy (which fixes accuracy/drift). qa-philosophy reconciles what the docs say; this trims what they cost and prunes docs that no longer earn their place.
  • Distinct from qa-skills (which decides which skills exist); this trims the text of what's already there.
  • In check-everything it belongs to Brain, running after the docs have been aligned (so it trims settled content).

How this gets triggered

Invoke directly — "cut context", "we're token-heavy", "trim the always-on load", "do we still need this doc?". Good cadence: after a stretch that grew CLAUDE.md / the rules / the skill set.