before-compact

before-compact is a skill for Claude Code from SoliEstre/EstreGenesis. It costs 79 tokens per session (808 once invoked), scanned A, original, Apache-2.0.

A procedure for saving important session details to a handoff file before the conversation is shortened. It records conventions, unfinished work, decisions, and resource identifiers that would otherwise exist only in memory.

In plain words
What is it for?
Use it before manual compaction or when a session becomes long, especially to preserve active tasks, paths, environment rules, and unresolved decisions.
Why use it?
It reduces the risk of losing the context needed to continue work after compaction or in a later session.

Skill for Claude Code

Written for Claude Code: PreCompact hook event.

Part of the constellation plugin — 10 skills, 1 hook shipped together

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.

agentmods
npx agentmods add skills/soliestre/estregenesis/before-compact
Any agent
npx skills add SoliEstre/EstreGenesis --skill before-compact
Clone the repo
git clone --depth 1 https://github.com/SoliEstre/EstreGenesis

Made for: Claude Code.

Or install constellation, the plugin that ships this one along with the rest of its 10 skills, 1 hook.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/soliestre/estregenesis/before-compact.svg)](https://agentmods.dev/skills/soliestre/estregenesis/before-compact)
Your own site
<a href="https://agentmods.dev/skills/soliestre/estregenesis/before-compact"><img src="https://agentmods.dev/badge/skills/soliestre/estregenesis/before-compact.svg" alt="Measured on agentmods" height="20"></a>
Per session 79 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 808 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00079 $0.00808
Opus 5 $0.00039 $0.00404
Sonnet 5 $0.00016 $0.00162
Haiku 4.5 $0.00008 $0.00081

Measured 6d ago against content hash 6ba2af766b67, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

before-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 6d 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/constellation/skills/before-compact/SKILL.md · 31 lines

How it starts

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

/before-compact — compact-survival handoff materialization

Write the things that exist only in the current context — and nowhere on disk — into the compact-handoff file (default .agent/compact-handoff.md, or the path your HANDOFF_PATH hook env points at). The PreCompact hook snapshots the environment (git state) deterministically and the SessionStart(compact) hook re-injects the file; this skill owns the half no script can collect: what is in the model's head.

This mechanizes Constellation §13.16.6 element 6 (pre-large-work context materialization) and is what makes §13.21 (fresh-context defer is an anti-pattern) operative for the procedural layer.

Procedure

  1. Codify recurring practices first (soft — only if Greatpractice is adopted). Before materializing session-specific state, invoke /routinize to mine this session's recurring work into durable practice captures. This timing is routinize's prime trigger: the accumulated context is the raw material and it is about to be compacted away, so cross-session durable practices should be captured before session-specific resume state. The two are complementary, not redundant — routinize captures what recurs across sessions (→ memory/feedback_*.md), this skill captures what is in flight in this one (→ the handoff card). Skip if Greatpractice / the /routinize skill is not in use.

  2. Scan for volatile details from this session:

    • Procedure conventions: script call requirements (env vars, arguments, ordering), policies agreed this session that are not yet in memory/guides. (Observed failure class: a required env-var prefix on one script call lived only in-context, was dropped by a compaction summary, and the post-compact agent reverted to the script's default — misrouting messages until a human noticed.)
    • In-flight cycle anchors: files touched so far + next step + the reasoning behind the current approach (if a track doc already holds this, record only the pointer).
    • Unrecorded decisions: user decisions from this session not yet in a durable artifact.
    • Active resources: background tasks / monitors / workflow run IDs + how to resume each.
  3. Update the standing card — edit the handoff file's standing-card section:

    • Update existing entries in place; append new ones; delete stale ones. Keep the card short (≤ ~15 entries) — the whole file re-enters context after every compaction, so length is a recurring tax.
    • Never touch the auto-snapshot block (between the AUTO-SNAPSHOT markers) — the PreCompact hook owns it.
  4. Promote durables — entries that have become permanent discipline belong in memory files or guides; promote them there and shrink the card entry to a pointer.

  5. Report + recommend — state what was recorded in 1-3 lines; if the user intended a manual compact, recommend running /compact now. (For auto-compact readiness, recording alone completes the skill.)

Read the full file on GitHub · 31 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. 6d ago First seen · 31 lines · 79 tokens per session scan A 6ba2af766b67

Subscribe to this mod's changes

before-compact is a skill published in the GitHub repository SoliEstre/EstreGenesis (8 stars, last pushed yesterday), licensed Apache-2.0. It adds 79 tokens to every session and 808 once invoked, about $0.0004 per session on Opus 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

Other skills, from other repositories

update-agent-context

This skill should be used to keep CLAUDE.md, AGENTS.md, and the skill files themselves compact, current, and internally consistent. It runs in three phases: Phase 1 performs a one-time structural refactor of CLAUDE.md using a Karpathy-inspired behavioral scaffold and derives AGENTS.md from it by stripping Claude…

mostlyharmless-ai/watercooler · 203 tokens

watercooler-onboarding

Bootstrap Watercooler memory for a repository by inspecting local code, docs, CI, git history, and existing Watercooler threads, then writing a small set of durable, provenance-backed seed threads that future agents can query and extend. Use when entering a repo for the first time, seeding a repo with Watercooler…

mostlyharmless-ai/watercooler · 79 tokens

recall

Recall project context or answer questions about history and decisions. Use before starting work, when investigating unfamiliar code, or asking "What was decided about X?" / "Why did we choose Y?".

mostlyharmless-ai/watercooler · 41 tokens

wiki

Use this skill when querying workspace knowledge before tasks or running mandatory post-review ingest evaluation and conditional wiki ingestion. Self-learning loop for the workspace.

wcgomes/agents-workspace · 30 tokens

agent-v3-memory-specialist

Agent skill for v3-memory-specialist - invoke with $agent-v3-memory-specialist.

ruvnet/ruflo · 25 tokens

agent-memory-coordinator

Agent skill for memory-coordinator - invoke with $agent-memory-coordinator.

ruvnet/ruflo · 19 tokens