Goals and loops
Keep a session working across turns until a stated goal is met, or run an instruction on a schedule.
A turn ends when the agent replies. A goal or a loop starts the next turn without a new message.
A goal
/goal Every test in the payments package passes and the linter is clean
/goal <objective> saves the goal on the session and starts a turn in which the agent confirms it, splits it into steps that can be checked, and begins. Each time the session goes idle, kcode sends the agent back to the goal. The tile shows looping while the goal drives the session.
The goal stops driving when one of these happens:
- The agent reports the goal as done. kcode posts a notification.
- The agent reports the goal as blocked. kcode posts a notification that asks for input.
- Three turns in a row call no tool.
Escstops a turn. The goal is kept./goal clearremoves the goal.
Bare /goal shows the current goal. After kcode restarts, /goal must be sent again to resume driving.
A loop
/loop runs an instruction again and again.
| Command | Result |
|---|---|
/loop 10m check the deploy |
Runs the instruction every ten minutes. |
/loop 5x fix the next failing test |
Runs it five times, each time the session goes idle. |
/loop 5x 10m run the tests |
Runs it five times, ten minutes apart. |
/loop keep going |
Runs it each time the session goes idle. |
/loop stop |
Stops every loop and timer of the session, and the goal’s driving. |
A tick that lands while a turn runs waits for the turn to end.
Timers the agent sets
The agent schedules its own later turns with a timer, once or on an interval, in the same cadence syntax as /loop. /loop stop ends those too.
While the Mac is idle
kcode keeps the Mac awake while a session works (session_daemon.keep_awake). Hooks start work from outside a session: a file change, a schedule or a script.