Compressing onboarding files
Instruction files load every session, so every saved token compounds. Compress
prose aggressively while never touching the technical payload - and never trading
away clarity where ambiguity is dangerous.
Announce at start: "Using compress-onboarding on at level ."
Usage: compress-onboarding <file> [--level off|lite|full|ultra]
Default file: the repo's AGENTS.md. Works under any SKILL.md-compatible runtime.
Levels (sticky per repo)
Resolve the level from --level if given, else .aiboarding/config.json: compression_level, else full. When --level is given, persist it back to
config.json - the level is a per-repo decision, not per-run.
off - no rewriting. Still run the size report (step 5) so bloat is visible.
lite - remove filler, pleasantries, hedging, and restatement. Full sentences
kept. ("In order to build the project, you should run…" → "To build, run…")
full (default) - additionally drop articles, compress to fragments and
short synonyms, allow X → Y notation. ("The dev server can be started with
npm run dev" → "Dev server: npm run dev.")
ultra - telegraphic; every non-load-bearing word goes. Use only when the
effective instruction-chain audit needs it; confirm with the user before first use.
Byte-preservation invariants (hard guarantees)
Compression must NEVER alter: fenced code blocks (including the fence lines),
inline backtick spans, shell commands, URLs, file paths, identifiers and symbol
names, quoted error strings, <!-- aiboarding-* --> markers, YAML frontmatter, and
table structure. If a protected span is wrong, fixing it is an update, not a
compression - route it through update-agent-onboarding.
While rewriting, keep commands/identifiers/paths/error strings backtick-quoted (add
backticks where the source lacks them - adding protection is allowed; removing it
is not). The checker treats backtick spans as protected.
High-consequence preservation
Before rewriting, classify complete high-consequence regions. Preserve every
identified region verbatim, byte-for-byte, by default. full or ultra never
authorize rewriting one.
Always classify complete Agent Guardrails and Escalation - Ask the User When
sections. Outside those headings, classify smallest complete paragraph, list item,
warning, or ordered procedure needed to retain context when it governs security,
authorization, approval or escalation, destructive or irreversible actions, or
required ordering or prerequisites for destructive or migration work. Record each
region's source section or line location and category. Do not classify ordinary
project purpose, architecture, domain, or routine descriptive prose solely because
it is important or technical; compress that prose at selected level.
If user asks to rewrite identified high-consequence content, name affected regions
and obtain explicit opt-in for selected regions in current operation. Level choice
and final diff approval do not count. Do not persist consent. Rewrite only selected
regions, retain unselected regions verbatim, preserve all protected spans, and keep
behavioral force unambiguous. Then show final diff and obtain normal approval.
Procedure
- Snapshot. Copy the target file to a temp path (
before).
- Classify and compress. Identify high-consequence regions, report their
locations and categories, and copy them verbatim unless current-operation,
per-region explicit opt-in permits rewriting. Compress remaining prose at
resolved level.
- Verify. Run
.aiboarding/tools/check-preservation <before> <after> (fall
back to the plugin's templates/tools/check-preservation if not installed).
Fix every reported span and re-run until clean. Never hand-wave this step.
- Approval gate. Show the user a diff of the compressed file against the
original. Write only after approval.
- Receipt. Measure before/after: exact bytes and lines always; token counts
with a real tokenizer if one is available in the environment (e.g. Python
tiktoken), otherwise tokens_approx = bytes / 4, explicitly labeled
approximate. Append to .aiboarding/state.json:receipts (one object per line,
keeping the file hook-readable):{ "file": "AGENTS.md", "level": "full", "bytes_before": 8123, "bytes_after": 4310, "lines_before": 190, "lines_after": 121, "tokens_before_approx": 2031, "tokens_after_approx": 1078, "high_consequence_regions": [{ "location": "Agent Guardrails", "category": "guardrails", "outcome": "preserved", "explicit_opt_in": false }], "measured_at": "2026-07-02" }
high_consequence_regions is optional for backward compatibility. Each entry
records location, category, outcome (preserved or rewritten), and explicit
opt-in status; never copy instruction text. Include [] when classification
verified no such regions. Report same evidence to user.
Report the saving to the user; since the file loads every session, note the
per-session saving - never claim unlabeled exact token numbers without a real
tokenizer.
Also write a compact compression-verification record with the subject, level,
measurements, preservation and size outcomes through write-evidence. Keep the
legacy receipt unchanged; a failed preservation or size check is recorded when
possible and never authorizes a sync-pointer advance.
- Size check. Run
.aiboarding/tools/check-size-budget <file> as a local
sensor. It does not prove chain safety; run
.aiboarding/tools/audit-onboarding-evidence <repo-root> before claiming an
effective Codex chain fits. If local guidance still WARNs after full, suggest
moving detail to .claude/rules/ or nested AGENTS.md files rather than jumping
to ultra.
Writing into shared files
When compression output must land inside a file that also has user-owned content
(e.g. a hand-written CLAUDE.md), write only within the aiboarding marker fence
via .aiboarding/tools/inject-fenced - re-runs stay idempotent and uninstall stays
clean.
1---2name: compress-onboarding3description: Use to compress any agent-instruction file (AGENTS.md, CLAUDE.md, .claude/rules/*.md, legacy AIBOARDING.md) into terse, high-signal prose without altering commands, code, URLs, or paths. Standalone compression engine with levels (off/lite/full/ultra), byte-preservation verification, and token receipts. Also invoked by the create/update onboarding skills.4---56# Compressing onboarding files78Instruction files load **every session**, so every saved token compounds. Compress9prose aggressively while never touching the technical payload - and never trading10away clarity where ambiguity is dangerous.1112**Announce at start:** "Using compress-onboarding on <file> at level <level>."1314**Usage:** `compress-onboarding <file> [--level off|lite|full|ultra]`15Default file: the repo's `AGENTS.md`. Works under any SKILL.md-compatible runtime.1617## Levels (sticky per repo)18Resolve the level from `--level` if given, else `.aiboarding/config.json:19compression_level`, else `full`. When `--level` is given, persist it back to20`config.json` - the level is a per-repo decision, not per-run.2122- **`off`** - no rewriting. Still run the size report (step 5) so bloat is visible.23- **`lite`** - remove filler, pleasantries, hedging, and restatement. Full sentences24 kept. ("In order to build the project, you should run…" → "To build, run…")25- **`full`** (default) - additionally drop articles, compress to fragments and26 short synonyms, allow `X → Y` notation. ("The dev server can be started with27 `npm run dev`" → "Dev server: `npm run dev`.")28- **`ultra`** - telegraphic; every non-load-bearing word goes. Use only when the29 effective instruction-chain audit needs it; confirm with the user before first use.3031## Byte-preservation invariants (hard guarantees)32Compression must NEVER alter: fenced code blocks (including the fence lines),33inline backtick spans, shell commands, URLs, file paths, identifiers and symbol34names, quoted error strings, `<!-- aiboarding-* -->` markers, YAML frontmatter, and35table structure. If a protected span is wrong, fixing it is an *update*, not a36compression - route it through `update-agent-onboarding`.3738While rewriting, keep commands/identifiers/paths/error strings backtick-quoted (add39backticks where the source lacks them - adding protection is allowed; removing it40is not). The checker treats backtick spans as protected.4142## High-consequence preservation43Before rewriting, classify complete high-consequence regions. Preserve every44identified region verbatim, byte-for-byte, by default. `full` or `ultra` never45authorize rewriting one.4647Always classify complete `Agent Guardrails` and `Escalation - Ask the User When`48sections. Outside those headings, classify smallest complete paragraph, list item,49warning, or ordered procedure needed to retain context when it governs security,50authorization, approval or escalation, destructive or irreversible actions, or51required ordering or prerequisites for destructive or migration work. Record each52region's source section or line location and category. Do not classify ordinary53project purpose, architecture, domain, or routine descriptive prose solely because54it is important or technical; compress that prose at selected level.5556If user asks to rewrite identified high-consequence content, name affected regions57and obtain explicit opt-in for selected regions in current operation. Level choice58and final diff approval do not count. Do not persist consent. Rewrite only selected59regions, retain unselected regions verbatim, preserve all protected spans, and keep60behavioral force unambiguous. Then show final diff and obtain normal approval.6162## Procedure631. **Snapshot.** Copy the target file to a temp path (`before`).642. **Classify and compress.** Identify high-consequence regions, report their65 locations and categories, and copy them verbatim unless current-operation,66 per-region explicit opt-in permits rewriting. Compress remaining prose at67 resolved level.683. **Verify.** Run `.aiboarding/tools/check-preservation <before> <after>` (fall69 back to the plugin's `templates/tools/check-preservation` if not installed).70 Fix every reported span and re-run until clean. Never hand-wave this step.714. **Approval gate.** Show the user a diff of the compressed file against the72 original. Write only after approval.735. **Receipt.** Measure before/after: exact bytes and lines always; token counts74 with a real tokenizer if one is available in the environment (e.g. Python75 `tiktoken`), otherwise `tokens_approx = bytes / 4`, explicitly labeled76 approximate. Append to `.aiboarding/state.json:receipts` (one object per line,77 keeping the file hook-readable):78 ```json79 { "file": "AGENTS.md", "level": "full", "bytes_before": 8123, "bytes_after": 4310, "lines_before": 190, "lines_after": 121, "tokens_before_approx": 2031, "tokens_after_approx": 1078, "high_consequence_regions": [{ "location": "Agent Guardrails", "category": "guardrails", "outcome": "preserved", "explicit_opt_in": false }], "measured_at": "2026-07-02" }80 ```81 `high_consequence_regions` is optional for backward compatibility. Each entry82 records location, category, outcome (`preserved` or `rewritten`), and explicit83 opt-in status; never copy instruction text. Include `[]` when classification84 verified no such regions. Report same evidence to user.85 Report the saving to the user; since the file loads every session, note the86 per-session saving - never claim unlabeled exact token numbers without a real87 tokenizer.88 Also write a compact `compression-verification` record with the subject, level,89 measurements, preservation and size outcomes through `write-evidence`. Keep the90 legacy receipt unchanged; a failed preservation or size check is recorded when91 possible and never authorizes a sync-pointer advance.926. **Size check.** Run `.aiboarding/tools/check-size-budget <file>` as a local93 sensor. It does not prove chain safety; run94 `.aiboarding/tools/audit-onboarding-evidence <repo-root>` before claiming an95 effective Codex chain fits. If local guidance still WARNs after `full`, suggest96 moving detail to `.claude/rules/` or nested `AGENTS.md` files rather than jumping97 to `ultra`.9899## Writing into shared files100When compression output must land inside a file that also has user-owned content101(e.g. a hand-written `CLAUDE.md`), write only within the aiboarding marker fence102via `.aiboarding/tools/inject-fenced` - re-runs stay idempotent and uninstall stays103clean.