From docs-hygiene
Compress (tighten, shorten, trim) markdown files by dropping flavor — filler, hedging, articles — while preserving all content (directives, qualifiers, thresholds, examples), with a mandatory semantic-diff subagent that reverts any SEMANTIC LOSS or AMBIGUITY. Use when: "compress this doc", "tighten markdown", "cut prose", "shorten without losing meaning", "trim onboarding doc", or verbose prose in docs/, READMEs, rule bodies, skill bodies, or third-party pasted text — actions: default (snapshot → backend → semantic-diff subagent → revert-pass → markdownlint) and audit (read-only dry-run classifying SKIP/COMPRESS/UNCERTAIN per file); flags: --force (bypass <3% revert rule), --keep-snapshot; not for: session compaction (/compact), markdown noise classification (/audit-noise), code-comment trimming, or content relocation/SSOT consolidation (/extract-ssot).
How this skill is triggered — by the user, by Claude, or both
Slash command
/docs-hygiene:compress [audit] [target] [--force] [--keep-snapshot][audit] [target] [--force] [--keep-snapshot]The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Current branch: !`git branch --show-current 2>/dev/null || echo "unknown"`
context/fan-out-orchestration.mdcontext/flavor-vs-content-matrix.mdcontext/integration.mdcontext/semantic-diff-prompt.mdcontext/target-types.mdevals/evals.jsonevals/fixtures/audit-fixture-dir/lean.mdevals/fixtures/audit-fixture-dir/mixed.mdevals/fixtures/audit-fixture-dir/verbose.mdevals/fixtures/verbose-onboarding-snippet.mdscripts/detect-caveman.shscripts/detect-caveman.test.shCurrent branch: !git branch --show-current 2>/dev/null || echo "unknown"
Uncommitted .md files: !git status --porcelain 2>/dev/null | grep '\.md$' | head -10 || echo "none"
Markdown in docs/, README files, onboarding docs, third-party pasted prose, and drifted skill bodies accumulates FLAVOR — filler ("just", "really", "basically"), hedging ("perhaps", "might"), articles, pleasantries, redundant restatement. context/flavor-vs-content-matrix.md defines FLAVOR (safe to cut) vs CONTENT (never cut); this skill applies that taxonomy AT EDIT TIME to content where author-time discipline does NOT apply.
Always-loaded instruction files (.claude/rules/**, AGENTS.md, CLAUDE.md, **/SKILL.md) bound empirically at 2-3% yield (baseline from the authoring repo: 3/3 attempts reverted, all flavor-only, 0 semantic loss). Likely 5-15% yield on author-time-undisciplined content.
Methodology: snapshot original → backend mechanical compression (the caveman plugin via /caveman:compress, OR in-session Edit fallback) → spawn semantic-diff subagent comparing original vs condensed (output: SEMANTIC LOSS / AMBIGUITY / FALSE POSITIVE per finding with verbatim citations) → revert every SEMANTIC LOSS + AMBIGUITY → run markdownlint-cli2 → ship or revert.
Default-action Step B picks the mechanical-compression backend: the caveman plugin (marketplace caveman, invoked as /caveman:compress) when present, otherwise the in-session Edit-based fallback. Caveman performs the mechanical flavor cuts (articles, fillers, hedging, verbose-verb collapses) as the compression backend — it is NOT the verification gate. Fallback policy is graceful: the in-session Edit-based path substitutes whenever caveman is absent or unwanted. Subsequent steps (semantic-diff dispatch, revert pass, markdownlint) wrap the output regardless of backend choice.
Note the distinction inside that plugin: /caveman:compress is a function-call skill (this skill's backend); /caveman:caveman is a session-wide response formatter — unrelated to this skill.
Step A — detect caveman plugin: bash "${CLAUDE_SKILL_DIR}/scripts/detect-caveman.sh"
Step B — caveman backend (preferred):
tempdir=$(mktemp -d)
trap 'rm -rf "$tempdir"' EXIT
cp "$target" "$tempdir/$(basename "$target")"
# Invoke caveman via Skill tool on tempdir copy:
# Skill(caveman:compress, args="$tempdir/$(basename "$target")")
# Caveman writes compressed output to tempdir/basename and backup to tempdir/<basename>.original.md.
# Both stay inside tempdir; trap cleans on EXIT.
cp "$tempdir/$(basename "$target")" "$target" # only on caveman success
Tempdir wrapper contains caveman's hardcoded <file>.original.md backup write. Real-path file replaced atomically on success. Consumers may add a defensive **/*.original.md entry to their .gitignore as belt-and-suspenders against tempdir cleanup races or future caveman backup-path-convention changes.
Step B fallback — in-session Edit (caveman absent or disabled):
Agent applies Edit ops directly on $target per the context/flavor-vs-content-matrix.md taxonomy. Same flavor-vs-content rules; no backend indirection.
Step C+ unchanged: semantic-diff dispatch (mandatory hard rule), revert pass for SEMANTIC LOSS / AMBIGUITY / UNCERTAIN findings, markdownlint-cli2, summary.
| Action | Args | Behavior |
|---|---|---|
<target> (default, no action keyword) | empty → uncommitted .md from git diff; file path → single-file; dir path → batch | snapshot → backend → dispatch → revert-pass → markdownlint verify → summary |
audit [target] | same target rules | read-only dry-run; compute expected-yield heuristic per context/target-types.md; classify SKIP/COMPRESS/UNCERTAIN |
Flags (apply to both actions):
--force — proceed even when the default <3% AND 0 semantic-loss → REVERT rule would trip. User owns the sub-3% diff--keep-snapshot — persist the original to ${CLAUDE_PLUGIN_DATA}/snapshots/<ISO-basic>Z-<basename>.orig.md (the plugin data directory survives plugin updates).md files → batch default action over those filesaudit → audit action on restmarkdownlint-cli2 MUST pass (using the consuming repository's markdownlint config when present). Non-zero exit blocks ship; revert and surface failures. markdownlint-cli2 is required for correctness (it is the ship gate): if the binary is absent (neither on PATH nor as the repo's node_modules/.bin/markdownlint-cli2), STOP at the entry point before compressing anything and surface the remediation — install it explicitly (npm install --save-dev markdownlint-cli2 or a global install); never treat absence as a lint failure and never ship unverified output.<3% AND 0 semantic-loss → REVERT. Proven safe in the authoring repo's empirical baseline (always-loaded instruction files: 3/3 attempts reverted). --force bypasses.mktemp -d, deleted post-dispatch). --keep-snapshot persists to ${CLAUDE_PLUGIN_DATA}/snapshots/ instead..claude/rules/** / AGENTS.md / CLAUDE.md / **/SKILL.md. --force bypasses on ANY file — user owns the result. audit heuristic emits informational SKIP recommendation on always-loaded paths citing the 2-3% empirical baseline; not a structural gate.context/semantic-diff-prompt.md template. Findings must carry verifiable citations; training-recall citation tokens are forbidden — [known] / [from memory] / [context] / [obvious] / [standard] / [usual]./compress falls back to in-session Edit-based compression. Backend selection determines only the mechanical-compression path; semantic-diff + revert pass + markdownlint hard rules apply regardless. LLM-compression fabrication risk (caveman backend OR in-session Edit) caught structurally by the revert pass.<basename>: <action_taken> (compression_pct=N.N%, semantic_loss=K, ambiguity=M, false_positive=P, markdownlint=PASS|FAIL)
action_taken ∈ {compressed, reverted, skipped}. Aggregate at end of batch.
Audit action output: table with target, expected_yield_pct, classify (SKIP/COMPRESS/UNCERTAIN), reason.
Observed failure points — each traces to a real incident; grown iteratively.
context/fan-out-orchestration.md: the main session dispatches separate compress + audit subagents, reconciling per finding.--force. Default <3% AND 0 semantic-loss → REVERT; always-loaded instruction files bound at 2-3% yield (empirical baseline: 3/3 reverted, all flavor-only). Pass --force only when a targeted sub-3% diff is intentional — the user owns the result.<file>.original.md backup beside the target. The caveman backend hardcodes this backup path; running it against the real file litters the repo. Backend Step B wraps caveman in a mktemp -d tempdir so the backup lands there and the trap cleans it; a gitignore entry for **/*.original.md in the consuming repo is optional belt-and-suspenders..cs, .py, .ts, .sh, etc.) — methodology is markdown-specific. Code-comment compression is out of scope.claude/rules/**, AGENTS.md, CLAUDE.md, **/SKILL.md) — audit will SKIP-recommend; sub-3% revert default applies (Gotchas "Sub-3% diffs auto-revert unless --force")/compact, different semantic/compress for batch fan-out — see Gotchas "Self-audit drifts toward EXPANSION"; follow context/fan-out-orchestration.md/compress prints a human-readable summary; no structured/--json outputmarkdownlint-cli2 is the post-edit verifier, not the primary purpose/code-review / /simplify shadow. The built-in /code-review and /simplify review code changes; /compress rewrites markdown prose. Different concerns/audit-noise. /compress owns FLAVOR (filler, hedging, articles, redundant restatement). /audit-noise owns NOISE classification (historical citations, ghost refs, "Why this file exists" preambles, hard-coupled enumerated consumer lists) per its own taxonomy. Different concerns; both may apply to the same target iteratively/extract-ssot when the duplicated cluster spans 3+ filescontext/semantic-diff-prompt.md — subagent dispatch template (Agent tool prompt + return-format contract)context/flavor-vs-content-matrix.md — canonical FLAVOR / CONTENT taxonomy + per-content-type variantscontext/target-types.md — per-action argument shapes + author-time-signal heuristiccontext/fan-out-orchestration.md — multi-phase batch fan-out recipe; read when compressing N files via parallel subagents (keeps the semantic-diff in a separate fresh-context auditor)context/integration.md — composition contract with sibling skills and consumer workflowsnpx claudepluginhub melodic-software/claude-code-plugins --plugin docs-hygieneGuides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
Dispatches multiple subagents concurrently for independent tasks without shared state. Use when facing 2+ unrelated failures or subsystems that can be investigated in parallel.