self-compact

self-compact is a command for Claude Code from Marcel-Bich/marcel-bich-claude-marketplace. It costs 32 tokens per session (3,328 once invoked), scanned A, original, MIT.

A command that saves an agent session's handoff information and then runs the session's real compact operation. Compacting shortens the working context so the session can continue with fewer tokens.

In plain words
What is it for?
Use it when a long coding session needs its context reduced while keeping a requirements log, handoff file, and recovery marker.
Why use it?
It preserves requirements and recovery notes before reducing the session context. A helper enters the command only when the terminal session is idle and wakes it afterward.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions subagents; mentions Claude Code.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the credo plugin — 28 skills, 21 commands, 7 hooks shipped together

Good fit Use it when a long coding session needs its context reduced while keeping a requirements log, handoff file, and recovery marker.

Compare 6 commands from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add Marcel-Bich/marcel-bich-claude-marketplace
Claude Code
/plugin install credo

Made for: Claude Code.

Or install credo, the plugin that ships this one along with the rest of its 28 skills, 21 commands, 7 hooks.

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 self-compact

README.md
[![agentmods](https://agentmods.dev/badge/commands/marcel-bich/marcel-bich-claude-marketplace/self-compact/github.svg)](https://agentmods.dev/commands/marcel-bich/marcel-bich-claude-marketplace/self-compact)
Your own site
<a href="https://agentmods.dev/commands/marcel-bich/marcel-bich-claude-marketplace/self-compact"><img src="https://agentmods.dev/badge/commands/marcel-bich/marcel-bich-claude-marketplace/self-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 self-compact

Your own site · 80×15
<a href="https://agentmods.dev/commands/marcel-bich/marcel-bich-claude-marketplace/self-compact"><img src="https://agentmods.dev/badge/commands/marcel-bich/marcel-bich-claude-marketplace/self-compact.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 32 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,328 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.00032 $0.03328
Opus 5.5 $0.00013 $0.01331
Sonnet 5.5 $0.00006 $0.00666
Haiku 4.5 $0.00003 $0.00333

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

Security

Grade A, and why

self-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 15d 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.

plugins/credo/commands/self-compact.md · 173 lines

How it starts

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

Credo Self-Compact

After compact-plus has secured the session state to disk (requirements log, rolling HANDOFF.md, rehydrate breadcrumb), this runs the REAL Claude Code /compact on the same session to save tokens. An agent cannot call /compact itself, so a detached worker types it into the session's OWN tmux pane - only once the session is idle and the input field is empty. After the compact the session wakes itself: a finished /compact does not start a model turn, so the worker waits for the deterministic compact-done signal and then types . to continue (details below).

Helper: ${CLAUDE_PLUGIN_ROOT}/scripts/credo-self-compact.py

Action What it does
check (default) Dry run. Resolves the tmux pane of THIS Claude process (TMUX_PANE from the Claude process environment, server socket from its TMUX), verifies the pane's process is this Claude process or the shell that started it with no other Claude process in between (a nested claude never types into the outer session's pane), checks the compact-plus breadcrumb (present and not older than --max-breadcrumb-age, default 7200 s = 2 h, also settable via CREDO_SELF_COMPACT_BREADCRUMB_MAX_AGE), prints the plan, the exact text it would type and the current pane state (background work in the footer does not count). Types nothing. Exit 1 with the reason when a precondition fails (not in tmux, pane of another process, no or stale breadcrumb, no session id).
run (--auto | --user-confirmed) [--delay S] [--timeout S] [--handoff PATH] Owner-rule guard first: refused -> exit 3, nothing started. Running background work does not block it (below). Then validates like check (exit 1 + ntfy on failure). Otherwise spawns a fully detached worker and returns at once. End your turn right after run. Refuses while another self-compact or a /credo:self-reload of this session is pending (both type into the same pane and share the wake file).
cancel Marks the pending self-compact of THIS session (CLAUDE_CODE_SESSION_ID) as cancelled and terminates its worker and removes a pending wake file. This works before typing, while typing (then no Enter is sent and the own line is taken back out of the input field, only when the field holds exactly that line) and while the worker waits for the compact or the wake. Once Enter was sent, the compact itself runs and only the wake is stopped. Nothing more is typed. Another session's pending self-compact is never touched.
status State line (pending / typing / sent / waking / woken / cancelled / failed: ...), the marker <configdir>/credo/self-compact-<session-id>.json and the tail of <configdir>/credo/self-compact-<session-id>.log of THIS session.

Read the full file on GitHub · 173 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. 15d ago First seen · 173 lines · 32 tokens per session scan A ab70fea513ae

Subscribe to this mod's changes

self-compact is a command published in the GitHub repository Marcel-Bich/marcel-bich-claude-marketplace (12 stars, last pushed yesterday), licensed MIT. It adds 32 tokens to every session and 3,328 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-10-10.