How it works
SessionStart hooks:- Run at session start: Triggered when starting new sessions or resuming
- Load context: Add relevant project information to the conversation
- Setup environment: Configure paths, environment variables, tools
- Check dependencies: Verify required tools and packages are available
- Persist state: Set environment variables for the entire session
Prerequisites
Basic tools for automation:Basic session automation
Load project context
Automatically provide Droid with project information. Create.factory/hooks/load-context.sh:
.factory/settings.json:
Setup development environment
Configure tools and paths automatically. Create.factory/hooks/setup-env.sh:
Advanced automation
Load recent Linear/GitHub issues
Provide Droid with context about current work. Create.factory/hooks/load-issues.sh:
Check and install dependencies
Automatically ensure dependencies are up-to-date. Create.factory/hooks/check-dependencies.sh:
Load custom project guidelines
Provide project-specific instructions automatically. Create.factory/AGENTS.md with project guidelines:
.factory/hooks/load-guidelines.sh:
Smart context based on Git branch
Load different context based on the current branch: Create.factory/hooks/branch-context.sh:
Real-world examples
Example 1: Monorepo workspace setup
Automatically switch to the right package: Create.factory/hooks/monorepo-setup.sh:
Example 2: Docker environment check
Ensure Docker services are running: Create.factory/hooks/check-docker.sh:
Best practices
1
Keep context concise
Only load essential information:
2
Cache expensive operations
Avoid repeated expensive checks:
3
Use DROID_ENV_FILE for environment
Persist environment variables correctly:
4
Handle missing tools gracefully
Check before using external commands:
5
Provide actionable suggestions
Tell users what to do next:
Troubleshooting
Problem: Too much information loaded Solution: Summarize and link to details:See also
- Hooks reference - Complete hooks API documentation
- Get started with hooks - Basic hooks introduction
- Custom notifications - Get notified about events
- Logging and analytics - Track session metrics
