Documentation Index Fetch the complete documentation index at: https://www.siya.com/llms.txt
Use this file to discover all available pages before exploring further.
Transform Siya into Your Personal Automation Engine Hooks are Siya’s automation superpower - creating intelligent, event-driven workflows that respond to your actions in real-time. From auto-formatting code to deploying applications, hooks turn repetitive tasks into seamless, background magic.
Understanding Hooks
Event-Driven Respond instantly to file changes, git operations, or Siya actions
Intelligent Pattern matching and conditional logic for smart automation
Non-Blocking Hooks run in parallel without interrupting your workflow
Creating Hooks
Multiple Ways to Create Powerful Automations Choose the method that fits your style - from natural language to precise configuration
Natural Language
Configuration File
Interactive Builder
Just Tell Siya What You Want The easiest way - describe your automation in plain English
Describe Your Need
Tell Siya what you want to automate
Siya Creates Hook
Siya generates the appropriate hook configuration
Instant Activation
Hook starts working immediately
Simple Request
Complex Automation
Notification Hook
Development Hook
"Run tests whenever I save a test file"
Siya understands context and creates appropriate patterns and commands
Define Hooks in Configuration Precise control through JSON configuration
Basic Hook
Advanced Hook
Multi-Event Hook
{
"hooks" : [
{
"name" : "Auto-format on save" ,
"event" : "file:modified" ,
"pattern" : "**/*.{js,ts,jsx,tsx}" ,
"command" : "prettier --write ${file}" ,
"enabled" : true
}
]
}
Hooks configuration can be in global, project, or session config files
Build Hooks Interactively Step-by-step hook creation with Siya’s guidance
User: "Help me create a hook"
Siya: I'll help you create a custom hook. Let me ask a few questions:
1. What event should trigger this hook?
- File change (save, create, delete)
- Git operation (commit, push, merge)
- Siya action (task complete, error)
- Time-based (scheduled)
User: "File change"
Siya: 2. Which files should this monitor?
- All files
- Specific extensions (e.g., *.js, *.py)
- Specific directories
- Custom pattern
User: "TypeScript files in src folder"
Siya: 3. What should happen when triggered?
- Run tests
- Format/lint code
- Build/compile
- Custom command
User: "Run type checking"
Siya: Great! I'll create this hook for you:
[Creates and activates the hook]
Interactive mode helps you discover all available options
Hook Events
Rich Event System for Every Scenario Hooks can respond to a wide variety of events in your development workflow
File Events
Git Events
Siya Events
Custom Events
Glob Patterns
Advanced Patterns
{
"pattern" : "src/**/*.ts" , // All TypeScript in src
"pattern" : "*.{js,jsx}" , // JS and JSX files
"pattern" : "!**/*.test.*" , // Exclude test files
"pattern" : "docs/*.md" // Markdown in docs
}
Version Control Automation Automate your Git workflow with intelligent hooks
Pre-Operation Before Actions
git:pre-commit - Validate before commit
git:pre-push - Check before pushing
git:pre-merge - Test before merging
These can block operations if they fail
Post-Operation After Actions
git:commit - After successful commit
git:push - After push completes
git:merge - After merge done
Used for notifications and follow-up Pre-commit Validation
Post-push Deployment
{
"name" : "Commit quality check" ,
"event" : "git:pre-commit" ,
"commands" : [
"npm run lint" ,
"npm run typecheck" ,
"npm test -- --coverage"
],
"blocking" : true ,
"timeout" : 60000
}
Siya Operation Hooks Respond to Siya’s actions and task lifecycle
Memory Events
siya:memory:compact - Memory compacted
siya:memory:checkpoint - Checkpoint created
siya:memory:restore - Memory restored
siya:memory:threshold - Limit approached
Tool Events
siya:tool:execute - Tool invoked
siya:tool:success - Tool completed
siya:tool:failure - Tool failed
siya:tool:timeout - Tool timed out
Create Your Own Events Define custom events for specialized workflows
Define Event
Register custom event with Siya
Emit Event
Trigger from your code or scripts
Hook Response
Hooks respond to your custom event
Emit Custom Event
Hook Configuration
// In your application code
fetch ( 'http://localhost:3000/siya/event' , {
method: 'POST' ,
body: JSON . stringify ({
event: 'app:build:complete' ,
data: {
version: '1.2.3' ,
duration: 45000 ,
status: 'success'
}
})
});
Hook Configuration
Fine-Tune Every Aspect of Your Automations Comprehensive configuration options for precise control
Execution Control
Debouncing & Throttling
Conditional Logic
{
"name" : "Smart executor" ,
"event" : "file:modified" ,
"pattern" : "**/*.ts" ,
"command" : "npm run process -- ${file}" ,
// Execution options
"parallel" : true , // Run commands in parallel
"continueOnError" : true , // Don't stop on failure
"timeout" : 30000 , // 30 second timeout
"retries" : 2 , // Retry failed commands
"retryDelay" : 1000 , // Wait between retries
"shell" : "/bin/zsh" , // Specific shell
"cwd" : "${projectRoot}" , // Working directory
"env" : { // Environment variables
"NODE_ENV" : "test" ,
"DEBUG" : "true"
}
}
{
"name" : "Debounced compiler" ,
"event" : "file:modified" ,
"pattern" : "src/**/*.ts" ,
// Prevent rapid firing
"debounce" : 2000 , // Wait 2s after last event
"throttle" : 5000 , // Max once per 5s
"accumulate" : true , // Batch multiple events
"maxAccumulated" : 10 // Process max 10 at once
}
Debouncing prevents hooks from firing too frequently during rapid changes
{
"name" : "Conditional deployment" ,
"event" : "git:push" ,
// Complex conditions
"condition" : `
branch === 'main' &&
!commit.message.includes('[skip-deploy]') &&
time.getHours() >= 9 &&
time.getHours() <= 17
` ,
// Multiple condition checks
"conditions" : {
"all" : [ // All must be true
"branch === 'main'" ,
"tests.passed === true"
],
"any" : [ // At least one true
"user === 'admin'" ,
"override === true"
],
"none" : [ // None can be true
"errors.length > 0" ,
"isHoliday === true"
]
}
}
Notification Channels {
"notifications" : {
"channels" : {
"desktop" : true ,
"sound" : true ,
"email" : "dev@company.com" ,
"slack" : "#dev-alerts" ,
"webhook" : "https://api.company.com/hooks"
},
"events" : {
"start" : false , // Don't notify on start
"success" : true , // Notify on success
"failure" : true , // Always notify failures
"timeout" : true // Notify on timeout
}
}
}
Custom Messages {
"notifications" : {
"templates" : {
"success" : "✅ ${name} completed in ${duration}ms" ,
"failure" : "❌ ${name} failed: ${error}" ,
"timeout" : "⏱️ ${name} timed out after ${timeout}ms"
},
"includeOutput" : true ,
"maxOutputLength" : 500
}
}
Hook Examples
Real-World Automation Patterns Production-ready hook configurations for common scenarios
Development Hooks
CI/CD Hooks
Monitoring Hooks
Workflow Hooks
{
"hooks" : [
{
"name" : "Format on save" ,
"event" : "file:modified" ,
"pattern" : "src/**/*.{js,ts,jsx,tsx}" ,
"command" : "prettier --write ${file}" ,
"enabled" : true
},
{
"name" : "Lint and fix" ,
"event" : "file:modified" ,
"pattern" : "**/*.{js,ts}" ,
"commands" : [
"eslint --fix ${file}" ,
"tsc --noEmit --skipLibCheck"
],
"continueOnError" : true ,
"debounce" : 1000
},
{
"name" : "Update imports" ,
"event" : "file:renamed" ,
"pattern" : "src/**/*.{ts,tsx}" ,
"command" : "node scripts/update-imports.js ${oldFile} ${newFile}"
}
]
}
{
"hooks" : [
{
"name" : "Test affected" ,
"event" : "file:modified" ,
"pattern" : "src/**/*.{js,ts}" ,
"condition" : "!file.includes('.test.')" ,
"command" : "jest --findRelatedTests ${file} --coverage" ,
"notifications" : {
"failure" : "desktop"
}
},
{
"name" : "E2E on feature complete" ,
"event" : "git:push" ,
"condition" : "branch.startsWith('feature/')" ,
"commands" : [
"npm run build" ,
"npm run test:e2e -- --headless"
],
"timeout" : 300000
}
]
}
{
"hooks" : [
{
"name" : "Generate API docs" ,
"event" : "file:modified" ,
"pattern" : "src/api/**/*.ts" ,
"command" : "typedoc --entryPoints ${file} --out docs/api" ,
"debounce" : 5000
},
{
"name" : "Update README" ,
"event" : "siya:task:complete" ,
"condition" : "task.includes('feature')" ,
"command" : "node scripts/update-readme.js"
}
]
}
{
"hooks" : [
{
"name" : "Pre-commit checks" ,
"event" : "git:pre-commit" ,
"commands" : [
"npm run lint" ,
"npm run typecheck" ,
"npm run test -- --coverage"
],
"blocking" : true ,
"parallel" : true ,
"timeout" : 120000
},
{
"name" : "Build on merge" ,
"event" : "git:merge" ,
"condition" : "targetBranch === 'main'" ,
"commands" : [
"npm run clean" ,
"npm run build:production" ,
"npm run test:integration"
]
}
]
}
{
"hooks" : [
{
"name" : "Deploy to staging" ,
"event" : "git:push" ,
"condition" : "branch === 'develop'" ,
"commands" : [
"npm run build:staging" ,
"npm run deploy:staging" ,
"curl -X POST https://api.company.com/notify/deploy"
],
"env" : {
"DEPLOY_ENV" : "staging" ,
"SKIP_TESTS" : "false"
},
"notifications" : {
"success" : "slack:#deployments" ,
"failure" : "email:ops@company.com"
}
},
{
"name" : "Production release" ,
"event" : "git:tag" ,
"condition" : "tag.match(/^v \\ d+ \\ . \\ d+ \\ . \\ d+$/)" ,
"commands" : [
"npm run build:production" ,
"npm run test:smoke" ,
"npm run deploy:production" ,
"npm run notify:customers"
],
"requireConfirmation" : true
}
]
}
{
"hooks" : [
{
"name" : "Log errors" ,
"event" : "siya:error" ,
"command" : "node scripts/log-error.js '${error}' '${stack}'" ,
"notifications" : {
"failure" : false // Don't notify about logging failures
}
},
{
"name" : "Critical error response" ,
"event" : "siya:error" ,
"condition" : "error.severity === 'critical'" ,
"commands" : [
"npm run diagnostics" ,
"git stash" ,
"git checkout main"
],
"notifications" : {
"email" : "emergency@company.com" ,
"sms" : "+1234567890"
}
}
]
}
{
"hooks" : [
{
"name" : "Update task tracker" ,
"event" : "siya:task:complete" ,
"condition" : "task.type === 'feature'" ,
"command" : "jira-cli update ${task.ticketId} --status 'Done'" ,
"env" : {
"JIRA_TOKEN" : "${JIRA_API_TOKEN}"
}
},
{
"name" : "Time tracking" ,
"event" : "siya:task:start" ,
"command" : "toggl start '${task.name}' --project 'Development'" ,
"notifications" : {
"start" : false
}
},
{
"name" : "Daily standup prep" ,
"event" : "schedule:daily" ,
"time" : "09:00" ,
"command" : "node scripts/generate-standup-notes.js" ,
"notifications" : {
"success" : "desktop"
}
}
]
}
{
"hooks" : [
{
"name" : "Auto-backup" ,
"event" : "siya:memory:checkpoint" ,
"command" : "cp -r .siya/memory .siya/backups/memory-$(date +%Y%m%d-%H%M%S)" ,
"maxBackups" : 10
},
{
"name" : "Project snapshot" ,
"event" : "git:commit" ,
"condition" : "commit.message.includes('[snapshot]')" ,
"commands" : [
"tar -czf backups/snapshot-$(date +%Y%m%d).tar.gz --exclude=node_modules ." ,
"aws s3 cp backups/snapshot-*.tar.gz s3://backups/"
]
}
]
}
Hook Management
Monitor and Control Your Automation Fleet Tools and commands for managing your hooks effectively
List Hooks
Control Hooks
Debug Hooks
Create/Modify
"Show all my hooks"
"List active hooks"
"What hooks are running?"
Siya provides natural language control over all hook operations
Ask “Show hook dashboard” for a real-time view of your automations
Use "dryRun": true to test hooks without executing commands
Advanced Hook Patterns
Master-Level Automation Techniques Sophisticated patterns for complex automation scenarios
Chain Reactions
State Machines
Dynamic Hooks
{
"hooks" : [
{
"name" : "Format chain start" ,
"event" : "file:modified" ,
"pattern" : "**/*.js" ,
"command" : "prettier --write ${file}" ,
"emitOnSuccess" : "format:complete"
},
{
"name" : "Lint after format" ,
"event" : "format:complete" ,
"command" : "eslint --fix ${file}" ,
"emitOnSuccess" : "lint:complete"
},
{
"name" : "Test after lint" ,
"event" : "lint:complete" ,
"command" : "jest --findRelatedTests ${file}" ,
"emitOnSuccess" : "test:complete"
}
]
}
{
"hooks" : [
{
"name" : "Deployment state machine" ,
"events" : [ "deploy:*" ],
"stateMachine" : {
"initial" : "idle" ,
"states" : {
"idle" : {
"on" : { "deploy:start" : "building" }
},
"building" : {
"entry" : "npm run build" ,
"on" : {
"build:success" : "testing" ,
"build:failure" : "failed"
}
},
"testing" : {
"entry" : "npm run test:e2e" ,
"on" : {
"test:success" : "deploying" ,
"test:failure" : "failed"
}
},
"deploying" : {
"entry" : "npm run deploy" ,
"on" : {
"deploy:success" : "complete" ,
"deploy:failure" : "rollback"
}
},
"rollback" : {
"entry" : "npm run rollback" ,
"on" : { "rollback:complete" : "failed" }
},
"complete" : {
"entry" : "npm run notify:success"
},
"failed" : {
"entry" : "npm run notify:failure"
}
}
}
}
]
}
Self-Modifying Automations Hooks that adapt based on conditions
{
"hooks" : [
{
"name" : "Adaptive test runner" ,
"event" : "file:modified" ,
"pattern" : "**/*.js" ,
"command" : "node scripts/smart-test.js ${file}" ,
"dynamicConfig" : {
"script" : `
// Analyze file changes
const complexity = analyzeComplexity(file);
const history = getTestHistory(file);
// Adjust hook behavior
if (complexity > 10 || history.failures > 2) {
return {
command: [
"npm run test:unit -- ${ file } ",
"npm run test:integration -- ${ file } ",
"npm run test:e2e -- ${ file } "
],
timeout: 300000,
notifications: { failure: "email" }
};
} else {
return {
command: "npm run test:unit -- ${ file } ",
timeout: 60000
};
}
`
}
}
]
}
Hook Security
Secure Automation Practices Keep your automations safe and controlled
Do's
Validate all inputs
Use environment variables for secrets
Limit command scope
Regular security audits
Principle of least privilege
Log all executions
Don'ts
Hardcode credentials
Execute untrusted input
Disable security features
Grant excessive permissions
Skip validation
Ignore security warnings
{
"hookSecurity" : {
"defaultPermissions" : "restricted" ,
"allowedCommands" : [
"npm" , "yarn" , "git" , "prettier" , "eslint"
],
"blockedPatterns" : [
"**/secrets/**" ,
"**/*.key" ,
"**/*.pem"
],
"requireConfirmation" : [
"rm -rf" ,
"deploy:production" ,
"database:migrate"
],
"sandboxMode" : {
"enabled" : true ,
"allowNetwork" : false ,
"allowFileWrite" : [ "./tmp" , "./dist" ]
}
}
}
Future of Hooks
The Evolution of Intelligent Automation Exciting developments coming to Siya’s hook system
Coming Soon Enhanced Capabilities
Visual hook builder
Hook marketplace
AI-powered hook suggestions
Cross-project hook sharing
Advanced Features
Distributed execution
Hook versioning
A/B testing for hooks
Performance analytics
Experimental Next-Gen Automation
Predictive triggering
Self-healing hooks
Natural language conditions
Voice-activated hooks
Integration Expansion
Cloud platform hooks
IoT device triggers
Calendar integration
Biometric triggers
Summary
Automation Mastery Unlocked Hooks transform Siya from an AI assistant into a complete automation platform. By responding intelligently to events in your workflow, hooks eliminate repetitive tasks and enforce best practices automatically. Whether you’re formatting code, running tests, or deploying applications, hooks work tirelessly in the background to keep your development process smooth and efficient.
Next: Advanced Topics Master advanced Siya techniques
Hook Library Browse community hook examples
Automate everything. Focus on what matters.