Configuration

Hooks are configured under the hooks key in a settings.json file. Command Code looks for settings.json in the following paths:

ScopeConfig fileApplies toCommitted to git?
User~/.commandcode/settings.jsonAcross all projectsNo
Project.commandcode/settings.jsonAnyone using the projectYes

Precedence: project > user. When the exact same command string appears in multiple scopes, the higher-priority source wins.


Within the same event, hooks fire in the order they appear in settings.json (project first, then user).

For example, PreToolUse hooks run sequentially. As soon as one blocks the tool, the remaining PreToolUse hooks are skipped. PostToolUse hooks run in parallel because the tool has already finished.

You can wire multiple hooks under a single matcher. They run in listed order:

{ "hooks": { "PreToolUse": [ { "matcher": "shell", "hooks": [ { "type": "command", "command": "./.commandcode/hooks/guard-bash.sh", "timeout": 5 }, { "type": "command", "command": "./.commandcode/hooks/log-shell.sh" } ] } ] } }

Here guard-bash.sh runs first. If it denies, log-shell.sh is skipped.

For a complete settings.json wiring multiple matchers across both events, see Hooks Reference: Example settings.json.