Expand description
Loading and resolving clash configuration and policy files.
This module is the entry point for the settings system. It defines the core
ClashSettings struct and re-exports public items from submodules:
env— Environment variable checks for clash mode control.- [
discovery] — Policy file discovery, preset types, and default policy compilation. - [
loader] — Policy loading, compilation, andClashSettingsconstruction.
Structs§
- Clash
Settings - Hook
Context - Session-level context from Claude Code hook input.
- Loaded
Policy - A policy source loaded from a specific level.
- Sandbox
Preset - A sandbox preset that can be selected during
clash init.
Enums§
- Policy
Level - Policy level — where a policy file lives in the precedence hierarchy.
Constants§
- CLASH_
DISABLE_ ENV - The environment variable that disables all clash hooks.
- CLASH_
NO_ HARNESS_ DEFAULTS_ ENV - Environment variable to disable harness default permissions.
- CLASH_
PASSTHROUGH_ ENV - The environment variable that enables passthrough mode.
- DEFAULT_
POLICY_ TEMPLATE - Default policy source template embedded at compile time.
Contains
{preset}placeholders for the sandbox preset name. - SANDBOX_
PRESETS - Available sandbox presets for
clash init.
Functions§
- compile_
default_ policy_ to_ json - Compile the embedded default policy template to JSON.
- compile_
default_ policy_ to_ json_ with_ preset - Compile the default policy with a preset name (legacy — presets are now baked into the template). Ignores the preset argument.
- evaluate_
policy_ file - Evaluate a policy file and return the compiled JSON source.
- evaluate_
star_ policy - Evaluate a
.starpolicy file and return the compiled JSON source. - is_
disabled - Check whether clash is disabled via the
CLASH_DISABLEenvironment variable. - is_
harness_ defaults_ disabled - Check whether harness defaults are disabled via the
CLASH_NO_HARNESS_DEFAULTSenvironment variable. - is_
passthrough - Check whether clash is in passthrough mode via the
CLASH_PASSTHROUGHenvironment variable. - parse_
notification_ config - Extract the
notifications:section from a YAML string. - policy_
file - Returns the user-level policy file path.
- project_
policy_ file - Returns the project-level policy file path.
- session_
policy_ file - Returns the session-level policy file path for the given session ID.
- settings_
dir - Returns the clash settings directory (
~/.clash/).