rig: generic actions for agentic workflows¶
Status: phase 1 was released as 0.1.0. Phases 2 and 2.5 ship together as
0.3.0 and are described in phase-2.md and
phase-2.5.md; workflows.md documents the
workflow file. Phase 3 (views and trackers) ships as 0.4.0 and 0.5.0: 0.4.0 is
built and is described in phase-3.md; rig tracker report is
built in 0.5.0, and rig tracker push in 0.6.0 (see phase-3.5.md). Later phases are outlines, each planned separately before
it is built.
Direction. rig provides generic actions (tasks, findings, notes, workflow transitions, push, pull requests, CI waits, context briefs, config, login) that any loop can use, driven by any harness: Claude Code, other agent CLIs, CI or a person. It has no built-in lifecycle: a workflow file defines states, transitions and the gates that guard them. A review loop is one such workflow, owned by the project that runs it. The sections below that describe such a loop are the history of how rig started.
rig is its own tool. It began as a subdirectory of an agent toolkit and
moved here with its history in phase 1.5. Its callers use it only through the
contract below.
Why¶
rig started as the mechanics of an agent review loop: plan → fanout → review → verify → record. In that loop, state and rules lived in prose and shell text:
- State is markdown the model re-reads. Task state is parsed out of
## Review round Nand## Wave verified — <sha>sections, then confirmed withghandgiton every turn. - Rules are enforced by parsing shell.
scripts/push-guard.shdecides whether a Bash command is a safe push by matching its text. A regex cannot understand bash: extending the guard to chained commands took four review rounds, each of which found another way to push tomain, and was reverted. - It is tied to GitHub.
ghis called fromscripts/ci-wait.shand from thestatus,wave,mergedandhandoffcommands. - It does not scale past one developer. Sequential task numbers collide,
and
PLAN.mdandHISTORY.mdconflict on merge.
rig is a small Go program that owns the mechanical parts: pushing, pull
requests, CI waits and status now; tasks, findings and context later. A command
that takes typed arguments can refuse a bad push by construction, where a guard
has to recognise one in arbitrary shell.
Decisions¶
- Go, standard library where possible. One static binary, no runtime.
- Forge adapters only.
ghnow,glabnext. Git is called directly; there is no git abstraction to swap. - The forge is auto-detected from the
originremote's host. The layered config (rig config) overrides it, by the scope orderrig config getreports (local, repo section,.claude/rig.json, global), then origin detection. A kind from a less specific scope never overrides a host from a more specific one; a host that names no known forge falls back to a less specific kind. Without a home directory forge selection treats the global layer as empty, butrig pushstill fails closed (exit 2): its policy may live in the global file. - rig holds a token only for a service with no CLI of its own. GitHub and
GitLab stay with
ghandglab: the adapters shell out to them and use whatever login the user already has, andrig login github|gitlabonly hands over togh auth loginorglab auth login. For Jira, which has no such tool,rig login jirastores a token, in the OS keychain unless the user explicitly chooses--store file. No config key holds a token or an account; see phase-2.5.md. - No built-in workflow. States, transitions, gates, severities and task
fields come from a workflow file; rig ships only a small
basicone. What rig enforces whatever the workflow says is listed in phase-2.md. - Harness-neutral. The CLI with
--jsonand exit codes, and later an MCP server, are the only surfaces. Nothing assumes Claude Code. scripts/push-guard.shis unchanged. It stays as the backstop for a rawgit push.rig pushis the allowed route; the guard is not extended.
Architecture¶
Three layers. Only adapters know a technology.
./
cmd/rig/ commands: policy and output
internal/forge/ port: Forge interface, PullRequest, Check
internal/store/ port: Store interface (phase 2)
internal/tracker/ port: Tracker interface (phase 3); adapters in
exec/, jira/, github/, gitlab/; trackertest/ holds the
contract test and the in-memory double
internal/forge/github adapter: runs `gh … --json`
internal/forge/gitlab adapter: runs `glab`
internal/forge/forgetest in-memory double, for tests
internal/git/ rev-parse, push, worktree list, merge-tree
internal/proc/ shell-free, time-limited subprocess
internal/config/ .claude/rig.json
- Commands (
cmd/rig) hold policy and output. Text by default,--jsonfor agents. A command never callsgh,glabor a store backend directly; it calls a port. - Ports (
internal/forge,internal/store) are interfaces in neutral types. Nothing in a port names GitHub or GitLab. - Adapters implement a port for one technology. They translate that tool's JSON and vocabulary into the neutral types.
Supporting packages:
internal/procruns a subprocess from an argument vector with a deadline. It never builds a shell string, and when the deadline passes or the context is cancelled it kills the whole process tree, not just the child: the process group on Unix, a Job Object on Windows. One narrow race remains on Windows: a descendant spawned between Start and the job assignment is not in the job and is not killed. A run that succeeds leaves its descendants running, on every platform.internal/gitwraps the handful of git calls rig needs.internal/configreads the layered config (rig config);.claude/rig.jsonis still honoured, and the forge and the push prefixes come from it:
| Key | Meaning | Default |
|---|---|---|
forge |
github or gitlab |
detected from the origin host |
host |
forge host, for self-hosted instances | the origin host |
pushPrefixes |
branch prefixes rig push may push |
["task", "record"] |
Install with go install github.com/AindriuB/rig/cmd/rig@<tag>. A caller
that installs rig for its users can pin a tag and check rig version against
the minimum it needs.
The contract between rig and its callers¶
A caller talks to rig only through its commands, their exit codes and their
--json output. It never imports rig's code or reads its files, and rig
never reads the caller's. That is what lets rig live in another repository and
be versioned on its own.
rig version prints a semantic version (0.1.0 for phase 1, 0.3.0 with
phases 2 and 2.5, 0.4.0 with the first part of phase 3) and exits 0. A
new command, flag or JSON field raises the minor version. A change to
anything in the tables below raises the major version.
Stable commands and exit codes
| Command | Exit codes |
|---|---|
rig version |
0 |
rig update [--check] [--to <version>] [--json] |
0 updated, or already current (with --check: no newer release, or the target is before 0.5.2); 1 refused (the latest release is older than the running rig, --to names a version before 0.5.2 or one that is not a version, or the binary's directory is not writable, or another update is in progress), or with --check a newer release exists; 2 a usage error (an extra argument, an unknown flag, or --to with no value), a network error, a failed check, or with --check a --to that is not a version |
rig push <task\|branch> [--worktree <path>] |
0 pushed; 1 git ran and the push failed; 2 refused, git push never started |
rig clean [--apply] [--online] [--fetch] [--dropped] [--min-age <dur>] [--keep <branch>]... [--include-ignored] [--no-open-files-check] [--no-sizes] [--json] [--repo <dir>] [--branch <exact> [--sha <sha>]] |
0 the run finished and nothing failed (kept items are not failures); 1 at least one item failed under --apply (the rest still run), or, with --branch, the target was kept or --sha did not match; 2 usage or environment error: not a git repo, unknown default branch, forge unreachable with --online, bad config, a bad --min-age, or --sha without --branch |
rig pr view [<pr\|branch> \| --task <id>] [--json] [--repo <dir>] |
0; 2 on any error, including no such pull request |
rig pr checks [<pr\|branch> \| --task <id>] [--json] [--repo <dir>] |
0; 2 on any error |
rig pr list [--mine] [--head <branch>] [--state open\|closed\|merged] [--limit <n>] [--json] [--repo <dir>] |
0; 2 on any error |
rig pr open --head <branch> --title <text> [--base <branch>] [--body <text>] [--draft] [--repo <dir>] |
0; 2 on any error |
rig pr wait <pr-number \| --run <run-id>> [--repo <dir>] |
0 green; 1 red; 2 error or timeout |
rig status [--json] |
0; 2 on a usage error |
rig task new --slug <s> --title <text> [--body <text> \| --body-file <path>] [--field <name>=<value>]… [--json] [--repo <dir>] |
0; 2 on any error |
rig task new --from [<kind>:]<key> [--state <s>] [--slug <s>] [--field <name>=<value>]… [--json] [--repo <dir>] |
0, also when the issue is already linked (the existing task is printed and a line goes to stderr); 1 --state is not an intake state, nothing written; 2 on any other error, including no usable tracker and a --field the tracker owns |
rig task show <task> [--findings] [--notes] [--history] [--children] [--format <text\|json\|markdown> \| --json \| --markdown] [--repo <dir>] |
0; 2 on any error, including two different formats |
rig task edit <task> [--json] [--repo <dir>] |
0 saved, or nothing changed; 1 a field changed underneath the edit, or the edit changes a field the linked tracker owns, nothing written; 2 on any error, including no terminal and no $VISUAL/$EDITOR, or a file that does not parse |
rig task list [--state <s>]… [--all] [--parent <task> \| --roots \| --tree] [--format <text\|json\|markdown> \| --json \| --markdown] [--repo <dir>] |
0; 2 on any error, including two different formats and more than one of --parent, --roots, --tree |
rig task parent <task> <parent\|none> [--json] [--repo <dir>] |
0; 1 the parent does not exist or would make a cycle, nothing written; 2 on any error |
rig task link <task> [<kind>:]<key> [--json] [--repo <dir>] |
0; 1 the issue is already linked to another task, nothing written; 2 on any error. If the link is written and the refresh after it fails, exit 2 and the link stays |
rig task unlink <task> [--json] [--repo <dir>] |
0; 1 the task is not linked; 2 on any error |
rig task start <task> [--task-file <path>] [--json] [--repo <dir>] |
0 made; 1 refused (no task file and no owns field, or the path or branch is taken), nothing created; 2 usage or any other error, and what was half made is removed again |
rig task finish <task> --sha <sha> [--json] [--repo <dir>] |
0 merged (the worktree is kept, with the reason, when it could not be removed); 1 refused, or a merge conflict that was aborted, nothing changed; 2 usage (<sha> must be the full commit id, 40 or 64 lowercase hex; a branch name, HEAD or an abbreviated id is refused) or any other error |
rig task move <task> <state> [--sha <sha>] [--pr <n>] [--reason <text>] [--json] [--repo <dir>] |
0 moved; 1 refused by a gate or the workflow, nothing written; 2 on any error |
rig task set <task> --field <name>=<value>… [--json] [--repo <dir>] |
0; 1 a field changed underneath, or the field is owned by the tracker the task is linked to, nothing written; 2 on any error |
rig task count <task> <counter> [--json] [--repo <dir>] |
0; 2 on any error |
rig task drop <task> --reason <text> [--actor <name>] [--once <k>] [--json] [--repo <dir>] |
as rig task move to the workflow's drop state: 0 moved; 1 refused (no drop state, no transition into it, or a gate), nothing written; 2 on any error, including no --reason |
rig task is <task> <state> [--repo <dir>] |
0 the effective state is <state>; 1 it is not; 2 on any error |
rig task landed <task> [--sha <sha>] [--online] [--json] [--repo <dir>] |
0 landed; 1 not landed; 2 usage or any other error, including an unknown default branch, an unreachable forge under --online, and a --sha that is not a full commit id |
rig task log <task> [--json] [--repo <dir>] |
0; 2 on any error |
rig finding add <task> --severity <sev> --summary <text> [--path <p[:line]>] [--key <k>] [--field <name>=<value>]… [--json] [--repo <dir>] |
0, also for a duplicate; 2 on any error |
rig finding list <task> [--status <s>]… [--blocking] [--json] [--repo <dir>] |
0; 2 on any error |
rig finding set <task> <finding> --status <s> [--json] [--repo <dir>] |
0; 2 on any error |
rig note add [<task>] --kind <k> --text <text> [--json] [--repo <dir>] |
0; 2 on any error |
rig note list [<task>] [--kind <k>] [--limit <n>] [--json] [--repo <dir>] |
0; 2 on any error |
rig workflow show [--tree \| --graph \| --json] [--repo <dir>] |
0; 2 on any error, including more than one of --tree, --graph and --json |
rig workflow validate [<file>] [--json] [--repo <dir>] |
0 valid; 1 invalid; 2 on any error |
rig workflow explain [<file>] [--json] [--repo <dir>] |
0; 2 invalid file or any error |
rig workflow try [<file>] [--json] [--repo <dir>] |
0 every move can be taken, every state is reached and none is a dead end; 1 a move is unreachable, a state has no move reaching it or a non-final state has no way out; 2 on any error. Gates that need the outside world are assumed to pass and reported as assumed |
rig workflow diff <file> [--json] [--repo <dir>] |
0 no task stranded; 1 some task stranded; 2 on any error |
rig next [--who agent\|human] [--limit <n>] [--json] [--repo <dir>] |
0; 2 on any error |
rig context <task> [--budget <tokens>] [--format <text\|json\|markdown> \| --json \| --markdown] [--repo <dir>] |
0; 2 on any error, including two different formats |
rig config get <key> [--global\|--repo\|--local] [--json] |
0; 1 not set; 2 error or unknown key |
rig config set <key> <value> --global\|--repo\|--local |
0; 2 on any error |
rig config unset <key> --global\|--repo\|--local |
0, also when not set; 2 on any error |
rig config list [--global\|--repo\|--local] [--show-origin] [--json] |
0; 2 on any error |
rig tracker pull <key> \| --query <q> \| --label <l> [--children[=<depth>]] [--limit <n>] [--state <s>] [--json] [--repo <dir>] |
0; 1 --state is not an intake state, before anything is read; 2 on any error, and at the end if any issue failed (the others are still made) |
rig tracker refresh [<task> \| --all] [--dry-run] [--json] [--repo <dir>] |
0; 2 on any error, and at the end if any task failed (the others are still refreshed) |
rig tracker report <task> [--status] [--comment pr\|state\|summary] [--include findings\|notes]… [--dry-run] [--actor <name>] [--once <k>] [--if-linked] [--json] [--repo <dir>] |
0, also when an earlier report already sent the same (skipped), and with --if-linked when the task has no tracker link or the repository has no tracker (nothing sent, nothing written); 1 the task's state has no tracker.report.status entry, the tracker has no transition to that status, or --comment pr and the task has no pull request, with nothing sent; 2 on any other error, including no tracker, an unlinked task, and a comment that failed after the status was sent (the status is recorded) |
rig tracker push <task> [--tree] [--dry-run] [--actor <name>] [--json] [--repo <dir>] |
0 pushed, or nothing to push (every selected task already linked, and no linked child still waits to be attached to its parent); 1 refused before anything is created: a type outside tracker.push.types, a depth beyond tracker.push.levels, a type the tracker lacks or places not below its parent's, an unlinked parent not in the run, a tracker that cannot create; 2 on any other error, including a create that failed part way (what was made stays linked) and a linked child whose parent attach is still incomplete or cannot be confirmed |
rig tracker show <key> [--json] [--repo <dir>] |
0; 2 on any error |
rig tracker status [--json] [--repo <dir>] |
0, also when the login does not work (it says so); 2 on any other error |
rig hooks start [--json] [--] <cmd> [args...] |
0; 2 on any error |
rig hooks deliver [--follow \| --json] [--repo <dir>] |
one-shot: 0 nothing parked or skipped; 1 at least one event parked or skipped; 2 on any error (2 wins); --follow with --json is 2 |
rig hooks status [--json] [--repo <dir>] |
0; 2 on any error |
rig hooks retry <hook> [--repo <dir>] |
0; 1 an unknown or inline hook; 2 on any error |
rig hooks skip <hook> <event> [--repo <dir>] |
0; 1 an unknown or inline hook, no such parked event, or a live runner holds the hook; 2 on any error |
rig hooks init <hook> [--json] [--repo <dir>] |
0 saved at the current tips; 1 an unknown or inline hook, one that already has a cursor, or a from: start hook; 2 on any error |
rig init --template <name> [--out <file>] [--force] [--json] |
0 written; 1 the file exists and no --force; 2 no or unknown template, an invalid result, or any other error |
rig login |
0; 1 a login failed; 2 on any error |
rig login github\|gitlab\|jira [--url <site>] [--user <email>] [--token] [--repo] [--store keychain\|file] |
0; 1 the login failed or Jira rejected the token, nothing stored; 2 on any error |
rig login status [--json] |
0; 2 on any error |
rig logout jira [--url <site>] [--repo] |
0, also when already logged out; 2 on any error, including a store that could not be checked when the entry was found nowhere |
rig logout github\|gitlab |
2: prints the gh/glab command that does it |
rig update --json prints one object: {current, target, action, path,
check?}. action is updated, up-to-date, available, refused or
failed; check is signature, checksum or version and is present only
when that check failed. Without --json the one-line message is printed.
Self-update. rig update takes releases from one fixed source, the
AindriuB/rig releases on the GitHub API. No flag, environment variable or
config key changes it. Every request, and every redirect, must be https to
api.github.com, github.com, objects.githubusercontent.com or
release-assets.githubusercontent.com on the default port, or rig refuses it.
Drafts and prereleases are never installed. rig downloads SHA256SUMS,
SHA256SUMS.sig and the platform binary, then verifies in this order: the
Ed25519 signature (a raw 64-byte .sig) over SHA256SUMS against the keys
built into rig; the binary's SHA-256 against its SHA256SUMS line; and the
staged binary's rig version, which must print the target version. Only then
is the file replaced. The embedded keys are a list, so a key can be rotated.
update.auto (off, notify, install; default off) is read from the
global config only. After a command returns, rig checks for a release at most
every 24 h (2 s timeout) and prints one stderr line. It is silent in CI, when
stderr is not a terminal, with machine output (--json or --format json)
and offline, and never changes the exit code.
An update takes a lock on a file beside the binary, .<binary name>.update.lock
in the binary's directory. rig update and the automatic install take the same
lock. A second rig update is refused with another update of <binary> is in
progress and exit 1; the automatic install skips silently, with no stderr line
and no change to the exit code.
The file is never deleted; the kernel drops the lock when its holder exits.
An unknown flag is always exit 2: rig never ignores an argument it does not
understand. In the phase-2 commands, exit 1 means refused by a gate or the
workflow with nothing written, and exit 2 covers usage errors, an unknown or
ambiguous task, a bad workflow file, and store or git errors. The commands'
flags and behaviour are described in phase-2.md and
phase-2.5.md, and the workflow file in
workflows.md. RIG_ACTOR names who acted and RIG_WORKFLOW
the workflow to use. The commands that write the store (task new, edit,
move, set, count, parent, link, unlink; finding add, set;
note add; tracker pull, refresh, report, push) also take --actor <name>, or its alias
--role <name>, which beats RIG_ACTOR and git's user.name for the actor
stamped on the events; an empty or control-character value, or the two flags
with different values, is exit 2 with nothing written, and every other command
rejects them as unknown options (exit 2); RIG_JIRA_TOKEN overrides a stored Jira token at use
time.
Hooks and the event feed (0.7.0). A hook is given
{"format":1,"event","task","effective"} on standard input, and rig events
--json prints the same object per line without effective. format is the
payload's version. New event kinds and new event fields are additive, a
kind:* consumer ignores kinds it does not know, and a change to an existing
kind's data bumps the event's v. A write made inside a hook records a
cause (event, hook, depth), with the depth read from the log, and a
write at depth 3 runs no inline hooks. Hooks get an allowlisted environment,
plus RIG_ACTOR=hook:<name> and RIG_HOOK_*. The full reference is
hooks.md.
Stable text output
rig pr wait, green: exactly one line,CI green: PR #<n>orCI green: run <id>. Red:CI red: …first, then the failed names, then at most 40 log lines after--- log tail ---. Errors go to stderr with the prefixci-wait:.rig pr list, and the pull request lines ofrig status:#<n> <ci> <head> <title, at most 50 characters>, thenconflictanddraftwhen they apply.rig push, on success:pushed <branch> to origin.rig task start, on success, exactly four lines, with these paddings:
WORKTREE: <worktree path>
BRANCH: <branch>
BASE: <base branch> @ <short sha> (<local|origin/<base branch>>)
OWNS: enforced from <task file path>
<branch> is task/<slug> for a task with a <slug>.md task file, and for a
name the store does not know. A store task with no such file starts on the
branch it records, else the workflow's template branch (for example
task/<short>-<slug>): the one rig task show prints. OWNS names the
task file, or, for a store task with no file but an owns field, a
generated file in the worktree's git directory. <task> is any handle the
store knows (id, short id or slug).
The base branch is origin's default branch, else main, master,
trunk or develop, else the current branch. The task starts from the
newer of local <base> and origin/<base>, and BASE names the one used:
local or origin/<base>. When the two have diverged, neither contains the
other, the task starts from local <base> and rig prints
rig: local <base> and origin/<base> have diverged: started from local <base>
on stderr. At a detached HEAD with no default or current branch the task
starts from HEAD: BASE reads HEAD @ <short sha> (HEAD), with no
local or origin comparison. The worktree is
<worktrees.root>/<repository directory name>/<slug>.
- rig task finish, on success: MERGED: <branch> @ <short sha> -> <base>,
then REMOVED: <worktree>, or KEPT: <worktree> (<reason>) when the
worktree could not be removed or the branch moved during the merge (its
later commits are not merged, and the branch is kept).
The kit-task marker. rig task start writes the file kit-task in the
new worktree's own git directory (git rev-parse --absolute-git-dir there),
where git never commits it. A caller that guards file ownership (the kit's
owns-guard) reads it to find the task file. Its contract: one line, the path of
the task file with forward slashes even on Windows, ending in a single LF, with
no byte order mark. The path is absolute: rig finds the file in
docs/plan/tasks of the main checkout or its enclosing workspace repository,
or resolves --task-file against the working directory. If the file cannot be written,
rig task start removes what it made and exits 2, so a worktree is never left
without its marker.
Stable JSON fields
A pull request, from rig pr view --json and each element of
rig pr list --json:
| Field | Value |
|---|---|
number |
integer |
url, title, head, headSha, base |
strings |
state |
open, closed or merged |
draft |
boolean |
mergeable |
mergeable, conflicting or unknown |
mergeSha |
the merge commit; present only once merged |
ci |
red, running, green or none |
checks |
array of {name, state, url}; state is pass, fail, cancel, pending or skipped |
rig pr checks --json is {number, ci, checks} with the same meanings.
rig status --json is {handoff, tasks, worktrees, prs, prsError}:
handoff is {written, lines} or absent; tasks is an array of task file
names without .md; each worktree is {path, branch, ahead, dirty}; prs
holds pull requests as above; prsError is present when the forge could not
be reached, and the rest of the output is still valid. It also has store,
the view of the local store, which needs no network:
{tasks, findings, error?}. tasks are the tasks not in a final state, in
the order a task moves through the workflow. Each is {id, short, slug, title,
state, parent?, external?}, where state is the effective state, parent is
the parent's short id and external is {kind, key}; findings is {open, byTask}, with byTask mapping a task's
short id to its open findings. error is set, and tasks empty, when the
store could not be read.
rig task landed --json is {slug, sha, landed, proof}, where proof is
ancestor or forge when landed is true and empty otherwise; on exit 2 it
also carries error.
rig clean --json is always exactly one document, also on a refusal or an
error (then error is set):
{repo, default, applied, checks: {openFiles}, items, freedBytes}. checks.openFiles is
lsof, skipped (--no-open-files-check) or unavailable. Each item is
{kind, path?, branch?, task?, tip?, proof?, action, reason?, message?, bytes?,
ignored?, unlanded?}:
kindisworktree,branch,prunableorbuildDir;actionisremoveorkeepin a preview, andremoved,keptorfailedwith--apply.proofisancestor,forge,droppedorrecorded.ignoredlists{path, bytes?}for the ignored files in a worktree;unlandedis a dropped item's count of commits not on the default branch.freedBytesis measured with--applyand estimated in a preview.bytesand sizes are left out with--no-sizes.- A removed branch keeps its tip in
tip, because deleting the branch also deletes its reflog.
rig clean previews by default and removes nothing without --apply. Reason
codes for a kept item:
- Worktrees and branches:
current-checkout,default-branch,not-rig-task,detached,task-open,unproven,branch-unproven(the worktree went, the branch stays),dropped(without--dropped),dirty,ignored-files,locked,busy,recent,open-files,open-files-unknown,keep,moved,checked-out(the branch is checked out in a worktree, or in the main checkout) andgit-refused(git's own message is inmessage). - Stale worktree metadata (
prunable):prune-blocked, andlocked. A locked worktree whose folder is missing is shown as a keptlockedentry and is never pruned. - Build folders:
owned,ambiguous,symlink,outside-checkout,contains-worktree,tracked,not-ignored,recent,open-filesandopen-files-unknown.
The open-files guard runs lsof -n -P -F n once per sweep, with a 30-second
limit. Only exit 0 with output counts. Exit 1 with empty output means "unknown",
and so does any other non-zero exit, a timeout or a missing lsof: the
check is unavailable and every item is kept as open-files-unknown until
--no-open-files-check is given. lsof only sees processes the user may inspect.
Build output config. clean.buildDirs and clean.disposable widen what
rig clean deletes, so they are read only from the global config
(~/.rig/config.json), never from a repository's .rig/config.json (a repo
file that sets them is ignored with a warning). The global file's per-repo
repos[...] section may set them. Without them rig deletes no build
folders and no ignored files, except when --include-ignored is passed.
{ "clean": {
"buildDirs": ["target/wt-{n}", "target/wt-{n}-*"],
"disposable": ["target/", "node_modules/"] } }
clean.disposablelists ignored paths inside a worktree that may go with it, relative to the worktree root. An entry ending in/covers that folder and everything under it; any other entry matches one path exactly.*matches within one path segment. Without a match, an ignored file keeps the worktree (ignored-files) unless--include-ignoredis given.clean.buildDirslists folders in the main checkout that belong to a task's worktree. A pattern is relative: an absolute pattern or one with..is rejected.{n}matches a run of digits,{slug}one path segment and*anything within one segment, sowt-{n}matcheswt-21but notwt-214x.- A worktree's keys are its folder name and the last segment of its branch; its
number is the leading digits of either (
spike/201-gpui-limitsis 201). A folder isownedwhile any registered worktree matches it, rig task or not, locked or kept. A folder that more than one worktree could own isambiguous. - An unowned folder goes only if it is not a symlink, is inside the main
checkout, holds no tracked file, is git-ignored, has nothing newer than
--min-age, and has no open files. It needs no landing proof.
rig task start --json is {worktree, branch, base, baseSha, taskFile}.
rig task finish --json is {merged: {branch, sha, base}, kept?: {worktree,
reason}, removed?}.
Task JSON. The task printed by rig task show --json, rig task list
--json and the other task commands gains parent (a task id; absent when
there is none) and external (absent when the task is not linked):
external field |
Value |
|---|---|
kind, key |
the tracker kind (jira, github, gitlab or exec) and the issue key |
host, project, url, type |
strings, each left out when empty; type is the tracker's own level label (epic, Sub-task) |
owned |
the rig fields the tracker owns |
syncedAt, rev |
when the task was last synced, and the tracker's revision of the issue then |
drift |
the owned fields whose local value differs from the last snapshot; [] when none |
rig task show --children --json is the task with a children array of tasks.
Tracker JSON.
rig tracker pull --jsonis{items, skipped}; an item is{task, key, existing, parent, warnings}, wheretaskis a task as above andparentis the short id of its parent task, or"".rig tracker refresh --jsonis{tasks}; an entry is{task, key, status, changed, replaced, error?, warnings?}.statusisunchanged,updated,goneorerror;changedlists the fields that changed;replacedis a list of{field, lost}for each local edit the refresh overwrote.rig tracker report --jsonis{task, key, status, comment, skipped?, dryRun?, warnings?};statusis{from, to}andcommentis{kind, id}, eachnullwhen that part was not sent. With--dry-runnothing is sent:statushas onlyto, andcommenthas no id but abody.rig tracker push --jsonis{dryRun?, pushed, skipped, notPushed}, each a list of{task, title, key?, url?, type?, parent?, status, error?, payload?}.taskis the task's short id.statusiscreated,linked(an earlier push's issue, found by its marker),created-with-error(the issue exists and is linked, but the create reported an error),skipped(the task was already linked and needs nothing),created-not-attached(the issue was made and linked but attaching it to its parent failed),verified(a retry found the child already under its parent and recorded it),attached(a retry attached the child and read it back),attach-failed(a retry's attach failed, or the tracker cannot attach),not-verified(the attach was sent but the read-back failed or did not show the parent),wrong-parent(the child is under another parent on the tracker; rig does not move it),would-verify(--dry-runof a retry),would-create(--dry-run) ornot-pushed(the run stopped before it; the first haserror).payloadis on--dry-runonly:{type?, title, body, acceptance?, labels, parentKey?}, exactly what a real run would send.rig tracker show --jsonis the issue:{key, url, title, description, acceptance, priority, assignee, labels, type, status, parent, rev}.rig tracker status --jsonis{kind, trusted, capabilities, login};capabilitiesis{parent, children, types, search, comment, setStatus, levels}ornull, andloginis{ok, error?}. For a tracker that can check its configured project (Jira) there is alsoproject,{key, exists, empty}, and the text output gainsproject: RIG ok,project: RIG not foundorproject: RIG ok (no issues yet); a missing project does not change the exit code. When the check fails with an error,projectis{error}and the text output saysproject: not checked: <error>.
Tracker push. rig tracker push <task> creates an issue on the
configured tracker for an unlinked task, and with --tree for its unlinked
descendants, parents first, then links each task to its issue. See
phase-3.5.md for what is sent and the failure cases.
- Only the task's
type, title, body, acceptance criteria (Jira, and only withtracker.jira.acceptanceField), a parent issue key and one marker label leave the machine. Nothing else of the task does. - A linked task is never created again, so a re-run never makes a second issue.
It is skipped unless rig made the link and the parent attach is still
pending; then the push resumes that attach (read back, attach if needed,
record
parentKey) and creates nothing. A link made by hand, byrig task link, is skipped. One task is created at a time; the first failure stops the run and exits 2, and the rest are listed asnot-pushed. - Before each create rig writes a
tracker-pushevent{marker, kind, host?, project?}(the marker label and the tracker). After the create, or after a link found by marker, rig writes a secondtracker-pushrecord withkey(the issue) andparent(the parent the attach is confirmed under) orattach(the parent it still has to be attached to). Rig owns a link only when a keyed record names its key and carries the stamp of the link event (sequence one higher, same time). On replay a keyed record withparentsets the link'sparentKeyif the link has the same kind, host and key. An unkeyed record is the intent. A task with that event and no link may already have an issue: the next push searches the tracker for the marker, and links what it finds instead of creating. A task's lock file under the git common directory (rig/push/<task>.lock) stops two pushes of one task at once. An older rig skips the event kind. - After the create the task gets an
externallink and atracker-syncsnapshot in one write, so the tracker owns the owned fields from then on. - A resume writes its
parentKeyrecord only while the attach is still pending, checked under the lock on the log it commits against. It leaves an existingtracker-syncsnapshot alone, so a later refresh compares against the values the task was last synced with. It writes one, from its last read, only when the link has none (SyncedAtzero) and that read has aRev. A GitHub parent in another repository resumes aswrong-parent. --dry-runcreates and writes nothing and prints each payload.
Tracker report. rig tracker report sends a task's progress to the issue
it is linked to (the task must be linked to an issue of the configured tracker,
else exit 2). With neither --status nor --comment it is --status --comment
state.
- The status is the workflow's
tracker.report.statusentry for the task's effective state, sent with the tracker's set-status call. It is sent before the comment, so a refusal means nothing has left the machine. A tracker that cannot set a status (or cannot comment) gives a warning and the other part is still sent; an unsupported status is dropped before the skip check, so a repeat whose other part is skipped reportsskipped. - The comment is one of three fixed templates, and nothing else of the task (title, body, fields) is ever sent:
pr:rig: pull request for task <short>: <url>. The URL comes from the forge, by the task's recorded pull request number.state:rig: task <short> is now in state <state>.summary: thestateline, thenCounters: <name>=<n>, ...(names sorted; left out when the task has none), thenPull request: <url>(left out when the task has none). If the forge read fails, the comment is sent without thePull request:line and the run warns.--include findingsappends a blank line,Open findings:and one- <short> <severity> <summary>line per open finding (nothing when there are none).--include notesappends a blank line,Notes:and one- <kind>: <text>line per note, oldest first. Line breaks inside a summary or note are folded to a space.- Each real run that sends something writes one
tracker-reportevent{kind, key, status?: {from, to, asked?}, comment?: {kind, id, digest}, at}, recording only what was sent;digestis the hex SHA-256 of the comment body, and the body itself is not stored.askedis the status name the report requested (tois the one the tracker reached, which may be spelled differently, as GitLab'sopenbecomesopened). An older rig skips the kind. - A part is skipped when the latest earlier report for the same issue, written
since the task's latest link event, sent the same thing: the status when the
requested name equals its last sent
askedorto(case and surrounding spaces ignored), the comment when the latest comment of the same kind has the same digest. Two report runs at once can both send: there is no lock. When every requested part is skipped nothing is sent, no event is written, and the output saysskipped("skipped": truein JSON).skippedmeans the repeat check dropped a part: when the tracker's capabilities alone empty the request, the run exits 0 with the warnings and the normal (or dry-run) line, andskippedis false.--if-linkedis a different skip: for a task with no tracker link, or a repository with no tracker, it sends nothing, writes no event and exits 0, printingskipped: <slug> is not linkedorskipped: no tracker configured. With--jsonit prints{"skipReason": "not linked"}or{"skipReason": "no tracker"}and does not setskipped, which stays the boolean above. --dry-runcalls no tracker method that writes, and writes nothing; it printsstatus: <name>andcomment (<kind>):followed by the exact body a real run would send, with the same skip rules and warnings applied (a tracker that cannot set a status or comment, or whose capabilities cannot be read).- It never writes planning fields. A comment that fails after the status was sent leaves the status recorded and exits 2; the next run sends the comment.
Markdown format. --format markdown (alias --markdown) is stable like
JSON: sections and fields are only added; removing or reordering one is a major
change. --format json is the alias of --json. Two different formats, or an
unknown one, are exit 2. Text output stays free-form. Every Markdown output is
UTF-8 with LF line endings, one trailing newline, no ANSI codes, no wrapping,
and times in RFC 3339 UTC. A field with no value is left out, and a
single-line value has its line breaks turned into one space.
rig task show:# <title>, then a bullet block with these labels in this order, each only when it has a value:id,slug,state,recorded state,branch,pr,head,reason,parent,external,created,updated. Then H2 sections in this order:Body,Fields,Counters,Findings(with--findings),Notes(--notes),History(--history),Children(--children).Body,FieldsandCountersare left out when empty; a requested section with nothing in it printsnone.Bodyis a blockquote: line endings become LF and every line starts with>(an empty line is>). So a task body, which may come from a tracker, cannot open a heading, a fence or an HTML block of its own.FieldsandCountersare- name: valuelines sorted by name. A finding is- <short> [<severity>] <status>: <summary> (<path>); a note is- <time> [<kind>] <text>.rig task list:# Tasks, then a bullet per task,- <short> [<state>] <title> (<slug>), followed by— <key>for a linked task and← <parent short>for a task with a parent. No tasks printsnone.--treeindents each child under its parent in place of the←.rig context: H2 sections named as the JSONsections[].name(Header,Body,Findings,Paths,Overlap,History,Commits); a section the budget hid is left out.Bodyis a blockquote as above and the others are-bullets. An omitted count is the line_… <n> more_. TheHeaderhasparent:andexternal:rows for a task that has them. The budget is counted against the Markdown's own bytes; text and JSON are counted as before.
What rig push does and does not guarantee¶
Any command line that starts rig push can only make a non-forced push of
one local branch named <prefix>/<name> to the branch of the same name on
origin. It cannot name main or any bare branch, a tag, a refspec, another
remote, or a force or delete option. Exit 2 means git push never started.
Two things sit outside that guarantee.
.claude/rig.jsonis the user's file. ItspushPrefixesdecide which prefixes count, so whoever can write it can widen the pushes: torelease/x, say, though still never to a bare branch, a tag or a force. In a bare layout the worktree's own files apply, as forrig config. An agent must not edit it. The project settings template makes any Edit or Write of.claude/rig.json, in the project or in a worktree below it, and any shell command that namesrig.json, ask first (tests/rig-settings.batspins those rules). A permission rule matches text, so this is a barrier, not a proof: a shell command can build the file name without spelling it, and two commands the template already allows can write and run a file (git log --output=<path>andrg --pre <program>). Narrowing those allow rules is a separate change.- Git's own configuration is not constrained. A pre-push hook, or
remote.origin.receivepack, runs whatever it says during any push, and an agent can set either withgit config.rig pushruns the repository's hooks like any push does, so it does not close this. The rawgit push origin task/<name>form the push guard allows has the same limit. Closing it would mean pushing with hooks disabled, which would also disable the hooks a project relies on; that trade has not been made.
The forge port¶
type Forge interface {
ViewPR(ctx context.Context, ref string) (PullRequest, error)
ListPRs(ctx context.Context, opts ListOptions) ([]PullRequest, error)
CreatePR(ctx context.Context, in CreatePRInput) (PullRequest, error)
Checks(ctx context.Context, pr int) ([]Check, error)
WaitChecks(ctx context.Context, target WaitTarget) (WaitResult, error)
FailedLogs(ctx context.Context, target WaitTarget, failed []Check) ([]LogLine, error)
}
type PullRequest struct {
Number int
URL string
Title string
State PRState // open | closed | merged
Draft bool
Head string // head branch
HeadSHA string
Base string
Mergeable Mergeable // mergeable | conflicting | unknown
Checks []Check
}
type Check struct {
Name string
State CheckState // pass | fail | cancel | pending | skipped
URL string
}
WaitTarget is a pull request number or a CI run id. Later phases add Merge,
Comment and Reviews.
A pull request's overall CI state is derived from its checks in one place, in
the port, so both adapters report it the same way: red if any check failed or
was cancelled, else running if any is pending, else green if there is at
least one check, else none.
Phase 1 commands¶
| Command | What it does | Exit codes |
|---|---|---|
rig push <task\|branch> [--worktree <path>] |
Pushes one loop branch to origin |
0 pushed, 1 rejected by the remote, 2 refused |
rig pr view\|list\|checks |
Prints neutral output from the forge | 0, 2 on error |
rig pr open --head <branch> … |
Opens a pull request. Never pushes, and takes its body only from --body, never from a file |
0, 2 on error |
rig pr wait <pr> or --run <id> |
Blocks until CI finishes | 0 green, 1 red, 2 error or timeout |
rig status [--json] |
The session brief, worktrees and one line per open PR | 0 |
rig push is the security-relevant command. It resolves a task to its
branch, trying in order: (1) a task in the store that matches the target
exactly (id, short id or slug): task/<slug> when it has a task file named
<slug>.md, else its recorded branch, else the workflow's template branch,
else task/<slug>; (2) a task file named exactly <target>.md:
task/<target>; (3) the prefix lookup, task/<target>-<slug> from
docs/plan/tasks/<target>-*.md (the same lookup as derive_slug in
scripts/_wt-common.sh), then a local task/<target>-* branch. A store match
that is ambiguous (two tasks share the slug) falls through to step 2: if
<target>.md exists the push is task/<target>, otherwise it is refused with
exit 2 naming the ambiguity. Any other store error is exit 2; a repository with
no store yet skips step 1. A target with a / is a branch name and skips
this resolution. The result then goes through the checks below, unchanged. It
refuses, with exit 2 and without running git, anything that is not a plain
branch name under a configured prefix: a refspec (a:b), a + prefix, a ..
segment, a tag, any force or delete flag, and any unknown flag. What remains is
run as
git -C <worktree> push -u origin <branch>:<branch> — an argument vector, so
there is nothing for a shell to reinterpret.
rig pr wait keeps the contract of scripts/ci-wait.sh, so callers do not
change: the same exit codes, CI green: PR #N as the only line when green, the
failed checks and a 40-line log tail when red, and CI_WAIT_TIMEOUT (seconds,
default 3600). ci-wait.sh becomes a wrapper that execs rig pr wait.
rig status prints one line per open pull request in the format
commands/status.md already uses:
#N red|running|green|none branch title [conflict] [draft].
Phase 1 is read-only on documents. State still comes from the existing
docs/plan files, git and the forge.
The store and workflows (phase 2)¶
A store holds work in progress outside the code tree: one append-only event
log per task under refs/rig/tasks/<ULID>, local to the clone unless the
user opts in to sharing it. A task's state is a fold over its events. Which
states exist, which transitions are allowed and which gates guard them come
from a workflow file, not from rig. Tasks, findings and notes carry typed
fields the workflow declares. phase-2.md has the format, the
commands and the extension points.
The state machine this section used to define (planned → implementing → reviewed → verified@sha → pr_open → ci_green → ready → merged) is now an example workflow file, shown in phase-2.md as the worked example.
Phases¶
| Phase | What it delivers |
|---|---|
| 0 | This document, and a baseline of permission prompts and tokens per task |
| 1 | rig push, rig pr, rig status, rig version; the github and gitlab adapters |
| 1.5 | cli/ moves to its own repository, AindriuB/rig, with its history |
| 2 | Shipped in 0.3.0. Generic core: the store port and git-ref backend, workflow files with gates and hooks, rig task, rig finding, rig note, rig workflow, rig next, rig context. An example review loop is a test fixture, not built in |
| 2.5 | Shipped in 0.3.0. rig config (global, per-repo and local scopes; forge and tracker settings) and rig login/rig logout with keychain-held tokens |
| 3 | Views and trackers, see phase-3.md. 0.4.0 is built: --format markdown for task show, task list and context; task parent and external links (task parent, link, unlink, list --parent\|--roots\|--tree, show --children); a tracker port with github, gitlab, jira and exec adapters; rig task new --from, rig tracker pull, refresh, show and status; branch stamping with {key}; the store view in rig status; rig task start and finish with worktrees.root. 0.5.0: rig tracker report. 0.6.0: rig tracker push |
| 3.5 | Self-update and tracker push, see phase-3.5.md. 0.5.2: signed releases, rig update, update.auto. 0.6.0: rig tracker push |
| 4 | Team scale: opt-in rig sync of the store, rig claim, retention and rig gc, a search index rebuilt from refs |
| 5 | Metrics from event logs, for any workflow: time in each state, counter values, stop reasons, findings by path |
| 6 | An MCP server over the same core; each workflow transition becomes a typed tool |
| Later, unscheduled | HTML views and templates; an importer for docs/plan task files as a program the user runs. Tracker intake in phase 3 covers most of the importer's use |
| 1.0 | Phase 1's compatibility parts (.claude/rig.json, claude-handoff.md and docs/plan/tasks reads, default push prefixes) move behind config or are dropped, as a major change |
README, architecture, conventions, release notes and ADRs stay in the tree throughout. Plans, tasks, findings and history are what move into the store, for the projects that choose to use it.