Skip to content
safran

Type to search. Enter opens the first result.

    Agent jobs: the harness commands

    This page documents the safran harness commands: every flag, real output, the --json shapes, exit codes and the mistakes people make. They queue jobs for an unattended coding agent, work the queue, and hand each job to you as a local branch. The commands are thin shells over @safran/harness; the job harness guide explains what happens to a job and what the checks mean.

    None of these commands pushes a branch, opens a pull request or posts to a tracker. A job ends as a local branch and a drafted pull request text.

    From nothing to a branch

    safran harness project payments-api --tickets PAY   # write the project into the profile
    safran harness doctor --gates                       # run setup and gates on the base branch
    safran harness add PAY-1423                         # queue a job
    safran harness run                                  # work the queue until Ctrl-C
    safran harness waiting                              # what waits for you
    safran harness approve 1                            # or: safran harness back 1 "what to change"

    The examples on this page were captured in /work/acme with the profile named by SAFRAN_PROFILE=safran.yaml, which is why the commands Safran prints carry --profile safran.yaml. The repository is a small generated payments-api; the tickets come from a test tracker. No agent was run to write this page: a scripted program stood in for the agent CLI and wrote the files, reports and reviews it was told to write. Everything the harness itself prints is real; the sentences of the agent and the reviewer are the script's, the agent line of safran harness doctor shows the stand-in's version string, and no job has a cost. Global options (--profile, --data-dir, --json, …) are described in the CLI overview.

    $ safran harness --help
    Usage  safran harness <project | add | run | list | waiting | show | diff | approve | back | retry | cancel | pause | resume | doctor> [options]
    
      harness project  Add a repository as a harness project: its setup and gates, read from its files
      harness add      Queue jobs for the agent: ticket keys, or a sentence saying what to do
      harness run      Work the queue: an agent per job, checked, reviewed, left as a branch
      harness list     The jobs and where each one is
      harness waiting  The jobs that wait for you, and what each one asks
      harness show     One job: the request, the agent's report, the checks and the review
      harness diff     What a job changed, against the commit it started from
      harness approve  Accept a job that waits for you
      harness back     Send a job back to the agent with a note saying what to change
      harness retry    Queue a failed or cancelled job again
      harness cancel   Stop a job and remove its worktree
      harness pause    Stop new jobs from starting (running ones finish)
      harness resume   Let the queue start jobs again, after a pause or a usage limit
      harness doctor   Check that jobs can run: the agent, each project's repository, the gates
    
    Run `safran harness <subcommand> --help` for details.

    Jobs, numbers and statuses

    A job is named by its number. Every command that takes <job> accepts 12, #12 and J-12.

    Status in --jsonPrinted asMeaningWhat you can do
    queuedqueuedWaits for safran harness run.cancel
    runningrunningA runner is working on it.cancel
    reviewwaiting for youEvery check and the review let it through.approve, back, cancel
    failedfailedIt did not get through; the reason is its last error.retry, back, cancel
    cancelledcancelledStopped by a person.retry
    donedoneApproved. Final.–

    A command that does not fit the job's status fails with the code CONFLICT and exit 1:

    $ safran harness approve 1
    ✘ Job 1 is done, not review
    → Look at the job again; something else moved it.

    safran harness project

    safran harness project <repo> [options]

    Adds a repository to the profile as a harness project, with the setup and gates it reads from the repository's own files.

    What it touches. It reads the top of the checkout (package.json and its lock file, a .sln or .csproj, go.mod, Cargo.toml, pyproject.toml) and looks for AGENTS.md, CLAUDE.md, CONTRIBUTING.md, docs/ARCHITECTURE.md and README.md. It runs nothing. It writes the profile through the validator, as safran profile set does, and keeps the previous file as safran.yaml.bak. Unless the permission mode is bypassPermissions, it also adds the stack's script and test runners to harness.agent.allowed_tools.

    FlagValueDefaultMeaning
    --checkoutdirthe repository Safran manages under that nameA checkout to branch from. With it, the project name is yours to choose. ~ is expanded.
    --baserefthe repository's default branchThe ref jobs branch from, for example origin/develop.
    --ticketskey …noneTracker project keys whose tickets belong here (PAY). Repeat the flag or separate with commas.
    --dry-run–offShow what would be written, and write nothing.
    --force–offReplace a project of that name that is already in the profile.

    <repo> is the name safran repos shows; the repository must be cloned (safran sync). A project name is lowercase letters, digits and dashes.

    $ safran harness project payments-api --tickets PAY --dry-run
    · Would add harness project payments-api  bun · repos/payments-api
      base          the repository's default branch
      setup         bun install
      gates         lint (bun run lint), test (bun run test)
      context       AGENTS.md
      tickets       PAY
      also allowed  Bash(bun run:*)  Bash(bun test:*)
    $ safran harness project payments-api --tickets PAY
    ✔ Added harness project payments-api  bun · repos/payments-api
      base          the repository's default branch
      setup         bun install
      gates         lint (bun run lint), test (bun run test)
      context       AGENTS.md
      tickets       PAY
      also allowed  Bash(bun run:*)  Bash(bun test:*)
    → Read the entry in safran.yaml, then check the gates on the base branch: `safran harness doctor --gates --profile safran.yaml`.

    The first line names the stack the proposal was read from (bun, npm, pnpm, yarn, dotnet, python, go, rust or unknown) and the checkout. What is proposed per stack:

    StackRead fromsetupgates
    bun, npm, pnpm, yarnpackage.json; the manager from the lock file, else from packageManager, else npm<manager> install (npm ci with a package-lock.json, pnpm install --frozen-lockfile with a pnpm-lock.yaml)One per script found: typecheck, lint, test, as <manager> run <script>. With Bun and test files but no test script: bun test.
    dotneta .sln or .csprojdotnet restorebuild (dotnet build --no-restore), test (dotnet test --no-build)
    gogo.modnonevet (go vet ./...), test (go test ./...)
    rustCargo.tomlnonecheck (cargo check), test (cargo test)
    pythonpyproject.toml, requirements.txt or setup.pyuv sync with a uv.lock, else nonelint (ruff check .), typecheck (mypy .), test (pytest), each only when pyproject.toml or the layout shows the tool; run through uv run with a uv.lock

    What was looked for and not found is printed as ! lines (for example a package.json without a test script). A project without a gate is accepted, and safran harness doctor then fails with It has no gate: nothing but the agent's word and the review says a job works.

    JSON output

    $ safran harness project payments-api --tickets PAY --force --json
    {
      "project": {
        "name": "payments-api",
        "tickets": [
          "PAY"
        ],
        "setup": [
          [
            "bun",
            "install"
          ]
        ],
        "gates": [
          {
            "name": "lint",
            "command": [
              "bun",
              "run",
              "lint"
            ]
          },
          {
            "name": "test",
            "command": [
              "bun",
              "run",
              "test"
            ]
          }
        ],
        "context": [
          "AGENTS.md"
        ]
      },
      "stack": "bun",
      "allowed_tools_added": [],
      "notes": [],
      "written": true
    }

    project is the entry as written. allowed_tools_added is empty here because the two patterns were already in the profile from the run before. written is false with --dry-run.

    $ safran harness project payments-api
    ✘ The profile already has a harness project "payments-api"
    → Edit it in the profile, or pass --force to replace it with what is read from the repository now.

    --force replaces the whole entry with what is read now: rules, notes, known_failures and anything else you added by hand are gone. The .bak file has them.

    safran harness add

    safran harness add <text…> [options]

    Queues jobs. One job is one branch and one worktree.

    What it touches. It writes to the queue (<data dir>/harness/harness.db) and nothing else. It does not call the tracker, does not touch the repository and starts no agent: the ticket is read when the job is worked.

    FlagValueDefaultMeaning
    --projectnamethe project owning the ticket, or the only oneThe harness project the job belongs to.
    --file, -ffilenoneRead the text from a file instead of the command line.
    --branchnamefrom the requestName the branch. Only when the text makes one job.
    --baserefthe project's baseBranch from this ref.
    --kindkindfeaturefeature, fix, refactor, chore or research. A research job may end without a change; every other kind must change something.
    --priorityn20 is first. A whole number of at least 0.
    --modelnameharness.agent.modelModel for this job's work sessions.
    --dry-run–offShow the jobs and branches the text would make, and make none.

    How the text becomes jobs:

    • A line that holds only ticket keys is one job. Two keys on one line are one job for both tickets; several such lines are several jobs.
    • Anything else is one job: its first line is the title, the whole text is the request. Ticket keys inside it are attached to the job.
    • A line of --- separates jobs.

    The branch of a ticket job comes from harness.branch_template (default feature/{keys}, keys in lower case joined by -). The branch of any other job is harness/<title>-<six hex digits>, computed from the request text. A job is known by its project and branch, so the same request twice is one job:

    $ safran harness add PAY-1423 --dry-run
    · would queue  payments-api · feature/pay-1423  PAY-1423
    $ safran harness add PAY-1423
    ✔ job 1 queued  payments-api · feature/pay-1423  PAY-1423
    → Work the queue with `safran harness run --profile safran.yaml`.
    $ safran harness add PAY-1423
    ! already job 1 (queued)  payments-api · feature/pay-1423  PAY-1423
    $ safran harness add "Refuse refunds that are not whole kuruş" --kind fix
    ✔ job 2 queued  payments-api · harness/refuse-refunds-that-are-not-whole-kurus-8da66a  Refuse refunds that are not whole kuruş
    → Work the queue with `safran harness run --profile safran.yaml`.

    Adding a request whose job has failed queues that job again with one more attempt (job 3 had failed and is queued again); in any other status it is reported as already job … and left alone.

    A file with two key lines, a separator and a free-text job, added after job 1 was approved:

    PAY-1423
    PAY-1500
    ---
    Log every refused refund
    With the payment id and the reason, through the logger.
    $ safran harness add -f jobs.txt --dry-run
    ! already job 1 (done)  payments-api · feature/pay-1423  PAY-1423
    · would queue  payments-api · feature/pay-1500  PAY-1500
    · would queue  payments-api · harness/log-every-refused-refund-29b1e8  Log every refused refund

    Which project a job goes to: the one named with --project; else the one whose tickets lists the key's project; else the only project there is. Tickets of two different projects in one job are refused, because a job works in one repository.

    JSON output

    $ safran harness add PAY-1500 --dry-run --json
    {
      "jobs": [
        {
          "result": "preview",
          "project": "payments-api",
          "branch": "feature/pay-1500",
          "title": "PAY-1500",
          "ticket_keys": [
            "PAY-1500"
          ],
          "id": null,
          "status": null
        }
      ]
    }

    result is created, exists (the same request is already a job), retried (it was one, and had failed) or preview (dry run). id and status are null only for a preview of a job that does not exist yet.

    safran harness run

    safran harness run [options]

    Works the queue: for each job a worktree on a branch of its own, one agent session, then the project's gates, the diff audit, the evidence check and an independent review. What they find goes back into the same session. The layers are described in the guide.

    What it touches. It reads tickets from the tracker. In each project's repository it adds and removes git worktrees and creates the job's branch; it commits on that branch and nowhere else, and the checkout itself is never edited. It runs the profile's setup commands, gates and agent command as programs, each without a shell. It writes under <data dir>/harness/. It never pushes and never opens a pull request.

    FlagValueDefaultMeaning
    --once–offStop when the queue is empty instead of waiting for new jobs. Also stops when nothing can start: the queue is paused or held by a usage limit.

    Without --once it stays in the foreground until Ctrl-C; jobs in flight then go back to the queue at no cost of an attempt. Everything it prints goes to stderr, one line per event:

    $ safran harness run --once
    harness: 1 job queued
    job 1  Attempt 1 of 1 started
    job 1  Setting up: bun install
    job 1  Work session started
    job 1  Sent back by the rules check: [focused-test] src/refund/policy.test.ts:16: A test is focused, so the rest of its file no longer runs. Remove the focus.
    job 1  Fix round session started
    job 1  Review session started
    job 1  Ready for you on branch feature/pay-1423 (b4ef3a2aee)

    (The lines a session prints about its own tool calls are left out here: they came from the stand-in.)

    A job that cannot be worked fails without a session. Here somebody else's branch has the name the job would take:

    $ safran harness run --once
    harness: 1 job queued
    job 3  Attempt 1 of 1 started
    job 3  The branch "feature/pay-1500" already exists in the repository and was not made by this job

    The profile must be named. A profile that was only found as ./safran.yaml may queue and list jobs, and run refuses to execute what it lists, with the code FORBIDDEN:

    $ safran harness run --once
    harness: 1 job queued
    ✘ This profile was picked up from the current directory, not named by you, so the harness will not run the commands it lists
    → The agent command, `setup` and `gates` run as programs on this machine. If you trust the profile, name it with --profile or pass --allow-plugins.

    One runner per queue. A second safran harness run on the same data directory fails with A harness runner is already working this queue (process <pid>). Jobs added meanwhile are picked up by the running one.

    JSON output

    With --json nothing is printed while it runs; when it stops, one document says where the queue stands. The run below found the queue paused:

    $ safran harness run --once --json
    {
      "counts": {
        "queued": 1,
        "running": 0,
        "review": 1,
        "done": 1,
        "failed": 0,
        "cancelled": 0
      },
      "paused": true,
      "pause_reason": "paused by a person",
      "blocked_until": null
    }

    blocked_until is an ISO timestamp while the account's usage limit holds the queue.

    Exit codes

    ExitWhen
    0The run stopped normally: the queue is worked, or (with --once) only a usage limit holds it. Failed jobs do not change the exit code; read them with safran harness waiting.
    1With --once: the queue is paused and jobs are still queued. Also: the profile was not named, another runner holds the queue, or the profile could not be opened.
    130Interrupted with Ctrl-C (without --once this is how it ends).

    safran harness list

    safran harness list [options]

    The jobs and where each one is. Reads the queue only.

    FlagValueDefaultMeaning
    --statusstatus …allOnly these: queued, running, review, done, failed, cancelled. Repeat the flag or separate with commas.
    --projectnameallOnly this project.
    $ safran harness list
    job  status           project       title             branch                                              cost  updated
    1    done             payments-api  PAY-1423: Kısmi…  feature/pay-1423                                          just now
    2    waiting for you  payments-api  Refuse refunds …  harness/refuse-refu…hat-are-not-whole-kurus-8da66a        just now
    3    failed           payments-api  PAY-1500          feature/pay-1500                                          just now
    $ safran harness list --status review,failed
    job  status           project       title                                    branch                       cost  updated
    2    waiting for you  payments-api  Refuse refunds that are not whole kuruş  harness/re…ole-kurus-8da66a        just now
    3    failed           payments-api  PAY-1500                                 feature/pay-1500                   just now

    The table fits the terminal: titles are cut at the end, branches in the middle, and on a narrow terminal the branch, cost and updated columns are dropped first. cost is what the agent reported for the job's sessions, in US dollars; it is empty while that is zero. A ticket job shows only its key until the runner has read the ticket.

    Below the table, one line says when the queue is not open:

    ! The queue is paused: paused by a person → safran harness resume --profile safran.yaml
    ! The usage limit holds the queue until 2100-01-01T00:00:00.000Z.

    (Two separate runs. The second comes from a stand-in scripted to report a usage limit, which is why the date is far away.)

    JSON output

    --json prints every job with the queue's state. Keys are snake_case. base is null until the job's worktree has been made, worktree is null before that and after it is removed, commit is the commit the job delivered.

    $ safran harness list --json
    {
      "jobs": [
        {
          "id": 1,
          "project": "payments-api",
          "title": "PAY-1423: Kısmi iade işlemi İstanbul şubesinde başarısız oluyor",
          "ticket_keys": [
            "PAY-1423"
          ],
          "kind": "feature",
          "priority": 2,
          "status": "done",
          "branch": "feature/pay-1423",
          "base": "main",
          "worktree": null,
          "commit": "b4ef3a2aee6d49c5fd8d1252ab646cbbf229309d",
          "attempts": 1,
          "max_attempts": 1,
          "cost_usd": 0,
          "last_error": null,
          "created_at": "2026-12-01T21:31:02.938Z",
          "updated_at": "2026-12-01T21:31:04.623Z"
        },
        {
          "id": 3,
          "project": "payments-api",
          "title": "PAY-1500",
          "ticket_keys": [
            "PAY-1500"
          ],
          "kind": "feature",
          "priority": 2,
          "status": "cancelled",
          "branch": "feature/pay-1500",
          "base": null,
          "worktree": null,
          "commit": null,
          "attempts": 0,
          "max_attempts": 1,
          "cost_usd": 0,
          "last_error": "The branch \"feature/pay-1500\" already exists in the repository and was not made by this job",
          "created_at": "2026-12-01T21:31:06.891Z",
          "updated_at": "2026-12-01T21:31:08.420Z"
        }
      ],
      "paused": false,
      "pause_reason": null,
      "blocked_until": null,
      "counts": {
        "queued": 0,
        "running": 0,
        "review": 0,
        "done": 1,
        "failed": 0,
        "cancelled": 2
      }
    }

    The output above is shortened in one place: job 2 (cancelled, same shape) was removed from jobs. It was taken at the end of the session, after jobs 2 and 3 had been cancelled. The job object is the same in every command of the family.

    safran harness waiting

    safran harness waiting

    The jobs that wait for you (review) and the ones that failed, each with what it asks of you. It has no flags and reads the queue only.

    $ safran harness waiting
    job 2  waiting for you  Refuse refunds that are not whole kuruş  harness/refuse-refunds-that-are-not-whole-kurus-8da66a
      Every check was confirmed by the review. Nothing to decide but approve.
    job 3  failed  PAY-1500  feature/pay-1500
      ! The job failed: The branch "feature/pay-1500" already exists in the repository and was not made by this job. Retry it, send it back with a note, or cancel it.
    
    → safran harness show --profile safran.yaml <job> · safran harness approve --profile safran.yaml <job> · safran harness back --profile safran.yaml <job> "<what to change>"

    Only what nobody independent confirmed is listed as a question; a check the review confirmed is not. ! lines need a look or a decision, · lines are notes. The guide lists every kind of line. With nothing to show, it prints Nothing waits for you.

    JSON output

    Each job object gets an asks list. kind is verify (nobody independent confirmed it), decide (a choice was made for you, or the job failed) or note. Job 1 before it was approved, with the job's other keys removed:

    {
      "jobs": [
        {
          "id": 1,
          "status": "review",
          "asks": [
            {
              "kind": "verify",
              "text": "Not verified by the agent: The three payments seen in production can now be refunded (no access to production data)"
            },
            {
              "kind": "decide",
              "text": "Decision made for you: Every branch code is folded by Turkish rules, not only İstanbul. the ticket names one branch; treating it differently from the others would be a special case"
            },
            {
              "kind": "note",
              "text": "Assumed: Branch codes hold only Turkish and ASCII letters"
            },
            {
              "kind": "note",
              "text": "The review notes: A branch whose code has a capital I without a dot would stop matching its lower-case spelling."
            }
          ]
        }
      ]
    }

    safran harness show

    safran harness show <job> [options]

    One job: the request, the agent's report, the checks and the review. Reads the queue only.

    FlagValueDefaultMeaning
    --pr–offPrint only the drafted pull request text: the title, a blank line, the body.
    $ safran harness show 1
    job 1  waiting for you  PAY-1423: Kısmi iade işlemi İstanbul şubesinde başarısız oluyor
      project   payments-api
      branch    feature/pay-1423  from main
      attempts  1 of 1
      tickets   PAY-1423
      commit    b4ef3a2aee6d
      worktree  data/harness/worktrees/payments-api/job-1
    
    The agent reports
      Branch codes are now compared with Turkish case folding, so "İSTANBUL" from the terminal and "istanbul" from the back office are the same branch and the partial refund goes through.
      ✔ A partial refund of a payment taken at the İstanbul branch succeeds  agent: met · review: ok
      ✔ Other branches behave as before  agent: met · review: ok
      ! The three payments seen in production can now be refunded  agent: unverified · review: unverifiable
    
    Gates
      ✔ lint  passed · 12 ms
      ✔ test  passed · 11 ms
    
    The review says
      Ran the tests and tried both spellings and a mixed one; the comparison holds. Production payments could not be looked at from here.
    
    For you
      ! Not verified by the agent: The three payments seen in production can now be refunded (no access to production data)
      ! Decision made for you: Every branch code is folded by Turkish rules, not only İstanbul. the ticket names one branch; treating it differently from the others would be a special case
      · Assumed: Branch codes hold only Turkish and ASCII letters
      · The review notes: A branch whose code has a capital I without a dot would stop matching its lower-case spelling.
    
    Sessions: work ok → fix ok → review ok
    
    → safran harness diff 1 --profile safran.yaml · safran harness approve 1 --profile safran.yaml · safran harness back 1 --profile safran.yaml "<what to change>"
    PartWhat it shows
    HeadProject, branch and the ref it was cut from, attempts used and allowed (with the cost when there is one), tickets, the delivered commit, the worktree, the last error, and your note when the job was sent back.
    The agent reportsThe agent's summary and its checks. ✔: the agent says met and the review says ok. ✘: the agent says not_met or the review says wrong. !: everything in between.
    GatesEach gate as the harness ran it: passed, known failures, failed, timeout or not run, with its duration.
    The review saysThe review's summary.
    For youThe same lines as safran harness waiting. Only while the job waits or has failed.
    SessionsEvery session of the job in order, as phase status. Phases: work, fix, review. Statuses: ok, error, timeout, aborted, rate_limited, environment.

    Once a job is approved, the last line becomes what is yours to do:

    → Yours to do: git push -u origin feature/pay-1423, then open the pull request (safran harness show 1 --pr --profile safran.yaml prints its text).

    --pr prints the text for that pull request, for a job that waits or is done:

    $ safran harness show 1 --pr
    PAY-1423: Recognise the İstanbul branch code in both spellings
    
    Branch codes are now compared with Turkish case folding, so "İSTANBUL" from the terminal and "istanbul" from the back office are the same branch and the partial refund goes through.
    
    ## Checks
    
    - [x] A partial refund of a payment taken at the İstanbul branch succeeds
    - [x] Other branches behave as before
    - [ ] The three payments seen in production can now be refunded (not verified)
    
    ## Decisions
    
    - **Every branch code is folded by Turkish rules, not only İstanbul**: the ticket names one branch; treating it differently from the others would be a special case
    
    ## Assumptions
    
    - Branch codes hold only Turkish and ASCII letters
    
    ## Review
    
    Ran the tests and tried both spellings and a mixed one; the comparison holds. Production payments could not be looked at from here.

    The title is the ticket keys and the title the agent gave its work. The text is the agent's own account, so read it as you would read a colleague's draft. For any other status, --pr fails: ✘ Job 3 has no pull request text yet: it is cancelled.

    JSON output

    --json prints the job object and, next to it, everything the harness recorded:

    KeyHolds
    bodyThe request as written. Empty for a job made from ticket keys alone.
    feedbackYour note from safran harness back, or null.
    outputThe agent's structured result, or null: status, title, summary, the one-line commit message, checks (each with requirement, source, how_verified, result, evidence, note), decisions, assumptions, changed_files, handoff.
    reviewThe review, or null: verdict, summary, check_verdicts (index, verdict, note), missing, findings (blocking, file, line, issue, human, fix). The verdict field is recorded and never used: the harness blocks on the parts.
    gatesOne entry per gate: name, status, duration_ms, and tail (the end of the output) when it did not pass.
    warningsWhat no check blocked on and a person should still see.
    asksAs in safran harness waiting --json.
    pull_requesttitle, body and push (the command as a list of words), or null.
    evidence_dirThe absolute path of the job's evidence directory.
    runsEvery session: id, job_id, attempt, phase, status, cost_usd, turns, duration_ms, log_file, started_at, session_id.
    eventsThe job's history: id, job_id, at, type, message, and layer on a sent_back event.

    Two entries of events and one of runs from job 1:

    {
      "runs": [
        {
          "id": 2,
          "job_id": 1,
          "attempt": 1,
          "phase": "fix",
          "status": "ok",
          "cost_usd": 0,
          "turns": 3,
          "duration_ms": 14,
          "log_file": "/work/acme/data/harness/jobs/1/logs/a1-fix-1796160663506.jsonl",
          "started_at": "2026-12-01T21:31:03.506Z",
          "session_id": "session-worker-0"
        }
      ],
      "events": [
        {
          "id": 5,
          "job_id": 1,
          "at": "2026-12-01T21:31:03.506Z",
          "type": "sent_back",
          "message": "Sent back by the rules check: [focused-test] src/refund/policy.test.ts:16: A test is focused, so the rest of its file no longer runs. Remove the focus.",
          "layer": "rules"
        },
        {
          "id": 8,
          "job_id": 1,
          "at": "2026-12-01T21:31:03.662Z",
          "type": "delivered",
          "message": "Ready for you on branch feature/pay-1423 (b4ef3a2aee)"
        }
      ]
    }

    safran harness diff

    safran harness diff <job>

    What a job changed, against the commit it started from. It has no flags. It runs git diff in the job's worktree, so it needs the worktree: use it while the job waits for you.

    $ safran harness diff 1
    diff --git a/src/refund/policy.test.ts b/src/refund/policy.test.ts
    index 6eb2a71..882d3d1 100644
    --- a/src/refund/policy.test.ts
    +++ b/src/refund/policy.test.ts
    @@ -12,3 +12,7 @@ test("a refund larger than the rest is refused", () => {
     test("branch codes ignore case", () => {
       expect(sameBranch("ankara", "ANKARA")).toBe(true);
     });
    +
    +test("the İstanbul branch code matches in both spellings", () => {
    +  expect(sameBranch("İSTANBUL", "istanbul")).toBe(true);
    +});
    diff --git a/src/refund/policy.ts b/src/refund/policy.ts
    index beeefe8..215d6ca 100644
    --- a/src/refund/policy.ts
    +++ b/src/refund/policy.ts
    @@ -8,7 +8,7 @@ export function canRefund(paid: number, refunded: number, amount: number): boole
       return amount > 0 && amount <= refundable(paid, refunded);
     }
     
    -/** Branch codes are compared without regard to case. */
    +/** Branch codes are compared without regard to case, by Turkish rules: "İSTANBUL" is "istanbul". */
     export function sameBranch(a: string, b: string): boolean {
    -  return a.toLowerCase() === b.toLowerCase();
    +  return a.toLocaleLowerCase("tr-TR") === b.toLocaleLowerCase("tr-TR");
     }

    --json prints { "id": 1, "diff": "…" } with the same text. After approval the worktree is gone and the command says where the work is:

    $ safran harness diff 1
    ✘ Job 1 has no worktree to read a diff from
    → Its work is commit b4ef3a2aee on branch feature/pay-1423.

    safran harness approve

    safran harness approve <job>

    Accepts a job that waits for you. It has no flags.

    What it touches. The job becomes done. Its worktree is removed when nothing in it is uncommitted; its branch stays. With deliver: staged the work exists only in the worktree, so the worktree stays too. Nothing is pushed.

    $ safran harness approve 1
    ✔ Job 1 is done. Its work is on branch feature/pay-1423; nothing was pushed.

    --json prints the job object. done is final: a job that is done cannot be sent back, retried or cancelled.

    safran harness back

    safran harness back <job> <note…>

    Sends a job that waits for you, or that failed, back to the agent with a note saying what to change. It has no flags; everything after the job number is the note.

    $ safran harness back 2 "Also refuse NaN, with a test"
    ✔ Job 2 is queued again with your note.

    The job is queued with one more attempt than it has used. The next session starts fresh in the same worktree, with your note and the earlier session's hand-off, and every check and the review run again on the whole job. safran harness show prints the note as your note until the job is delivered again. --json prints the job object.

    $ safran harness back 1
    ✘ harness back needs a note saying what to change
    → For example: safran harness back 12 "the empty state is missing"

    safran harness retry

    safran harness retry <job>

    Queues a failed or cancelled job again, with one more attempt, in a fresh session that is told why the last one did not get through. It has no flags. Use safran harness back instead when you have something to tell the agent.

    $ safran harness retry 3
    ✔ Job 3 is queued again.

    Retrying does not repair the reason: job 3 above fails again for as long as the branch it wants exists. --json prints the job object.

    safran harness cancel

    safran harness cancel <job>

    Stops a job and removes its worktree. It has no flags. Any job that is not done or already cancelled can be cancelled.

    What it touches. A running agent is stopped; when the runner is another process, at that runner's next tick. The worktree is removed. The job's branch is kept when the job committed to it and removed when it holds nothing of its own. A branch the job did not make is never touched.

    $ safran harness cancel 2
    ✔ Job 2 is cancelled.

    After this, job 2's branch is still in the repository with its commit. --json prints the job object. A cancelled job can be queued again with safran harness retry.

    safran harness pause and resume

    safran harness pause
    safran harness resume

    pause stops new jobs from starting; running ones finish. resume lets the queue start jobs again, after a pause by a person, after the harness paused itself, or after a usage limit. Neither has flags. Both only write a switch in the queue, so they work from another terminal while a runner is going.

    $ safran harness pause
    ✔ The queue is paused. → safran harness resume --profile safran.yaml
    $ safran harness run --once
    harness: 1 job queued, paused (paused by a person)
    ! The queue is paused: paused by a person
    $ safran harness resume
    ✔ The queue is open.

    The harness pauses itself when something is broken that every job would trip over: a gate that cannot be started, a setup command that fails, a tracker that cannot be read, an agent session that started without its guard. Fix that first; resume does not check that you did. --json prints { "paused": true } and { "paused": false }.

    safran harness doctor

    safran harness doctor [options]

    Checks that jobs can run, and prints the ledger of which check layer sent jobs back.

    What it touches. Without --gates it starts the agent program once with --version, finds each project's repository and base ref, and reads the queue. With --gates it also makes a throwaway worktree of each project's base, runs setup and every gate in it, and removes it; that runs the profile's commands, so the profile must be named.

    FlagValueDefaultMeaning
    --gates–offAlso run every project's setup and gates on its base branch, in a throwaway worktree.
    --projectnameall projectsWith --gates: only this project.
    $ safran harness doctor --gates
    ✔ agent (claude-code)  0.0.0 (fake agent)
    ✔ permissions  acceptEdits: the agent may run its project's gates, git's views of the worktree, and what `allowed_tools` names (2 patterns)
    ✔ project payments-api  branches from main (9f1ee3a19f), 2 gates, reviewed
    
    On the base of payments-api  main (9f1ee3a19f)
      ✔ setup  bun install
      ✔ lint  passed · 15 ms
      ✔ test  passed · 13 ms

    (One progress line on stderr is left out.)

    LineFails when
    projectsPrinted only when the profile has no harness project.
    agent (claude-code)The agent program cannot be started. On success it shows the version the program printed.
    permissionsNever; it states which permission mode is in force and how many patterns allowed_tools holds.
    project <name>The repository is not a git checkout on this machine, the base cannot be resolved, or the project has no gate. NOT reviewed marks a project with review: false.
    queuePrinted only while the queue is paused, with the reason.

    Unlike a job, the baseline runs every gate even after one failed: the point is to know each of them. A failing gate shows the last lines of its output:

    $ safran harness doctor --gates
    ✔ agent (claude-code)  0.0.0 (fake agent)
    ✔ permissions  acceptEdits: the agent may run its project's gates, git's views of the worktree, and what `allowed_tools` names (0 patterns)
    ✔ project payments-api  branches from main (9f1ee3a19f), 2 gates, reviewed
    
    On the base of payments-api  main (9f1ee3a19f)
      ✘ lint  failed · 7 ms
          src/refund/policy.ts: use the logger, not console.log
      ✔ test  passed · 12 ms
    
    ! A gate that fails on the base branch fails every job. Fix it, remove it, or list what fails under `known_failures` (with `fail_pattern`).

    (From a second profile whose lint gate was made to fail for this example.)

    Once a job has been sent back by a layer, the ledger follows the checks:

    $ safran harness doctor
    ✔ agent (claude-code)  0.0.0 (fake agent)
    ✔ permissions  acceptEdits: the agent may run its project's gates, git's views of the worktree, and what `allowed_tools` names (2 patterns)
    ✔ project payments-api  branches from main (9f1ee3a19f), 2 gates, reviewed
    
    Sent back by
      rules  1 time

    The layers are output, changes, gates, rules, evidence and review; only the ones that sent something back are listed.

    JSON output

    $ safran harness doctor --gates --json
    {
      "ok": true,
      "checks": [
        {
          "ok": true,
          "subject": "agent (claude-code)",
          "detail": "0.0.0 (fake agent)"
        },
        {
          "ok": true,
          "subject": "permissions",
          "detail": "acceptEdits: the agent may run its project's gates, git's views of the worktree, and what `allowed_tools` names (2 patterns)"
        },
        {
          "ok": true,
          "subject": "project payments-api",
          "detail": "branches from main (9f1ee3a19f), 2 gates, reviewed"
        }
      ],
      "ledger": [
        {
          "layer": "rules",
          "count": 1
        }
      ],
      "baselines": [
        {
          "project": "payments-api",
          "base": "main",
          "commit": "9f1ee3a19fe03bc35e7505e2c64b23ddda767c72",
          "setup": [
            {
              "command": [
                "bun",
                "install"
              ],
              "ok": true
            }
          ],
          "gates": [
            {
              "name": "lint",
              "status": "passed",
              "duration_ms": 12,
              "tail": null
            },
            {
              "name": "test",
              "status": "passed",
              "duration_ms": 11,
              "tail": null
            }
          ]
        }
      ]
    }

    baselines is empty without --gates. A setup step that failed carries a tail, and the gates after it are not_run.

    Exit codes

    ExitWhen
    0Every line is ✔, and with --gates every setup step and gate passed (a gate with only known failures counts as passed).
    1A line failed, the queue is paused, a setup step or a gate failed on the base, --project names no harness project, or --gates was asked of a profile that was not named.

    Exit codes of the family

    run and doctor have their own tables above. For every other command:

    ExitWhen
    0The command did what it was asked.
    1A Safran error: no such job (NOT_FOUND), a job in the wrong status (CONFLICT), a project that is not in the profile, a profile that could not be opened.
    2Usage: a missing or malformed job number, a missing note or text, a value outside the choices of --status or --kind. Nothing was done.
    130Interrupted with Ctrl-C.
    $ safran harness show 99
    ✘ There is no job 99
    → List the jobs with `safran harness list`.
    $ safran harness show abc
    ✘ "abc" is not the number of a job
    → List the jobs with `safran harness list`.
    $ safran harness list --status nope
    ✘ --status must be one of queued, running, review, done, failed, cancelled; got "nope"
    → Did you mean done?

    With --json, an error is one document on stdout, as for every command:

    $ safran harness approve 1 --json
    {
      "error": {
        "code": "CONFLICT",
        "message": "Job 1 is done, not review",
        "hint": "Look at the job again; something else moved it."
      }
    }

    Common mistakes

    • Expecting a pull request. No command pushes. After approve, run the git push that safran harness show prints, and open the pull request yourself with the text of --pr.
    • Skipping doctor --gates. A gate that fails on the base branch fails every job and spends a session each time. Run it after every change to setup or gates.
    • Running from a directory where the profile is only found. add and list work and run refuses. Name the profile with --profile or SAFRAN_PROFILE.
    • A branch that already exists. The harness never takes over a branch it did not make. Delete or rename the branch, or queue the job with --branch.
    • Reading waiting for you as "correct". It means the gates passed and the review found nothing that blocks. Read the ! lines, then the diff.
    • A resume without a fix. resume only flips the switch. The next job pauses the queue again for the same reason.
    • Deleting the data directory. <data dir>/harness/ is not a cache: it holds the queue and the record of every job. The branches survive in the repository; the queue does not.
    • Allowing too little. Under acceptEdits a session may run its project's gates, git's views of the worktree and what harness.agent.allowed_tools names. A review that wants to try something else is refused and reads instead; the job then tells you how many tool calls were refused.