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.
git clone --depth 1 https://github.com/open-latch/latchWrote 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.
[](https://agentmods.dev/commands/open-latch/latch/latch-compact)<a href="https://agentmods.dev/commands/open-latch/latch/latch-compact"><img src="https://agentmods.dev/badge/commands/open-latch/latch/latch-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.
<a href="https://agentmods.dev/commands/open-latch/latch/latch-compact"><img src="https://agentmods.dev/badge/commands/open-latch/latch/latch-compact.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00011 | $0.00564 |
| Opus 5.5 | $0.00004 | $0.00226 |
| Sonnet 5.5 | $0.00002 | $0.00113 |
| Haiku 4.5 | $0.00001 | $0.00056 |
Grade A, and why
latch-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 1mo 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.
What it actually says
Run a compaction pass for the current Claude Code session against the
per-project knowledge base under <KB_HOME>.
The compaction runs in a separate claude -p subprocess that takes its
own context — it does NOT consume tokens from this session. We launch it
in the background so the main session stays interactive while compaction
runs.
This combines/overwrites the prior session_summary node with the latest
state (see src/latch/pipeline/compactor.py).
Steps:
-
The wrapper targets the invoking session automatically: it reads
$CLAUDE_CODE_SESSION_ID(set by Claude Code on the Bash subprocess) and selects that session's transcript explicitly — a concurrent session's newer transcript is never picked. An explicit session id can be passed as the first positional arg to compact a different session. -
Launch the compactor with the Bash tool in the background so the main session is not blocked while compaction runs (a full compact can take 30–90s):
Bash( command="bash <KB_HOME>/bin/run_compact_now.sh", run_in_background=true, description="Run KB compaction in background" )Return control to the user immediately with the background shell id. Do not poll — the harness will notify you when the subprocess exits. Omit
--final— manual/latch-compactis a rolling compact, not a session end. The session_summary node stays instagingstatus. -
While the compactor is running, the project lock at
<KB_HOME>/projects/<sanitized-cwd>/compactor.lockis held. Anylatch_insert/latch_update/latch_link/latch_unlinkcalls made by the main session will block for up to 60s waiting for the compactor to finish, then return{"ok": false, "reason": "compaction_in_progress", "retry_after_s": 10}if it still hasn't finished. This is the deterministic write-side serialization — the busy payload'smessagetells you what to do: retry the write once, and if it is still locked, ask the user whether to retry again or investigate. Don't chase the lock. -
When the harness notifies that the background shell completed, fetch its stdout and report which
summary_node_idwas updated and a one-line gist.
If anything fails, check <KB_HOME>/compactor.log.
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.
- 1mo ago Changed 096b9b6697d3
- 1mo ago First seen · 56 lines · 11 tokens per session scan A e0d4f2590f46
latch-compact is a command published in the GitHub repository open-latch/latch (9 stars, last pushed 7d ago), licensed Apache-2.0. It adds 11 tokens to every session and 564 once invoked, about $0.0000 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.
Other commands, from other repositories
ctx
Search agent history or trace code to its original agent session.
krimto-status
Show the current state of Krimto memory — total facts, scope breakdown, recent writes, and index health.
context-save
Save project context, decisions, and progress for a later session.
kiro-steering-custom
Command "kiro-steering-custom" from gotalab/cc-sdd, covering kiro custom steering creation, workflow, available templates, steering principles and tool guidance.
save-session-learnings
Document session learnings to CLAUDE.md and AGENTS.md. Use after completing significant tasks, debugging sessions, or discovering project patterns.
memory-why
Show why a memory recall returned what it did -- BM25 vs vector vs hybrid provenance.