Context Preservation for Claude Code

Every Session Starts Where You Left Off

ctx hooks into Claude Code's compaction cycle to automatically capture and restore your working context — goal, decisions, and next steps — across every session.

$ curl -fsSL .../install.sh | sh
View on GitHub
terminal — ctx workflow
ready
act 1 of 4
1
snapshot per branch
always current
3
hooks registered
zero config
300
max tokens per snapshot
maximum signal
The Problem

Compaction erases what matters most

Every time Claude Code hits its context limit, it compacts. The conversation is summarized — but your specific goal, the decisions you made, the file you were editing — all of it gets diluted or lost.

  • Claude forgets what you were building and why
  • Decisions already made get revisited or contradicted
  • New sessions start from scratch, with no prior context
What gets lost without ctx
Goal
add snapshot pruning and ctx list
Decisions
branch-scoped paths, path.txt for reverse lookup
In Progress
snapshot/store.go | 3 files changed
Next
implement ctx list --all flag
✓ with ctx — all of this survives
How It Works

Compact. Snapshot. Resume.

ctx hooks into three Claude Code events. Install once, it works automatically from that point forward.

01
Compact your session

Run /compact manually or let Claude Code auto-compact. The PreCompact hook fires and ctx gets to work.

02
Snapshot is written

ctx reads the session transcript and git state, calls claude -p to extract semantics, and writes a structured snapshot scoped to the current branch.

03
Resume exactly here

On every new session, the SessionStart hook finds the snapshot for your project and branch and injects it as context. Claude knows exactly where you were and what to do next.

Philosophy

Built on a clear conviction

Vision
Every Claude Code session starts exactly where you left off.
Mission
Capture the minimum context needed to resume work, automatically, at the right moment.
Philosophy
The most recent state is the only state that matters. Compaction is not loss — it's a checkpoint. One snapshot per branch, always current, never accumulated.
Installation

Up in 30 seconds

Install the binary, run ctx init, and ctx starts working on every compaction and session start.

Single binary, no runtime dependencies
Hooks registered automatically via ctx init
Works with any project, with or without git
MIT licensed, open source
# Download and install
curl -fsSL https://raw.githubusercontent.com/AgusRdz/ctx/main/install.sh | sh

# Register hooks in Claude Code
ctx init
# PowerShell - download and install
irm https://raw.githubusercontent.com/AgusRdz/ctx/main/install.ps1 | iex

# Register hooks in Claude Code
ctx init
# Add tap and install
brew install AgusRdz/tap/ctx

# Register hooks in Claude Code
ctx init
# Install via Go toolchain
go install github.com/AgusRdz/ctx@latest

# Register hooks in Claude Code
ctx init

Binary lands in ~/.local/bin (macOS/Linux) or %LOCALAPPDATA%\Programs\ctx (Windows)