Files
Claude-Code-Game-Studios/.claude/docs/hooks-reference/hook-input-schemas.md
T
DonchitosandClaude Opus 5 d05699707f Release 1.1.0 — one config file, and a process weight you choose
`project.yaml` at the repo root is now the single source of truth for a
project's configuration, replacing `production/stage.txt`,
`production/review-mode.txt` and `.claude/docs/technical-preferences.md` (all
three still read as a fallback; nothing is force-deleted).

**`modes.rigor` — one question instead of six.** `minimal`, `standard` or
`full` fronts six knobs: `modes.workflow`, `docs.density`, `qa.level`,
`modes.story_granularity`, `modes.review_mode` and `team.size`. It defaults to
`minimal`, which is a change from 1.0's behaviour: the heavier tier was
measured costing several times more to reach working code without producing a
better result, and returning nothing when a fresh developer inherited the
project. Pin `modes.rigor: standard` to keep 1.0's process level.

Also in this release:

- `/settings` to view or change any setting, and `project.local.yaml` for
  per-developer preferences that should not be committed.
- `system_overrides` to hold one system to a higher standard than the rest of
  the project, and `testing.strict` to set per test type whether missing
  evidence blocks a story or warns.
- A story that changes anything the player sees is not closed until the game
  has been launched, observed, and a screenshot retained in
  `production/qa/evidence/`. A parse check is not a run. This holds at every
  rigor level, including `minimal`, where automated tests are waived but the
  look is not.
- The code root is engine-specific and enforced as such: Godot `src/`, Unity
  `Assets/`, Unreal `Source/<Module>/`. Two of the three will not build a
  project laid out any other way.
- Migration tooling for existing projects: `.claude/scripts/migrate-v1-config.sh`
  converts a 1.0 layout, non-destructively by default, with a report to review
  before `--finalize` deletes anything.
- Ask-before-write holds regardless of personal automation settings.

Upgrading from 1.0 or earlier: see UPGRADING.md. Full list of changes:
CHANGELOG.md.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016xvzG3i7pWQg4LjyDwWMXd
2026-09-23 12:25:11 +10:00

129 lines
2.9 KiB
Markdown

# Hook Input/Output Schemas
This documents the JSON payloads each Claude Code hook receives on stdin for every event type.
## PreToolUse
Fired before a tool is executed. Can **allow** (exit 0) or **block** (exit 2).
### PreToolUse: Bash
```json
{
"tool_name": "Bash",
"tool_input": {
"command": "git commit -m 'feat: add player health system'",
"description": "Commit changes with message",
"timeout": 120000
}
}
```
### PreToolUse: Write
```json
{
"tool_name": "Write",
"tool_input": {
"file_path": "src/gameplay/health.gd",
"content": "extends Node\n..."
}
}
```
### PreToolUse: Edit
```json
{
"tool_name": "Edit",
"tool_input": {
"file_path": "src/gameplay/health.gd",
"old_string": "var health = 100",
"new_string": "var health: int = 100"
}
}
```
### PreToolUse: Read
```json
{
"tool_name": "Read",
"tool_input": {
"file_path": "src/gameplay/health.gd"
}
}
```
## PostToolUse
Fired after a tool completes. **Cannot block** (exit code ignored for blocking). Stderr messages are shown as warnings.
### PostToolUse: Write
```json
{
"tool_name": "Write",
"tool_input": {
"file_path": "assets/data/enemy_stats.json",
"content": "{\"goblin\": {\"health\": 50}}"
},
"tool_output": "File written successfully"
}
```
### PostToolUse: Edit
```json
{
"tool_name": "Edit",
"tool_input": {
"file_path": "assets/data/enemy_stats.json",
"old_string": "\"health\": 50",
"new_string": "\"health\": 75"
},
"tool_output": "File edited successfully"
}
```
## SubagentStart
Fired when a subagent is spawned via the `Agent` tool (named `Task` before
Claude Code 2.1.63; `Task` still works as an alias in permission rules and
`tools:` frontmatter, but the hook payload's `tool_name` is now `Agent`).
```json
{
"agent_name": "game-designer",
"model": "sonnet",
"description": "Design the combat healing mechanic"
}
```
## SessionStart
Fired when a Claude Code session begins. **No stdin input** — the hook just runs and its stdout is shown to Claude as context.
## PreCompact
Fired before context window compression. **No stdin input** — the hook runs to save state before compression occurs.
## Stop
Fired when the Claude Code session ends. **No stdin input** — the hook runs for cleanup and logging.
## Exit Code Reference
| Exit Code | Meaning | Applicable Events |
|-----------|---------|-------------------|
| 0 | Allow / Success | All events |
| 2 | Block (stderr shown to Claude) | PreToolUse only |
| Other | Treated as error, tool proceeds | All events |
## Notes
- Hooks receive JSON on **stdin** (pipe). Use `INPUT=$(cat)` to capture.
- Parse with `jq` if available, fall back to `grep` for cross-platform compatibility.
- On Windows, `grep -P` (Perl regex) is often unavailable. Use `grep -E` (POSIX extended) instead.
- Path separators may be `\` on Windows. Normalize with `sed 's|\\|/|g'` when comparing paths.