Engineering Memory OS · local-first

Git remembers the what. Hunch remembers the why.

A persistent, git-native reasoning graph over your codebase — the decisions, bugs, and invariants behind every line — surfaced to Claude Code at reasoning time. So your AI stops re-deriving understanding, and stops undoing intentional design.

0
Decisions captured
0
Components mapped
0
SaaS required
hunch · reasoning graph
commit a1b2c3d bug_009 leaked token decision Redis sessions constraint con_004 component cmp_auth
Bug Decision Constraint Component
The problem

Every AI session starts from zero. The model re-reads your code, re-guesses the intent, and happily "fixes" the thing you deliberately did last month — because the reasoning lives in PRs, Slack, and people's heads, not in the repo.

Stateless by designCursor and Copilot do ephemeral RAG over your current code. The horizon is this session — value stays flat.
Intent evaporatesThe codebase records the final state, never the rejected alternative or the invariant you must never break.
The same mistakes, againWithout memory, the agent re-discovers the bug you already fixed — and undoes the workaround that prevents it.
How it works

Captured as a byproduct of normal work — commits and test failures.

Three layers, no documentation chore. Index is deterministic. Learning happens on every commit. Grounding reaches Claude Code through every door it has.

01 / INDEX

Map the code, no LLM

tree-sitter parses your repo into a symbol & dependency graph — functions, call edges, imports, components — plus churn and fan-in metrics. Pure, fast, deterministic.

hunch index
02 / LEARN

Turn events into memory

Each commit becomes a structured Decision; a failing test becomes a Bug with a ranked suspect list; recurring or severe bugs are promoted into Constraints that raise a component's fragility.

post-commit → synthesis
03 / GROUND

Feed it back, with citations

Claude Code reads it through an MCP server, an auto-maintained CLAUDE.md, and slash commands — and every answer cites its provenance: source, confidence, evidence. Nothing is a blind assertion.

MCP + CLAUDE.md + slash
The reasoning graph

A bug spawns a decision. A decision spawns a constraint.

The links are what let the agent answer “why” and “what must not break” with evidence, not vibes — every node attached to its components, symbols, and commits.

In Claude Code

Just ask the codebase why.

  • Grounded from second one. The agent doesn't re-discover the revocation lesson — it reads bug_009 and con_004 before touching the file.
  • Blast radius, known. One Hunch lookup returns every caller and dependent component before a refactor, so nothing breaks silently.
  • Evidence, not vibes. Each claim carries its source, confidence, and the commit or test that proves it.
  • Write-back. After a non-trivial choice, the decision is recorded — the graph gets denser as you work.
claude code — why is the session module built this way?
What's inside

Everything is local, diffable, and yours.

/ 01

MCP-native

Claude queries Hunch for the why behind a file, the blast radius of a change, a bug's lineage, and the invariants in scope — and writes new decisions back. The structured two-way API it calls under the hood.

/ 02

Provenance on everything

Every record carries source, confidence and evidence. Inferred < llm-draft < human-confirmed. Low-confidence items stay advisory and cheap to discard.

/ 03

Git is the sync

The Hunch graph is plain JSON committed beside your code — the source of truth, reviewable in PRs, synced for free over push/pull. A merge driver resolves it by record id, not conflict markers.

/ 04

Works offline

Synthesis is billed to your Claude subscription via the CLI — never the pay-per-token API. No claude? A deterministic heuristic keeps the loop alive.

/ 05

Fragility report

Rank the riskiest code by churn × bug-count × fan-in × coverage gaps — and get the bug history behind it, not a generic lecture.

/ 06

Atomic & durable

Every write is temp-file + rename with a Windows-safe fallback. An interrupted write can't truncate the index; a corrupt index refuses to be flattened.

/ 07

Time-travel memory

Decisions and invariants carry a git-anchored valid-time window. Query the graph --as-of any commit or tag; supersession closes a window instead of deleting it, so history stays auditable.

/ 08

Regression Guard

Re-adding a symbol or dependency a decision deliberately retired gets flagged — warns always, fails a strict commit only when tied to a blocking invariant. The AI stops undoing intentional design.

/ 09

CI Constraint Guard

A GitHub Action runs on every PR — comments the invariants and decisions a change affects (with con_/dec_ ids) and fails the check on a direct, high-confidence, non-stale blocking invariant. Memory that blocks a merge, not just advises.

Why it's different

Copilot reads the blueprints fresh each morning. Hunch has been on-site for ten years.

 
Cursor / Copilot
🧠  Hunch
Core data model
Ephemeral RAG over current code
Curated graph of decisions, bugs, constraints
Time horizon
This session
The lifetime of the codebase
What it indexes
Syntax + embeddings of files
Why — intent, causality, invariants
Write path
None (read-only over code)
First-class — it learns at commit & test time
Value over time
Flat — re-derived each time
Compounds — a flywheel
Failure it removes
“AI can't see enough code”
“AI repeats past mistakes / breaks design”
Get started

One npm install — wired into every assistant.

~/your-repo
# install from npm — Node 20+ (puts `hunch` on PATH)
$ npm install -g @davesheffer/hunch
# index + hooks + wire up EVERY assistant
$ cd your-repo && hunch init
# cold start: seed decisions from git history
$ hunch backfill --since 90d
# the "why" behind any file or symbol
$ hunch why src/auth/session.ts

Install it

Node 20+. npm install -g @davesheffer/hunch puts a global hunch on your PATH. That's the whole install — no build, no SaaS.

Initialize — wires every assistant

One hunch init indexes the repo, installs the hooks + merge driver, and writes MCP config + rules for Claude Code, Cursor, VS Code & Windsurf — all pointing at the same .hunch/ graph. Reload your editor to pick up the tools.

Seed the memory

hunch backfill --since 90d replays recent history so an empty graph isn't your day-1 experience.

Just ask

In any of those editors: “why is the session module built this way?” — and it answers from memory, with the commit as evidence.

One hunch init wires the same graph into every door your AI knocks on — the MCP server is client-agnostic, so each assistant reads the same .hunch/.

🧠Claude Code
.mcp.jsonCLAUDE.md · slash commands · agent hooks
Cursor
.cursor/mcp.json.cursor/rules/hunch.mdc
VS Code
.vscode/mcp.json.github/copilot-instructions.md
🌊Windsurf
.windsurf/mcp_config.json.windsurf/rules/hunch.md

Plus AGENTS.md / Codex, and a VS Code visualizer extension on Open VSX. Skip any with hunch init --no-providers.

Make your codebase
remember why.

The longer it runs, the smarter it gets — and the more expensive it is to go back to a stateless AI.

$ hunch init
Changelog

Every release, since v0.1.

Jun 18, 2026
v0.12.1Guard hardening — the CI guard now fetches the PR base ref and fails loudly on an unresolvable --base, so it can never silently pass a PR; fork-PR comments degrade gracefully.
v0.12.0CI Constraint Guardhunch ci scaffolds a GitHub Action that runs hunch check on every PR, comments the affected invariants/decisions (con_/dec_ ids), and fails on a blocking one. Memory that blocks a merge, not just advises.
v0.11.3Cleaner githunch init auto-gitignores the derived SQLite index, so the working tree never goes dirty on index writes (which blocked branch switches).
v0.11.2Worktree fix — correct hooks-dir resolution inside a Windows git worktree (a worktree-compatibility audit confirmed root detection, the rebuilt index, and atomic writes are worktree-safe).
v0.11.1Parallel backfillhunch backfill synthesizes commits through a worker pool (--concurrency), ~Nx faster than the old one-at-a-time replay.
v0.11.0On npm + safe strict mode — install with npm i -g @davesheffer/hunch. --strict now fails a commit only on a direct, high-confidence, non-stale invariant — safe to enable on a shared repo.
v0.10.224× faster indexing — per-file git log spawns collapsed into two batched passes; hunch index drops from ~24s to ~1s on a 400-file repo.
v0.10.1Faster read path — memoized record loads + collapsed graph queries across the CLI & MCP server.
Jun 17, 2026
v0.10.0Windsurf supporthunch init scaffolds .windsurf/ (MCP config + always-on rule). Five assistants now wired to one graph.
v0.9.0Time-Travel Memory + Regression Guard — git-anchored --as-of queries, timeline, supersede-don't-delete; guard blocks re-introducing retired code.
Jun 16, 2026
v0.8.0Agent hooks + firmness — memory injected before every edit; four enforcement levels; first-class record-constraint.
v0.7.0Multi-CLI synthesis — Codex & Cursor join Claude; write path bills to your coding subscription.
v0.6.0Multi-assistant — Cursor, VS Code (Copilot), Codex & AGENTS.md wired to one graph.
v0.5.0Guardrails everywhere — auto pre-commit guard, hunch_blast_radius MCP tool, VS Code near-violations.
Jun 15, 2026
v0.4.0Blast-radius near-violationshunch check flags invariants reached transitively.
v0.3.0Drift repairhunch stale --resync + hardened test-learning loop.
v0.2.0Failure-learning loophunch test captures bugs from failing tests; recurrences promote constraints.
v0.1.2Semantic search polish — graceful fallback to keyword FTS.
Jun 14, 2026
v0.1.0Initial release — git-native decision/bug/constraint graph, MCP server, post-commit learning, auto CLAUDE.md, VS Code extension.