Skip to content

feat: capture all 25 Claude Code hook events for complete headless coverage#45

Merged
scotthavird merged 2 commits intomainfrom
feat/headless-hook-coverage
Apr 11, 2026
Merged

feat: capture all 25 Claude Code hook events for complete headless coverage#45
scotthavird merged 2 commits intomainfrom
feat/headless-hook-coverage

Conversation

@scotthavird
Copy link
Copy Markdown
Contributor

Summary

PromptConduit was only installing 12 of Claude Code's 25 hook events. This PR adds the missing 13, giving users complete event capture across all Claude Code features — including agent teams, MCP interactions, context compaction, worktrees, and headless/CI workflows.

Closes #44

Companion PR (platform): promptconduit/platform#100 (link TBD — created in parallel)

Changes

cmd/install.gobuildClaudeCodeHooks()

  • Added 13 missing hook events: StopFailure, PermissionDenied, TaskCreated, TaskCompleted, TeammateIdle, InstructionsLoaded, ConfigChange, CwdChanged, FileChanged, PostCompact, WorktreeCreate, WorktreeRemove, Elicitation, ElicitationResult
  • Reorganized the map by logical category (session, per-turn, tool, agent/task, file/config, context, MCP, notifications)
  • TRACKED_EVENTS in the platform adapter now auto-derives from the map keys (no separate list to keep in sync)

README.md

  • Updated event types table from 9 rows to 29 (all canonical types)
  • Added Headless Mode section documenting claude -p compatibility and the --bare limitation with --settings workaround

Code Walkthrough

Before vs. After — buildClaudeCodeHooks()

// Before: 12 hooks
return map[string]interface{}{
    "UserPromptSubmit": ..., "PreToolUse": ..., "PostToolUse": ...,
    "PostToolUseFailure": ..., "SessionStart": ..., "SessionEnd": ...,
    "Stop": ..., "SubagentStart": ..., "SubagentStop": ...,
    "PreCompact": ..., "PermissionRequest": ..., "Notification": ...,
}

// After: 25 hooks (all Claude Code hook events)
return map[string]interface{}{
    // Session lifecycle
    "SessionStart": ..., "SessionEnd": ...,
    // Per-turn
    "UserPromptSubmit": ..., "Stop": ..., "StopFailure": ...,
    // Tool
    "PreToolUse": ..., "PostToolUse": ..., "PostToolUseFailure": ...,
    "PermissionRequest": ..., "PermissionDenied": ...,
    // Agent/task
    "SubagentStart": ..., "SubagentStop": ...,
    "TaskCreated": ..., "TaskCompleted": ..., "TeammateIdle": ...,
    // File/config
    "InstructionsLoaded": ..., "ConfigChange": ...,
    "CwdChanged": ..., "FileChanged": ...,
    // Context
    "PreCompact": ..., "PostCompact": ...,
    "WorktreeCreate": ..., "WorktreeRemove": ...,
    // MCP
    "Elicitation": ..., "ElicitationResult": ...,
    // Notifications
    "Notification": ...,
}

All new hooks use the same makeHook(5000) or makeMatcherHook(5000) helpers — zero new infrastructure, purely additive.

Headless Mode (--bare) Limitation

# Events NOT captured — hooks skipped:
claude --bare -p "do something"

# Workaround — explicitly load settings:
claude --bare -p "do something" --settings ~/.claude/settings.json

This is documented in the README. The --bare mode is expected to become default for -p in a future Claude Code release, making this documentation critical.

Testing

  • make build passes cleanly
  • All 25 hook entries verified present in the generated map
  • No new helper functions — existing code path handles all new events identically
  • Platform adapter changes verified type-clean (companion PR)

Agent Review Context

  • change-type: feature
  • risk-level: low
  • key-files: cmd/install.go (the only functional change), README.md (docs)
  • testing-confidence: high — additive change, same code path as existing 12 hooks

Checklist

  • Tests pass (make build)
  • No breaking changes — additive only; existing installs can re-run promptconduit install claude-code
  • Code follows project conventions

Previously only 12 of 25 hooks were installed. Added the missing 13:
- StopFailure, PermissionDenied
- TaskCreated, TaskCompleted, TeammateIdle (agent teams)
- InstructionsLoaded, ConfigChange, CwdChanged, FileChanged
- PostCompact, WorktreeCreate, WorktreeRemove
- Elicitation, ElicitationResult (MCP)

Also updated README with complete event type table and headless mode
documentation including the --bare limitation and --settings workaround.

Refs #44
AI-Tool: claude-code
AI-Session: d2758b26-b1c4-40fd-94cb-61f497c2110e
- PreCompact, PostCompact, WorktreeCreate, WorktreeRemove are session-
  level events with no tool context; use makeHook not makeMatcherHook
- Add missing subagent_stop row to README event types table

Refs #44
AI-Tool: claude-code
AI-Session: d2758b26-b1c4-40fd-94cb-61f497c2110e
@scotthavird
Copy link
Copy Markdown
Contributor Author

Conversation Transcripts

Tool Session Gist Local Path
Claude Code d2758b26-b1c4-40fd-94cb-61f497c2110e View transcript ~/.claude/projects/-Users-scotthavird-Documents-GitHub-promptconduit/d2758b26-b1c4-40fd-94cb-61f497c2110e.jsonl

Full conversation context including problem discovery, solution design, and implementation decisions.

To load in a future session:

gh gist view 63490157b111484b986112e7dd21796b --raw

@scotthavird scotthavird merged commit b0252ee into main Apr 11, 2026
1 check passed
@scotthavird scotthavird deleted the feat/headless-hook-coverage branch April 11, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: capture all 25 Claude Code hook events for complete headless coverage

1 participant