hunch docs · v1.52
Documentation

Hunch documentation

A shared record for AI agents: what was decided, what happened, and what still needs doing.

Hunch keeps decisions, rules, action records and commitments with their sources. A new agent can check that record instead of rebuilding the story from scratch. Engineering memory explains the reasons behind code; the served state layer extends the same approach to repository, user, team and organization records. Both ship today.

The vision is for agents working across different tools to share one current record. Wider organizational impact is still being tested in a pilot. Hunch checks defined rules about records and evidence; it does not make every submitted statement true or guarantee that an agent uses what it receives.

NewWhat’s new in 1.52
  • hunch ui — browse, search and edit memory in a local web UI.
  • Deliberate — review cards for conflicts, stale links, duplicates and weak memory.
  • Grill me and the decision board — an assistant challenges a record from checked evidence.
  • Five memory verbs — hunch new, edit, link, remove and restore.
  • Elixir — .ex and .exs files are indexed with symbol-level dependency edges.

Also recent: one memory home and hunch log --for (1.51), hunch derive-rules (1.49), hunch verify (1.46), hunch uninstall (1.44). Full changelog

Quick start#

Three steps. You need Node 22.13+ and a Git repository.

  1. Install

    terminal
    npm i -g @davesheffer/hunch
  2. Initialize your repo

    terminal
    cd your-repo
    hunch init
    hunch backfill --since 90d   # optional: draft memory from recent history
  3. Ask why

    Reload your assistant and ask: “Why is this built this way, and what should I preserve when changing it?” Or ask from the terminal:

    terminal
    hunch why src/auth/session.ts

Next: browse memory in the browser, check your integration, or press / to search these docs.

Install#

Hunch needs Node ≥ 22.13. Install the CLI globally — that puts a hunch binary on your PATH:

terminal
npm install -g @davesheffer/hunch

If the shell reports that hunch is not found, no global binary is required. From the repository directory, run npx -y @davesheffer/hunch@latest init.

Or run from source (for hacking on Hunch itself):

terminal
git clone https://github.com/davesheffer/hunch && cd hunch
npm install
npm run build        # compile to dist/
npm link             # optional: global `hunch` from source

The optional Hunch editor companion is available from Open VSX. It reads the same memory home as the CLI and MCP server; its version is separate from the CLI version.

Initialize a repo#

Run hunch init in the repo you want a memory for. One command scaffolds everything:

terminal
hunch init                  # scaffold .hunch/, index, install hooks, wire up assistants
hunch init --details        # print every setup step and the integration matrix
hunch init --all-assistants # configure every supported assistant, found or not
hunch backfill --since 90d  # cold start: seed decisions from recent git history

Init prints a short summary and one next step. Warnings always print. It is idempotent: re-running is safe and merges into existing files.

  • Scaffolds .hunch/ and indexes the repo into a symbol/dependency graph.
  • Installs a post-commit hook (the learning loop) and a pre-commit Constraint Guard.
  • Writes .mcp.json + slash commands + an auto-maintained CLAUDE.md, and registers a git merge driver for the graph.
  • Configures the assistants it finds: a config already in the repository, a settings folder in your home directory, or the command on PATH. AGENTS.md and Claude Code are always written. If none is found, every assistant is configured.
  • Warns when the repository’s ignore rules exclude .hunch/, and names the rule and the fix. Ignored memory is never committed, shared or kept on a fresh clone.
ℹInstalled releases write portable MCP launchers pinned to an exact Hunch npm version. Each teammate still runs init for local hooks and setup. In Matrix mode it also validates .hunch/team.json, clones the dedicated memory repo into ignored local storage, and writes this machine’s ignored pointer. Source-checkout installs may use local executable paths.

Update Hunch#

Ask an agent to “update Hunch”, or run hunch update from the repository root. If the shell reports that hunch is not found, run npx -y @davesheffer/hunch@latest update instead. It installs the latest release and aligns all configured harness pins while preserving existing settings.

For standalone npm projects, the command keeps Hunch in its current dependency section and saves an exact version. Without a repository dependency it updates the global CLI. Add --global to update both, or --dry-run to preview the commands. Other package managers and workspaces should update their dependency explicitly, then run hunch integrations repair-pins.

The update also repairs known legacy hook commands while preserving unrelated settings and intentionally disabled hooks. Restart or reconnect active assistant sessions afterward. In Codex, open /hooks to review and trust changed commands, then start a new session. Changing the pinned version changes the command and requires renewed trust; Hunch does not approve it for you. Each invocation updates the current repository; repeat it in other repositories as needed.

Installed interactive CLI commands may show a cached update notice. At most once every 24 hours, a detached worker asks npm for the package's public latest version. Hooks, MCP, CI, servers, the updater, non-interactive commands, and source checkouts skip that request. Set HUNCH_NO_UPDATE_CHECK=1 or NO_UPDATE_NOTIFIER=1 to disable it.

verify the connection
hunch integrations check --harness codex --probe --require mcp
hunch integrations check --harness codex --require context

The first command checks a fresh MCP process. Run the second after trusted hooks have run in a new Codex session: it checks recorded host delivery on the expected Hunch version. Configuration, delivery, and the agent's use of memory are different evidence. Requiring edit-blocking additionally needs strict firmness and a delivered pre-edit event.

Remove Hunch v1.44#

terminal
hunch uninstall --dry-run   # show what would change
hunch uninstall             # remove what Hunch installed; keep .hunch/ (your memory)
hunch uninstall --purge     # also delete .hunch/, the derived cache and Hunch's .gitignore blocks

It removes the instruction blocks, MCP entries, agent and git hooks, merge driver, slash commands and CI workflow that Hunch installed. Your own content in those files stays.

  • Fails closed. If a file it needs to edit can’t be parsed, it changes nothing and says which file.
  • Opts the repo out. It writes .hunch-removed. While that file exists, no Hunch command sets Hunch up here again. Commit it so every clone stays opted out.
  • To reinstall, delete .hunch-removed and run hunch init.
  • Linked worktrees. Git hooks and merge drivers are shared by every worktree of a clone, so uninstall keeps them in a linked worktree and names the main checkout to run it from.
ℹClose running hunch mcp and hunch serve processes first, so they can’t recreate files. Global Windsurf and Antigravity MCP entries are reported and left alone.

Your first query#

Ask the codebase why — from the CLI, or in your assistant once the MCP server is registered:

terminal
hunch why src/auth/session.ts   # decisions / bugs / invariants behind a file
hunch doctor                    # git, schema version, synthesis mode

…and in your assistant: “why is the session module built this way?” — the assistant consults Hunch and answers with citations (record ids + provenance).

Synthesis & billing#

Optional synthesis drafts memory from commits and failures. Agent-initiated work stays with that agent's provider and its CLI authentication; an unavailable or unknown origin uses the deterministic local fallback. Human terminal invocations can use an explicitly selected provider. Installing a CLI alone does not select it.

CLISubscriptionDetected by
claude (Claude Code)CLI's configured authenticationclaude --version
codex (OpenAI Codex)CLI's configured authenticationcodex --version
cursor-agent (Cursor)Cursorcursor-agent --version

A terminal provider preference lives in gitignored local config. It does not override a known initiating agent with another provider. hunch provider shows availability and why a provider was selected:

terminal
hunch provider codex-cli              # local choice: Claude, Codex, Cursor, openai-compat, deterministic
hunch provider                         # see availability + why this provider is selected
export HUNCH_SYNTH_PROVIDER=claude-cli # one-shell override; `auto` disables the local choice

Local & self-hosted models. No subscription CLI is required: point Hunch at an OpenAI-compatible endpoint — Ollama, vLLM, LM Studio, llama.cpp server, and anything else that speaks the chat-completions format. Select it like any other provider (hunch provider openai-compat, or the one-shell override):

terminal
export HUNCH_SYNTH_PROVIDER=openai-compat      # alias: ollama
export HUNCH_SYNTH_BASE_URL=http://localhost:11434/v1
export HUNCH_SYNTH_MODEL=qwen2.5-coder:7b
export HUNCH_SYNTH_API_KEY=your-key-here          # optional — omit for keyless local servers
export HUNCH_SYNTH_TIMEOUT_MS=300000             # optional, default 5 min — local models can be slow
export HUNCH_SYNTH_MAX_TOKENS=2048               # optional output cap
export HUNCH_SYNTH_ALLOW_METERED=1                # public remotes only; deliberate billing/trust opt-in

Opt-in only: leave these unset and Hunch behaves exactly as above. Localhost, private/link-local IPs, and conventional LAN names work directly. Every public remote requires HUNCH_SYNTH_ALLOW_METERED=1 so a newly launched paid provider can never bypass a stale hostname list; set it only when the endpoint is deliberately trusted and any billing is understood.

Deep Synthesis. --deep takes repeated samples through the bound provider and reconciles them. --verify checks the draft against the commit. These are model-assisted drafting steps, not independent proof; the result stays advisory. They do not fan out to another installed provider.

terminal
hunch backfill --deep        # higher-quality notes across history
hunch sync <sha> --deep       # a single commit (fact-check on)
hunch sync <sha> --verify     # fact-check a single note

MCP & assistants#

The Hunch MCP server lets supported clients query the same memory. hunch init writes MCP configuration and guidance for supported assistants. Automatic context delivery and edit blocking depend on the host's lifecycle hooks, settings and trust; an MCP connection alone proves neither.

AssistantMCP configGrounding file
Claude Code.mcp.jsonCLAUDE.md + /hunch-* commands
Cursor.cursor/mcp.json.cursor/rules/hunch.mdc
VS Code (Copilot).vscode/mcp.json.github/copilot-instructions.md
Windsurf / Devin Desktop.windsurf/mcp_config.json.windsurf/rules/hunch.md + hooks in .windsurf/hooks.json and .devin/hooks.json
Codex.codex/config.tomlAGENTS.md + .codex/hooks.json (review with /hooks)
Antigravity.agents/mcp_config.jsonAGENTS.md + .agents/hooks.json

The server runs over stdio and exposes memory tools under hunch_*. State tools under nuryel_* are exposed when enabled for the configuration or state root, not by default in every plain repository. Use hunch mcp --root <partition-dir> for a served partition. Other MCP clients can register a launcher manually; starting it is not a connectivity test:

terminal
hunch mcp   # serves Hunch over stdio (this is what .mcp.json launches)

Fast connect. hunch mcp answers the handshake before its startup sync. The overlay pull and index rebuild run 5 s after the client connects, or before the first tool call if that comes first, so no call answers from memory the sync would have refreshed.

★Prefer hunch init over a global claude mcp add. .mcp.json is registered by file path, so it’s robust and travels with the repo.

Reload your assistant#

After hunch init or an update, a running assistant may still hold the old MCP process. Reload or reconnect your assistant in the repo so it loads the current tools. Codex hooks also require command trust: review changed commands with /hooks, then start a new session.

ℹThe on-disk directory is .hunch/ and the tools are hunch_*. If the tools don’t appear after a reload, run hunch doctor.

Private memory v0.17#

Keep sensitive decisions, bugs and constraints in a separate private overlay. Authorized local queries and checks can include that overlay; public-only outputs use the public store. Choose the destination when capturing private information and control access to the overlay through your local and Git permissions.

One command sets it up (no env var, no shell-profile edit):

terminal
hunch private                       # default ./.hunch-private (gitignored)
hunch private ~/work/secret-memory   # or a path you choose
hunch private --repo git@github.com:you/mem-private.git   # or clone a private repo

It writes a gitignored .hunch/local.json pointing at the store, installs the --private post-commit hook, and that’s it — Hunch, the MCP server, and the local VS Code extension auto-detect it; hunch doctor shows private: on → …. It’s opt-in and default-off: no local.json (and no HUNCH_PRIVATE_DIR) means the overlay is completely inert.

Record sensitive items with private: true on hunch_record_decision / hunch_record_correction; they’re written to the overlay, never the committed repo. Post-commit synthesis routes its auto-captured decisions there too, so a private-memory repo’s auto-decisions never land in the public tree. HUNCH_PRIVATE_DIR overrides local.json per-shell (e.g. for portability); the git hook lives in .git/hooks/ and is never committed.

Auto-commit is on by default. Captures attempt to commit to their actual memory home. A private/shared Git store can also be pushed; public memory in an application repository rides your next code-branch push. Managed grounding documents can be refreshed alongside memory. Failed or disabled synchronization can leave a record local, so inspect the saved durability result. Opt out with --no-auto-commit on hunch init, private or shared.

ℹSeparate public outputs from private inspection. Generated public guidance and scaffolded CI comments use public-only memory. Local queries and reports can contain private records, so review an artifact before sharing it. Keep HUNCH_PRIVATE_DIR unset in public CI; the scaffolded guard also uses --public-only. Private rules still need the same human authority and enforcement conditions as public ones.

One memory home per repository v1.51#

Hunch picks where memory lives from the repository’s identity, not from the checkout you are in. Worktrees, second clones and local-path clones of one repository all write overlay-homed records to the same private overlay.

  • repo_id. A repo_id committed in .hunch/config.json gives clones with no network origin a stable identity.
  • No silent fallback. When the home can’t be resolved, captures are refused with a message instead of landing in a local .hunch/.
  • Doctor checks it. hunch doctor warns when the policy itself is not committed.
terminal
hunch memory-policy status                     # the effective policy and the overlay this checkout resolves
hunch memory-policy check --base origin/main   # CI: fail when a branch adds a public record the policy homes in the overlay
hunch memory-policy migrate --dry-run          # list public records that would move to the overlay

Memory commits name the code they were captured against

Every public .hunch/ memory commit carries Hunch-Code-Branch and Hunch-Code-Head trailers. hunch log --json reports them per move. A revert of a Hunch commit counts as a memory commit, so it is never named as the code head.

Trace memory to a feature commit

terminal
hunch log --for feature-x          # memory grouped by the feature commit it led to, for a branch
hunch log --for <sha>              # or for one commit
hunch log --for feature-x --json   # the same, for tooling

Memory captured before the next code commit on the branch’s first-parent line belongs to that commit, which survives a rebase. Merges are expanded where they brought new commits to the line. Every case the attribution cannot cover is listed in notes.

No automatic memory commits on the default branch

On main/master (or the branch origin/HEAD names), captures and the post-commit hunch sync write to .hunch/ but leave it uncommitted, with a one-line notice. A typed --commit, feature branches and state-contract writes are unchanged.

To opt back in, set "autoCommitDefaultBranch": true in .hunch/local.json, or HUNCH_AUTO_COMMIT_DEFAULT_BRANCH=1.

Linked worktrees are grounded

When a session runs in the main checkout and edits a file in a linked worktree, the edit hooks use that worktree’s memory. A worktree without .hunch/ gets one “edit proceeds ungrounded” line. hunch task verify finds a task opened in the main checkout (or the reverse) and runs the check where you stand.

Windows note#

On Windows, a global claude mcp add writes to ~/.claude.json keyed by the raw working-directory string. Drive letters are case-insensitive (c:\ and C:\ are the same folder) but Claude Code compares the key case-sensitively — so it can create two project blocks for one directory, and a session that resolves to the other casing sees no hunch_* tools.

If you hit this, run hunch doctor — on Windows it detects the split and heals it (merging the MCP servers across both casings, after backing up ~/.claude.json). hunch init runs the same heal automatically.

Shared state for agents#

Suppose one agent records a customer commitment and another agent ships the fix. Hunch can link the commitment, engineering decision and action receipt so either agent can check what is still open and what evidence supports completion. Agents continue to own their source tools and permissions.

Deterministic state means defined rules check record identity, repeated writes, access, conflicting current decisions and changes to supporting evidence. Hunch preserves the difference between an observation and a verified action record. It does not independently verify a CRM or email action merely because an agent records it.

hunch serve provides HTTP access to repository, user, team and organization partitions. Each token identifies a principal and its allowed partitions. To try one locally:

local state service
hunch serve init --config ./hunch-serve.json --partition user:demo --root ./demo-state --principal assistant@demo
hunch serve --config ./hunch-serve.json

Initialization prints the agent token once; keep it private. The server listens on 127.0.0.1. Use a Git repository for the partition when you need committed history; write results distinguish local, committed and pushed records. Read and write through HTTP, MCP, hunch state, or the typed TypeScript and repository-built Python clients. The Python package is not yet published to PyPI.

Open /operator on your server to inspect current records, completed work, commitments and writer-supplied field citations. The browser view is read-only. Optional per-record audiences limit which authorized principals can read or write a record. Optional key-bound credentials add proof from the configured private key on each request. Explicit user, team and organization conventions stay advisory.

Before enabling record visibility or key-bound authentication, upgrade and restart every serving process. Protected partitions refuse older state readers.

Engineering memory and this service ship today. Broader organizational results remain a pilot, with emulated runs and limited live use reported separately. Hunch is not a managed CRM, mail or chat connector service.

Memory and Project DNA#

Memory records what matters: a decision and its reason, a rejected approach, a rule, a fixed bug or an open finding. Project DNA describes observed conventions: the repository's terminology, contribution habits and review expectations. It helps an agent fit the project without turning common habits into mandatory rules.

inspect the project
hunch why src/auth/session.ts
hunch dna inspect
hunch dna context

The code graph connects symbols and dependencies. Engineering Landscape records connect systems, services, owners and operational resources. hunch prove origin/main --public-only can bind an exact committed change to these records and its checks. A proof describes the evidence and gaps; it does not authorize a merge or deployment.

See Hunch's contribution#

A task completion card and local report show what memory reached the agent, what the agent says it used, and which checks actually ran. A remembered lesson, an agent's attribution and a passing test are separate evidence; none alone proves that Hunch caused a better outcome.

inspect a task
hunch report
hunch report <task-id> --html

The agent reuses a task ID supplied by a trusted prompt hook, or starts one through hunch_task. It carries that ID through context and captures, runs relevant checks through the returned verification launcher, then finishes the task. Missing instrumentation stays unverified.

The HTML report is a saved local file and may contain private memory.

The reasoning graph#

These core engineering records explain a project; the code graph connects them to files and symbols. Action records, commitments and other state extend the same store:

RecordWhat it captures
DecisionWhy a change was made — an ADR auto-drafted from each commit (context, decision, alternatives, consequences).
BugA root cause + its history (introduced → fixed → recurred), captured from a failing test.
ConstraintA do-not-break rule. Recurring or severe bugs become one; corrections create one directly.
FindingAn observed gap, incident or measurement with dated evidence, which may remain open.
Code mapHow your code connects — functions, files, and components — so Hunch can see the ripple effect of a change.

Durable memory is kept in readable files. Code and search indexes are derived data that Hunch can rebuild from the repository and its records.

Supported languages#

The code map is parsed with tree-sitter, statically, with no LLM. Memory — decisions, bugs, rules — works for any language, because it reads commits and diffs.

LanguageFilesWhat resolves
TypeScript / JavaScript.ts .tsx .js .jsx .mts .cts .mjs .cjsImports and calls, including namespace imports (ns.fn(), <ns.Comp/>), CommonJS require and literal dynamic import(). A call is linked only when exactly one symbol in the bound module matches.
Python.py .pyiModule-attribute and aliased-import calls resolve through import bindings.
Go.goPackage-qualified calls resolve through import bindings.
PHP.phpSymbols and dependencies.
Elixir v1.52.ex .exsReal calls and references edges between symbols, so blast radius, dependents and constraint checks work on Elixir repos.
Helm, Kustomize, YAML.yml .yaml .tplreferences edges: a Helm helper lists the templates that include it.
ℹElixir limits. The analysis uses no mix xref, and an ambiguous reference produces no edge. Rare layouts can still mis-resolve or resolve nothing: an alias written between two clauses of one function, __MODULE__.Sub.fun() calls, and Mod.fun/1 arity globs.

Provenance & confidence#

Records carry provenance and confidence so you can distinguish an agent's observation from human-confirmed intent. A source label does not independently prove the statement. Captured memory starts as advisory context; blocking needs human authority and a supported enforcement path. hunch escalations surfaces conflicts and decisions that still need human review.

Time-travel#

Decisions and constraints carry a git-anchored valid-time window. Supersession closes a window instead of deleting the record, so history stays auditable. Ask the graph what was believed at any past commit or tag:

terminal
hunch why src/auth/session.ts --as-of v0.7.0
hunch timeline src/auth/session.ts   # the full decision history, newest first

The hunch_why and hunch_context MCP tools take the same optional as_of ref.

Decision-grounding#

Architectural Conformance keeps the code honest to the graph; decision-grounding keeps your docs honest to it. A decision can be anchored to a topic (e.g. auth.session), and a topic always has one live answer — the current decision, its history, and what was rejected along the way.

Capture with /capture. It interviews the decision to a resolved state — topic, rationale, rejected alternatives — before anything is written, and the graph refuses to hold two live decisions on one topic. A git merge is the one thing that can create two; hunch reconcile-topics catches it for human resolution.

Markdown topic anchors — AGENTS.md as a drift surface

Anchor a section of AGENTS.md, CLAUDE.md, or any repo markdown to a topic with an HTML comment:

AGENTS.md
<!-- hunch:topic auth.session -->                 # grounds only
<!-- hunch:topic auth.session dec_a1b2c3d4e5 -->  # pinned: prose written against that decision
  • Grounding: whenever an assistant edits the file, the pre-edit hook injects each declared topic's current decision and what it rejected — follow the graph, not the stale prose being edited.
  • Drift: a pinned marker whose decision has been superseded fires doc-anchor-stale; a pin to a missing decision fires doc-anchor-dangling. Only an explicit pin can fire — never a semantic guess. Unpinned markers ground but never drift.
  • Heal: hunch heal lists each drifted section with the decision to reconcile toward, then you update the pin. Read-only — it never rewrites your prose.
terminal
hunch drift             # ⛔ exits non-zero on any anchor-stale drift or topic collision — wire into CI
hunch heal              # what to reconcile, and toward which decision
hunch reconcile-topics  # >1 live decision on a topic (post-merge) — exits non-zero

The component wiki & specs ledger#

hunch wiki renders a component wiki from the graph — one page per component (why it's shaped this way, invariants, structure, bug history, relations) plus a specs ledger that grades every markdown doc in your repo deterministically: ✅ grounded (anchored to current decisions — safe to trust), ⚠ stale (pinned to a superseded decision, says "proposed" about shipped code, or references only deleted files), ◻ unverified (no anchors — Hunch can't vouch either way). No LLM in any grade.

Stale docs get adopted. The wiki copies a stale doc into wiki/docs/ as a wiki-managed page healed against the graph — every stale pin re-pinned to the current decision with a 🧭 correction inline quoting what changed and what was rejected. Your original file is never touched; heal it (or delete it) and the copy retires automatically. The ledger routes readers to the trustworthy version either way.

Freshness is drift, not a cron job. Each page's graph inputs are content-hashed into a manifest; when the graph moves, hunch drift names exactly which pages went stale and hunch wiki --heal regenerates only those. Hand-editing a generated page trips the same wire (the graph is the source of truth — edit records, not pages).

terminal
hunch wiki            # generate/refresh wiki/ + the specs ledger
hunch wiki --check    # CI gate: non-zero if any page is stale (green no-op if never adopted)
hunch wiki --heal     # regenerate ONLY the stale pages; retire orphans
hunch wiki --private  # render the FULL graph (private overlay included) into the OVERLAY repo

With a private overlay, the public wiki is built from the committed store only — a private record can never reach a committed page, by construction. --private writes the full-graph wiki into the overlay repo instead; nothing lands here.

Memory UI — hunch ui v1.52#

A local web UI for your repository’s memory. It serves on loopback with a keyed link and opens your browser.

terminal
hunch ui              # serve on 127.0.0.1 and open the browser
hunch ui --no-open    # print the link without opening a browser
hunch ui --port <n>   # choose the port (default: any free port)

In the UI you can:

  • Browse and search records.
  • Edit, link, remove and restore them, and add new memory.
  • Confirm memory as yours, with Undo.
  • See the history of changes.
ℹHow it stays safe. The server binds 127.0.0.1 and makes a new access key on every launch. The key rides in the link’s #fragment, which browsers never send to a server. The UI never edits .hunch/ directly: every write goes through a CLI verb. Press Ctrl+C to stop it.

Deliberate — what deserves a person’s judgment

Deliberate proposes review cards for conflicts, stale links, duplicates and weak memory, ranked by how many components a change could reach. Open findings, unlinked memory and unconfirmed memory sit on the same page as tabs.

It runs no assistant. Only a person’s click changes memory. Deliberate reopens the card you left.

Grill me, the decision board, and Think this through

  • Grill me on this asks one question at a time, up to five, then suggests keep, fix wording, remove or replace.
  • The decision board explains a decision with what it rejected.
  • Think this through, the button on a memory, asks a thought-through question and shows exactly what would be sent before anything is spent.

These use an assistant, under fixed limits:

  • Only a subscription assistant, with its tools off.
  • Code is read from git blobs at HEAD.
  • Secret-looking files and credential lines are withheld and named on screen.
  • A reply is dropped if it cites evidence that was not sent.
  • Only a person’s click writes memory.

Edit memory from the CLI v1.52#

Five verbs change one record by id. They are what hunch ui runs. Each change is auto-committed as one memory move, and --json prints the result.

VerbWhat it does
new <kind>Add a decision, constraint or finding by hand. Never overwrites an existing or unreadable record. It lands unconfirmed.
edit <id>Change a record’s text: --title, --text, --context (decisions), --rationale (constraints).
link <id>Link a record to files, components or a feature (topic): --add-file, --remove-file, --add-component, --feature.
remove <id>Retire a record without deleting it. A bug can’t be removed. --superseded-by <dec_id> closes a replacement the newer decision already claims.
restore <id>Undo remove. --clear-superseded-by also forgets who replaced a decision.
terminal
hunch new decision --title "Sessions stay server-side" --text "Keep sessions on the server" --feature auth.session
hunch edit <id> --text "Keep sessions on the server; no client tokens"
hunch link <id> --add-file src/auth/session.ts
hunch remove <id> --reason "replaced"        # retire, never delete
hunch remove <id> --superseded-by <dec_id>   # the newer decision already claims it
hunch restore <id> --clear-superseded-by     # undo that
hunch review --confirm <id>                  # sign a record as yours

A record added with hunch new is unconfirmed until you sign it with hunch review --confirm <id>. A new constraint is advisory or warning; blocking is granted on confirm.

MCP tools#

The tools your assistant calls. Read tools answer “why”, “what must not break” and “what does this reach”. Write tools persist new memory.

Everyday tools

Every Hunch MCP server registers these 27.

ToolWhat it does
hunch_taskStart or finish a task’s contribution report. Pass the returned task_id to hunch_context.
hunch_contextThe minimal relevant slice for a task — invariants, why, bug history, blast radius. Call it first (accepts as_of).
hunch_structureThe indexed shape of the repo, a directory, a file or a symbol — orient from the graph instead of grep rounds.
hunch_workspacesWorktrees and branches across machines.
hunch_runbookThe proven steps for a recurring task.
hunch_nowRecent activity and the roadmap.
hunch_escalationsThe decisions a human must make now — asked inline, not queued.
hunch_whyDecisions, bugs and constraints behind a file, symbol or record id, including what was rejected (accepts as_of).
hunch_current_decisionThe single in-force decision for a topic, with what it rejected.
hunch_timelineA target’s decision history over time, with valid-time windows.
hunch_bug_lineageBugs matching a symptom or symbol, with their introduced → fixed → recurred lineage.
hunch_compareRank candidate branches or commits by architectural fit.
hunch_queryFull-text + graph search across all records, ranked with provenance.
hunch_pathShortest dependency chain between two symbols, files or components.
hunch_check_constraintsInvariants whose scope matches a path or glob — call before editing.
hunch_get_dependentsTransitive dependents of a symbol — the blast radius.
hunch_blast_radiusDependent files plus near-violations a change could break indirectly.
hunch_findingsOpen findings for a file, glob or symbol.
hunch_conformanceDoes the code still satisfy recorded intent? Deterministic, over the graph.
hunch_pr_impactThe dependency and memory surface of a change. Advisory — the gate is hunch_merge_verdict.
hunch_merge_verdictA cited BLOCK / WARN / PASS over a working-tree, staged, branch or commit diff (see Causal Merge Verdict).
hunch_capture_decisionStart a capture session: a one-question-at-a-time interview plus a capture_token.
hunch_record_decisionPersist a decision. Refuses a second live decision on a topic, and refuses to change a human-confirmed decision unless the human confirms it.
hunch_record_correctionSave a human correction as a scoped rule (see Never Twice). supersedes: [con_*] retires the rule it reverses.
hunch_record_findingPersist an observation with no code change, anchored to a date and evidence.
hunch_review_imported_adrApply the human’s exact answer to an imported-ADR question.
hunch_reportInspect the evidence for Hunch’s contribution to a task.

Specialist groups

Specialist tools are hidden until they are needed, so a host doesn’t pay for their schemas on every session. A hidden tool is not registered at all.

GroupOn whenTools
policyThe repo holds a policy.hunch_policy_candidates hunch_policy_plan hunch_policy_card hunch_policy_shadow hunch_policy_proof hunch_policy_evaluate hunch_policy_upgrade_correction — Constitution policy review. Only a human activates a policy.
nuryelThe root stores state records, or the server is pinned with hunch mcp --root <dir>.nuryel_capabilities nuryel_read nuryel_write nuryel_capture nuryel_capture_batch nuryel_subscribe nuryel_records — the state contract.
analysisOpt-in only.hunch_project_dna hunch_project_dna_delta hunch_project_match hunch_change_proof hunch_change_identity hunch_shortlist hunch_evidence_map hunch_wiki_status — research, audit and sealed-proof tools.
constitution-experimentsOpt-in only.hunch_constitution_g2_readiness hunch_constitution_g3_readiness hunch_constitution_g2_shadow_queue hunch_constitution_g2_operational_drill hunch_constitution_g2_candidates hunch_constitution_g2_behavior_candidates hunch_constitution_g2_behavior_replay hunch_constitution_g2_behavior_materialization hunch_constitution_g2_behavior_policy_materialize — experiment track; the CLI remains the primary surface.

Choose groups with HUNCH_MCP_TOOLS or the mcp_tools key in .hunch/config.json: all, core, or extra groups on top of core such as core,nuryel. The server’s startup log names what is hidden.

Slash commands#

For Claude Code, hunch init also writes ergonomic slash commands:

CommandWhat it does
/hunch-why <file|symbol>The decisions, invariants, and bug history behind it — with citations.
/hunch-fix <bug>Fix a bug grounded in past root causes, blast radius, and constraints.
/hunch-fragileA fragility report — the riskiest code, with evidence.
/captureGrill you through a decision one question at a time, then persist it against its topic (via hunch_capture_decision).
/healRead-only doc↔graph reconciliation — surface where a doc disagrees with the graph; never rewrites prose silently.

Firmness levels#

hunch init installs supported lifecycle hooks and guidance for the assistant. Where the host loads and trusts those hooks, they can deliver relevant memory before work. Firmness controls how Hunch responds; use integration checks to see which capabilities were actually observed in your host.

terminal
hunch firmness          # print the current level
hunch firmness strict   # change it (takes effect on the next edit; no restart)
LevelBefore an edit
offnothing (the hook is a no-op)
advisory defaultinject the relevant Hunch slice as context
firmadvisory + explicitly flag invariants in the file’s scope
strictfirm + deny a supported direct violation of a human-confirmed blocking constraint; indirect blast-radius warnings stay advisory
ℹUnsupported hook input or an internal hook error does not establish a successful check. Blocking requires a supported rule, human authority, strict firmness and host enforcement. Configuration alone cannot verify that chain.

The memory loop — it runs itself#

Captured memory becomes available as advisory context without routine manual triage. Genuine conflicts and authority decisions can still need review. Blocking power requires human confirmation. Configured hooks and synchronization handle much of the loop; task reports show what was observed:

terminal
hunch log              # the memory timeline: capture · adopt · supersede · prune · repair · edit
hunch log --diff <sha>  # what one move changed
hunch log --for <branch> # which memory led to which feature commit
hunch revert-move <sha> # undo one move (local git revert, never pushed)
hunch escalations       # the decisions only YOU can make — normally empty
hunch repair --apply    # heal bindings after a rename (sync does this automatically)
hunch push              # the one deliberate outward step
PieceWhat it does on its own
Auto-trusta capture is live advisory memory instantly; migrate an old draft backlog once with hunch adopt-drafts
Self-repairrenames heal every exact file binding — decision files, tripwire & constraint scopes, policy selectors — from git’s own rename detection; each repair is a revertable timeline move
Inline escalationsonly what the graph can’t settle itself asks you: a topic conflict, a candidate rule, a proposed rule with its proof, a repaired rule needing a fresh proof — each a question with its resolution verb
Local-firstmemory auto-commits locally and rides your next push; hunch push (or the panel’s Approve-to-push) is the explicit outward step. On the default branch, memory is written but left uncommitted
Failing-test recallwhen a Bash or PowerShell run fails and its output contains failing tests, the hook says which past bug matches, at failure time
Review memoryautomatic review memory reads the whole PR conversation — conversation comments and review bodies, not only inline review comments
Timely escalationsthe prompt hook asks only the escalations the prompt touches, once per session; hunch escalations lists the rest

In VS Code, the Hunch Memory panel is the same spine as a source-control view: the timeline with click-to-diff and one-click local revert, a ⚖ Needs your decision group that exists only while something real needs you, and a 🏛 Constitution group where activate / demote / withdraw / retire are each one audited click.

ℹThe rule of the loop: advisory is automatic; blocking is always one explicit human act — and a rule whose bindings were auto-repaired asks once for a fresh proof before it can block again.

Run only the tests a change needs v1.46#

hunch verify selects the tests that import a changed file, or that the impact map shows ran it. Doubt always means more tests: a change it can’t trace runs the full suite.

terminal
hunch verify                      # tests the working-tree change can affect
hunch verify --staged             # select from staged changes only
hunch verify --base origin/main   # select from a branch range plus the working tree
hunch verify --list               # print the selection with reasons; run nothing
hunch verify --refresh-map        # rebuild the impact map (each test under V8 coverage)
hunch verify --full               # run the whole suite; --ci does the same in CI

The impact map is a derived cache at .hunch-cache/test-impact.json. Without one, selection uses the import graph.

hunch verify or hunch task verify?

CommandUse it to
hunch verifyChoose and run tests for the current change.
hunch task verify <id> -- <command>Record a check for a task report. It runs the command you name and keeps its result and hash, never raw output.

hunch task verify stops a check after 8 minutes by default — under the agent host’s 10-minute shell cap, so a long check fails fast instead of being backgrounded. Change it with --timeout <seconds>.

terminal
hunch task verify <task-id> -- hunch verify                   # record the selected tests as this task's check
hunch task verify <task-id> --timeout <seconds> -- npm test   # a longer or shorter budget

Never Twice v0.13#

The most expensive failure in AI coding is being corrected and then re-corrected: you say “no, never call X here”, the agent complies once, and next session it does it again — because the feedback was stored as advisory text, not enforced. Hunch closes that loop.

The agent can save your correction as a scoped Constraint through hunch_record_correction. A capture without a verified human interview token remains agent-reported testimony, capped at warning severity. Human confirmation can give a supported rule blocking authority; strict firmness and a working host hook or CI guard are also required.

in your assistant
You:   "no — never import lodash, we ship our own utils"
Agent: hunch_record_correction({ rule: "never import lodash; use src/utils",
                                 scope_hint_file: "src/cart.ts", severity: "blocking" })
→ con_… recorded as advisory testimony without a capture token.
  Confirm the rule through the supported human review flow before relying on a deny.

The UserPromptSubmit hook nudges the agent to persist a rule whenever your prompt reads like a correction. Scoping is conservative by default (the file you were in); a repo-wide rule is only blocking when you pass applies_to_all, so one correction can’t silently gate the whole tree.

Reverse a rule without leaving the old one live

When a correction reverses an earlier rule, pass supersedes: [con_*] (up to 16). Each target is marked retired with a valid_to in the same memory home. Nothing is deleted, and the edit hook stops serving the reversed rule next to its replacement. The response also lists up to 8 other active rules on exactly the same scope.

An agent write never replaces a constraint a human confirmed.

Rules from your docs — hunch derive-rules v1.49#

Mark a rule in any markdown doc and the sentence that follows becomes a constraint. The doc is the rule’s source; the graph stays the authority.

CONTRIBUTING.md
<!-- hunch:rule scope=src/api/** severity=warning -->
Handlers never read the database directly; go through the repository layer.

The marker is <!-- hunch:rule scope=<glob> [severity=…] [type=…] [id=…] -->.

terminal
hunch derive-rules                    # import marked rules from every tracked .md file
hunch derive-rules --dry-run          # report what would change; write nothing
hunch derive-rules --check            # CI: exit 1 when docs and graph disagree
hunch derive-rules --accept-changes   # also apply rules that were edited or renamed

Nothing is guessed:

  • Markers in code blocks or example ranges are ignored.
  • An unclosed fence or a bad attribute is reported.
  • An edited or renamed rule is held until --accept-changes.
  • A removed marker leaves its constraint reported as orphaned, never auto-retired.
  • An id collision is reported as a conflict.

Draft rules from unmarked prose

terminal
hunch derive-rules --propose CONTRIBUTING.md       # draft rules with your selected subscription CLI
hunch derive-rules --proposals                     # list the local review queue
hunch derive-rules --accept <id> --expect <hash>   # accept one draft as an active constraint
hunch derive-rules --drop <id>                     # drop one; it is not proposed again

Drafts are queued for review and never applied on their own. They are capped at warning and must quote the doc verbatim.

Causal Merge Verdict v0.14#

A diff-only reviewer sees what changed. It can’t see that the line you’re deleting is the fix for an incident, that the symbol you’re re-adding was deliberately retired, or that the helper you’re adding already exists three modules over. Hunch can — because it holds the why and the whole graph.

hunch_merge_verdict (and hunch check / the CI guard) replays a diff against the graph and returns one cited verdict — BLOCK / WARN / PASS — that shows the reasoning, not just the rule:

hunch_merge_verdict
VERDICT: ⛔ BLOCK — this change breaks a recorded invariant or re-opens a known bug.

⛔ pay() must verify the session before charging — con_pay
   🧠 why: "Charge must verify the session first" (dec_pay)
   🐞 guards against: Double-charge on unverified session — pay() charged without verifying (bug_…)

No model in the loop, so it’s safe as a merge gate: it blocks only on a high-confidence rule you’ve confirmed, and warns on everything softer. Call it with {} to check staged changes, or pass base: "origin/main" for a PR range.

Decision Guard (Veto) v0.15#

Decisions record not just what you chose but the alternatives you rejected. The Decision Guard flags a change that reverses a decision — re-introducing an approach an in-force decision rejected — so the agent can’t quietly walk back a deliberate call.

terminal
hunch veto              # flag changes that reverse a rejected alternative

Like the other gates: it warns by default and blocks under strict only on a rejected approach you’ve explicitly vouched for — the one-click activation in the VS Code Hunch Memory panel, or hunch review --accept <id> in the terminal. Blocking power is never granted automatically.

Regression Guard#

Re-adding a symbol or dependency that an in-force decision deliberately retired gets flagged — warns always, fails a strict commit only when the retirement is tied to a blocking invariant. The agent stops undoing intentional design. The pre-edit hook also surfaces what a decision retired from a file (“don’t re-add login here — dec_017 removed it”), and the commit-time hunch check does the actual gating.

Redundancy Guard v0.16#

Coding agents work from a local context window, so they re-implement a helper that already lives three modules over, or re-add a dependency the codebase already has — sprawl a diff-only reviewer can’t see. Hunch holds the whole symbol graph, so a diff that adds a function or class already defined elsewhere is flagged with its existing location.

hunch check
Possibly re-implements 1 symbol(s) that already exist (advisory — review, never blocks):

  ⟲ adds function `formatDate` — already defined in src/util/date.ts

It’s advisory — it never blocks a commit; it surfaces in hunch check, the CI guard, and the merge verdict. It’s tuned to stay quiet, so a refactor that just moves code around isn’t mistaken for a duplicate.

CI Constraint Guard#

Memory that can hold a merge — when you've asked it to. hunch ci scaffolds a GitHub Action that runs hunch check on every PR and comments the affected invariants and decisions (with con_/dec_ ids and the causal why). The check fails only on a direct, high-confidence, non-stale blocking invariant — a rule you confirmed yourself.

terminal
hunch ci    # scaffold .github/workflows/ + the PR comment action
run a check locally
hunch check --staged --strict      # gate staged changes
hunch check --base origin/main      # gate a PR range (used in CI)

CLI reference#

Commands grouped by what you are doing. Run hunch <command> --help for every flag, or press / and type a command name.

Set up

CommandWhat it does
initScaffold .hunch/, index, install hooks, wire up the assistants it finds. --details, --all-assistants, --firmness <level>, --no-auto-commit.
updateInstall the latest release and repair every configured harness pin in this repository. --global, --dry-run.
uninstallRemove what Hunch installed and opt the repository out. --dry-run, --purge.
integrationsintegrations check reports harness coverage (--harness, --probe, --require); integrations repair-pins repairs stale pins.
providerShow or set the local synthesis provider. Never changes team config.
firmnessGet or set how firmly the agent hooks enforce Hunch.
mcpStart the MCP server over stdio. --root <dir> serves one partition.
ciScaffold the CI Constraint Guard (GitHub Action).
doctorDiagnose the environment: git, synthesis provider, index freshness, memory home, ignore rules.

Ask

CommandWhat it does
uiOpen the local web UI for this repository’s memory. --port <n>, --no-open.
whyExplain why a file, symbol or record id is the way it is. --as-of <ref>.
queryFull-text + graph search. --semantic adds embeddings recall.
contextAssemble the minimal relevant slice for a task.
timelineThe decision history for a file or symbol.
structureRepo map, directory contents, file outline or symbol definition, from the graph.
pathShortest dependency chain between two points: hunch path chargeUser verifySession.
nowRecent decisions and the roadmap: every live proposed decision.
findingsLive findings — observed gaps with no fix landed yet. --all for history.
fragileRanked fragility report with evidence.
runbookCapture a runbook from a commit range, or --find <query> to look one up.
dnaProject DNA: dna inspect, dna context, dna diff <older-ref> <newer-ref>.

Check a change

CommandWhat it does
checkFlag changes that touch a do-not-break invariant, and (advisory) symbols you add that already exist. --staged, --working, --base <ref>, --commit <sha>, --strict, --blast, --public-only.
verifyRun only the tests the change can affect. --staged, --base <ref>, --list, --refresh-map, --full, --ci.
vetoDecision Guard — flag changes that reverse a rejected alternative.
conformProve the code still satisfies recorded intent over the graph. --strict to fail.
impactThe impact surface of a change: dependents reached, invariants, decisions concerned. Advisory.
compareRank candidate branches or commits by architectural fit.
driftDetect doc≠graph and memory drift. Deterministic; exits non-zero for CI.
reconcile-topicsFind topics with more than one live decision and exit non-zero.
statusEnforcement readiness: what’s enforcing, what’s waiting for confirmation, what went stale.
proveDerive a sealed proof for one exact committed change.
evalScore retrieval over a golden set. --guards scores enforcement; --grounding replays each case through the prompt hook’s selection and reports precision and recall.

Record and edit memory

CommandWhat it does
newAdd a decision, constraint or finding by hand.
editEdit one record’s text by id.
linkLink a record to files, components or a feature (topic).
removeRetire a record without deleting it. --superseded-by <dec_id>.
restoreUndo remove. --clear-superseded-by.
reviewTriage drafts and answer imported-ADR questions. --confirm <id>, --accept <id>, --reject <id>, --accept-verified.
record-constraintRecord an invariant the codebase must not break.
retire-constraintRetire an active constraint: close its valid-time window.
record-bugCapture a bug from a failing test (symptom + suspects).
supersedeMark one decision as replaced by another (invalidate, don’t delete).
derive-rulesDerive constraints from hunch:rule markers in markdown. --check, --accept-changes, --propose.
capture-commentsLift inline hunch-why: / hunch-rule: comments into the graph.
testRun tests; capture failures as bugs and mark passing tests’ bugs fixed.
import-adrImport an existing MADR/Nygard ADR corpus into the decision graph. No LLM.
export-adrProject the public decision graph as a regenerated MADR corpus.

The memory loop

CommandWhat it does
indexParse the repo into a symbol/dependency graph (deterministic, no LLM).
backfillReplay git history to seed decisions. --since 90d.
syncCapture a decision from a commit (run by the post-commit hook). --deep, --verify.
logThe memory-move timeline. --diff <sha>, --for <commit|branch>, --json.
revert-moveUndo one memory move (local only, never pushed).
escalationsThe decisions a human must make now.
repairHeal memory bindings after a rename. Dry-run unless --apply.
repair-provenanceDetect a decision whose commit was orphaned by a squash-merge and propose the match.
pushThe explicit outward step: push the current branch to its remote.
adopt-draftsAdopt a legacy draft backlog as advisory memory, once.
review-memoryTurn sourced PR review threads into scoped review rules.

Tasks and reports

CommandWhat it does
taskThe task lifecycle: task start, task verify, task finish, task list.
reportInspect what memory reached a task and which checks ran. --html.
statsAccumulated memory, caught violations and payback.
servedWhich memory records actually reached an agent, how often, and which never have.
footprintMeasure how much text Hunch injects into an agent’s context.

Docs

CommandWhat it does
healEvery drift finding with its next action. Never rewrites prose silently.
wikiGenerate the component wiki + specs ledger. --check, --heal, --private.
groundingCheck the committed grounding docs against what the public graph generates.

Team, worktrees and state

CommandWhat it does
privateEnable a private memory overlay. --repo <url>, --migrate.
sharedEnable a shared memory repo. --repo <url>, --trust, --sync.
memory-policyThe committed memory home policy: memory-policy status, memory-policy check, memory-policy migrate.
worktreeCreate a git worktree already wired into Hunch. -b <name> for a new branch.
workspacesThis repository’s worktrees and branches across machines.
branchesEvery local branch with a deterministic merged verdict. Read-only.
serveThe self-hosted state server. serve init creates a partition config.
stateRead and write a served workspace using the state contract; JSON output.
policyConstitution policy review. Only a human activates a policy.

Maintenance and internals

CommandWhat it does
staleList decisions and constraints whose files changed after they were last verified.
compactPreview low-value auto-captured records eligible for compaction. It deletes nothing.
migrateUpgrade .hunch/ records to the current schema version.
embedGenerate local embeddings for semantic search (opt-in).
hookThe agent hook handler installed by init; reads the event JSON on stdin. Never blocks on its own failure.
merge-driver(internal) git merge driver for .hunch/ JSON — resolves concurrent edits by record id.

Environment variables#

All optional. Unset, Hunch uses its defaults.

Synthesis

VariableEffect
HUNCH_SYNTH_PROVIDEROne-shell provider override, for example claude-cli or openai-compat. auto disables the local choice.
HUNCH_SYNTH_BASE_URLBase URL of an OpenAI-compatible endpoint.
HUNCH_SYNTH_MODELModel name for that endpoint.
HUNCH_SYNTH_API_KEYOptional key. Omit for keyless local servers.
HUNCH_SYNTH_TIMEOUT_MSRequest timeout. Default 5 minutes.
HUNCH_SYNTH_MAX_TOKENSOptional output cap.
HUNCH_SYNTH_ALLOW_METERED1 allows a public remote endpoint. A deliberate billing and trust opt-in.
HUNCH_CLI_CONFIGCLI adapter config. A missing or malformed file falls back to deterministic synthesis, and hunch doctor prints why. HUNCH_REVIEW_CLI_CONFIG is the review-memory equivalent.
HUNCH_PR_CONTEXT0 stops commit synthesis from fetching the merged PR’s description with your gh CLI.
HUNCH_SIG_MIN_LINESChanged-line threshold below which a commit with no structural change and no explanatory body isn’t sent to a model. Falls back to 12 when it isn’t positive.

Memory, hooks and retrieval

VariableEffect
HUNCH_PRIVATE_DIRPath to the private overlay. Overrides .hunch/local.json per shell. Keep it unset in public CI.
HUNCH_AUTO_COMMIT_DEFAULT_BRANCH1 restores automatic memory commits on the default branch.
HUNCH_TASK_SELECTION0 restores the previous, broader prompt-hook delivery instead of task-scored selection.
HUNCH_SIBLING_WARM0 turns off the background worker that computes sibling-fix lessons for the pre-edit hook.
HUNCH_DEAD_PRIOR_SHIFTExtra ranking shift that sinks superseded, retired and rejected records in retrieval. Default 2; 0 restores the old behaviour.
HUNCH_PIPELINE0 is the kill switch for the verification pipeline hooks.
HUNCH_COMMIT_GIT_TIMEOUT_MSLongest one git call inside a memory flush may take. Default 60 s.
HUNCH_MCP_TOOLSWhich MCP tool groups a server exposes: all, core, or a comma-separated list.

State client and update check

VariableEffect
HUNCH_STATE_URLServer base URL for hunch state. Default http://127.0.0.1:7474.
HUNCH_STATE_TOKENAgent token for hunch state. Tokens are not accepted as command arguments.
HUNCH_NO_UPDATE_CHECK1 disables the cached update notice. NO_UPDATE_NOTIFIER=1 does the same.

Common workflows#

Copy-paste sequences for the everyday tasks. Run hunch <command> --help for every flag.

Set up a new repo

terminal
hunch init                          # scaffold, index, install hooks, wire up assistants
hunch backfill --since 90d          # seed decisions from recent history (no empty day-1)
# …reload your assistant, then ask: "why is X built this way?"

Join a repo that already uses Hunch

terminal
git pull                            # the .hunch/ graph travels with the code
hunch init                          # wire YOUR assistants to the shared graph (idempotent)
# …reload your assistant — the team's memory is now in context

Ask why a file is the way it is

terminal
hunch why src/auth/session.ts                  # decisions, bugs & rules behind it
hunch timeline src/auth/session.ts             # how the thinking changed over time
hunch why src/auth/session.ts --as-of v1.2.0   # what was believed at a past release

Turn a correction into an enforced rule

Tell your assistant the rule (it records it for you), or do it from the CLI — then confirm it so it actually blocks. Name the actual violation with --forbid-dep (or --forbid-symbol): the rule then blocks the real change across the file's whole life and stays quiet on edits that don't break it, where a scope-only rule relaxes to advisory once the file is edited again.

terminal
hunch record-constraint "never import lodash; use src/utils" \
      --scope "src/**" --severity blocking --forbid-dep "lodash"
hunch review --accept <id>            # confirm → now held against every assistant

--forbid-dep matches the parsed import (a comment or string naming the module can't trip it; a submodule like lodash/groupBy is caught). A correction your assistant records is given the same matcher automatically. --match <regex> remains as a lint-grade textual fallback. None of these are bypass-proof — deliberate indirection can still route around any rule.

Curate the draft queue

terminal
hunch review                        # segmented: ready-to-confirm vs needs-scrutiny
hunch review --accept-verified      # batch-accept the well-grounded ones
hunch compact                       # preview low-value drafts eligible for compaction

Review memory in the browser

terminal
hunch ui   # browse, search, edit; Deliberate lists what needs your judgment

Run only the tests your change needs

terminal
hunch verify --list   # see the selection and the reason for each test
hunch verify          # run it

Check a change before you merge

terminal
hunch check --staged --strict       # does this break a do-not-break rule?
hunch veto --staged                 # does it reverse a rejected decision?
hunch conform --strict              # does the code still honor recorded intent?
# …or check a whole PR range instead of staged files:
hunch check --base origin/main

Add the CI merge gate

terminal
hunch ci                            # scaffold the GitHub Action (runs on every PR)
git add .github && git commit -m "ci: add Hunch constraint guard"

Capture a higher-quality note for an important commit

terminal
hunch sync <sha> --deep             # reconcile several drafts + fact-check the note
hunch review                        # then confirm it

Make an existing public repo's memory private

terminal
hunch private --repo git@github.com:you/mem-private.git --migrate
# moves existing memory into the private store, makes this repo code-only,
# and prints the one git command to commit the now-clean public repo

Work across branches & worktrees

terminal
hunch worktree ../feature-x -b feature-x   # new worktree, already sharing memory
hunch doctor                        # confirms "worktree: linked — sharing the repo's memory"

It's not working

terminal
hunch doctor                        # git, synthesis provider, index freshness, drift
hunch index                         # rebuild the code map from current source
hunch migrate                       # after an upgrade, bring records to the latest schema

Where it’s stored#

The source of truth is plain, readable JSON in a Git repository you control: under .hunch/ in the code repo by default, or in a dedicated private memory repo in Matrix mode. The code repo then carries only the credential-free .hunch/team.json; local paths and the derived SQLite search index stay ignored and can be rebuilt at any time.

PathWhat it holdsCommitted?
.hunch/Memory records as JSON.Yes (public memory)
.hunch/config.jsonShared config: the memory home policy and the repo_id.Yes
.hunch/team.jsonCredential-free pointer to the shared memory repo.Yes
.hunch/local.jsonThis machine’s overlay path and preferences.No (gitignored)
.hunch-cache/test-impact.jsonThe test impact map, a derived cache.No
.hunch-removedThe opt-out marker written by hunch uninstall.Yes, to keep every clone opted out

Doctor & troubleshooting#

hunch doctor is the first stop for anything that looks off — it reports git status, the resolved synthesis provider, schema version, index freshness, and record counts (and on Windows, heals the ~/.claude.json casing split).

terminal
hunch doctor
SymptomFix
Assistant shows no hunch_* toolsReload the assistant in the repo; if still missing, hunch doctor.
Synthesis is deterministicLog into Claude Code, Codex, or Cursor. If more than one is available, choose with hunch provider <name>.
Graph looks stalehunch index to rebuild the symbol graph from current source.
Schema mismatch after upgradehunch migrate to upgrade .hunch/ records.
A capture is refused: the memory home can’t be resolvedRun hunch memory-policy status, then commit the policy and repo_id in .hunch/config.json. See One memory home.
Captured records never reach teammatesThe ignore rules may exclude .hunch/. hunch doctor names the rule and the fix.
Memory is written but not committed on mainExpected: see the default branch.
Synthesis fell back after setting a CLI configA missing or malformed HUNCH_CLI_CONFIG uses the deterministic provider. hunch doctor prints why.
Advertised team memory is unavailableCheck Git access and .hunch/team.json, then run hunch shared --repo <the-same-url>. Hunch refuses to fall back to another graph.

Working as a team — the Matrix v1.9#

Matrix mode gives a project one living engineering-memory spine across teammates, branches, worktrees, agents, and operating systems. The source of truth is a separate private Git repository you control; You provide the Git hosting; the committed pointer contains no credentials.

Create that repository first, grant the team normal Git access, and have one maintainer connect it:

maintainer
npm i -g @davesheffer/hunch
hunch shared --repo git@github.com:acme/project-hunch-memory.git
git add .gitignore .hunch/team.json
git commit -m "chore: connect shared Hunch memory"
git push

Use a credential-free HTTPS or SSH URL and leave authentication in SSH or the Git credential helper. Add --migrate only when moving existing public .hunch/ records into the dedicated store.

After the pointer commit lands, each teammate installs the same Hunch version, pulls, and runs hunch init. Hunch validates .hunch/team.json, creates an ignored .hunch-private/ clone, and merges the local path and preferences into ignored .hunch/local.json. An unparseable local config is never overwritten.

Always pumping. CLI operations attempt a bounded pull at startup; long-lived MCP servers refresh at tool-request boundaries. Captures commit and synchronize the memory-only repository by default, concurrent JSON records merge by identity, and a failed push stays local for hunch shared --sync to retry.

Authority stays fail-closed. Captures become advisory memory immediately. Blocking policy authority still requires an explicit audited human action, and public receipts should use --public-only so the shared graph never appears on a public surface.

Pause or roll back without deleting memory

terminal
hunch firmness off
hunch shared --repo git@github.com:acme/project-hunch-memory.git --no-auto-commit
# Keep the installed version; inspect the problem before choosing a rollback.

This preserves every shared and local memory record while disabling enforcement and automatic publication. Revert the .hunch/team.json setup commit only if new clones must stop discovering the Matrix; do not delete the memory repo or local overlay. Keep every client on the same supported Hunch version before resuming shared policy workflows, then run hunch shared --sync.

Maintenance#

Two housekeeping commands keep the graph healthy over time:

terminal
hunch compact   # preview low-value auto-captured records eligible for compaction
hunch stale     # list records whose files changed after they were last verified

Routine captures are available as advisory memory, and hunch escalations asks you inline about the few things the graph can't settle itself. Migrating an older repo? One hunch adopt-drafts clears a legacy queue, and hunch log shows every memory move — each one revertable.

Release integrity#

Hunch tests release artifacts before publication credentials are available. The immutable npm tarball and VSIX are then passed to isolated publishers, which verify the public registries converged on the expected version. npm publishes with GitHub Actions provenance; one tested VSIX goes unchanged to Open VSX and is downloaded again for byte verification.

audit
npm view @davesheffer/hunch version dist.integrity dist.attestations --json
git tag --list 'v*' 'vscode-v*'

Inspect GitHub Actions, npm, and Open VSX for the public receipts.

License & contributing#

Hunch is source-available under the Functional Source License (FSL-1.1-ALv2).

  • You can use, modify and run Hunch for your own work, internal or commercial.
  • You can’t offer it to others in a commercial product or service that competes with Hunch.
  • Each release converts to Apache-2.0 two years after it ships.
  • Releases before the change keep the license they shipped with: Apache-2.0 from v0.15.2, MIT before that. clients/python stays Apache-2.0 and vscode-extension stays MIT.

See LICENSE and NOTICE for the exact terms.

Contributions are welcome and need a signed Contributor Assignment Agreement (CLA.md), checked on every pull request. Start with CONTRIBUTING.md and the repo.