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

Creates an account if needed, mines the agent sessions already on disk, and registers the end-of-turn hook for the coding agents on this machine. If tern isn’t on PATH, it’s at ~/.tern/bin/tern. Then go back to your agent — the hook catches decisions as you work.

Other agents

The installer registers the hook for Claude Code, Codex, Cursor, opencode, Grok CLI, Pi, and oh-my-pi. Harnesses has the full list. If your harness isn’t registered automatically (Copilot CLI, for one), register this as the Stop / end-of-turn hook, with a 600-second timeout:

tern hook --stop-hook

It 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" --agent

That’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 every supported agent on your machine; the other-agents command is the same loop by hand.

If the hook is overfiring or too noisy, drop us a note.

Adding your team’s context

Commit a .tern/standards.md file to your repo with anything the hook should know about how your team builds software: architecture decisions, conventions, rules that live in people’s heads. It’s optional, and plain markdown. Tern reads it on every run and asks when a change goes against it.

Every API handler checks org membership before reading data.

The billing module is being replaced; don't add new callers to it.

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.