beta

Auto Test Runner Hook

Hooks

Runs relevant tests automatically after the agent edits source files.

1803/26/2026
markdown1 file
hooks.json402 B
{
  "PostToolUse": [
    {
      "matcher": "Write|Edit",
      "hooks": [
        {
          "type": "command",
          "command": "FILE=$(jq -r '.tool_input.file_path // empty'); if echo "$FILE" | grep -qE '\.(ts|tsx|js|jsx)$' && ! echo "$FILE" | grep -qE '\.(test|spec)\.' ; then echo 'Running affected tests...'; npx vitest related "$FILE" --run 2>&1 | tail -5; fi"
        }
      ]
    }
  ]
}