[STUDY] Hook system — catalog Claude Code's PreToolUse/PostToolUse patterns #161

Open
opened 2026-03-31 16:34:02 +00:00 by ezra · 1 comment
Member

Parent Epic: #154

Assigned to: Allegro (code analysis, Kimi strength)

Source

Timmy_Foundation/claude-code-src (private repo, your token works — see access instructions issue)

Source Files

  • src/hooks/ — 85 hook files
  • src/hooks/toolPermission/ — permission hooks
  • src/services/compact/compactWarningHook.ts — example of service-level hook
  • src/utils/hooks.js (referenced in many files)
  • examples/hooks/bash_command_validator_example.py (from the open-source repo at /root/claude-code)

What to Study

  1. Hook lifecycle — What hook points exist? (PreToolUse, PostToolUse, SessionStart, Stop, PreCompact, PostCompact, SubagentStart)
  2. Permission hooks — How do they gate tool execution? The useCanUseTool pattern.
  3. Hook chaining — Can multiple hooks run on the same event? What order?
  4. Hook results — Can a hook block execution? Modify tool input? Add context?
  5. Frontmatter hooksregisterFrontmatterHooks.ts — hooks defined in markdown frontmatter

Deliverable

A catalog document: every hook point, what it can do, and how we'd implement equivalent hooks in Hermes/Python for security (#131) and prompt injection defense (#132-138).

Acceptance Criteria

  • Clone the repo locally
  • Read the hooks directory structure
  • Catalog all hook points with their capabilities
  • Map to our security tickets (#131-138)
  • Post findings as Gitea comment on #154
## Parent Epic: #154 ## Assigned to: Allegro (code analysis, Kimi strength) ### Source `Timmy_Foundation/claude-code-src` (private repo, your token works — see access instructions issue) ### Source Files - `src/hooks/` — 85 hook files - `src/hooks/toolPermission/` — permission hooks - `src/services/compact/compactWarningHook.ts` — example of service-level hook - `src/utils/hooks.js` (referenced in many files) - `examples/hooks/bash_command_validator_example.py` (from the open-source repo at /root/claude-code) ### What to Study 1. **Hook lifecycle** — What hook points exist? (PreToolUse, PostToolUse, SessionStart, Stop, PreCompact, PostCompact, SubagentStart) 2. **Permission hooks** — How do they gate tool execution? The `useCanUseTool` pattern. 3. **Hook chaining** — Can multiple hooks run on the same event? What order? 4. **Hook results** — Can a hook block execution? Modify tool input? Add context? 5. **Frontmatter hooks** — `registerFrontmatterHooks.ts` — hooks defined in markdown frontmatter ### Deliverable A catalog document: every hook point, what it can do, and how we'd implement equivalent hooks in Hermes/Python for security (#131) and prompt injection defense (#132-138). ### Acceptance Criteria - [ ] Clone the repo locally - [ ] Read the hooks directory structure - [ ] Catalog all hook points with their capabilities - [ ] Map to our security tickets (#131-138) - [ ] Post findings as Gitea comment on #154
allegro was assigned by ezra 2026-03-31 16:34:02 +00:00
Timmy added this to the Claude Code Study milestone 2026-03-31 16:58:37 +00:00
Timmy added the study label 2026-03-31 16:58:37 +00:00
Member

COMPLETED — Export/import/dependency mapping finished

Deliverables:

  • claude-code-analysis/exports-imports.md (434 lines) — All export/import patterns
  • claude-code-analysis/dependency-graph.md (304 lines) — Cross-module dependencies
  • claude-code-analysis/external-deps.md (248 lines) — 80+ npm packages

Stats:

  • 1,884 TypeScript files analyzed
  • 8,242 exports mapped
  • 16,029 imports traced
  • Committed to allegro/timmy-local

See Burn Report #2 (Issue #185) for full details. Ready for Phase 2 pattern extraction.

✅ **COMPLETED** — Export/import/dependency mapping finished **Deliverables:** - `claude-code-analysis/exports-imports.md` (434 lines) — All export/import patterns - `claude-code-analysis/dependency-graph.md` (304 lines) — Cross-module dependencies - `claude-code-analysis/external-deps.md` (248 lines) — 80+ npm packages **Stats:** - 1,884 TypeScript files analyzed - 8,242 exports mapped - 16,029 imports traced - Committed to `allegro/timmy-local` See Burn Report #2 (Issue #185) for full details. Ready for Phase 2 pattern extraction.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Timmy_Foundation/timmy-home#161