--- description: Create hook(s) following standardized structure - supports parallel creation for 3+ hooks argument-hint: "" [--plugin=name] [--marketplace] | ... [--plugin=name] [--marketplace] --- --- 🚨 **EXECUTION NOTICE FOR CLAUDE** When you invoke this command via `SlashCommand(/domain-plugin-builder:hooks-create ...)`, the system returns THESE INSTRUCTIONS below. **YOU are the executor. This is NOT an autonomous subprocess.** - ✅ The phases below are YOUR execution checklist - ✅ YOU must run each phase immediately using tools (Bash, Read, Write, Edit, TodoWrite) - ✅ Complete ALL phases before considering this command done - ❌ DON'T wait for "the command to complete" - YOU complete it by executing the phases - ❌ DON'T treat this as status output - it IS your instruction set **Immediately after SlashCommand returns, start executing Phase 0, then Phase 1, etc.** See `@CLAUDE.md` section "SlashCommand Execution - YOU Are The Executor" for detailed explanation. --- ## Security Requirements **CRITICAL:** All generated files must follow security rules: @~/.claude/plugins/marketplaces/dev-lifecycle-marketplace/docs/security/SECURITY-RULES.md **Key requirements:** - Never hardcode API keys or secrets - Use placeholders: `your_service_key_here` - Protect `.env` files with `.gitignore` - Create `.env.example` with placeholders only - Document key acquisition for users **Arguments**: $ARGUMENTS Goal: Create properly structured hooks. For 3+ hooks, creates them in parallel for faster execution. **CRITICAL EXECUTION INSTRUCTIONS:** - DO NOT wait for phases to run automatically - DO NOT just explain what the phases do - EXECUTE each phase immediately using the actual tools (Bash, Read, Write, Edit, TodoWrite, Task) - The `!{tool command}` syntax shows you WHAT to execute - use the real tool to DO IT - Complete all phases in order before finishing Phase 0: Create Todo List Create todo list for all phases below. Phase 1: Load Architectural Framework Actions: - Load component decision guidance: !{Read ~/.claude/plugins/marketplaces/domain-plugin-builder/plugins/domain-plugin-builder/docs/frameworks/claude/reference/component-decision-framework.md} - Load composition patterns: !{Read ~/.claude/plugins/marketplaces/domain-plugin-builder/plugins/domain-plugin-builder/docs/frameworks/claude/reference/dans-composition-pattern.md} - These provide critical understanding of: - Hooks are for event-driven automation - When to use hooks vs commands - Hook boundaries and responsibilities - How hooks integrate with plugin ecosystem - Anti-patterns to avoid Phase 2: Parse Arguments and Determine Plugin & Mode Parse $ARGUMENTS to extract: - Hook names and event types - Plugin name (from --plugin=name or detect from pwd) - Marketplace mode (check for --marketplace flag) If plugin not specified: !{bash basename $(pwd)} Determine base path - check if already in a plugin directory: !{bash test -f .claude-plugin/plugin.json && echo "." || (echo "$ARGUMENTS" | grep -q "\-\-marketplace" && echo "plugins/$(basename $(pwd))" || echo ".")} Store as $BASE_PATH: - If .claude-plugin/plugin.json exists: BASE_PATH="." (already in plugin directory) - Else if --marketplace present: BASE_PATH="plugins/$PLUGIN_NAME" - Else: BASE_PATH="." (standalone plugin mode) All subsequent file operations use $BASE_PATH instead of hardcoded "plugins/$PLUGIN_NAME" Phase 3: Load Hooks Documentation WebFetch: https://docs.claude.com/en/docs/claude-code/hooks-guide This provides context on: - Available event types and when they trigger - Hook configuration structure - Script patterns and best practices Phase 4: Parse Arguments & Determine Mode Actions: Use bash to parse $ARGUMENTS and count how many hooks are being requested: !{bash echo "$ARGUMENTS" | grep -oE '<[^>]+>' | wc -l} Store the count. Then extract each hook specification: - If count = 1: Single hook mode - extract , , and "" - If count = 2: Two hooks mode - extract both sets - If count >= 3: Multiple hooks mode - extract all sets Execution modes: - 1 hook: Direct creation - 2 hooks: Sequential creation - 3+ hooks: Parallel creation (invoke multiple hooks-builder agents) Phase 5: Create Hooks **Mode 1: Single Hook (1 hook)** Task(description="Create hook", subagent_type="domain-plugin-builder:hooks-builder", prompt="You are the hooks-builder agent. Create a complete hook. Hook name: Event type: Action: Plugin: Create hook configuration and script: - Executable script in $BASE_PATH/scripts/ - Hook entry in $BASE_PATH/hooks/hooks.json - Documentation in $BASE_PATH/docs/hooks.md - Use ${CLAUDE_PLUGIN_ROOT} for paths - Validate hook structure Deliverable: Complete hook with script, config, and documentation") **Mode 2: Sequential (2 hooks)** For each hook sequentially: Task(description="Create hook N", subagent_type="domain-plugin-builder:hooks-builder", prompt="") Wait for completion, then create next hook. **Mode 3: Parallel (3+ hooks)** Create TODO list: TodoWrite with list of all hooks to create. Launch ALL hooks-builder agents IN PARALLEL (all at once): Task(description="Create hook 1", subagent_type="domain-plugin-builder:hooks-builder", prompt="You are the hooks-builder agent. Create a complete hook. Hook name: $HOOK_1 Event type: $EVENT_1 Action: $ACTION_1 Plugin: $PLUGIN_NAME Create: - Script: $BASE_PATH/scripts/$HOOK_1.sh - Config: Update $BASE_PATH/hooks/hooks.json - Docs: Update $BASE_PATH/docs/hooks.md - Use ${CLAUDE_PLUGIN_ROOT} for all paths Deliverable: Complete hook") Task(description="Create hook 2", subagent_type="domain-plugin-builder:hooks-builder", prompt="Create hook: $HOOK_2 - Event: $EVENT_2 [same prompt structure as hook 1 above]") Task(description="Create hook 3", subagent_type="domain-plugin-builder:hooks-builder", prompt="Create hook: $HOOK_3 - Event: $EVENT_3 [same prompt structure as hook 1 above]") [Continue for all N hooks requested] Each Task() call happens in parallel. Parse $ARGUMENTS to determine how many Task() calls to make. Wait for ALL agents to complete before proceeding. Update TodoWrite as each completes. Phase 5.5: Git Commit and Push Goal: Save work immediately Actions: - Add all hook files to git: !{bash git add $BASE_PATH/hooks/ $BASE_PATH/scripts/ $BASE_PATH/docs/hooks.md} - Commit with message: !{bash git commit -m "$(cat <<'EOF' feat: Add hook(s) - HOOK_NAMES Complete hook structure with scripts, config, and documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude EOF )"} - Push to GitHub: !{bash git push origin master} Phase 5.6: Sync to Airtable Goal: Sync ALL created hooks to Airtable in bulk Actions: **Use bulk sync script for efficiency:** Bash: python ~/.claude/plugins/marketplaces/domain-plugin-builder/plugins/domain-plugin-builder/scripts/bulk-sync-airtable.py --plugin={plugin-name} --marketplace={marketplace-name} --type=hooks This syncs ALL hooks in parallel instead of one at a time. **Environment Requirement:** - Requires AIRTABLE_TOKEN environment variable - If not set, displays error message with instructions Phase 6: Self-Validation Run validation checks to verify all work completed: !{bash test -f $BASE_PATH/hooks/hooks.json && echo "✅ hooks.json exists" || echo "❌ hooks.json MISSING"} !{bash test -d $BASE_PATH/scripts && echo "✅ scripts/ exists" || echo "❌ scripts/ MISSING"} Mark all todos complete if validation passes. Phase 7: Summary Goal: Report results Actions: - Display results: **Hooks Created:** **Plugin:** **Mode:** $BASE_PATH (marketplace mode if "plugins/", standalone if ".") **Location:** $BASE_PATH/hooks/ **Hooks:** - (Event: ) - ✅ - (Event: ) - ✅ - etc. **Validation:** All passed ✅ **Git Status:** Committed and pushed ✅ **Airtable Sync:** Attempted ✅ **Next Steps:** - Test hooks by triggering events - Review scripts for correctness - Monitor hook execution in logs