Cortex Code CLI 设置

Cortex Code CLI 设置用于控制工具权限、连接和会话行为。您可以使用托管策略(如果由组织提供)、配置文件、环境变量和命令行实参来配置这些设置。

配置文件

Cortex Code CLI 使用以下配置文件:

FilePurpose
<admin-managed path>/managed-settings.jsonOrganization-managed policy file (optional). For OS-specific locations, see .
~/.snowflake/cortex/settings.jsonMain Cortex Code CLI settings file.
~/.snowflake/cortex/permissions.jsonPermission preferences.
~/.snowflake/cortex/mcp.jsonMCP server configuration (see ).
~/.snowflake/config.tomlSnowflake connections (see Cortex Code CLI). Shared with Snowflake CLI.

主要配置目录的完整布局为:

~/.snowflake/cortex/        # Main Cortex Code CLI config directory
 settings.json          # Main settings
 mcp.json               # MCP server configs
 permissions.json       # Saved permissions
 hooks.json             # Global hooks
 history                # Command history
 conversations/         # Session files
 cache/                 # Temporary cache
    table_cache.json   # SQL result metadata
    sql_result_cache/  # Parquet files
 logs/                  # Log files
 memory/                # Persistent memory
 agents/                # Custom agents
 skills/                # Global skills
 commands/              # Custom commands
 hooks/                 # Hook scripts
 remote_cache/          # Cloned repos

设置优先级

设置按以下优先顺序(从高到低)应用:

  1. Managed settings restrictions (settings.* fields in managed-settings.json). Can’t be overridden by any user-level configuration. See .
  2. Profile overrides (settingsOverrides from the active profile, if any).
  3. Project settings (.cortex/settings.json or .claude/settings.json in the working directory).
  4. Managed settings defaults (defaults.* fields in managed-settings.json). Users can override these in their own settings.json.
  5. Global user settings (~/.snowflake/cortex/settings.json).
  6. Default values embedded in the Cortex Code CLI.

Permissions follow a separate evaluation order. See Permission evaluation.

settings.json

~/.snowflake/cortex/settings.json

Cortex Code CLI 的主要设置文件。

示例内容:

{
   "compactMode": true,
   "autoUpdate": true,
   "theme": "dark"
}

以下设置可用:

  • compactMode: Enables compact output formatting.
  • autoUpdate: Enables automatic updates.
  • theme: Sets the CLI theme (light or dark).

permissions.json

~/.snowflake/cortex/permissions.json

控制工具访问权限。

示例内容:

{
  "onlyAllow": ["read_file", "execute_sql"],
  "defaultMode": "ask",
  "dangerouslyAllowAll": false
}

以下设置可用:

  • onlyAllow: List of allowed tool patterns.
  • defaultMode: Default permission mode (ask, allow, deny).
  • dangerouslyAllowAll: Allows all tools without prompts (unsafe).

托管设置(组织策略)

Administrators can deploy a system-level JSON policy file to enforce Cortex Code CLI behavior across an organization, restricting tools, accounts, and minimum versions. For details, see Managed settings (organization policy).

环境变量

Cortex Code CLI 可识别以下配置环境变量:

VariableDescription
SNOWFLAKE_HOMEOverrides the default ~/.snowflake directory.
CORTEX_AGENT_MODELOverrides model selection.
CORTEX_ENABLE_MEMORYEnables the memory tool (set to true or 1).
COCO_DANGEROUS_MODE_REQUIRE_SQL_WRITE_PERMISSIONRequires confirmation for SQL write operations in bypass mode.

Note

For additional permission-related environment variables, see Security.

命令行替换

Cortex Code CLI 设置可以通过命令行实参替换,其中包括以下内容:

ExampleDescription
cortex -c productionSpecifies the connection.
cortex --workdir /pathSets the working directory.
cortex --continueContinues the last session.
cortex --resume <session_id>Resumes a specific session.
cortex --planEnables planning mode.
cortex --dangerously-allow-all-tool-callsDisables permission prompts (unsafe).

会话存储

对话和设置存储位置:

LocationDescription
~/.snowflake/cortex/conversations/Session files.
~/.snowflake/cortex/permissions.jsonPermission preferences.
~/.snowflake/cortex/mcp.jsonMCP configuration.