> ## 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 init — Scaffold Your Kode Project Configuration

> kode init scaffolds a .kode/kode.json config file in your project root with TDD mode, blast radius limits, token budgets, and auto-detected test commands.

`kode init` gets your project ready for Kode in a single step. It creates a `.kode/` directory, writes a `kode.json` configuration file with sensible production-ready defaults, auto-detects your test command from the project root, and downloads the Sicario SAST binary that powers the security gate. Running `init` takes under ten seconds and requires no arguments.

## Synopsis

```bash theme={null}
kode init [directory]
```

## What it does

1. **Creates `.kode/`** in your project root (or the directory you specify).
2. **Writes `.kode/kode.json`** with all engine, provider, and permission fields populated. If a `kode.json` already exists, the command exits without overwriting it.
3. **Auto-detects your test command** by scanning the directory for well-known project files:
   * `go.mod` → `go test ./...`
   * `package.json` → `npm test`
   * `Cargo.toml` → `cargo test`
   * `pyproject.toml` / `requirements.txt` → `pytest`
   * `Gemfile` → `bundle exec rspec`
4. **Downloads Sicario** — Kode's embedded SAST binary — into `.kode/`. The security gate uses Sicario to block patches that introduce high or critical findings. If the download fails (e.g. no network), you can install it later with `kode install sicario`.

## Arguments

<ParamField path="directory" type="string">
  Optional target directory. Defaults to the current working directory. Kode resolves the path to an absolute location before creating `.kode/` inside it.

  ```bash theme={null}
  # Init in the current directory
  kode init

  # Init in a subdirectory
  kode init ./services/api
  ```
</ParamField>

## Generated kode.json

The file written to `.kode/kode.json` contains every supported field. Edit it freely after running `init`.

```json theme={null}
{
  "$schema": "https://trykode.xyz/config.json",
  "version": "3.0.0",
  "model": "anthropic/claude-sonnet-4-6",
  "small_model": "anthropic/claude-haiku-4-5",
  "instructions": ["AGENTS.md"],
  "permission": {
    "edit": "ask",
    "bash": "ask"
  },
  "engine": {
    "tdd_mode": true,
    "test_command": "go test ./...",
    "max_blast_radius": 3,
    "token_budget_usd": 1.50,
    "blindfold_mode": false
  },
  "providers": {
    "primary": "kode",
    "gateway_url": "https://api.trykode.xyz"
  }
}
```

### Engine fields

<ParamField path="engine.tdd_mode" type="boolean" default="true">
  When `true`, Kode refuses to write to production source files if no corresponding test file exists in the codebase. Disable only if your project has no tests yet.
</ParamField>

<ParamField path="engine.test_command" type="string">
  The shell command used to run your test suite. Kode appends this as the final step of the `kode loop` pipeline and rolls back if it exits non-zero.
</ParamField>

<ParamField path="engine.max_blast_radius" type="integer" default="3">
  Maximum number of files a single verify round is allowed to touch. Patches that exceed this limit are rejected before any gate runs.
</ParamField>

<ParamField path="engine.token_budget_usd" type="float" default="1.50">
  Cost ceiling per `kode loop` cycle in USD. Kode estimates token costs using current model pricing and aborts generation once the budget is reached.
</ParamField>

<ParamField path="engine.blindfold_mode" type="boolean" default="false">
  When `true`, Kode obfuscates variable and function identifiers in the code sent to the LLM. Useful for proprietary codebases where exposing symbol names is undesirable.
</ParamField>

## Example output

```
── Kode Init ────────────────────────────────────

  ✓  Created directory /home/you/project/.kode
  ·  Auto-detected test command: go test ./...
  ✓  Written /home/you/project/.kode/kode.json

── Engine Features ──────────────────────────────

  TDD Mode:        ON  (writes blocked unless test file present)
  Test Command:    go test ./...
  Blast Radius:    3 files max per verify round
  Token Budget:    $1.50 per loop cycle
  Blindfold:       OFF (identifier obfuscation before LLM send)

── Security Engine ──────────────────────────────

  ✓  Sicario installed at /home/you/project/.kode/sicario
  ·  Security gate active — high/critical findings block patches

  edit .kode/kode.json to customize
```

<Note>
  Running `kode init` in a directory that already has `.kode/kode.json` **will not overwrite it**. The command prints an error and exits cleanly. Delete the existing file or specify a different directory if you want to regenerate it.
</Note>

For the complete list of every supported `kode.json` field, see the [kode.json configuration reference](/configuration/kode-json).
