Configuration
OpsCode merges settings from command-line flags, environment variables, user configuration (~/.opscode/), and project dotfiles (.opscode/). This page covers the configuration files, precedence rules, DevOps environment preservation, and directory layout.
Configuration files overview
| File | Purpose |
|---|---|
~/.opscode/config.toml | Model defaults, provider endpoints, UI preferences, shell allowlists, and permissions |
| Environment variables | API keys, runtime flags, and preserved DevOps CLI contexts |
hooks.json | Pre/post tool execution hooks for formatting, logging, and notifications |
.mcp.json | Global and project Model Context Protocol server definitions |
How settings resolve
OpsCode resolves settings using strict precedence rules so you can override any persistent setting for a single command or CI/CD job:
| Setting category | Precedence order (highest to lowest) |
|---|---|
| General options | CLI flags → OPSCODE_CODE_* env var → canonical env var → ~/.opscode/config.toml → built-in default |
| Provider API keys | OPSCODE_<KEY> env var → canonical env var → ~/.opscode/.env → project .env → /auth store |
| Skills | .agents/skills/ → .opscode/skills/ → ~/.agents/skills/ → ~/.opscode/skills/ → plugins → built-in |
| Memory | Project .opscode/memory/ → User ~/.opscode/memory/ |
| Subagents | Project .opscode/agents/ → User ~/.opscode/{agent}/agents/ → built-in subagents |
| MCP servers | --mcp-config → Project .mcp.json / .opscode/.mcp.json → User ~/.opscode/.mcp.json |
| Hooks | Project .opscode/hooks.json + User ~/.opscode/hooks.json (both execute) |
Inspect effective configuration
Use opscode config to inspect resolved settings and their origin without launching the TUI:
opscode config show # Print every resolved option and its source
opscode config list # List all configurable keys, types, and defaults
opscode config get model.default # Inspect a single setting and its source
opscode config set ui.theme dark # Update a setting in ~/.opscode/config.toml
opscode config path # Show configuration file paths and existence status
Environment variables
Runtime control variables (OPSCODE_CODE_*)
| Variable | Default | Description |
|---|---|---|
OPSCODE_CODE_DEBUG | false | Enable verbose debug logging |
OPSCODE_CODE_DEBUG_FILE | /tmp/opscode_debug.log | Output file path for debug logs |
OPSCODE_CODE_LOG_LEVEL | INFO | Runtime log level (DEBUG, INFO, WARNING, ERROR) |
OPSCODE_CODE_AUTO_UPDATE | enabled | Toggle automatic background package update checks |
OPSCODE_CODE_COLLAPSE_PASTES | enabled | Collapse large pasted snippets in the chat input box |
Blocked .env variables
To prevent untrusted repository .env files from hijacking your shell or injecting shared libraries, OpsCode blocks the following system variables from being loaded via .env files:
PATH, HOME, USER, LOGNAME, SHELL, TERM, DISPLAY, PYTHONPATH, PYTHONSTARTUP, PYTHONHOME, NODE_PATH, NODE_OPTIONS, LD_PRELOAD, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, DYLD_INSERT_LIBRARIES, HISTFILE, HISTSIZE, SSH_AUTH_SOCK, GPG_AGENT_INFO, TMPDIR, TEMP, TMP.
Preserved DevOps CLI variables
When OpsCode spawns subprocesses or subagents, it automatically preserves standard cloud and infrastructure environment variables so tools like kubectl, tofu, terraform, helm, and aws work seamlessly:
| Ecosystem | Preserved environment variables |
|---|---|
| Kubernetes | KUBECONFIG, KUBE_CONTEXT |
| AWS | AWS_PROFILE, AWS_REGION, AWS_DEFAULT_REGION, AWS_SHARED_CREDENTIALS_FILE |
| Google Cloud | GOOGLE_APPLICATION_CREDENTIALS, GOOGLE_CLOUD_PROJECT, CLOUDSDK_CORE_PROJECT |
| Azure | AZURE_SUBSCRIPTION_ID, AZURE_TENANT_ID |
| Terraform / OpenTofu | TF_CLI_CONFIG_FILE, TERRAGRUNT_CONFIG |
| Helm & ArgoCD | HELM_HOME, HELM_REPOSITORY_CONFIG, ARGOCD_SERVER, ARGOCD_AUTH_TOKEN |
| Ansible | ANSIBLE_CONFIG, ANSIBLE_INVENTORY |
Project root detection
OpsCode detects the workspace root by walking up from your current working directory until it finds one of these markers:
.opscode/or.git/terragrunt.hcl,Chart.yaml, oransible.cfgpyproject.toml,package.json, orMakefile
Data locations
User directory (~/.opscode/)
| Path | Purpose |
|---|---|
~/.opscode/config.toml | Primary user configuration file |
~/.opscode/.env | Global API keys and provider credentials |
~/.opscode/hooks.json | Global lifecycle hooks |
~/.opscode/.mcp.json | Global MCP server definitions |
~/.opscode/memory/ | User-scoped saved memories |
~/.opscode/settings.json | User-scoped plugin enablement state |
~/.opscode/plugins/ | Downloaded marketplace plugins and cache |
~/.opscode/.state/sessions.db | SQLite database storing conversation threads and checkpoints |
Project directory (.opscode/)
| Path | Purpose |
|---|---|
.opscode/AGENTS.md | Project instructions committed to Git |
.opscode/skills/ | Project-specific SKILL.md directories |
.opscode/agents/ | Project-specific custom subagents |
.opscode/plugins/ | Project-bundled plugins |
.opscode/memory/ | Project-scoped saved memories |
.opscode/settings.json | Shared project plugin settings (Git-tracked) |
.opscode/settings.local.json | Personal project overrides (gitignored) |
.opscode/hooks.json | Project lifecycle hooks |
.opscode/.mcp.json | Project MCP server configuration |