Skip to main content

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​

FilePurpose
~/.opscode/config.tomlModel defaults, provider endpoints, UI preferences, shell allowlists, and permissions
Environment variablesAPI keys, runtime flags, and preserved DevOps CLI contexts
hooks.jsonPre/post tool execution hooks for formatting, logging, and notifications
.mcp.jsonGlobal 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 categoryPrecedence order (highest to lowest)
General optionsCLI flags → OPSCODE_CODE_* env var → canonical env var → ~/.opscode/config.toml → built-in default
Provider API keysOPSCODE_<KEY> env var → canonical env var → ~/.opscode/.env → project .env → /auth store
Skills.agents/skills/ → .opscode/skills/ → ~/.agents/skills/ → ~/.opscode/skills/ → plugins → built-in
MemoryProject .opscode/memory/ → User ~/.opscode/memory/
SubagentsProject .opscode/agents/ → User ~/.opscode/{agent}/agents/ → built-in subagents
MCP servers--mcp-config → Project .mcp.json / .opscode/.mcp.json → User ~/.opscode/.mcp.json
HooksProject .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_*)​

VariableDefaultDescription
OPSCODE_CODE_DEBUGfalseEnable verbose debug logging
OPSCODE_CODE_DEBUG_FILE/tmp/opscode_debug.logOutput file path for debug logs
OPSCODE_CODE_LOG_LEVELINFORuntime log level (DEBUG, INFO, WARNING, ERROR)
OPSCODE_CODE_AUTO_UPDATEenabledToggle automatic background package update checks
OPSCODE_CODE_COLLAPSE_PASTESenabledCollapse 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:

EcosystemPreserved environment variables
KubernetesKUBECONFIG, KUBE_CONTEXT
AWSAWS_PROFILE, AWS_REGION, AWS_DEFAULT_REGION, AWS_SHARED_CREDENTIALS_FILE
Google CloudGOOGLE_APPLICATION_CREDENTIALS, GOOGLE_CLOUD_PROJECT, CLOUDSDK_CORE_PROJECT
AzureAZURE_SUBSCRIPTION_ID, AZURE_TENANT_ID
Terraform / OpenTofuTF_CLI_CONFIG_FILE, TERRAGRUNT_CONFIG
Helm & ArgoCDHELM_HOME, HELM_REPOSITORY_CONFIG, ARGOCD_SERVER, ARGOCD_AUTH_TOKEN
AnsibleANSIBLE_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, or ansible.cfg
  • pyproject.toml, package.json, or Makefile

Data locations​

User directory (~/.opscode/)​

PathPurpose
~/.opscode/config.tomlPrimary user configuration file
~/.opscode/.envGlobal API keys and provider credentials
~/.opscode/hooks.jsonGlobal lifecycle hooks
~/.opscode/.mcp.jsonGlobal MCP server definitions
~/.opscode/memory/User-scoped saved memories
~/.opscode/settings.jsonUser-scoped plugin enablement state
~/.opscode/plugins/Downloaded marketplace plugins and cache
~/.opscode/.state/sessions.dbSQLite database storing conversation threads and checkpoints

Project directory (.opscode/)​

PathPurpose
.opscode/AGENTS.mdProject 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.jsonShared project plugin settings (Git-tracked)
.opscode/settings.local.jsonPersonal project overrides (gitignored)
.opscode/hooks.jsonProject lifecycle hooks
.opscode/.mcp.jsonProject MCP server configuration