hunch cookbook
Cookbook

Recipes for running Hunch

Copy-paste recipes for day-to-day Hunch. Every recipe says what you should observe when it works — a passing gate, an injected block, a red CI — never "it's configured". For decisions, completed work and commitments shared across agents, use the state-server guide.

1 · First install on a repo#

terminal
npm i -g @davesheffer/hunch
cd your-repo
hunch init --firmness advisory   # start gentle; raise later
hunch backfill --since 90d       # cold start: seed from history

Observe: .hunch/ appears and supported assistant configurations gain lifecycle hooks. Claude Code uses .claude/settings.json; Codex uses .codex/hooks.json and requires review and trust through /hooks. Reload the assistant, then use hunch integrations check to inspect configuration and observed delivery. Configuration alone does not prove that the host ran a hook.

For later updates, run hunch update in the repository. Reconnect the assistant; in Codex, review and trust changed commands with /hooks, then start a new session. A version pin change changes the command and requires renewed trust.

2 · Choose an enforcement level#

firmnesspre-edit groundingblocking invariants deny editsverification stop-gate
off———
advisory✔—nag only
firm✔—✔ blocks unverified turn-end
strict✔✔✔
terminal
hunch firmness firm

No restart needed — the hook reads firmness at run time.

3 · The verification pipeline (v1.4.0+)#

On hosts that support and run the configured hooks, the operating loop — scope → evidence → change → verify → attack → report — is delivered at session start. PostToolUse records observed product-file edits and subsequent verification-shaped commands. At firm/strict, a supported Stop hook can request continued work when edits lack that evidence, at most twice per turn. This does not prove a check passed or the model used the context; task reports distinguish those claims.

📊Why it exists (benchmark, 2026-07-08): instruction skills installed as files were read in 0/20 benchmark sessions; directly supplying the same content changed hard-bug diagnosis in the tested cells. That result motivated hook delivery. It is scoped evidence, not a guarantee about every host or task: delivered context can still be ignored or misunderstood.
terminal
HUNCH_PIPELINE=0          # kill switch, per env
hunch firmness advisory   # keep grounding, drop the gate

Docs and .claude/ / .hunch/ edits never arm the gate.

4 · Capture a decision that survives the session#

After any non-trivial choice, in your assistant:

text
/capture     # grilling interview: topic, rationale, rejected alternatives

Or mid-flow: hunch_capture_decision(topic) → answer the questions → hunch_record_decision(...) with the returned token.

Observe: the decision shows in hunch now, and editing a file it governs injects it — including what was rejected, so the next session doesn't re-litigate it.

5 · Turn a human correction into a permanent rule#

text
hunch_record_correction({ rule, scope_hint_file, severity: "blocking" })

Observe: at strict, an edit violating the rule is denied with the rule quoted back. Never Twice.

6 · Keep docs honest (doc≠graph)#

Anchor a doc to a topic:

markdown
<!-- hunch:topic auth.session-storage -->
terminal
hunch drift              # CI-gateable: stale anchors fail
hunch heal               # guided reconciliation — never rewrites prose silently
hunch reconcile-topics   # after merges: one live decision per topic

7 · Wire CI#

terminal
hunch ci                 # constraint guard on the diff
hunch drift              # doc anchors still current
hunch reconcile-topics   # merge didn't fork a topic

All exit non-zero on violation — make them required checks.

8 · Make an instruction skill actually fire#

Measured: models under-trigger skills badly — 0/20 sessions read an installed skill whose description was polite prose. If you ship a skill:

  • Write the description as a pushy trigger: “MANDATORY before X — invoke FIRST, do not skip because the task looks simple.” This alone took Opus from never-reads to reads-and-passes.
  • Weaker models (Haiku-class) ignore even pushy descriptions — name the skill in the prompt, or inject the content via hooks (recipe 3 is exactly this, productized).
  • Never conclude a skill “doesn't help” without checking the transcript for an actual Skill invocation — availability ≠ delivery.

9 · Benchmark your own setup#

!Changed in v1.45: the benchmark harness scripts moved out of the public repository, so the bench/ commands below need a checkout that still has them. What ships today is hunch eval: hunch eval --guards --generate scores the guards on a starter golden set, and hunch eval --grounding --file <golden.json> reports the precision and recall of what the prompt hook delivers.

The harnesses under bench/:

terminal
npx tsx bench/run.ts --arms A,C --model claude-sonnet-5
npx tsx bench/external/run-zod.ts --arms A,S --no-repro
npx tsx bench/external/run-zod.ts --arms S --force-skill --only zod-5937

Rules learned the hard way: use --no-repro (diagnosis mode) or everything ceilings at PASS; drop tasks that fail for every arm (they measure spec-guessing, not diagnosis); verify skill invocations in transcripts before comparing arms.

10 · Connect the team-memory Matrix#

Create a dedicated private Git repository for memory. It must differ from every code-repo remote, and its committed URL must not contain credentials. On one maintainer machine:

terminal
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

Add --migrate only when moving existing public .hunch/ memory into the dedicated store. On every teammate machine:

terminal
npm i -g @davesheffer/hunch
git pull
hunch init
hunch doctor

Observe: the code repo commits only .hunch/team.json; credentials remain in SSH or the Git credential helper. Each machine gets an ignored memory clone and local pointer. CLI operations refresh at startup, MCP tools refresh at request boundaries, and captures synchronize automatically.

For a coordinated pause or rollback that preserves every memory record:

terminal
hunch firmness off
hunch shared --repo git@github.com:acme/project-hunch-memory.git --no-auto-commit

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; after upgrading every client to the same compatible release, hunch shared --sync publishes pending memory. Do not blindly downgrade across storage or capability versions; follow the target release's upgrade or rollback guide and restore a compatible backup when that guide requires one.

11 · Private overlay (public repo, private memory)#

terminal
hunch init --private-sync   # captures go to the HUNCH_PRIVATE_DIR overlay
hunch private               # point a clone at the overlay

Observe: hunch_* tools see the union; the public repo carries only what you curate.

12 · The self-running memory loop (v1.8.0+)#

Nothing to manage. Capture happens on every commit, memory lands trusted-advisory immediately, and renames heal their own bindings:

terminal
hunch log                    # every memory move: capture · adopt · supersede · prune · repair
hunch log --diff <sha>       # what one move changed
hunch revert-move <sha>      # undo one move (local git revert, never pushed)
hunch escalations            # the decisions only YOU can make — normally empty
hunch adopt-drafts           # one-time: clear a legacy draft backlog into advisory memory
hunch push                   # the one deliberate outward step (memory auto-commits locally)

Observe: after a commit that renames a file, hunch log shows a 🔧 repair move — the bindings healed themselves; nothing went stale. In VS Code, the Hunch Memory panel is the same spine with click-to-diff, one-click revert, and the inline activate / demote / withdraw / retire authority actions.

Rule of the loop: advisory is automatic; blocking is always one explicit human click, and a repaired rule asks once for a fresh proof before it can block again.

13 · Use a local or self-hosted model#

Point Hunch at any OpenAI-compatible chat-completions endpoint. Ollama, vLLM, LM Studio, and llama.cpp work without a subscription CLI:

terminal
export HUNCH_SYNTH_PROVIDER=ollama
export HUNCH_SYNTH_BASE_URL=http://localhost:11434/v1
export HUNCH_SYNTH_MODEL=hunch-synth
export HUNCH_SYNTH_TIMEOUT_MS=300000
export HUNCH_SYNTH_MAX_TOKENS=2048

For predictable large-diff synthesis with Ollama, pin the context window in a custom model:

Modelfile
FROM qwen2.5-coder:latest
PARAMETER num_ctx 32768
terminal
ollama create hunch-synth -f Modelfile
hunch doctor

Observe: hunch doctor reports openai-compat and no longer warns that num_ctx is unpinned.

!Public remotes fail closed. Localhost, private/link-local IPs, and conventional LAN names work directly. Every public endpoint requires HUNCH_SYNTH_ALLOW_METERED=1; set it only when you trust the endpoint and understand any billing.

14 · Install the editor companion and verify a release#

Install Hunch from Open VSX, then open a repository initialized with the Hunch CLI. The extension reads the same public, private, or Matrix memory home and never writes Hunch JSON directly.

audit
HUNCH_RELEASE=1.33.0
HUNCH_VSCODE_RELEASE=0.18.2
npm view "@davesheffer/hunch@$HUNCH_RELEASE" version dist.integrity dist.attestations --json
git tag --list "v$HUNCH_RELEASE" "vscode-v$HUNCH_VSCODE_RELEASE"

Observe: npm reports version 1.33.0, an integrity digest, and provenance metadata; Open VSX reports 0.18.2. Each tag’s GitHub Actions run validates the exact content-addressed artifact before isolated publishing begins and verifies the same public bytes afterward.

15 · Review memory in the browser (v1.52.0+)#

terminal
hunch ui             # serve on 127.0.0.1 with a keyed link and open the browser
hunch ui --no-open   # print the link without opening a browser

Then work top-down:

  • Deliberate — 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 are tabs on the same page.
  • Confirm as yours — sign the memory you stand behind. Undo is one click.
  • Grill me on this — one question at a time, up to five, then a suggestion: keep, fix wording, remove or replace.

Observe: the terminal prints the link and Press Ctrl+C to stop. Deliberate runs no assistant, and only your click changes memory. Each change you save shows in the UI's history; the UI never edits .hunch/ directly, it runs hunch new, hunch edit, hunch link, hunch remove or hunch restore.

Grill and the decision board use only a subscription assistant with its tools off. Secret-looking files and credential lines are withheld and named on screen.

16 · Turn your CONTRIBUTING rules into constraints (v1.49.0+)#

Put a marker above a rule you already wrote. The sentence that follows becomes a constraint:

CONTRIBUTING.md
<!-- hunch:rule scope=src/api/** severity=warning -->
Handlers never read the database directly; go through the repository layer.
terminal
hunch derive-rules --dry-run   # what would change; writes nothing
hunch derive-rules             # import the marked rules
hunch derive-rules --check     # CI: exit 1 when docs and graph disagree

Observe: edit the rule's sentence and --check exits 1 until you run hunch derive-rules --accept-changes. Delete the marker and its constraint is reported as orphaned, never auto-retired.

No markers yet? Let your subscription CLI draft them, then decide each one yourself:

terminal
hunch derive-rules --propose CONTRIBUTING.md        # drafts go to a local review queue
hunch derive-rules --proposals                      # list them, each with its hash
hunch derive-rules --accept <id> --expect <hash>    # accept one
hunch derive-rules --drop <id>                      # drop one; it is not proposed again

Drafts are capped at warning and must quote the doc verbatim.

17 · Run only the tests your change needs (v1.46.0+)#

terminal
hunch verify --refresh-map        # once: build the impact map (each test under V8 coverage)
hunch verify --list               # the selection, with a reason per test; runs nothing
hunch verify                      # run the tests the working-tree change can affect
hunch verify --staged             # …or only what is staged
hunch verify --base origin/main   # …or a whole branch
hunch verify --ci                 # CI keeps the whole suite

Observe: --list names each selected test and why. Doubt always means more tests: a change hunch verify can't trace runs the full suite.

In an agent task, record the run as evidence with hunch task verify <task-id> -- hunch verify. Its default budget is 8 minutes; change it with --timeout <seconds>.

18 · Trace which memory led to a feature commit (v1.51.0+)#

terminal
hunch log --for feature-x   # a branch: memory grouped by the feature commit it led to
hunch log --for <sha>       # or one commit
hunch log --json            # every move, with the code branch and head it was captured against

Observe: each feature commit is listed with the memory captured before it. Memory captured before the next code commit on the branch's first-parent line belongs to that commit, which survives a rebase. Anything the attribution cannot cover is listed in notes.

Separately, every public .hunch/ memory commit carries Hunch-Code-Branch and Hunch-Code-Head trailers naming the code it was captured against.