Configuration

AutoCode reads optional JSONC configuration from global OpenCode configuration first, then from project locations. Later candidates override earlier candidates, so local worktree or directory settings can replace global defaults without copying the whole file.

Configuration locations

PrecedenceLocationBehaviour
1~/.config/opencode/autocode.jsoncGlobal defaults are considered first.
2.opencode/autocode.jsonc in the OpenCode worktreeProject or worktree settings override matching global values.
3.opencode/autocode.jsonc in the active directory, when different from the worktreeDirectory-specific settings override matching worktree and global values.

Configuration keys

KeyTypeDescriptionDefault
autocode.tierstringSelects a named tier set from autocode.tiers.No selected set.
autocode.tiersobjectEither a direct map of cheap, fast, balanced, and smart tier settings, or a map of named tier sets containing those tiers.No overrides.
autocode.tiers.<tier>.modelstringOptional model override for a tier.Uses the agent or OpenCode default when omitted.
autocode.tiers.<tier>.variantstringOptional variant override for a tier.Uses the agent or OpenCode default when omitted.
permission.external_directoryobject or stringPath-pattern permissions for external-directory access. Values are allow, ask, or deny.{}
autocode.sandbox.sync_methodstringSandbox sync strategy. Valid values are auto, overlayfs, reflink, and copy.Unset.
autocode.sandbox.distro.cache_pathstringOptional sandbox distribution cache path.Unset.
autocode.sandbox.distro.expirestring or numberOptional sandbox distribution expiry value.Unset.

Recognised model tiers are cheap, fast, balanced, and smart. The cheap tier is also used as the small_model fallback for OpenCode title generation and compaction when OpenCode has no explicit small_model.

For example:

{
  "autocode": {
    "tier": "go",
    "tiers": {
      "go": {
        "smart":    { "model": "opencode-go/glm-5.2", "variant": "high" },
        "balanced": { "model": "opencode-go/minimax-m3", "variant": "medium" },
        "fast":     { "model": "opencode/deepseek-v4-flash-free", "variant": "low" },
        "cheap":    { "model": "opencode/deepseek-v4-flash-free", "variant": "low" }
      },
      "openai": {
        "smart":    { "model": "openai/gpt-5.5", "variant": "high" },
        "balanced": { "model": "openai/gpt-5.4", "variant": "medium" },
        "fast":     { "model": "openai/gpt-5.3-spark", "variant": "low" },
        "cheap":    { "model": "openai/gpt-5.4-mini", "variant": "low" }
      },
      "zai": {
        "smart":    { "model": "zai/glm-5.2", "variant": "high" },
        "balanced": { "model": "zai/glm-5.2", "variant": "medium" },
        "fast":     { "model": "zai/glm-5-turbo", "variant": "low" },
        "cheap":    { "model": "zai/glm-4.7", "variant": "low" }
      }
    }
  },
  "permission": {
    "external_directory": {
      "/tmp/safe/**": "allow",
      "/tmp/safe/specific": "deny"
    }
  }
}

OpenCode applies a last-matching-rule-wins model to external-directory permissions. Place broad defaults first and more specific overrides later.

See OpenCode Go documentation for supported model names.

Database environment variables

Variable patternDescriptionDefault
AUTOCODE_DB_{db_key}_CONNECTIONRequired connection string for one configured database target. Supported formats determine the adapter automatically.None.
AUTOCODE_DB_{db_key}_USERNAMEOptional username supplied alongside the connection when needed.Unset.
AUTOCODE_DB_{db_key}_PASSWORDOptional password supplied alongside the connection when needed.Unset.

Replace {db_key} with letters, digits, or underscores. Environment lookup is case-insensitive. Then instruct agent to use your chosen {db_key} to access your DB.

SSH tool suite

Configure each SSH target with {ssh_key} environment variables:

Variable patternDescriptionDefault
AUTOCODE_SSH_{ssh_key}_HOSTRequired SSH hostname or IP address for one target.None.
AUTOCODE_SSH_{ssh_key}_PORTOptional SSH port. Valid range is 1 to 65535.22.
AUTOCODE_SSH_{ssh_key}_KEYFILEOptional private key file path.Unset.
AUTOCODE_SSH_{ssh_key}_KEYPASSOptional private key passphrase.Unset.
AUTOCODE_SSH_{ssh_key}_USERNAMEOptional SSH username.root.
AUTOCODE_SSH_{ssh_key}_PASSWORDOptional SSH password.Unset.
AUTOCODE_SSH_{ssh_key}_AGENTOptional SSH agent socket or path.Unset.

AUTOCODE_SSH_{ssh_key}_HOST must contain only a hostname or IP address. AutoCode does not parse host:port values from HOST; set AUTOCODE_SSH_{ssh_key}_PORT when a target uses a non-default port.

Keyfile auth has precedence. A nonexistent or unreadable keyfile falls back to password. AUTOCODE_SSH_{ssh_key}_AGENT is used only when there is no readable AUTOCODE_SSH_{ssh_key}_KEYFILE and no AUTOCODE_SSH_{ssh_key}_PASSWORD. Idle SSH connections can be reused for 5 minutes. Remote glob/grep/patch/edit/write mirror local tool intent where practical, not exact parity.