pqant/claude-continuity
Acerca de
Zero-touch session rotation and supervision for Claude Code
Herramientas de desarrolloCrecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
Originalcc-continuity
Zero-touch session rotation and supervision for Claude Code.
Why it exists. Long sessions die when the context window fills up, and local LLMs make it worse: their window is fixed and small, and the built-in compaction (/compact, auto-compact) is a lossy one-shot summary. With a small model it silently drops decisions, rejected approaches and the exact stopping point, and every compaction then summarizes a summary, so the drift compounds. cc-continuity exists to give long work room to breathe inside the window: at a safe threshold it rotates the session with a structured, validated handoff instead of a lossy summary.
The goal is to let an agent drive a planned project end-to-end, from 0 to done, with a human involved only when the agent is truly blocked. This repository is the proof of concept: it was developed with cc-continuity itself, and the full development history is in this git log.
cc-continuity watches the context ratio and, when it crosses a threshold, rotates the session with no user action:
- the agent finishes the current step,
- cc-continuity makes it write a validated handoff,
- the git tree is snapshotted non-invasively (
refs/continuity/*refs: no commits, no tags, no branches touched), - the context is cleared and the session renamed,
- a continuation prompt is injected and the successor session starts
with
Continuing from cp-<NNN> (<slug>-<NNN+1>).
An optional watchdog daemon keeps long unattended runs recoverable when the model server (for example a local vLLM box) dies or freezes, and optional ntfy pushes let you watch from your phone.
What's new
The five most recent updates, newest first. Each line links to its commit, so you can see what changed lately without digging through the log:
- 2026-12-01: Housekeeping: the What's new entries that still linked their pre-maintenance commit hashes now resolve to their canonical commits (commit).
- 2026-11-30: Split merged headers now hand off completely flush, and the session header got the approved variant A redesign (issues #118 #119). The first sticky-header fix left a roughly 10 px sliver (previous block tail plus gap) at each session boundary because the shared block spacing and the header's remaining bottom margin still opened below the sticky clamp; the split rule now zeroes every header margin and drops the last content block's bottom margin, and the merge sidecar bootstrap injects both rules so pre-fix pages are repaired without re-exporting their HTML. The header itself is now a neutral theme-token surface (title
--fgon--bg) that reads consistently in light, dark and auto themes with accent colour reserved for the identity marks (thick top border and left band), it gains a 2 px gap below in the non-split flow, a click-to-collapse chevron witharia-expanded(no persistence, every session starts expanded) and a muted "N block" count badge filled as each sidecar mounts, with unit tests written first and live proofs in a real Chrome asserting the pane top is always covered by a header across a real 111-session merged fixture and the chevron, aria and badge behaviour end to end (flush fix, redesign). - 2026-11-30: No more half-clipped text at session boundaries in the split merged view (issue #118). The sticky session header kept the 30 px top margin shared with the non-split view, and a sticky element is confined to its own section, so the incoming header arrived 30 px late and the trailing block of the previous session stayed painted at the top of the pane (measured 25 to 31 px window); the split rule now stacks headers flush (
margin:0 0 8px) with the boundary separation carried by each header's accent top border and opaque tint, the non-split view keeps its roomy spacing because nothing is sticky there, and pages exported before the fix are repaired by a lateccStickyFixstyle injection carried in the merge sidecar instead of re-exporting their HTML, with two tests written first and a live proof in a real Chrome scanning every scroll step of a real two-session split fixture and asserting the pane top is always covered by a session header (commit). - 2026-11-30: Skill-pasted images are back in the transcript (issue #117). Claude Code writes an image pasted during a skill invocation as one record carrying both the base64 image and the "Base directory for this skill:" protocol line, and the noise-prefix filter in
parse_conversationdropped the whole record once the text matched, so the image was lost while its chip stayed dead ("could not be embedded") and opened nothing on click; now only the noise text is dropped and the image falls through to the existing chip, dedup and fold path, so the chip embeds the image and clicking it opens the lightbox on the embedded data URL, with two tests written first and a live proof in a real Chrome asserting a live chip in the exported page and a click that opens the lightbox (commit). - 2026-11-30: Search now works in the merged view (issue #116). The search loop cached its
.blocklist at page load, but the merged document is built after load and its sections lazy-mount from sidecars, so marks landed only in the hidden original export and the default merged view showed no highlights at all; the target document is now resolved at run time (merged when shown, original otherwise), an active query of two or more characters first mounts every pending placeholder so "marks all matches" really means all matches, and each completed mount schedules a debounced re-mark so sections mounted by scrolling get marked too, with three tests written first and a live proof in a real Chrome asserting marks and their visibility inside the merged document, the stats line and the unmerged fallback (commit).
How it works
The whole flow in one picture: the automatic session loop, the optional watchdog, and the opt-in notifications:

The live look of the status line itself, every frame drawn by the real renderer: the context-usage segment sweeping, then the rotation handoff moments and the fresh successor session.

Demo
A full recorded run: install → five chained sessions → four context
rotations → a completed task, captured end to end. It is a long,
video-style GIF, so it is offered as a download rather than embedded
in the page:
- demo-high-res.gif - 896x1920, 20 fps (~20 MB)
- demo-low-res.gif - 700x1500, 12 fps (~12 MB)
The demo itself is recorded by
tools/demo_gif.sh (it needs a local-model
endpoint in ANTHROPIC_* env); the cut list and the pipeline that
turned the recording into the GIFs are in
tools/demo_segments.txt and
tools/gif_from_video.sh.
Requirements
- macOS, or Windows 10/11 with WSL (see Windows (via WSL))
- Python ≥ 3.11 (standard library only at runtime)
- tmux and curl on PATH; zsh on macOS (bash is fine on WSL)
- Claude Code ≥ 2.1.209
To verify your setup: cc-continuity doctor checks the Claude Code
version, and the WSL e2e script
(tools/e2e_wsl.sh) exercises the rotation/hook
path end to end.
Windows (via WSL)
cc-continuity runs inside a Windows Subsystem for Linux distro: the Linux side is unchanged: same rotation, same watchdog, same ntfy pushes, and only the daemon hosting differs. Where macOS uses launchd, the distro uses a detached tmux session (default) or systemd user units (WSL 2 with systemd enabled), plus one optional Windows logon task so the daemons come back when the WSL VM restarts.
- WSL 2 recommended; WSL 1 works too (minus the systemd option).
- Ubuntu 24.04 recommended; Ubuntu 22.04 works with
python3.11from deadsnakes. - Native Windows is out of scope; the distro is the runtime.
Full guide (requirements, install, watchdog, autostart,
troubleshooting): docs/WINDOWS.md. An end-to-end
test for the WSL install lives in tools/e2e_wsl.sh.
Quick start
From Git:
git clone https://github.com/pqant/claude-continuity
cd claude-continuity
python3 -m cc_continuity.cli install --window 262144
exec zsh # reload the shell (claude() wrapper)
cc-continuity doctor # everything should be green
From PyPI (recommended: pipx, the standard way to install Python CLIs):
pipx install cc-continuity # or: uv tool install cc-continuity
cc-continuity install
exec zsh
cc-continuity doctor
Plain pip install cc-continuity also works inside a venv or when
embedding it as a library; pipx/uv tool put the CLI on PATH without
touching your Python environment.
On Windows (WSL) the same steps run inside the distro (bash as the
login shell); the full WSL guide is docs/WINDOWS.md.
The installer touches (all as identifiable managed blocks, all reversible
via cc-continuity uninstall): hooks + status line in
~/.claude/settings.json, a managed block in ~/.claude/CLAUDE.md, the
claude() wrapper in ~/.zshrc, seven /continuity-* skills, the
cc-continuity launcher on PATH, and the app copy in
~/.claude-continuity/app/. A timestamped backup of
settings.json is written before any merge.
Daily use
cd ~/anything
claude # auto-tmux, session named <project>-001
Watch the status line: the context ratio climbs (default thresholds
55% warn → 62% rotate → 72% hard ceiling). Rotation is zero-touch
(quick-start list above). After a crash, sleep, or reboot: just run
claude in the project and say "continue".
Chaining a third-party status line such as claude-hud?
cc-continuity registers ~/.claude-continuity as an additional directory,
and claude-hud 0.15.4+ renders every additional directory inline after the
project name, so you see an extra +.claude-continuity segment. Hide it by
setting {"display": {"showAddedDirs": false}} in
~/.claude/plugins/claude-hud/config.json; cc-continuity doctor prints
that exact hint when it detects the combination (issue #85).
In-session commands: /continuity-status, /continuity-checkpoint,
/continuity-rotate, /continuity-off / /continuity-on,
/continuity-history. Full CLI reference: docs/USAGE.md.
Configuration
Global: ~/.claude-continuity/config.json, start from
config.example.json (all keys, placeholder values). Per-project
override: .claude/continuity.json (e.g. {"enabled": false} to opt one
project out). CC_CONTINUITY=0 disables everything for one launch.
Notifications (ntfy, opt-in)
cc-continuity can push lifecycle events to any ntfy-compatible server, so you can watch long unattended runs from your phone:
cc-continuity configure --ntfy https://ntfy.sh/your-topic # or at install: --ntfy <url>
cc-continuity configure --ntfy off
cc-continuity doctor sends a test message to verify the endpoint.
| Event | Title | Meaning |
|---|---|---|
| start | ▶ session started |
a session registered itself (first hook or resume claim) |
| warn | ⚠ context warning |
ratio crossed the warning threshold |
| pending | ◆ rotation pending |
ratio crossed the hard threshold; rotates at turn end |
| verified | ✓ handoff written & verified |
checkpoint finalized, sha256 verified |
| complete | 🔄 rotation complete |
the successor session is running |
| resumed | ↻ resumed |
successor consumed the checkpoint |
| blocked | 🛑 BLOCKED, waiting for you |
agent hit a needs-human point (urgent) |
| done | ✅ task complete |
agent finished the task you gave it |
| error | ✗ … failed |
a lifecycle step failed (urgent) |
| end | ■ session ended |
SessionEnd (rotation, /clear, or close) |
Privacy: a push is a title + a body of at most 200 characters
containing only the project slug, session number, context ratio, a short
reason/summary you control, and the hostname. No file contents, no
prompts, no secrets; recorded text is secret-redacted on the way out.
Messages only ever go to the endpoint YOU configure, and only when
notify_enabled is on.
Unattended mode (opt-in)
⚠️ Loud warning:
launch --unattended(orconfig.json: "unattended": truefor a whole project) spawns the session withclaude --dangerously-skip-permissions: the agent edits files and runs commands without per-action approval. Use it only on machines/projects you trust with that. Theneeds-humanmechanism (below) is a signal the agent sends, not a permission boundary: it enforces and blocks nothing. The default mode is unchanged; nothing skips permissions unless you opt in.
claude --unattended # via the zsh wrapper (one launch)
cc-continuity launch --unattended
cc-continuity configure --unattended # project setting (whole chain)
Because a rotation is a /clear inside the same process, one flag (or
one project setting) carries the entire rotation chain: every successor
session stays unattended.
When it blocks on you
The agent signals you when it cannot safely continue (a destructive/irreversible operation, an ambiguous requirement, the same fix failing three times):
cc-continuity signal needs-human "<short reason>"
That pushes an urgent notification and marks the status line
⛔ BLOCKED (machine-side truth, visible on any later attach). Remote
in to the pane, reply in the session; the block clears on your next
prompt. On completion the agent runs:
cc-continuity signal done "<one-line summary>"
Watchdog (opt-in)
A daemon that keeps long runs recoverable (launchd on macOS; a tmux
session or systemd user unit on WSL): a health probe for
your model server (2-fail debounce), per-session liveness classification,
a bounded nudge state machine (the session is told WHY its turn stopped),
an exit-hang killer, frozen-turn escalation, and optional auto
power-cycle of the box + a log digest relayed into the active session.
Off by default; the health URL is yours to supply. Details:
docs/WATCHDOG.md.
Security
Read SECURITY.md before installing. It states the trust model: what
code runs with your rights, what the installer merges and how it
uninstalls, and what data ever leaves the machine.
Limitations
See LIMITATIONS.md (an honest list).
Development
python3 -m pytest -q # unit + contract tests
Tests redirect all state through CC_CONTINUITY_HOME (a temp dir) and
use throwaway git repos; they never touch the real
~/.claude-continuity or ~/.claude. Architecture:
docs/ARCHITECTURE.md.
License
MIT, see LICENSE.
Explorar proyectos relacionados
Cargando…