Skip to main content

Configuration

Configure OpsCode with config.toml, environment variables, hooks, and CLI flags.

OpsCode stores configuration under ~/.opscode/ and in project-level dotfiles (.opscode/). For the full directory tree, session storage, and skill paths, see Data locations.

The main configuration files are:

FileDescription
config.tomlModel defaults, provider settings, UI themes, tool allowlists, and permissions
Environment variablesAPI keys and secrets in ~/.opscode/.env or shell exports
hooks.jsonLifecycle event subscriptions for audit logging and tool guards
.mcp.jsonGlobal and project MCP server definitions

How settings resolve

OpsCode merges settings from several sources in a strictly defined precedence order.

General options (interpreter limits, update settings, themes, and config.toml keys) resolve in this order:

  1. OPSCODE_CODE_-prefixed environment variable
  2. Canonical environment variable (when applicable)
  3. ~/.opscode/config.toml
  4. Built-in default

Provider API keys use a separate resolution order. See Key resolution order.

Dotenv files load at startup: the nearest project .env (walking up from the launch directory), then ~/.opscode/.env. Shell exports always take priority over .env values. See Loading order and precedence.


Inspect configuration

The opscode config command group reports what configuration is in effect and where each value originates, without starting an interactive session.

CommandDescription
opscode config showResolve every option and print the effective value and source
opscode config list (alias ls)List every available option with its type, default, and valid scopes
opscode config get <key>Show the effective value and source for a single option
opscode config set <key> <value>Set a configuration value in ~/.opscode/config.toml
opscode config pathShow config file locations and whether each exists

Or use /config inside an interactive session to view and modify settings.


Environment variables

Loading order and precedence

OpsCode loads .env files at startup in this order:

  1. Project .env — walks up from the current directory to find the nearest .env file
  2. Global ~/.opscode/.env — user-level keys (provider credentials, Tavily, LangSmith)

Shell exports always override .env values. The OPSCODE_ prefix takes priority over canonical variable names:

OPSCODE_OPENAI_API_KEY  >  OPENAI_API_KEY  >  ~/.opscode/.env  >  project .env

Security

The following environment variables are blocked from being set via .env files to prevent environment hijacking:

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.

warning

These variables are blocked because a malicious .env file committed to a repository could hijack your shell, inject preloaded libraries, or redirect temporary files.

OPSCODE_CODE_* variables

OpsCode reads the following runtime environment variables:

VariableDescription
OPSCODE_CODE_DEBUGEnable verbose debug logging
OPSCODE_CODE_DEBUG_FILEPath for the debug log file (default: /tmp/opscode_debug.log)
OPSCODE_CODE_LOG_LEVELOverride runtime logging level (DEBUG, INFO, WARNING, ERROR)
OPSCODE_CODE_AUTO_UPDATEToggle automatic package updates (default: enabled)
OPSCODE_CODE_COLLAPSE_PASTESCollapse large chat-input pastes into placeholders (default: enabled)

DevOps environment preservation

OpsCode automatically isolates and preserves DevOps-specific environment variables across tool and subprocess executions:

CategoryVariables
KubernetesKUBECONFIG, KUBE_CONTEXT
AWSAWS_PROFILE, AWS_REGION, AWS_DEFAULT_REGION, AWS_SHARED_CREDENTIALS_FILE
GCPGOOGLE_APPLICATION_CREDENTIALS, GOOGLE_CLOUD_PROJECT, CLOUDSDK_CORE_PROJECT
AzureAZURE_SUBSCRIPTION_ID, AZURE_TENANT_ID
AnsibleANSIBLE_CONFIG, ANSIBLE_INVENTORY
HelmHELM_HOME, HELM_REPOSITORY_CONFIG
ArgoCDARGOCD_SERVER, ARGOCD_AUTH_TOKEN
Terraform / OpenTofuTF_CLI_CONFIG_FILE, TERRAGRUNT_CONFIG

This ensures that when the agent runs kubectl, terraform, tofu, helm, or other DevOps CLIs, your local credentials and cluster contexts remain immediately accessible.


Project detection

OpsCode auto-detects the project root by walking up from the current working directory, looking for these markers:

MarkerType
.opscode/OpsCode project configuration root
.git/Git repository
terragrunt.hclTerragrunt project
Chart.yamlHelm chart root
ansible.cfgAnsible project
pyproject.tomlPython project
package.jsonNode.js project
MakefileBuild system

When a project root is detected, project-level configuration (.opscode/, .env, skills, subagents, memory) is discovered and merged with user-level settings.


Data locations

User-level (~/.opscode/)

PathPurpose
~/.opscode/config.tomlMain configuration file
~/.opscode/.envGlobal API keys and secrets
~/.opscode/hooks.jsonLifecycle hooks
~/.opscode/.mcp.jsonGlobal MCP server definitions
~/.opscode/memory/User-scoped memory entries
~/.opscode/settings.jsonUser-scope settings (enabled plugins, etc.)
~/.opscode/plugins/Plugin storage (cache, data, marketplaces)

Agent-specific (~/.opscode/{agent}/)

PathPurpose
~/.opscode/{agent}/skills/User-level skills for this agent
~/.opscode/{agent}/agents/User-level subagents for this agent
~/.opscode/{agent}/AGENTS.mdUser-level agent instructions and memories

Managed state (~/.opscode/.state/)

These files are machine-managed. Do not edit them manually.

PathPurpose
sessions.dbConversation checkpoints and threads
auth.jsonCredential store (gateway/OpenRouter auth)
history.jsonlInteractive command input history
recent_models.jsonRecent /model selections (up to 10 entries)
mcp_trust.jsonMCP project trust decisions
skill_trust.jsonSkill trust decisions
onboarding_completeFirst-run onboarding marker
installed_plugins.jsonInstalled plugin registry
plugin_state.jsonPlugin runtime state
plugin_marketplaces.jsonMarketplace sources registry

Project-level (.opscode/)

PathPurpose
.opscode/skills/Project skills
.opscode/agents/Project subagents
.opscode/plugins/Project plugins
.opscode/memory/Project-scoped memory
.opscode/AGENTS.mdProject-level agent instructions
.opscode/settings.jsonProject-scope settings (committed to Git)
.opscode/settings.local.jsonLocal-scope settings (gitignored personal overrides)
.opscode/hooks.jsonProject-level hooks
.opscode/.mcp.jsonProject-level MCP servers

Universal shared data (~/.agents/, .agents/)

PathPurpose
~/.agents/skills/User-level tool-agnostic skills (shared across agents)
.agents/skills/Project-level tool-agnostic skills (shared across agents)

Settings precedence summary

Setting typeResolution order (first wins)
General optionsOPSCODE_CODE_* env → canonical env → config.toml → default
Provider API keysOPSCODE_{KEY} env → canonical env → ~/.opscode/.env/auth stored
Provider base URLsStored base URL → env var → default endpoint
SkillsBuilt-in → Plugin → User → Project (project overrides all)
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 → Global ~/.opscode/.mcp.json
HooksProject .opscode/hooks.json + Global ~/.opscode/hooks.json (merged)