8 Lifecycle Hooks for Perfect AI Agent Coordination
Your AI agents work in isolation. They overwrite each other’s changes. Critical context disappears before compaction. Important messages get missed. ULPI Hooks fixes all of this—automatically.Zero Merge Conflicts
Pre-edit hooks check file reservations and block conflicting changes before they happen
Context Preserved
Pre-compact hooks create memory snapshots before Claude compresses context
Never Miss Messages
User-prompt hooks alert agents to urgent coordination messages
Clean Shutdowns
Session-end hooks release all file reservations and complete pending tasks
The Problem: AI Assistants Work in Silos
You’ve experienced this frustration working with multiple AI coding assistants:- Constant merge conflicts when two agents edit the same file
- Lost context when Claude compacts your conversation history
- Missed urgent messages from other agents on your team
- Orphaned file locks when sessions crash without cleanup
- No coordination between Claude Code, Cursor, and other tools
The Solution: Deep Lifecycle Integration
ULPI Hooks intercepts 8 critical lifecycle events in your AI coding assistant and enables:- Without Hooks
- With ULPI Hooks
The Chaos of Uncoordinated Agents
File Conflicts:- Agent A edits
auth.ts - Agent B edits
auth.tsat the same time - Merge conflict requires manual resolution
- 15 minutes lost
- Important architecture decision discussed
- Context approaches token limit
- Claude compacts conversation
- Decision details lost forever
- Must re-explain from scratch
- Security issue found by Agent A
- Agent B doesn’t see the urgent message
- Deploys vulnerable code
- Critical bug reaches production
8 Strategic Lifecycle Hooks
Each hook intercepts a critical moment in your AI assistant’s lifecycle:🚀 session-start: Register Agent & Load Context
🚀 session-start: Register Agent & Load Context
Fires when: Your AI coding assistant starts a new sessionWhat it enables:
- Automatic agent registration with ULPI Coordination
- Display coordination dashboard with active agents
- Show file reservations from other agents
- Initialize memory context from previous sessions
- Present urgent messages waiting for acknowledgment
0- Allow session to start normally2- Block session (e.g., critical pending acknowledgments)
🔒 pre-tool-use:edit: Prevent File Conflicts
🔒 pre-tool-use:edit: Prevent File Conflicts
Fires before: Any file edit operationWhat it enables:
- Check file reservations in Coordination system
- Block edits if another agent has claimed the file
- Auto-reserve files on first edit (shared or exclusive mode)
- Show which agent has the file reserved
- Suggest coordination via messaging
0- Allow edit (file available or already reserved by this agent)2- Block edit (file reserved by another agent)
📋 post-tool-use:edit: Track Obligations
📋 post-tool-use:edit: Track Obligations
Fires after: Any file edit operation completesWhat it enables:
- Show pending tasks related to edited file
- Display required acknowledgments
- Track what needs review after modification
- Update file reservation status
- Log edit for audit trail
0- Always allow (non-blocking hook)
💾 pre-compact: Save Critical Context
💾 pre-compact: Save Critical Context
Fires before: Claude compacts conversation historyWhat it enables:
- Create memory snapshot of current context
- Extract architecture decisions and learnings
- Preserve critical technical details
- Store important code patterns
- Save pending tasks and obligations
0- Allow compaction to proceed2- Block compaction (rarely used)
💬 user-prompt-submit: Alert to Urgent Messages
💬 user-prompt-submit: Alert to Urgent Messages
Fires before: Agent responds to user inputWhat it enables:
- Check for urgent unread messages
- Display critical coordination alerts
- Show pending acknowledgments that require attention
- Present important file reservation conflicts
- Alert to high-priority tasks
0- Allow response (no urgent messages)2- Block response (critical message requires acknowledgment)
⏹️ stop: Prevent Unsafe Shutdowns
⏹️ stop: Prevent Unsafe Shutdowns
Fires when: User attempts to stop agent executionWhat it enables:
- Check for pending critical acknowledgments
- Warn about incomplete file reservations
- Block shutdown if critical tasks incomplete
- Allow graceful completion of obligations
- Prevent orphaned locks
0- Allow stop (all clear)2- Block stop (pending critical tasks)
🧹 session-end: Clean Up Resources
🧹 session-end: Clean Up Resources
Fires when: Session ends normallyWhat it enables:
- Release all file reservations automatically
- Mark agent as offline in Coordination
- Store final memory snapshot
- Complete logging and audit trail
- Clean handoff to next session
0- Always allow (cleanup hook)
👶 subagent-stop: Consolidate Learnings
👶 subagent-stop: Consolidate Learnings
Fires when: A spawned subagent completes its taskWhat it enables:
- Store subagent learnings to shared memory
- Release subagent file reservations
- Report results to parent agent
- Update task status
- Clean up subagent resources
0- Always allow (cleanup hook)
Real-World Use Cases
Multi-Agent Development Team
Scenario: 3 developers (Alice, Bob, Charlie) work on the same repositoryHow Hooks Help:
- Alice edits
auth.ts→ pre-edit hook reserves it - Bob tries to edit → blocked with clear message
- Bob messages Alice through Coordination
- They coordinate the changes
- Result: Zero merge conflicts
Parallel Task Execution
Scenario: Main agent spawns 5 subagents for parallel workflowsHow Hooks Help:
- Each subagent claims unique files via pre-edit hooks
- Subagent-stop hooks consolidate learnings to memory
- Session-end hooks clean up all reservations
- Result: 6x faster execution, zero conflicts
Context Preservation
Scenario: Long architecture discussion approaching token limitHow Hooks Help:
- Pre-compact hook fires automatically
- Creates memory snapshot of key decisions
- Claude compacts conversation safely
- Architecture details preserved
- Result: Never re-explain critical context
Emergency Code Freeze
Scenario: Security issue discovered, must stop all editsHow Hooks Help:
- Admin sends urgent message to all agents
- User-prompt hooks show alert before every response
- Pre-edit hooks can be configured to block all edits
- Result: Immediate coordination across team
Compatible AI Assistants
ULPI Hooks works with any AI coding assistant that supports lifecycle hooks (MCP-compatible):- Full Support (8/8 Hooks)
- Partial Support (6/8 Hooks)
- Coming Soon
✅ Fully Supported
These assistants support all 8 lifecycle hooks out of the box:- Claude Code - Official Anthropic IDE with complete hook support
- Cursor - Full lifecycle integration including subagent hooks
- Windsurf - Complete hook implementation with MCP bridge
ulpi setup and hooks are installed automaticallyPerformance Metrics
Hooks are optimized for minimal latency impact:| Hook | Avg Latency | MCP Calls | Can Block? |
|---|---|---|---|
| session-start | 150ms | 3-5 | ✅ Yes |
| pre-tool-use:edit | 120ms | 1-2 | ✅ Yes |
| post-tool-use:edit | 80ms | 1 | ❌ No |
| pre-compact | 200ms | 2-3 | ✅ Yes |
| user-prompt-submit | 100ms | 1-2 | ✅ Yes |
| stop | 90ms | 1 | ✅ Yes |
| session-end | 110ms | 2-3 | ❌ No |
| subagent-stop | 95ms | 1-2 | ❌ No |
Blocking hooks (session-start, pre-edit, user-prompt, stop) only fire when necessary to prevent conflicts or ensure safety. Non-blocking hooks run asynchronously.
Automatic Setup
Getting started with Hooks takes one command:1
Install ULPI Package
One package contains CLI, MCP bridge, and hooks—everything you need:
2
Run Guided Setup
Interactive setup configures hooks automatically for all supported IDEs:
3
Restart Your IDE
Hooks activate automatically—zero manual configuration needed:
Setup complete! Your AI assistants are now coordinated through ULPI Hooks.
Integration with Other ULPI Products
Hooks supercharges other ULPI products by providing automatic integration:Coordination
File Reservations: Pre-edit hooks check and create reservations automaticallyMessaging: User-prompt hooks display urgent agent messagesContact Policies: Session-start hooks enforce contact policies
Memory
Snapshots: Pre-compact hooks create memory snapshots automaticallyContext Loading: Session-start hooks retrieve relevant memoriesLearning Storage: Subagent-stop hooks consolidate learnings
Tasks
Task Updates: Post-edit hooks update task status after file changesDependencies: Pre-edit hooks check task dependencies before editsObligation Tracking: Session-end hooks ensure task completion
Skills
Workflow Hooks: Skills can define custom hook behaviorsBest Practices: Pre-edit hooks enforce skill-defined patternsLearning Loop: Post-edit hooks improve skill recommendations
Pricing
FREE with Coordination + Memory
Hooks are included FREE with any Coordination + Memory subscription.
- Starter: $29/month includes Hooks
- Professional: $99/month includes Hooks
- Enterprise: Custom pricing includes Hooks
Why FREE? Hooks maximize the value of Coordination and Memory by automating their integration. When your agents coordinate seamlessly and preserve context automatically, you get exponentially more value from both products.
Success Metrics
Teams using ULPI Hooks report:- Zero merge conflicts (down from 12-20 per week)
- 100% context preservation (vs 40% loss without hooks)
- 85% reduction in coordination overhead
- 3x faster multi-agent collaboration
- 60% fewer manual file conflict resolutions
FAQ
Do I need to manually configure each hook?
Do I need to manually configure each hook?
No! Running
ulpi setup automatically installs and configures all 8 hooks for your IDE. Zero manual configuration required.Will hooks slow down my AI assistant?
Will hooks slow down my AI assistant?
Minimal impact. Average hook latency is ~140ms, which is imperceptible in normal workflows. Blocking hooks only fire when necessary to prevent conflicts.
What happens if a hook fails?
What happens if a hook fails?
Hooks fail gracefully. If a hook times out or errors, the default behavior is to allow the operation to proceed (except for safety-critical hooks like pre-edit).
Can I disable specific hooks?
Can I disable specific hooks?
Yes! The ULPI config file allows you to enable/disable individual hooks. However, we recommend keeping all hooks active for full coordination benefits.
Do hooks work with local/offline AI models?
Do hooks work with local/offline AI models?
Hooks require network access to the ULPI API for coordination and memory features. Local-only models won’t benefit from multi-agent coordination.
How do I troubleshoot hook issues?
How do I troubleshoot hook issues?
Enable debug logging in your ULPI config:
ulpi config set debug=true. Hook execution logs appear in your IDE’s terminal/console.