Documentation Index
Fetch the complete documentation index at: https://docs.trykode.xyz/llms.txt
Use this file to discover all available pages before exploring further.
kode loop is Kode’s most complete command. It runs the full workflow in a single invocation: generate patches from a task description, verify each patch through the 6-gate pipeline, apply passing patches to disk, execute your test suite, and automatically roll back to a pre-patch snapshot if tests fail. Use kode loop when correctness matters and you want deterministic, test-backed results rather than just structural verification.
Synopsis
What it does
- Generate — sends your task and optional context to the LLM; receives structured JSON hunks.
- Verify — runs each hunk through the 6-gate pipeline (syntax, imports, call graph, architecture, security, blast radius).
- Apply — writes hunks that pass all gates to disk.
- Test — runs your test command (from
.kode/kode.jsonor--test-command). - Rollback — if tests fail, restores all modified files from the pre-patch snapshot and exits non-zero.
kode loop prints a JSON result to stdout and exits 0.
Flags
Override the LLM model for this run. Accepts
provider/model format. When omitted, Kode reads from .kode/kode.json, then KODE_LLM_MODEL, then defaults to gpt-4o.Path to a context packet JSON file from
kode plan --packet. Providing a context packet gives the LLM a focused, token-capped view of relevant files and symbols.Test command to run after applying patches. Overrides the
test_command in .kode/kode.json. If neither is set, Kode auto-detects the command from your project root.Project root directory. All file paths and the test command are resolved relative to this directory.
Enable Ghost Branch mode by setting this to
2 or 3. Kode spawns the given number of parallel git worktrees, each using a different implementation strategy, then scores and merges the winner.Examples
Output
On success,kode loop prints a JSON summary to stdout:
Ghost Branch mode
When you pass--branches 2 or --branches 3, kode loop enters Ghost Branch mode. Each branch runs the full loop in an isolated git worktree using a different implementation strategy:
| Branch | Strategy | Approach |
|---|---|---|
| Alpha | Lightweight | Minimal implementation, smallest diff |
| Beta | Robust | Modular architecture, future-proofed |
| Gamma | Aggressive | Performance-optimized, maximum throughput |
Rollback behaviour
Before applying any patches,kode loop snapshots all files that will be modified. If the test step fails, every snapshotted file is restored to its pre-patch state. The snapshot is in-memory; no additional git commits or stashes are created. This means the rollback is instantaneous and leaves no git history.