cc-compact

cc-compact is a command for Claude Code from yeisonrestrepo/code-conductor. It costs 13 tokens per session (1,944 once invoked), scanned A, original, MIT.

A command that saves the current phase state, decisions, pending work, changed files, and related details so a long conversation can be shortened and continued later.

In plain words
What is it for?
Use it at the end of a planning, specification, implementation, or review phase when the conversation needs to be compacted.
Why use it?
It preserves handoff information before context is compacted, reducing the risk of losing what has already been decided.

Command for Claude Code

Written for Claude Code: a Claude Code command (commands/*.md).

Good fit Use it at the end of a planning, specification, implementation, or review phase when the conversation needs to be compacted.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/yeisonrestrepo/code-conductor/cc-compact
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/yeisonrestrepo/code-conductor

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cc-compact

README.md
[![agentmods](https://agentmods.dev/badge/commands/yeisonrestrepo/code-conductor/cc-compact/github.svg)](https://agentmods.dev/commands/yeisonrestrepo/code-conductor/cc-compact)
Your own site
<a href="https://agentmods.dev/commands/yeisonrestrepo/code-conductor/cc-compact"><img src="https://agentmods.dev/badge/commands/yeisonrestrepo/code-conductor/cc-compact/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cc-compact

Your own site · 80×15
<a href="https://agentmods.dev/commands/yeisonrestrepo/code-conductor/cc-compact"><img src="https://agentmods.dev/badge/commands/yeisonrestrepo/code-conductor/cc-compact.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 13 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,944 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00013 $0.01944
Opus 5.5 $0.00005 $0.00778
Sonnet 5.5 $0.00003 $0.00389
Haiku 4.5 $0.00001 $0.00194

Measured 18d ago against content hash 5653e8a7bc9e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

cc-compact scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 18d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

global/commands/cc-compact.md · 65 lines

How it starts

The opening of the file, as written. The whole thing — 65 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Run git rev-parse HEAD to get the current commit SHA (the full 40-char hash — NOT --short, whose abbreviation length auto-scales with repo size and is unstable across growth). Lowercase and trim it; if it does not match /^[0-9a-f]{7,40}$/, or the command exits non-zero (non-git workspace, no commits, git absent, or permission-denied), use "0000000". Wrap the call with shell timeout only when command -v timeout (or gtimeout) succeeds; otherwise run it unwrapped. This same value is sys.c and the sessions / snapshots git-hash key.

Determine sys.s: take the active specification file path from this phase's context, split on / and \, keep the last segment, strip a trailing .md extension, truncate to 200 characters. If no active spec file exists, use "none".

Collect from the current conversation context:

  • Phase (sys.ph): spec | plan | impl | rev, the phase that just completed
  • Decisions (mem.d): finalized decisions this phase, max 10 elements, each ≤300 chars (JSON-serialized length)
  • Pending (ops.n): next immediate step(s), max 3 elements, each ≤200 chars
  • Files Touched (ops.f): each entry <relpath>:C|M|D (uppercase only); replace any backslash in the path with /; if the path contains a literal :, percent-encode it as %3A before appending the suffix; max 20 elements, each ≤300 chars
  • Constraints (mem.x): hard constraints next phase must respect, max 5 elements, each ≤200 chars

For all four array fields: filter out empty/whitespace-only strings, deduplicate by exact case-sensitive string equality (first occurrence wins), then truncate each surviving element to its per-element cap (snap-build does the cut, to the cap measured as JSON-escaped length, never splitting a character; an over-cap ops.f entry keeps its :C/:M/:D suffix and loses path, and one with no such suffix is refused with SNAP_FILE_NO_ACTION), then if the array still exceeds its cap, drop from the head (oldest first) until it fits. Empty arrays are valid and must still be serialized (never omitted).

Serialize by piping a flat JSON object {ph, c, s, n, f, d, x} (no pr) on stdin to node .claude/scripts/snap-build.mjs; its stdout is the canonical single-line v1 SNAP JSON. snap-build performs all array normalization (filter/dedup/per-element cap/head-drop) and the 4096-char size trim internally — do not pre-serialize. If snap-build exits non-zero (malformed field object), report the error and stop; do not write the handoff file, do not run the DB tail, do not print the compact prompt.

Write the single JSON line, followed by exactly one trailing newline, to .claude/memory/session-snapshot.json.

If .claude/memory/session-snapshot.md exists, delete it as part of this write.

Idempotently append .claude/memory/session-snapshot.json to the project's .gitignore: read the file; if any line, after stripping leading/trailing whitespace, exactly equals .claude/memory/session-snapshot.json, skip the append. Otherwise, check whether the last byte of .gitignore is a newline; if not, prepend a newline before the appended entry. If .gitignore cannot be read or written (permission or lock error), log a non-fatal warning to stderr and continue; do not block the snapshot write.

If writing the snapshot fails (e.g., missing .claude/memory/ directory), report the error and stop. Do NOT output the compact prompt.

Once the snapshot is written successfully, output exactly:

Snapshot written. Run /compact now to clear history.


Fail-open DB tail (best-effort, synchronous)

After the handoff file is written and the compact prompt is ready — and only if the authoritative write succeeded — run this synchronous, fail-open tail. Any failure here is non-fatal: never revert the handoff file, never suppress the compact prompt.

Preconditions. c is the full-40 git rev-parse HEAD, lowercased, matching /^[0-9a-f]{7,40}$/, "0000000" on any failure; s is the active spec stem or "none". Both are derived exactly as this command's body already specifies.

Read the full file on GitHub · 65 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 18d ago Changed 5653e8a7bc9e
  2. 2mo ago Changed · +15 lines 52d6ed4c866a
  3. 3mo ago First seen · 50 lines · 13 tokens per session scan A 461ab9cc3e0c

Subscribe to this mod's changes

cc-compact is a command published in the GitHub repository yeisonrestrepo/code-conductor (22 stars, last pushed 2d ago), licensed MIT. It adds 13 tokens to every session and 1,944 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

cc-compact compared with commands from other repositories

cc-compact next to 6 commands from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
cc-compactyeisonrestrepo/code-conductorCommand222d agoMITA13Claude Code
reportrohitg00/awesome-claude-code-toolkitCommand2.9k6mo agoApache-2.0A17Claude Code
generate-changelogrohitg00/awesome-claude-code-toolkitCommand2.9k6mo agoApache-2.0A19Claude Code
explainrohitg00/awesome-claude-code-toolkitCommand2.9k6mo agoApache-2.0A0Claude Code
build-imagerohitg00/awesome-claude-code-toolkitCommand2.9k6mo agoApache-2.0A19Claude Code
env-setuprohitg00/awesome-claude-code-toolkitCommand2.9k6mo agoApache-2.0A0Claude Code
debug-podrohitg00/awesome-claude-code-toolkitCommand2.9k6mo agoApache-2.0A0Claude Code