Skip to main content

Module settings

Module settings 

Source
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, and ClashSettings construction.

Structs§

ClashSettings
HookContext
Session-level context from Claude Code hook input.
LoadedPolicy
A policy source loaded from a specific level.
SandboxPreset
A sandbox preset that can be selected during clash init.

Enums§

PolicyLevel
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 .star policy file and return the compiled JSON source.
is_disabled
Check whether clash is disabled via the CLASH_DISABLE environment variable.
is_harness_defaults_disabled
Check whether harness defaults are disabled via the CLASH_NO_HARNESS_DEFAULTS environment variable.
is_passthrough
Check whether clash is in passthrough mode via the CLASH_PASSTHROUGH environment 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/).