---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://sourcecraft.dev/portal/docs/en/cli-ref/src-code.md
  - https://sourcecraft.dev/portal/docs/ru/cli-ref/src-code.md
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt

# src code

Launch OpenCode with SourceCraft configuration.

This command starts OpenCode with the proper environment configured to use
SourceCraft as the AI provider. It handles:
* Checking that OpenCode is installed
* Copying default configuration if needed
* Setting up environment variables for SourceCraft authentication

Arguments after -- are passed directly to OpenCode.

## Usage

`src code [-- opencode-args...] [flags]`

### Available commands

| Command | Description |
| --- | --- |
| [install](src-code-install.md) | Install OpenCode |

### Examples

**Launch OpenCode**

`src code`

**Launch and auto-install if needed (for Autoinstall environments)**

`src code --cde`

**Reset configuration to defaults before launching**

`src code --reset-config`

**Pass arguments to OpenCode (after --)**

`src code -- serve --port 9999`

**Combine src flags with OpenCode arguments**

`src code --cde -- --continue`

**Use verbose mode and pass args to OpenCode**

`src code --verbose -- -m anthropic/claude-sonnet`

### Flags

| Flag | Description |
| --- | --- |
| `--autoinstall` | Auto-install OpenCode if not present (for Autoinstall environments) |
| `--log-llm` | Log LLM requests to files (via local proxy) |
| `--model string` | Model to use: ds, legacy, ds-alt (overrides config) |
| `--no-tools` | Do not load sourcecraft API tools, commands and modes |
| `--reset-config` | Reset configuration to defaults before launching |

### Inherited flags

| Flag | Description |
| --- | --- |
| `--env string` | Override Sourcecraft environment (use 'src envs' to list available) |
| `--json string` | Output JSON, optionally filtered (--json or --json=field1,field2) |
| `--json-compact string` | Output compact JSON, optionally filtered |
| `-R, --repo string` | Select another repository using OWNER/REPO format |
| `-V, --verbose` | Enable debug logging output |

### Learn more

Use `src code <subcommand> --help` for more information about a command.
