Skip to main content

Session Steward (sessionsteward)

Versioned snapshots for agent working state. Coding agents silently degrade: compaction drops constraints, and one "remember this" can overwrite your 30-line CLAUDE.md with a single bullet — no warning, no undo. sessionsteward git-versions your agent config + memory files on every change: instant undo, pre-compaction snapshots, and a context-diet report showing what's eating the window.

Scope: session ops (snapshots, undo, compaction guard) — not memory storage. That boundary stays clean.

Install

Zero dependencies — Python 3.10+ stdlib only (uses your system's git).

git clone <repo> && cd sessionsteward
# no-install alias (run from the repo root):
alias sessionsteward="python3 -m sessionsteward"

Or install it properly (console script sessionsteward):

pip install .

Usage

sessionsteward init                        # set up the snapshots repo
sessionsteward watch --add NOTES.md ~/x.md # watch extra paths

sessionsteward snap -m "before refactor"   # snapshot now
sessionsteward precompact                  # snapshot before compaction
sessionsteward watch                       # daemon: auto-snapshot on change

sessionsteward log                         # list snapshots (this project only)
sessionsteward diff                        # what changed (e.g. what compaction dropped)
sessionsteward undo                        # restore the previous snapshot
sessionsteward restore <sha>               # restore a specific snapshot
sessionsteward diet                        # what's eating the context window
sessionsteward install-hooks               # print Claude Code hooks JSON
sessionsteward install-hooks --write       # merge it into ~/.claude/settings.json

The horror-story scenario, fixed:

$ sessionsteward snap -m "before letting the agent edit memory"
$ # agent overwrites your 30-line CLAUDE.md with one bullet
$ sessionsteward undo
undone 1 step(s) -> a3f9c21
  /home/you/proj/CLAUDE.md

Safety rules: empty snaps are skipped (no noise commits); undo/restore never delete — files that didn't exist in the target snapshot are moved to ~/.sessionsteward/trash/ instead, directories included. log/diff/undo/restore are scoped to the current project (--root, default: cwd): snapshots record their project root, and a restore of a snapshot from another project is refused rather than clobbering your files. Undoing (or restoring) with unsaved changes first snapshots the current state as pre-undo/pre-restore, so every undo is reversible — redo is restore of that snapshot.

Ignored on every snap and by the watch daemon: *.log, *transcript*, __pycache__, .git, node_modules (transcripts would otherwise balloon the snapshots repo).

Claude Code hooks

sessionsteward install-hooks            # print the hooks JSON + where it goes
sessionsteward install-hooks --write   # merge into ~/.claude/settings.json

This wires PreCompact → sessionsteward precompact and SessionStart → sessionsteward snap -m "session start". --write merges into the existing settings file without clobbering your other hooks (re-running is a no-op).

Context diet

# Context diet

Watched files: 3, total ~12,400 chars (~3,100 tokens)

## Biggest files
| file | chars | lines |
...
## Duplicated content (4 lines in 2+ files)
- _Be helpful and concise in all responses_ …
  - `/proj/CLAUDE.md`
  - `/proj/.claude/settings.json`

Suggested hook wiring

  • Pre-compaction: run sessionsteward precompact (or add it to your agent's pre-compact hook) — then sessionsteward diff afterwards to see exactly what the compaction dropped.
  • Session start: sessionsteward snap -m "session start".
  • Memory writes: point the steward at the same files your agent's memory hook writes.

Tests

python3 -m unittest discover -s tests   # 24 tests, temp dirs only

License

TBD

Metadata

Release files for sessionsteward 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sessionsteward 0.1.0
File Size Uploaded Provenance
sessionsteward-0.1.0.tar.gz 17.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sessionsteward 0.1.0
File Interpreter ABI Platform
sessionsteward-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.3 kB

Release files / sessionsteward-0.1.0.tar.gz

Download URL sessionsteward-0.1.0.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9c42c1b2fa4f2086e481dfc32ea12b289e2eed972e4a19a65ec67083ebe0e819
BLAKE2b-256 checksum
How to use checksums
f2d44048a123a7741c3f51371afc62c2520533d8bf8031b07c83128a373bf0e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / sessionsteward-0.1.0-py3-none-any.whl

Download URL sessionsteward-0.1.0-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
39543c137a9fef43f556bdb9a11e5cc9fa426e9b1d324f2d749b12b3a05e5a0d
BLAKE2b-256 checksum
How to use checksums
ca5a1dd24690a204bbdc534b83318ac401947a021020a8f71334c95002b41753
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Security for sessionsteward 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page