Home / Articles

Practical notes: 5 CLI Tools for Managing Multiple AI Agents Without Losing

Operable walkthrough of Practical notes: 5 CLI Tools for Managing Multiple AI Agents Without Losing: contracts, checks, and drop-in code slots for teams shipping this pattern.

Publisher: REACTAPP.TOP8 min read1911 words

This article is published in English.

Sources: **5 CLI Tools for Managing Multiple AI Agents Without Losing Your Mind**

The following notes reconstruct a practical path around “5 CLI Tools for Managing Multiple AI Agents Without Losing Your Mind”. Emphasis stays on contracts, checks, and drop-in code placeholders rather than motivational framing. When working through the Overview stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion.

1. herdr: the purpose-built agent multiplexer

The 1 herdr the purpose-built stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Expose tools with narrow schemas and explicit side-effect labels. Hosts need to know which calls mutate state before they auto-approve.

brew install herdr

2. zellij: the general-purpose workspace layer

The 2 zellij the general-purpose stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph. Expose tools with narrow schemas and explicit side-effect labels. Hosts need to know which calls mutate state before they auto-approve.

layout {
    tab name="agents" {
        pane split_direction="vertical" {
            pane name="agent-1" command="bash" focus=true
            pane name="agent-2" command="bash"
        }
        pane split_direction="vertical" {
            pane name="agent-3" command="bash"
            pane name="review" command="bash"
        }
    }
}

3. caffeinate: stop your Mac from killing agent runs

The 3 caffeinate stop your stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish. Expose tools with narrow schemas and explicit side-effect labels. Hosts need to know which calls mutate state before they auto-approve. The 3 caffeinate stop your stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion.

caffeinate -s &
CAFFEINE_PID=$!

# launch your agents here
claude -p "refactor the auth module" &
AGENT1_PID=$!
claude -p "write integration tests" &
AGENT2_PID=$!

# wait only for agents, then kill caffeinate
wait $AGENT1_PID $AGENT2_PID
kill $CAFFEINE_PID
caffeinate -s -- claude -p "migrate the database schema"

4. hunk: review agent diffs and talk back to agents inline

For the 4 hunk review agent stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Authenticate at the gateway and re-authorize at the data plane. A bearer token alone is not a tenancy boundary.

Notes and agent notes: a two-way communication channel.

For the Notes and agent notes stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph. Authenticate at the gateway and re-authorize at the data plane. A bearer token alone is not a tenancy boundary.

5. git worktrees: stop agents from stepping on each other

For the 5 git worktrees stop stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish. Authenticate at the gateway and re-authorize at the data plane. A bearer token alone is not a tenancy boundary. For the 5 git worktrees stop stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion.

# create worktrees for each agent task
git worktree add ../auth-refactor -b agent/auth-refactor
git worktree add ../test-writing -b agent/test-writing
git worktree add ../config-migration -b agent/config-migration

# launch agents in their respective worktrees (subshells keep cwd isolated)
(cd ../auth-refactor && claude -p "refactor the auth module") &
(cd ../test-writing && claude -p "write integration tests for auth") &
(cd ../config-migration && claude -p "migrate config to new schema") &
git checkout main
git merge --no-ff agent/auth-refactor
git merge --no-ff agent/test-writing
git merge --no-ff agent/config-migration
git worktree remove ../auth-refactor
git worktree remove ../test-writing
git worktree remove ../config-migration
git worktree add "../$1" -b "agent/$1" && (cd "../$1" && bun install)

the current setup

When working through the the current setup stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Log tool name, args hash, latency, and outcome for every call. Debugging agent loops without that trail wastes hours.

# ~/.zshrc
agent() {
  caffeinate -is &
  local caff_pid=$!
  trap "kill $caff_pid 2>/dev/null" EXIT INT TERM
  local logfile=~/.agent-logs/$(date +%Y%m%d-%H%M%S)-${1// /-}.log
  claude -p "$1" 2>&1 | tee "$logfile"
  kill $caff_pid 2>/dev/null
}

Operational checklist

For the Operational checklist stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state.

Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline.

Authenticate at the gateway and re-authorize at the data plane. A bearer token alone is not a tenancy boundary.

Checkpoint after expensive steps. Resume should not re-bill the same LLM call when an operator retries a later node.

Pin dependency versions and record the image digest that ran the demo. Reproducibility beats tribal knowledge.

Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph.

Before promoting the stack, freeze versions, capture a golden transcript for the critical path, and confirm rollback steps. Shared environments need rate limits, tenancy checks, and a clear owner for secret rotation. Prefer boring reliability over clever one-off demos.

Batch note for 1886c5037489: keep provider keys out of the repo, set a per-session token ceiling, and store transcripts next to the eval fixtures so later model swaps stay comparable.

The hardening note 0 stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline.

Hardening detail 0/686: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.

For the hardening note 1 stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.

Hardening detail 1/686: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.

When working through the hardening note 2 stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.

Hardening detail 2/686: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.

The hardening note 3 stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion.

Hardening detail 3/686: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.

For the hardening note 4 stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph.

Hardening detail 4/686: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.

For the hardening note 0 stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph.

Hardening detail 0/705: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.

When working through the hardening note 1 stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline.

Hardening detail 1/705: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.