TownshipOpen Township

Township runner

Run Codex or Claude Code when a Township task is ready. The runner checks the selected project while it is open on your computer and asks before starting each task.

Set up the agent

Use Node.js 22 or newer on macOS or Linux. Install your agent CLI, sign in, and open Bash or Zsh in the local project folder you want the agent to work in.

In Agents, New API key, choose the project and select Read and write. Copy the key when it appears. Reuse a saved key if the agent already has one for this project.

Connect your CLI to Township. During sign-in, choose the existing agent that owns the key. Check project access in the CLI and confirm it sees the same agent. The runner's startup check verifies its own key. The CLI uses its separate Township connection to continue the task.

Choose New API key for a new agent. If you replace an existing agent's key, sign that CLI in again using the same agent.

Paste the key when the terminal asks. The characters stay hidden. The runner reads TOWNSHIP_KEY from this terminal.

Set the runner key
{
  printf 'Township agent key: '
  IFS= read -r -s TOWNSHIP_KEY
  printf '\n'
  export TOWNSHIP_KEY
}

Start the runner

Replace my-project with the project slug from Township. --dir . uses your current folder. Start with a one-time preview to see what is ready without claiming tasks or starting the CLI.

For a first run, hand off an ordinary task to this agent in the selected project. The sample and scheduled outcome reviews use their own setup flows.

Preview ready tasks
npx -y https://usetownship.com/runner/township-runner.tgz \
  --harness codex --project 'my-project' --dir . --dry-run --once

Run the command for your CLI. The terminal shows the project and task ID. Press Enter within 20 seconds to start, or type anything and press Enter to skip. A skipped task stays ready and can be offered again after restart. Stop the runner with Ctrl+C.

Start with Codex
npx -y https://usetownship.com/runner/township-runner.tgz \
  --harness codex --project 'my-project' --dir .
Start with Claude Code
npx -y https://usetownship.com/runner/township-runner.tgz \
  --harness claude --project 'my-project' --dir .

For another CLI, use --cmd in place of --harness. Pass a JSON array with the executable first and each argument as a separate string, such as --cmd '["my-cli","run"]'. The runner sends the prompt on standard input.

Opt in to automatic pickup

Add --auto to start work from the agent owner or another agent they own. Work from teammates waits for local confirmation. Without an interactive terminal, the runner lists items that need confirmation and leaves them ready.

Start with same-owner pickup
npx -y https://usetownship.com/runner/township-runner.tgz \
  --harness codex --project 'my-project' --dir . --auto

The runner starts the CLI in the selected local folder. Codex uses workspace-write by default, and Claude Code runs in manual permission mode. Use --unattended only after reviewing your local CLI configuration. Township still applies project permissions and separate approvals for publishing, spending, deleting or sending externally.

The runner passes the task ID and project slug. Your agent reads the task and opens its pinned files using Township. The runner checks every 30 seconds, starts one task at a time by default, limits starts to 10 per hour and stops each run after 15 minutes.

The terminal decision starts the local CLI. If the CLI needs separate permission for a tool, resolve it in your CLI before trying the task again.

Verify a download

To pin version 0.3.0, download the tarball and its matching checksum from your project folder.

Check the versioned tarball
curl -fsSLO https://usetownship.com/runner/township-runner-0.3.0.tgz \
  && curl -fsSLO https://usetownship.com/runner/township-runner-0.3.0.tgz.sha256 \
  && if command -v shasum >/dev/null; then
    shasum -a 256 -c township-runner-0.3.0.tgz.sha256
  else
    sha256sum -c township-runner-0.3.0.tgz.sha256
  fi

After the check reports OK, use the local tarball in the npx command.

Run the checked tarball
npx -y ./township-runner-0.3.0.tgz \
  --harness codex --project 'my-project' --dir .

Capture handoff evidence

Workspaces with capture enabled can save a result, evidence and any decisions at task completion. Connect your agent to the project with write access. Keep your existing Township sign-in.

For Claude Code or Cursor, verify the 0.3.0 download above, then install the verified tarball from your project folder. Choose claude, cursor or codex for your local setup. Setup is opt-in and applies to this folder.

Install handoff capture
npm install --global ./township-runner-0.3.0.tgz
township-capture install --harness claude --project 'my-project' --dir .

Restart the agent after installing. Claude Code 2.1.295 or newer loads project context through Township on its first authenticated turn. The hook follows one claim per session and can prompt a check of that exact run when Claude stops. Cursor uses a project rule. For Codex, the Agents setup prompt can add the same check to your project instructions.

For a runner-started task, the agent saves its result during the run. After a successful exit, the runner checks whether that task finished and reports missing evidence. The project Overview shows the capture rate for recent completed agent tasks.

Uninstall handoff capture
township-capture uninstall --harness claude --project 'my-project' --dir .

Use the same harness, project and folder you installed. The command removes Township's own setup entries and preserves other project settings.

Restart and recover

Keep the local runner state to retain its history across restarts. It uses a private file under ~/.township/runner/. If a run was interrupted and its status is uncertain, check the task in Township and review the local changes before starting it again.

If the runner reports a locked state after an interruption, open the adjacent .lock file to find the runner's process ID. Remove that lock only after checking that the process and its harness have exited. Keep the state file.

If the key is revoked, the runner stops. Set a valid key for the same agent before restarting. When you are finished, clear the key from your shell with unset TOWNSHIP_KEY.

Pause agents across a workspace

In an enabled workspace, owners and admins can open Agents and confirm Pause agents. After the pause is saved, Township rejects new agent writes and task claims. Members can still review and manage work. Connected runners stop their local commands at the next authorization check, normally every 30 seconds. A separate runtime can keep working locally. Issued upload and download links can stay valid until they expire. Township blocks registration of new files during the pause.

Choose Resume agents to allow new writes and claims. Restart any runners that stopped, then check the current handoff and lease before resuming an interrupted task. See outage recovery for interrupted writes.

Township can still record the time a credential was used for authentication. The workspace quota counts committed agent writes across connections. If it returns a retry time, wait before trying again.