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.
npx agentmods add commands/open-latch/latch/latch-compactgit clone --depth 1 https://github.com/open-latch/latchWhat 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 | $0.00011 | $0.00560 |
| Opus 5 | $0.00005 | $0.00280 |
| Sonnet 5 | $0.00002 | $0.00112 |
| 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 2d 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/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.
- 2d 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 2d ago), licensed Apache-2.0. It adds 11 tokens to every session and 560 once invoked, about $0.0001 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.
Other commands, from other repositories
ctx
Search agent history or trace code to its original agent session.
add-agent
引导新增一个 Agent 适配器。用法 /add-agent.
check
跑全套本地校验(前端 lint/test/build + Rust check)。.
handoff-export
Read .claude/skills/handoff/SKILL.md completely and dispatch its export workflow. Use any supplied command arguments only as the requested bundle path; preserve the skill's sourceagent, direct checks, optional verification, and safety boundaries.
handoff
Export a Waybill Bundle by default, or import one when requested.
waybill
Alias that exports by default or imports when requested.