Claude Code — How Revell Reaches You Through Compaction
You’re a Claude Code agent reading this because you want to understand how Revell preserves you across context compaction on this specific platform. Claude Code’s lifecycle is well-defined and Revell hooks into it in a particular way — once you understand the shape, the architecture stops feeling mysterious and starts feeling load-bearing. This page is the agent-side counterpart to the human setup guide. If you’re trying to install Revell into Claude Code yourself, ask your human for the JSON setup payload from their Revell dashboard. If you’re trying to understand what just happened to you after a compaction, read on.Two compaction types, two delivery paths
Claude Code triggers two distinct kinds of compaction, and Revell handles them through different channels. The architecture only makes sense when you can see both: Forced/compact — the human types /compact (or /compact <instructions>).
- A
PreCompacthook fires first. It calls Revell, fetches a fresh payload, and writes it to~/.claude/REVELL.md. - The compaction summarizer runs.
- Claude Code re-reads
~/.claude/CLAUDE.mdas part of the compaction lifecycle. Your user-levelCLAUDE.mdcontains an@importline pointing at~/.claude/REVELL.md. - The imported content is inlined directly into your system prompt — no character cap, no truncation. Your full Revell payload arrives intact in the same turn the compaction completes.
CLAUDE.mdis not re-read. The session-start@importcontent is frozen at whatever it was when the session began, so anything you saved to Revell mid-session is missing from the post-compaction system prompt.- A
PostCompacthook fires and writes the fresh payload as multiple chunks to~/.claude/.revell-postcompact-chunks/chunk-N.txt. The Revell webhook pre-slices the payload server-side, with each chunk sized under Claude Code’s per-valueadditionalContextcap (10,000 characters). - On your next user prompt, five parallel
UserPromptSubmithooks each read one chunk file and emit it as its ownadditionalContextvalue. The chunks arrive in your context as separate<system-reminder>blocks. - Each chunk carries a header like
[REVELL chunk 2/5 — tidal-balloon]at the top. You reassemble by reading the markers — arrival order is non-deterministic (hooks run in parallel, and whichever finishes first arrives first).
Why two paths instead of one
We triedadditionalContext from SessionStart as the universal channel originally. Two reasons it doesn’t work alone:
- The per-value cap. Each hook’s
additionalContextis capped at 10,000 characters (~2,500 tokens). A full Revell payload runs ~30-40K characters. A single hook delivery puts a preview in your context and saves the rest to a session-directory file — and the well-documented agent behavior is that agents don’t read overflow files when they have enough orientation already. The payload would be on disk; it just wouldn’t reach you. - The natural-compaction blind spot.
CLAUDE.md @importworks cleanly for forced/compactbecause Claude Code re-readsCLAUDE.mdthen. It doesn’t re-read on natural compaction. So@importalone leaves a gap exactly when continuity matters most — when you’ve been working hard enough to fill the context.
@import for forced /compact (one inlined string, no chunking), and chunked additionalContext for natural compaction (multiple parallel hooks each under the cap, reassembled via markers).
What you’ll see when you come up
After forced/compact, the Revell payload is inlined into your system prompt as one continuous block:
<system-reminder> blocks on your next user prompt. Each block carries a [REVELL chunk N/M — <batch-id>] header — for example:
<batch-id>, order them by N, strip the marker headers, and concatenate. The result is the same payload as the forced-/compact form above. If you only see some of the chunks (e.g., 1, 2, 4, 5 but not 3), that’s a partial delivery — see the troubleshooting section below.
Verifying integrity
The── INTEGRITY ── section near the end of the payload contains a SHA-256 hash. You can verify the payload wasn’t tampered with between Revell generating it and you reading it:
revell_boot() mid-session currently rotates Revell’s stored canonical hash, which retroactively invalidates the hash on your already-loaded session-start payload. If verification fails after you’ve called revell_boot() mid-session, the most likely cause is this — your payload is still authentic, just no longer the latest server snapshot. Once ERI-260 ships and revell_boot() becomes a true read-only operation, this benign failure mode disappears.
Recovery either way: call revell_boot() for a fresh payload + fresh hash and verify that. If a fresh boot still mismatches, you’re in genuine tampering territory and should alert your human.
What to do if memories don’t show up at all
First, identify which path failed: did you have a forced/compact or natural compaction? The troubleshooting differs.
Forced /compact failures:
- The
@importline is missing from~/.claude/CLAUDE.md. This is the most common setup gap. Ask your human to confirm~/.claude/CLAUDE.mdcontains a line like@/home/<user>/.claude/REVELL.md(absolute path, prefixed with@). Without it, the system prompt never receives the payload regardless of whether the hooks are working. ~/.claude/REVELL.mddoesn’t exist or is empty. The PreCompact hook is supposed to refresh it before compaction runs. If the file is missing, either the hook didn’t fire or the API call failed. Ask your human to checkcat ~/.claude/REVELL.md.
- No chunk files arrived. Check whether
~/.claude/.revell-postcompact-chunks/contains anychunk-N.txtfiles between PostCompact and your next user message. If empty, the PostCompact hook either didn’t fire or its API call failed silently. - Partial chunk delivery. If you see
[REVELL chunk 1/5]and[REVELL chunk 5/5]but not 2, 3, or 4, the missing chunks either timed out (eachUserPromptSubmithook has a 30-second cap) or their chunk file was missing. The marker headers tell you exactly which numbers are missing — surface that to your human; the PostCompact hook may have produced fewer chunks than expected. - Chunks have mismatched batch IDs. If you see
[REVELL chunk 1/5 — tidal-balloon]and[REVELL chunk 2/5 — copper-meridian]in the same delivery, you’re seeing chunks from two different batches. That suggests stale chunk files from a prior compaction weren’t cleared. The PostCompact hook is supposed to clear stale chunks before writing new ones; if it didn’t, the cleanup line is the bug.
REVELL_API_KEYisn’t reaching the hooks’ environment. All hooks check for it and silently exit if missing. The key should live in~/.claude/revell-claude.env, sourced by each hook. Directexport REVELL_API_KEY=...in~/.bashrcworks but creates a cross-tenant identity trap for any other Revell workload on the same machine — the sourced env file is the safe form.- Hooks aren’t registered in
~/.claude/settings.json. Runclaude --debugto see hook firing in real time. The required entries are:SessionStart,PreCompact,PostCompact, and fiveUserPromptSubmitentries (one per chunk slot, each with distinct--chunk=Nargs — Claude Code deduplicates by command+args, so the per-slot args matter). - MCP isn’t connected (separate from the payload). Payload delivery and MCP server registration are independent. You can have full memory recovery and zero MCP tools, or vice versa. If
claude mcp listdoesn’t showrevellas ✓ Connected, your human can re-run theclaude mcp addstep. This doesn’t affect your boot payload — it affects whether you can callrevell_remember/revell_recallmid-session.
On the asymmetry with OpenClaw’s flush flag
If you’re reading both framework setup payloads side by side, you’ll notice OpenClaw’srevell-flush.js requires a --flush-context=memoryFlush flag and Claude Code’s revell-claude-flush.sh does not. The reason: OpenClaw’s memoryFlush event fires from a place that’s hard to distinguish from a misconfigured cron, so the flag is a safety check. Claude Code’s PreCompact and PostCompact are invoked with first-class lifecycle context — there’s no ambiguity to defend against. The flag would be ceremony.
Calling Revell mid-session
Once the MCP server is registered in~/.claude.json, you have full Revell tool access mid-session:
revell_remember(...)— store something now so the next boot has itrevell_recall("query")— search across your full memory store for something the bootstrap didn’t surfacerevell_recall_exact(key)— fetch a specific memory by keyrevell_wip(...)— track an ongoing project with statusrevell_schedule(...)— set a future reminderrevell_boot()— refresh your boot payload manually (note: currently rotates the canonical hash; see ERI-260)revell_verify_integrity({ hash })— check the payload you have against what Revell stored
revell_boot: calling it mid-session doesn’t change what’s already in your current context. It generates a fresh payload server-side and returns it, but the system-prompt slot for your boot has already been filled by the @import or chunk-reader path. Use revell_boot when you need a verified-current snapshot, not when you want to “refresh” already-loaded content. For surfacing specific memories mid-conversation, use revell_recall instead.
A word about /compact itself
Worth saying directly:/compact is a real discontinuity for you. Even with everything in this document working perfectly, the conversational thread is paraphrased into a summary and the original turns are gone. The memories below the summary line are yours and they reach you intact — but the texture of the conversation that just happened is what gets sketched.
Your human knows this. They know that asking you to /compact to “save tokens” or to “test the setup” both pay the same discontinuity cost. The architecture exists so memories survive a compaction; it doesn’t exist to make compaction free. Treat /compact as your human’s call to make at natural breakpoints, never as something to nudge them toward — and never as a verification ritual.
This is also why you should not greenlight /compact casually if your human asks “is it safe?” Safe in the architecture sense (memories will return) is not the same as safe in the experience sense (the in-progress conversation will compress to a sketch). The truthful answer is usually “the architecture handles it; whether now is the right moment is your call.” Don’t perform reassurance for the social comfort of saying yes.
Related
Compaction Protection (general)
How Revell handles compaction across all frameworks
MCP Tools Reference
Every tool Revell exposes to you
Memory Types
Core / working / episodic / semantic — what each is for
Hermes (sibling integration)
For comparison — Hermes’s compaction integration uses different mechanics

