Cortex Code CLI 设置¶
Cortex Code CLI 设置用于控制工具权限、连接和会话行为。您可以使用托管策略(如果由组织提供)、配置文件、环境变量和命令行实参来配置这些设置。
配置文件
Cortex Code CLI 使用以下配置文件:
| File | Purpose |
|---|---|
<admin-managed path>/managed-settings.json | Organization-managed policy file (optional). For OS-specific locations, see . |
~/.snowflake/cortex/settings.json | Main Cortex Code CLI settings file. |
~/.snowflake/cortex/permissions.json | Permission preferences. |
~/.snowflake/cortex/mcp.json | MCP server configuration (see ). |
~/.snowflake/config.toml | Snowflake connections (see Cortex Code CLI). Shared with Snowflake CLI. |
主要配置目录的完整布局为:
设置优先级
设置按以下优先顺序(从高到低)应用:
- Managed settings restrictions (
settings.*fields inmanaged-settings.json). Can’t be overridden by any user-level configuration. See . - Profile overrides (
settingsOverridesfrom the active profile, if any). - Project settings (
.cortex/settings.jsonor.claude/settings.jsonin the working directory). - Managed settings defaults (
defaults.*fields inmanaged-settings.json). Users can override these in their ownsettings.json. - Global user settings (
~/.snowflake/cortex/settings.json). - Default values embedded in the Cortex Code CLI.
Permissions follow a separate evaluation order. See Permission evaluation.
settings.json¶
~/.snowflake/cortex/settings.jsonCortex Code CLI 的主要设置文件。
示例内容:
以下设置可用:
compactMode: Enables compact output formatting.autoUpdate: Enables automatic updates.theme: Sets the CLI theme (lightordark).
permissions.json¶
~/.snowflake/cortex/permissions.json控制工具访问权限。
示例内容:
以下设置可用:
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 可识别以下配置环境变量:
| Variable | Description |
|---|---|
SNOWFLAKE_HOME | Overrides the default ~/.snowflake directory. |
CORTEX_AGENT_MODEL | Overrides model selection. |
CORTEX_ENABLE_MEMORY | Enables the memory tool (set to true or 1). |
COCO_DANGEROUS_MODE_REQUIRE_SQL_WRITE_PERMISSION | Requires confirmation for SQL write operations in bypass mode. |
Note
For additional permission-related environment variables, see Security.
命令行替换
Cortex Code CLI 设置可以通过命令行实参替换,其中包括以下内容:
| Example | Description |
|---|---|
cortex -c production | Specifies the connection. |
cortex --workdir /path | Sets the working directory. |
cortex --continue | Continues the last session. |
cortex --resume <session_id> | Resumes a specific session. |
cortex --plan | Enables planning mode. |
cortex --dangerously-allow-all-tool-calls | Disables permission prompts (unsafe). |
会话存储
对话和设置存储位置:
| Location | Description |
|---|---|
~/.snowflake/cortex/conversations/ | Session files. |
~/.snowflake/cortex/permissions.json | Permission preferences. |
~/.snowflake/cortex/mcp.json | MCP configuration. |