Rewrites a markdown or plain-text file into terse form to reduce input tokens when the file is loaded. Preserves code, URLs, paths, commands, headings, tables, YAML, and JSON verbatim. Writes a .original backup before modifying the source. Use when user says "compress this file", "shrink this doc", "reduce tokens in <file>".
hooks/scripts/reference-compression-validate.shRewrite a target markdown or text file into terse form following the blitz Terse Output Protocol. This is an author-time transform: it modifies files in the repo, saves a backup, and runs structural validation. It is not a runtime compression layer — the compressed file is what ships.
One or more file paths. Supported extensions: .md, .txt, .rst, or extensionless text files. The skill refuses to operate on: .py, .js, .ts, , , , , , or any file already matching / .
.json.yaml.yml.toml.sh*.original*.original.md0.1 Register session per session-protocol.md and verbose-progress.md. Generate SESSION_ID, log skill_start to .cc-sessions/activity-feed.jsonl.
0.2 Validate inputs. For each target:
<file>.original sibling (if present, it means the file was already compressed — skip with a notice, do not re-compress).0.3 If any target is rejected, list the rejected files and continue with accepted ones. If zero targets remain, exit with a summary.
1.1 For each accepted target, write a backup to <file>.original (preserving the original extension order: reference.md → reference.md.original). Use Read + Write. Never skip this step.
1.2 Verify the backup: its byte count must match the source. If not, abort with error.
2.1 Read the target file. Apply the Terse Output Protocol at full intensity:
/_shared/terse-output.md).2.2 Specific preservation rules, enforced mechanically:
``` in the original MUST appear unchanged in the output at a corresponding position.http(s)://... URL in the original MUST appear in the output (set equality).^#+ ) in the original MUST appear in the output with identical text.|) MUST remain a table row in the output; row count must match.` must remain verbatim.2.3 If the source file contains any of these markers anywhere, ABORT compression with a clear explanation: "File contains exact-match agent prompt or grep-pattern content — classified UNSAFE, refusing to compress. See caveman-compress input-side research for classification."
agent prompt template (heading or bold)Grep Patterns by Checkoutput_style: exact (opt-out signal)2.4 Write the compressed content back to the target file path.
3.1 Run the structural validator on the compressed pair:
bash hooks/scripts/reference-compression-validate.sh
3.2 If validation fails:
mv <file>.original <file> (delete the backup to return to pre-compress state).3.3 If validation passes, target is COMPLETE.
4.1 Write a summary to the user: