Skip to main content
kode golf is a competitive optimization command: you point it at a single source file, and it spins up three isolated git worktrees that each attempt a different optimization strategy in parallel. All three are benchmarked against the original baseline, and the version that shows the most improvement is offered to you for merge. If no strategy beats the baseline, your original code is left completely untouched.

How it works

Usage

Flags

Example output

Best use cases

Code Golf is most effective when you already suspect a specific file is a bottleneck:
  • Hot paths — a function that is called millions of times per request and shows up in profiles
  • Algorithms you know are slow — O(n²) loops, repeated string concatenation, linear searches over large slices
  • Memory-intensive data structures — caches, buffers, and pools that allocate on every call
  • Parsers and serializers — files that transform large inputs and are called on every request
Avoid running Golf on files that are primarily I/O-bound (network calls, database queries) — the LLM-generated strategies optimise CPU and memory patterns and will not improve latency caused by external systems.

Benchmark commands for non-Go projects

The default benchmark command is go test -bench=. -benchmem. For other languages, pass --test-command with an equivalent:
The benchmark command must write results to stdout in a format Kode can parse. For Go this is automatic. For other runtimes, Kode reads raw stdout and compares the numeric throughput figures between runs — any benchmark framework that prints numbers works, but structured output (JSON, TAP) gives cleaner comparisons.
Run kode plan --graph "<task>" on the file before golfing to understand its blast radius — how many other files import it and could be affected by a change. A file with a blast radius of 10+ is a good candidate for caution: the benchmark might improve but callers may rely on specific allocation behaviour or ordering that changes under the algorithmic strategy.

Next steps

Loop Mode

Run the full pipeline with test execution, rollback, and multi-strategy Ghost Branches.

Daemon Mode

Let Kode watch your git history and proactively surface performance regressions as they accumulate.