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 generate is the core generation command. It takes a task description, builds a prompt from it (optionally augmented with a context packet from kode plan), sends it to your configured LLM, and returns structured JSON hunks — each one a targeted replacement scoped to a specific symbol or anchor in a single file. By default the output goes to stdout so you can inspect, store, or pipe it. Add --apply and Kode will also verify the hunks and write passing ones to disk.
Synopsis
What it does
- Reads the model and API endpoint from
.kode/kode.json(or environment variables). - Optionally loads a context packet from
--context-fileto enrich the prompt with relevant code symbols. - Sends the prompt to the LLM and receives a structured response.
- Parses the response into an array of
StructuredHunkobjects. - Without
--apply: prints the hunk array as indented JSON to stdout and exits. - With
--apply: passes the hunks throughkode verify’s pipeline and writes passing hunks to disk, then prints an execution summary to stdout.
Flags
Override the LLM model for this run. Accepts
provider/model format. When omitted, Kode reads the model from .kode/kode.json (model field), then falls back to the KODE_LLM_MODEL environment variable, and finally gpt-4o.Path to a context packet JSON file produced by
kode plan --packet. The packet is injected into the LLM prompt as structured context, improving patch quality and reducing hallucinated file paths.Verify and apply hunks to disk after generation. Kode runs each hunk through the 6-gate pipeline and writes patches that pass all gates. Equivalent to running
kode run.Project root directory. Kode resolves all file paths relative to this directory. Defaults to the current working directory.
Environment variables
| Variable | Description |
|---|---|
KODE_LLM_API_KEY | API key for the LLM provider (required) |
OPENAI_API_KEY | Fallback API key when KODE_LLM_API_KEY is not set |
KODE_LLM_ENDPOINT | Custom API base URL (default: https://api.openai.com/v1) |
KODE_LLM_MODEL | Default model (default: gpt-4o) |
Examples
JSON hunk format
When run without--apply, kode generate prints a JSON array to stdout:
hunks envelope:
Relationship to other commands
kode generate --apply and kode run are identical. Use kode generate (without --apply) when you want to inspect or version-control the raw hunks before applying them.
| Command | Generates | Verifies | Applies | Runs tests |
|---|---|---|---|---|
kode generate | ✓ | — | — | — |
kode generate --apply | ✓ | ✓ | ✓ | — |
kode run | ✓ | ✓ | ✓ | — |
kode loop | ✓ | ✓ | ✓ | ✓ |