Files
claude-howto/openspec/changes/update-hooks-lesson/tasks.md
T
Luong NGUYEN ee0f4bd5d9 docs: Update slash commands documentation with official features
- Add comprehensive built-in commands reference (40+ commands)
- Document argument handling ($ARGUMENTS, $1, $2, etc.)
- Add bash execution syntax (! prefix) and file references (@ prefix)
- Update frontmatter to official fields (allowed-tools, argument-hint, model, etc.)
- Add Plugin Commands and MCP Slash Commands sections
- Add SlashCommand Tool documentation for programmatic invocation
- Add Skills vs Slash Commands comparison table
- Create commit.md example with bash execution and context
- Update existing examples to use official frontmatter format
- Add OpenSpec proposal for change tracking
2025-12-24 15:30:47 +01:00

3.3 KiB

Tasks: Update Hooks Lesson

1. Content Structure Update

  • 1.1 Update introduction to explain hooks as event-driven automation scripts
  • 1.2 Replace hook architecture diagram with correct event flow
  • 1.3 Update hook types table with all 9 official hook events

2. Configuration Format

  • 2.1 Rewrite configuration section with array-based matcher/hooks structure
  • 2.2 Add hook matcher documentation (exact match, regex patterns, wildcards)
  • 2.3 Add timeout configuration examples

3. Hook Events Documentation

  • 3.1 Document PreToolUse event (matchers, decision control, updatedInput)
  • 3.2 Document PermissionRequest event (decision behavior, messages)
  • 3.3 Document PostToolUse event (block decision, additionalContext)
  • 3.4 Document Notification event (matchers: permission_prompt, idle_prompt, etc.)
  • 3.5 Document UserPromptSubmit event (block decision, context addition)
  • 3.6 Document Stop event (block continuation, stop_hook_active)
  • 3.7 Document SubagentStop event (subagent completion handling)
  • 3.8 Document PreCompact event (manual vs auto matchers)
  • 3.9 Document SessionStart event (startup/resume/clear/compact matchers, CLAUDE_ENV_FILE)
  • 3.10 Document SessionEnd event (reason field)

4. Hook Input/Output

  • 4.1 Document JSON stdin input structure (session_id, transcript_path, cwd, etc.)
  • 4.2 Document exit code semantics (0=success, 2=blocking error, other=non-blocking)
  • 4.3 Document JSON stdout output structure (continue, stopReason, hookSpecificOutput)
  • 4.4 Add examples for each hook event's specific output format

5. Prompt-Based Hooks

  • 5.1 Add section on type="prompt" hooks for Stop/SubagentStop
  • 5.2 Document LLM response schema (decision, reason, continue, stopReason)
  • 5.3 Add practical examples of intelligent stop hooks

6. Environment Variables

  • 6.1 Document CLAUDE_PROJECT_DIR usage
  • 6.2 Document CLAUDE_ENV_FILE for SessionStart env persistence
  • 6.3 Document CLAUDE_CODE_REMOTE for web environment detection
  • 6.4 Document plugin hook variables (${CLAUDE_PLUGIN_ROOT})

7. Security Section

  • 7.1 Add official security disclaimer (USE AT YOUR OWN RISK)
  • 7.2 Document security best practices (input validation, quoting, path traversal)
  • 7.3 Add configuration safety notes (snapshot at startup, modification warnings)

8. Advanced Features

  • 8.1 Add MCP tool hook patterns (mcp____)
  • 8.2 Add plugin hooks documentation
  • 8.3 Add project-specific hook script examples

9. Debugging and Troubleshooting

  • 9.1 Update debugging section with claude --debug flag
  • 9.2 Add verbose mode (ctrl+o) documentation
  • 9.3 Update troubleshooting with correct error scenarios

10. Example Scripts

  • 10.1 Rewrite format-code hook to use JSON stdin
  • 10.2 Rewrite security-scan hook with proper JSON input parsing
  • 10.3 Rewrite bash command validator example from official docs
  • 10.4 Add intelligent stop hook example with prompt type
  • 10.5 Remove non-existent PreCommit/PostCommit/PrePush examples

11. Final Cleanup

  • 11.1 Update Mermaid diagrams for accuracy
  • 11.2 Update variable reference table to reflect JSON input
  • 11.3 Update best practices table
  • 11.4 Update directory structure section
  • 11.5 Verify all links and references