Skip to main content

Hook-based repo context continuity for coding agents.

Project description

repo-context-hooks

Agent-level continuity skill for coding agents.

context score

repo-context-hooks brand mark showing hook events flowing into an impact monitor

Context Continuity Engine showing README.md, specs/README.md, AGENTS.md, hook events, impact monitor, Score 90, and +70 uplift

repo-context-hooks is an agent-level skill that keeps interrupted work, next-step context, and handoff notes alive across sessions. Install once to agent home — every workspace you open picks it up automatically.

The goal: a new agent session should start with full project context without rediscovering everything from scratch.

Install

pip install repo-context-hooks
repo-context-hooks install --platform claude

That's the full install. Hooks write to ~/.claude/settings.json and activate in every workspace from that point on.

Need per-repo hooks too?

repo-context-hooks install --platform claude --also-repo-hooks

Set Up a Workspace Contract (per-repo)

repo-context-hooks init          # scaffold specs/README.md, UBIQUITOUS_LANGUAGE.md
repo-context-hooks doctor        # verify contract health
repo-context-hooks recommend     # suggest next steps

doctor answers "is this workspace contract healthy?" recommend answers "what should the agent do next?"

Other Platforms

repo-context-hooks install --platform codex
repo-context-hooks install --platform cursor
repo-context-hooks install --platform replit
repo-context-hooks install --platform windsurf
repo-context-hooks install --platform lovable
repo-context-hooks install --platform openclaw
repo-context-hooks install --platform ollama
repo-context-hooks install --platform kimi

Why Agent-Level, Not Repo-Level

Coding sessions rarely fail because the model forgot a fact. They fail because useful state of the work never survived the session boundary.

The old approach (install a hook per repo) means every new workspace starts from zero. The right approach is a skill installed once at agent home that activates in every workspace and uses checked-in repo files as its persistence layer.

repo-context-hooks brings the same model as superpowers and caveman: install once to the agent runtime, works everywhere.

  • Agent skill: fires on SessionStart, PreCompact, PostCompact, SessionEnd
  • Workspace contract: specs/README.md (engineering memory), README.md (product intent), UBIQUITOUS_LANGUAGE.md (shared terms)
  • Telemetry: local JSONL events so repo-context-hooks measure can verify hooks actually fired

How It Works

  1. Agent skill loads at session start and reads workspace contract from repo
  2. Captures tactical state into specs/README.md before compact or handoff
  3. Reloads from repo state at next session start - not from fragile session memory
  4. Leaves the next session a cleaner handoff than the one inherited

Lifecycle flow diagram showing an interrupted bugfix, a checkpoint written to specs/README.md, and the next session resuming from repo state

Supported Platforms

Platform Support Notes
Claude native Full lifecycle hooks, session transitions, continuity checkpoints
Codex partial Repo-native continuity via AGENTS.md; install_global_hooks() writes marker to ~/.codex/settings.json
Cursor partial Repo contract and instruction surfaces; no Claude-style lifecycle parity
Replit partial replit.md and repo contract; no native lifecycle hooks
Windsurf partial Root AGENTS.md and .windsurf/rules; no native lifecycle hooks
Lovable partial Repo knowledge exports plus AGENTS.md; requires manual UI steps
OpenClaw partial SOUL.md, USER.md, TOOLS.md, AGENTS.md; requires manual workspace config
Ollama partial Modelfile.repo-context for local-model workflows
Kimi partial Root AGENTS.md for Kimi Code CLI; no generic API or lifecycle hooks

See docs/platforms.md for the full support matrix.

Readiness and Recommendations

repo-context-hooks doctor --all-platforms
repo-context-hooks recommend

For scripts and CI:

repo-context-hooks platforms --json
repo-context-hooks doctor --json
repo-context-hooks recommend --json
repo-context-hooks measure --json

Prove Impact

repo-context-hooks measure
repo-context-hooks measure --snapshot-dir docs/monitoring

Badge

Print an SVG badge of the current contract score to stdout:

repo-context-hooks measure --badge

Write the badge to a file (for example, to embed in your README):

repo-context-hooks measure --badge-out docs/badge.svg

Then embed it in your README:

![context score](docs/badge.svg)

The badge uses shields.io flat style and is entirely self-contained - no external dependencies or network requests.

measure compares current repo continuity score against an estimated no-continuity baseline and reports observed hook events from local JSONL telemetry.

Current repo snapshot:

  • Score 90
  • Baseline 20
  • Uplift +70
  • Observed hook events 39
  • Unique sessions 21
  • Active days 2
  • Lifecycle coverage 25% (session-start only so far; pre-compact and session-end fire on longer sessions)
  • Monitoring view: docs/monitoring/index.html
  • Time-series data: docs/monitoring/history.json

Remote telemetry is not enabled. Any future community metrics require explicit opt-in per docs/telemetry-policy.md.

See TELEMETRY.md for what is collected locally and how to opt out.

Telemetry Visibility

Surface What it shows How to use it
Impact monitor Score, uplift, lifecycle coverage, event mix Open from GitHub or publish via GitHub Pages
History JSON Time-series score, daily hook events, usability metrics Import into Observable Plot, Vega-Lite, DuckDB
Local dashboard Private per-repo monitoring.html from local event log Run repo-context-hooks measure after agent sessions
Public snapshot Sanitized dashboard for README or docs site Run repo-context-hooks measure --snapshot-dir docs/monitoring

Concrete Stories

Interrupted Task Recovery

A compact event lands in the middle of a bugfix. The useful checkpoint is written back into the repo so the next session can resume with context instead of re-explaining the problem.

Repo contract diagram showing the open PR story in README.md, handoff notes in specs/README.md, and a Cursor, Codex, or Replit session re-entering with repo context

Before and After Handoffs

Without a checked-in continuity contract, teams repeat themselves. With one, the next session can reopen the repo and keep moving.

Before and after continuity comparison showing repeated bug explanation versus resuming from checked-in continuity

What's New in v0.3.0

  • Agent-level install - hooks write to ~/.claude/settings.json once; active in every workspace automatically
  • Session metrics - session_id in every telemetry record; is_sampled() probabilistic gate (10% default, configurable via REPO_CONTEXT_HOOKS_SAMPLE_RATE)
  • auto_commit_snapshot() - auto-commits docs/monitoring/history.json on session end
  • --also-repo-hooks flag - opt into per-repo hooks alongside agent-level
  • Graceful degradation - non-git and no-contract workspaces print helpful messages and exit cleanly
  • Codex parity - install_global_hooks() for Codex
  • CI/CD - GitHub Actions with pytest matrix (Python 3.9-3.12, ubuntu + windows) and OIDC PyPI publish

See CHANGELOG.md for full history.

See Also

Development

pip install -e ".[dev]"
python -m pytest -q

Pull requests are welcome when they make the repo contract clearer, more durable, or easier to adopt without widening the product claims beyond what the implementation supports.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

repo_context_hooks-0.5.0.tar.gz (70.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

repo_context_hooks-0.5.0-py3-none-any.whl (66.5 kB view details)

Uploaded Python 3

File details

Details for the file repo_context_hooks-0.5.0.tar.gz.

File metadata

  • Download URL: repo_context_hooks-0.5.0.tar.gz
  • Upload date:
  • Size: 70.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for repo_context_hooks-0.5.0.tar.gz
Algorithm Hash digest
SHA256 8c2eeb9a6dd8137911b3a84c38583dc082fa38b1c3744d08b3d2e77f6e8dfa92
MD5 6cf41699fa7e9c7927a444f266abe318
BLAKE2b-256 0350cb709c7023e2190ca30bb4009ed5647837ee3f67c524d97b217684a4cb33

See more details on using hashes here.

Provenance

The following attestation bundles were made for repo_context_hooks-0.5.0.tar.gz:

Publisher: publish.yml on narendranathe/repo-context-hooks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repo_context_hooks-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for repo_context_hooks-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0213fd4baec3080d2e3fbde8ac6f609d3fed117dd5eb39254d26a035df093487
MD5 5416ba0a53db95fdd98ea1fbe4942ea1
BLAKE2b-256 8c6089a186ea5a5d683255ac4d22b13dd9723d1344099fac43cde8afdd2e299b

See more details on using hashes here.

Provenance

The following attestation bundles were made for repo_context_hooks-0.5.0-py3-none-any.whl:

Publisher: publish.yml on narendranathe/repo-context-hooks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page