Tracehub CLI
Tracehub has three parts: the Tracehub CLI (this package, the tracehub command), the Tracehub Worker (the API and web pages, with .json twins) and the Tracehub GitHub App. One Cloudflare Worker serves the API on https://assisted-by.aui.dev and pages on https://tracehub.aui.dev, reading storage on every authorized request with no page cache between uploads and reads.
Attach the work behind coding-agent commits (Claude Code, Codex, OpenCode): turns with evidence that they produced the commit, their prompts, recent user steering and final agent replies, per-turn file changes, and which turn wrote each added line of the diff.
A commit made while an agent session is active gets an Assisted-by: https://tracehub.aui.dev/t/<owner>/<repo>/<trace id> trailer: a link to its trace, under a random trace id that says nothing about the session. The commit also records where each session stood when it was made. On push, the CLI turns each session into its trace at that commit, redacts it and uploads it; TraceHub keeps one self-contained document per commit.
Only work with evidence that it produced the commit is shared: a turn or subagent run that wrote one of its lines, or edited one of its files since the session's previous commit. Discussion and research that changed nothing stay on your machine. Run tracehub preview before a push to see exactly what will leave it. The full rule is in What a trace holds.
Install
Set it up once with setup (tracehub --help lists the other commands). Run it in your terminal:
npx --yes tracehub@latest setup
Setup is a form of four steps. Each step saves what you chose before the next one starts; cancelling (Ctrl-C) keeps the steps already done.
- Account. Shows whether you're signed in to GitHub and as whom. Keep that account, or sign in with another one: setup shows a one-time code, and Enter copies it to the clipboard and opens GitHub's device sign-in in the browser (without a clipboard tool,
pbcopy, clip, wl-copy, xclip or xsel, you type the code). A spinner shows while GitHub waits for you; Ctrl-C stops it. GitHub signs in the account your browser is signed in to, so switch accounts on github.com first. One account is stored at a time. Signed out, you can sign in or skip the step.
- Permission rules. Lists your rules, then lets you add or revoke them. A rule allows uploads for a GitHub organization (
owner, every repository of it, including future ones) or for one repository (owner/repo). Inside a clone, setup offers the current repository and its organization; any other owner or owner/repo can be typed, or a pasted GitHub URL. Before a rule is added, setup shows what an upload shares and asks to confirm.
- Git hooks. Explains the global Git hooks, then installs them, or, when they are installed, keeps or removes them.
- Agent skill. Offers the optional tracehub skill for Claude Code and Codex, or keeps it (updating it to this version) or removes it when installed. Skipping it leaves setup complete.
Setup and uninstall open with a title and close with an outro, and each setup step has a "Step N of 4" header. It ends with a summary of the account, the allowed rules, the hooks and the skill, and what is left to do. Setup needs an interactive terminal; without one it exits 1.
Setup installs a managed copy under ~/.config/tracehub/current for the hooks to run locally.
Git hooks
| hook |
does |
prepare-commit-msg |
in an allowed repository, adds the trailer and records a marker per session; an agent's git commit that Claude Code has not written to its session yet waits for it, up to 20 s |
pre-push |
adds the other sessions that edited each pushed commit (as backfill --add does, up to 1 s), uploads the traces of pushed commits (15 s budget, then the rest in the background), and retries the traces an earlier push left pending |
- A hook never blocks a commit and never prompts. A hook that can't record or upload a trace says so in one
WARNING line naming the commits and tracehub backfill <sha>; the next commit retries them in the background, as does tracehub backfill without arguments.
- Failures name their cause: low disk space (a hook checks free space before it writes), a trace too large for TraceHub (413), or TraceHub out of reach. A background upload that fails exits non-zero, and its log says why. In a repository your rules cover, a push whose traces can't be read stops with the reason instead of going on untraced.
- In a repository your rules cover, a push stops when a pushed commit the remote doesn't have yet still has no trace, saying why and how to fix it. When every attached session is omitted, it reports that its attached session shared nothing of the commit; an omitted session does not count as an upload and is not retried. A session retracted during upload is settled without blocking the push or being retried.
TRACEHUB_ALLOW_MISSING=1 git push overrides the gate; CI never checks.
- A hook command does nothing without a permission rule for the repository, with
TRACEHUB=0, or outside a repository. The one exception is the daily update check on push, which needs no rule; TRACEHUB=0 skips it too.
- A repository, worktree or command that sets its own
core.hooksPath (Husky does) still gets traces with Git 2.54 or newer, which runs tracehub's two hooks from the global configuration beside the repository's own. With an older Git it skips the global hooks and gets no traces; setup warns when the current repository does.
- Setup refuses conflicting files, a global setting another tool changed, and global or system
include/includeIf configuration, whose hook paths can vary across checkouts, instead of overwriting them.
- A hook that can't run tracehub (a deleted checkout, npx offline) prints one line,
tracehub: … run "tracehub setup" to repair the hooks, and lets the commit or push go on.
- Hooks use the managed copy, so an update needs no new setup. A setup from a source checkout keeps running that checkout's
cli.js; if the managed installation fails offline, setup keeps its existing runner.
How the hooks run, and what they leave alone: Architecture.
Agent skill
The optional skill teaches Claude Code and Codex when to use tracehub to read the work behind a line or commit, repair missing traces, attach pull request context, preview a push or retract an upload. Its command reference is generated from the same definitions as tracehub --help. Setup and uninstall need a person at an interactive terminal; agents must not run them.
Setup installs skills/tracehub/SKILL.md only inside existing agent directories: CLAUDE_CONFIG_DIR or ~/.claude for Claude Code, and CODEX_HOME or ~/.codex for Codex. Managed upgrades refresh installed skills, and uninstall removes them. A skill without the tracehub ownership marker is kept untouched.
Updates
Automatic updates check in the background on push at most once a day and install stable releases that have been public for at least a day. Run tracehub upgrade to update immediately, tracehub upgrade --auto=off to turn automatic updates off, or tracehub upgrade --auto=on to turn them on. If the managed current version, or the running version when higher, is deprecated on the registry, both paths move to the highest stable, nondeprecated release even when it is lower and report Moved tracehub <from> → <to> (<from> is deprecated). Automatic recovery still requires the target release to be at least a day old. Otherwise, neither path downgrades. These commands need no terminal and never prompt.
Hooks of earlier releases move to the managed copy with one npx --yes tracehub@latest upgrade; there is no need to repeat setup. A source checkout keeps running its own CLI until you choose to migrate with tracehub upgrade.
Uninstall
npx --yes tracehub@latest uninstall
Lists what it removes and asks first (default no); with nothing set up it says so and asks nothing. Then it removes the global Git hooks and their hook.tracehub-* entries and restores your previous global core.hooksPath setting, removes installed tracehub agent skills, deletes the permission rules (consent.json), signs you out (auth.json), and removes the managed versions/, current, update.json and update.lock under ~/.config/tracehub. It asks before deleting the deny list and the current repository's .git/tracehub (its markers, including ones not uploaded yet). Other repositories keep their .git/tracehub; delete it by hand if you want. Before signing out it asks TraceHub to forget this machine's rules (see Consent registry); when TraceHub can't be reached it says that TraceHub still lists them, and goes on. If the global hooks setting was changed by another tool since setup, uninstall leaves the hooks alone, still removes the rest, and exits 1.
Sign in
Setup's first step signs you in with the device flow of GitHub.
- The credentials go to
~/.config/tracehub/auth.json (mode 0600). A replacement is saved only after GitHub confirms the new account; cancelling keeps the current one. The access token is refreshed when needed; a refresh that GitHub refuses removes the file.
- The GitHub App TraceHub Bot (
tracehub-bot, formerly assisted-by-bot) must be installed. Uploads require current push access and verified assistant-ui organization ownership. Reading traces follows who sees a trace; maintainers have current GitHub write, maintain or admin access to the repository.
- A hook that finds no sign-in leaves its work pending and says so; the first push after signing in uploads it.
| setting |
environment |
default |
| The Tracehub API |
TRACEHUB_URL |
https://assisted-by.aui.dev |
| client id of the GitHub App |
TRACEHUB_GITHUB_CLIENT_ID |
Iv23limQrRDTbi0xJG3f |
Permission rules
Nothing is attached until a permission rule allows the repository. Setup's second step adds and revokes the rules; a rule is scoped to a GitHub organization or to one repository, nothing else.
An allowed repository means: the commit-scoped traces of its agent sessions (retained messages, per-turn changes and sourcemaps; never tool calls, results or thinking) are uploaded, redacted, to Tracehub, for you and the repository's maintainers with GitHub write, maintain or admin access; everyone else sees nothing. On the way in, the Tracehub API sends the redacted messages to TypeSafe's Jev model to find what the patterns missed (see Privacy).
The rules are kept in ~/.config/tracehub/consent.json under normalized GitHub keys: github.com/owner/* for an organization, github.com/owner/repo for a repository. Every clone and worktree shares them; filesystem paths never identify a rule. A repository's rule wins over its organization's.
- A rule for all GitHub repositories (
github.com/*) allows no uploads; setup removes it from the file. Add an organization or repository rule instead. A repository refusal blocks that repository until it is revoked in setup.
- Rules are separate from upload eligibility and the hooks. A rule does not authorize non-GitHub origins or bypass the current assistant-ui-only ownership policy, GitHub App installation, repository access, or sign-in checks. A rule for another organization is stored but uploads nothing in this release. It does not make traces public.
| rule for the repository |
a commit with an active session |
| allowed |
gets the trailer and markers |
| declined (older consents) |
is left alone |
| none |
is left alone, with a hint to run tracehub setup |
Uploads go only to repositories owned by the assistant-ui organization; Architecture says how that is checked, and Consent registry what TraceHub keeps of your rules.
Commands
tracehub --help lists every command, and tracehub <command> --help explains one with examples; both are rendered from src/cli/usage.ts. The hooks run tracehub hook prepare-commit-msg and tracehub hook pre-push, an internal entry point that --help leaves out.
Preview
Run tracehub preview in a clone before pushing to print every session the next push of the current branch would upload, with the same discovery, commit boundaries and redaction as the hook. It considers commits absent from the upstream, or from every remote ref when the branch has no upstream, includes sessions found by edit linking, and retries pending traces in the branch’s history. It reads local sessions without signing in, making network requests, uploading, changing markers or creating state files. If nothing is pending, it prints one line saying so. Review the messages before pushing; TraceHub may withhold additional messages during its server sensitivity check.
npx --yes tracehub preview
Retract
Run tracehub retract <commit>… in a clone to withdraw the sessions you uploaded behind each commit's Assisted-by trace links. It needs the uploader’s sign-in, requires no current repository access, permission rule or terminal, and never prompts. It prints the number of sessions retracted per commit and exits 1 if a commit has no trace link or a request fails.
npx --yes tracehub retract HEAD
npx --yes tracehub retract 1a2b3c4d 5e6f7a8b
Retraction removes your sessions' content from trace, commit and pull request pages, leaving other uploaders' sessions visible. A trace with no live sessions shows that its author retracted it and remains accounted for by the TraceHub traces check. A tombstone retains the session's identity, commit time, uploader and retraction time; only its uploader can upload that session again. Retraction leaves local sessions and Git trailers in place.
Backfill
Commits made before tracehub setup, or whose trace never reached TraceHub (a lost push), have no trace, and their pull request's check fails. tracehub backfill finds the agent sessions behind them on this machine and uploads them, so the check passes:
npx --yes tracehub backfill --pr 386 --dry-run # print the evidence, upload nothing
npx --yes tracehub backfill --pr 386 # upload the sure matches
npx --yes tracehub backfill --pr 386 --add # also add the sessions that edited traced commits
Run it in a clone of the pull request's repository, on the machine where the agent ran; --repo <owner/repo> only confirms the clone. It needs a sign-in and a permission rule, as uploads do, and only works on pull requests you opened. Commits whose trace TraceHub already has, and merges, are skipped; a commit whose message names a trace TraceHub never got is backfilled under that trace id. With --add, a commit whose trace TraceHub has also gets the high-confidence sessions that edited it in a checkout of the repository and are not in the trace yet; the push hook does the same.
For each commit it scores the Claude Code sessions and subagents (~/.claude/projects), Codex rollouts (~/.codex/sessions) and OpenCode sessions that were written to after the commit's time and name one of its short shas or paths: