The hook
The hook runs at the end of a turn and catches decisions your coding agent made that you didn’t ask for. Install it once. It fires when a turn lands a commit, stays quiet on most turns, and puts a question in the session when there’s something to settle:
│ opencode sessions now answer which branch they were on, but four other
│ lookups still return nothing. Build those four now, or ship branch
│ support first?
❯ 1. Build all four now
opencode reaches parity with Claude Code and Copilot in this branch.
2. Ship the two, add the rest later
The remaining lookups keep returning "unsupported" until a follow-up.
3. Type something.1 changes the code to the other reading. 2 keeps the decision. 3 is a freeform instruction to the agent. Most turns produce nothing.
The hook stays quiet unless all of these are true: HEAD moved this turn, the change made a decision you didn’t ask for, and that decision touches something your lens cares about (the nouns your org steers on: auth, schemas, money, the words your team uses). Reformatting a file, a turn that doesn’t commit, or a change outside the care map all stay quiet. See Troubleshooting if it’s been quieter than you expected.
Installing
curl https://tern.sh/install | bash
tern hook installCreates an account if needed, mines the agent sessions already on disk, and registers the end-of-turn hook for Claude Code. If tern isn’t on PATH, it’s at ~/.tern/bin/tern.
Other agents
The same binary works on Cursor, Codex, Copilot CLI, opencode, and Grok CLI. Harnesses has the full list. If your harness isn’t registered automatically, register this as the Stop / end-of-turn hook, with a 600-second timeout:
tern hook --stop-hookIt reads JSON on stdin (session, transcript path, working directory) and writes JSON on stdout. Always exit 0. A quiet turn emits nothing.
How it runs
There are two sides, and both are CLI calls.
Report. The harness runs tern hook --stop-hook at the end of a turn. Tern reads the session and the commit, and returns any decisions that need a call. That’s the command you register as the hook; the findings come back to the agent. A quiet turn emits nothing.
Resolve. When you pick an option, the agent records it with what you said:
tern checks resolve <id> --comment "ship branch support first" --agentThat’s how Tern learns.
Because both sides are ordinary commands, you can wire this into any harness that can run a command at end of turn and let the agent shell out afterwards. tern hook install does that for Claude Code; the other-agents command is the same loop by hand.
If the hook is overfiring or too noisy, drop us a note.
See also
Once you’re running the hook, create a tour to get a summary of what your branch is doing based on these decisions.
- Install Tern: the CLI,
tern hook install, auth. - The tour: the summary of the branch.
- Harnesses: which coding agents work with Tern.
- AI Models: which LLM providers Tern can use.
