Skip to content

loop

ward loop alternates between an external coding agent and ward check until the quality gates pass or a limit is reached.

Terminal window
ward loop <task> --agent-command <command> [-C <dir>] [--max-iterations <n>] [--timeout-seconds <n>] [--allow-dirty]
Terminal window
ward loop "Fix the failing tests" --agent-command "claude -p" --max-iterations 3
OptionWhat it doesDefault
<task>The prompt for the first iteration.required
--agent-command <command>The agent to run. It is split into arguments and run without a shell from the project root, with the prompt appended as the final argument.required
-C, --directory <dir>Run for the project in <dir> instead of the current directory.current directory
--max-iterations <n>Maximum number of agent runs.3
--timeout-seconds <n>Time limit for each agent run.300
--allow-dirtyStart even when the Git working tree has uncommitted changes.off
--verbosePrint diagnostics to stderr. See Verbose diagnostics.off

Each iteration runs the agent, then the default profile gates.

  • The first iteration sends <task>.
  • Later iterations send only the failure feedback: the name, status, and output of every failed gate, prefixed with Fix these failed quality gates:.
  • By default, the loop refuses to start when the Git working tree has uncommitted changes, so the agent’s changes are easy to review or revert. --allow-dirty disables this check.

The command prints one result line, for example PASSED after 2 iteration(s): All quality gates passed.

StateMeaning
PASSEDAll gates passed after an agent run.
MAX_ITERATIONS_REACHEDGates still failed after the last iteration.
TIMEOUTThe agent exceeded --timeout-seconds, or the loop was interrupted.
AGENT_ERRORThe agent command exited unsuccessfully or could not be run.
GATE_ERRORWard could not run the checks, or the working tree was dirty.

Use ward --verbose loop ... to inspect iteration, agent and check phases, timeouts, interruption, and terminal-state transitions. Task text, feedback, command arguments, and process output are never emitted as application logs.

CodeMeaning
0PASSED.
1Any other terminal state.
2Invalid usage.