Four Shell Scripts Between Claude Code and Amnesia
I’ve been building Flowplane, an Envoy control plane, using Claude Code heavily. Not simple scripts — a full system with xDS protocol servers, filter chain management, mTLS certificate lifecycle. The kind of project where a single architectural decision ripples through six other modules.
For the first few weeks, Claude Code was extraordinary. But as the project grew, something started breaking down. Not the code. The memory.
The Memory Wall
If you’ve used Claude Code on large projects, you know the moment. The context window fills up, compaction hits, and Claude continues — but the nuance is gone. The specific rationale for why you chose one approach over another is the edge case you discussed three turns ago. Evaporated.
It got worse with teams. Claude Code’s multi-agent teams are powerful — specialised teammates handling research, implementation, and testing in parallel. But when a teammate finishes and shuts down, everything it learned disappears. I’d have a researcher spend fifteen minutes mapping out Envoy’s filter chain architecture, produce excellent findings, and then... nothing. The next session started from zero.
I tried the built-in options. MEMORY.md is post-it notes on a monitor — fine for “user prefers Rust,” useless for tracking a multi-week refactor. Auto memory is shallow. Plan files rot because Claude updates them inconsistently. MCP memory servers require the agent to actively choose to remember, and at the critical moments — compaction, session end, teammate shutdown — that’s exactly when it doesn’t.
Every solution I found required the agent to decide to remember. None of them automated it.
Lifecycle Hooks as a Memory Bus
Claude Code has lifecycle hooks — events that fire shell scripts at key moments. SessionStart, PreCompact, Stop, TaskCompleted. Separately, there’s Hindsight — a graph-based memory engine by Vectorize. It extracts entities, builds temporal links between memories, and does semantic search with reranking. It understands that “migrated PostgreSQL to port 5433” and “database configuration” are related, and that one happened before the other.
The insight: what if lifecycle hooks automatically piped context to Hindsight at every boundary where memory is at risk? Not “Claude, please remember to save.” The system fires a hook, a script runs, and memory is saved or recalled without anyone asking.
Four Scripts
SessionStart queries Hindsight for recent memories about the project and injects them into Claude’s context. Claude begins every session already knowing what happened last time.
PreCompact fires before context compression. Instead of dumping to a file nobody reads, it instructs Claude to save its current state to Hindsight — what it’s working on, what it’s decided, what’s left to do. When compaction finishes, the critical state is recoverable.
Stop saves a session summary when Claude shuts down. Tomorrow’s SessionStart recalls it.
TaskCompleted is the one that matters most for teams. When a teammate finishes a task, this hook fires and writes the task details directly to Hindsight’s REST API. No agent involvement. A researcher’s 15 turns of architecture mapping are automatically persisted. The next session recalls them as project context.
Does It Work?
I ran a research task using a multi-agent team. Before the session, the project had one memory from a previous session. After the team finished, four new memories had been created automatically — research findings, task completions, session summary. Each with entities extracted and temporal links established.
The next day, I started a new session. SessionStart fired, and Claude’s first message referenced the previous team’s findings without me mentioning them. It knew what had been researched, what had been decided, and what was left to do.
The Infrastructure
I want to be honest: this isn’t a “copy these four scripts and you’re done” solution. Hindsight needs PostgreSQL with pgvector. I run it in Docker on a non-standard port because Flowplane’s tests use their own PostgreSQL. Hindsight needs an LLM for entity extraction — I use Ollama running Qwen locally, so there’s no API cost. On macOS, I run Hindsight as a LaunchAgent so it starts on boot.
It’s not zero effort. But once it’s running, it’s invisible. You just notice that Claude remembers things it shouldn’t be able to.
What I Don’t Know Yet
Memory decay is real. I haven’t tested what happens three months and five hundred memories deep. Does the graph get noisy enough that recall starts returning irrelevant context? I don’t know yet. I’ve been running this for weeks, not months.
I also haven’t tuned Hindsight. I’m running defaults — default entity extraction, default recall parameters, default reranking. There’s almost certainly a better configuration for how I work. I’ve been too busy building Flowplane to optimise the tool I use to build Flowplane. There’s some irony there.
And the PreCompact hook is the least tested piece. Compaction doesn’t happen on a schedule — it triggers when the context window fills. I’ve seen it work. I haven’t stress-tested it.
So this is a “here’s what’s working for me right now” post, not a “here’s the solved problem” post. The pattern feels right. The implementation needs more mileage.
The Larger Point
Complex projects need memory that scales with complexity. MEMORY.md works for a weekend CLI tool. When you’re building something with a dozen interacting subsystems and multi-week timelines, you need memory that has structure, understands relationships, and persists automatically.
I suspect this pattern — lifecycle hooks piping context to structured external memory — will become standard as agentic coding matures. Right now it’s custom scripts and early-stage tools. In a year, I’d expect something like it built into the platforms. In the meantime here is the gist
If you’re hitting the memory wall with Claude Code, I’d be curious to hear what you’ve tried. The tooling is young and the patterns are still emerging. Find Flowplane at github.com/rajeevramani/flowplane, or connect with me on LinkedIn.


Keep building in public @rajeev!