Section: Hooks basics

Minimal command hook template

json
json
{
  "version": 1,
  "hooks": {
    "preToolUse": [
      {
        "type": "command",
        "bash": "./scripts/pre-tool.sh",
        "powershell": "./scripts/pre-tool.ps1",
        "cwd": "scripts",
        "timeoutSec": 30
      }
    ]
  }
}
Explanation

The command-hook schema supports `bash`, `powershell`, `cwd`, `env`, and `timeoutSec`.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Hooks basics
Store hooks in the repository
Hooks are loaded from a repository folder.
OpenIn sheettextsame section
Run a session-start hook script
Trigger repo automation when a session begins.
OpenIn sheetjsonsame section
Log prompts for auditing
Call a script that records prompt activity.
OpenIn sheetjsonsame section
Add an MCP server for one session from a file
Load additional MCP server config at runtime.
OpenIn sheetbash1 tag match
Project skill directory
Store project skills in the standard directory.
OpenIn sheettext1 tag match
Disable all built-in MCP servers
Run without the default built-in servers.
OpenIn sheetbash1 tag match