-
Notifications
You must be signed in to change notification settings - Fork 0
Hooks Events
Status: ✅ Complete
Last Updated: December 5, 2025
This guide documents all available events that can trigger hooks in ricecoder. Events are emitted when specific system actions occur, and hooks registered for those events will be triggered automatically.
File operation events are emitted when files are created, modified, deleted, renamed, or moved.
Emitted when a file is created.
Event Context:
{
"file_path": "/path/to/file.ts",
"size": 1024,
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "New file created"
event: "file_created"
action:
type: "command"
command: "echo"
args:
- "New file: {{file_path}}"Emitted when a file is modified.
Event Context:
{
"file_path": "/path/to/file.ts",
"old_hash": "abc123def456",
"new_hash": "def456ghi789",
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "File modified"
event: "file_modified"
action:
type: "command"
command: "prettier"
args:
- "--write"
- "{{file_path}}"Emitted when a file is deleted.
Event Context:
{
"file_path": "/path/to/file.ts",
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "File deleted"
event: "file_deleted"
action:
type: "command"
command: "echo"
args:
- "File deleted: {{file_path}}"Emitted when a file is renamed.
Event Context:
{
"old_path": "/path/to/old_name.ts",
"new_path": "/path/to/new_name.ts",
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "File renamed"
event: "file_renamed"
action:
type: "command"
command: "echo"
args:
- "Renamed: {{old_path}} -> {{new_path}}"Emitted when a file is moved to a different directory.
Event Context:
{
"old_path": "/path/to/old/file.ts",
"new_path": "/path/to/new/file.ts",
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "File moved"
event: "file_moved"
action:
type: "command"
command: "echo"
args:
- "Moved: {{old_path}} -> {{new_path}}"Emitted when a file is read.
Event Context:
{
"file_path": "/path/to/file.ts",
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "File read"
event: "file_read"
action:
type: "command"
command: "echo"
args:
- "File read: {{file_path}}"Directory operation events are emitted when directories are created or deleted.
Emitted when a directory is created.
Event Context:
{
"directory_path": "/path/to/new/directory",
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "Directory created"
event: "directory_created"
action:
type: "command"
command: "echo"
args:
- "Directory created: {{directory_path}}"Emitted when a directory is deleted.
Event Context:
{
"directory_path": "/path/to/deleted/directory",
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "Directory deleted"
event: "directory_deleted"
action:
type: "command"
command: "echo"
args:
- "Directory deleted: {{directory_path}}"System events are emitted when ricecoder operations complete.
Emitted when tests pass.
Event Context:
{
"test_file": "/path/to/test.ts",
"test_count": 42,
"duration_ms": 1234,
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "Tests passed"
event: "test_passed"
action:
type: "command"
command: "echo"
args:
- "Tests passed! ({{test_count}} tests in {{duration_ms}}ms)"Emitted when tests fail.
Event Context:
{
"test_file": "/path/to/test.ts",
"failed_count": 2,
"passed_count": 40,
"duration_ms": 1234,
"error_message": "Expected 42 to equal 43",
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "Tests failed"
event: "test_failed"
action:
type: "ai_prompt"
prompt_template: |
Tests failed:
Failed: {{failed_count}}
Passed: {{passed_count}}
Error: {{error_message}}
Suggest fixes.
model: "gpt-4"
stream: trueEmitted when code generation completes.
Event Context:
{
"generated_files": 5,
"total_lines": 1234,
"duration_ms": 5678,
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "Generation complete"
event: "generation_complete"
action:
type: "command"
command: "echo"
args:
- "Generated {{generated_files}} files ({{total_lines}} lines)"Emitted when build completes.
Event Context:
{
"build_status": "success",
"output_dir": "/path/to/dist",
"duration_ms": 3456,
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "Build complete"
event: "build_complete"
action:
type: "command"
command: "echo"
args:
- "Build {{build_status}} in {{duration_ms}}ms"Emitted when deployment completes.
Event Context:
{
"deployment_status": "success",
"environment": "production",
"version": "1.2.3",
"duration_ms": 12345,
"timestamp": "2025-12-05T10:30:00Z"
}Example Hook:
hooks:
- name: "Deployment complete"
event: "deployment_complete"
action:
type: "command"
command: "echo"
args:
- "Deployed v{{version}} to {{environment}}"Each event provides context variables that can be used in hooks. Variables are accessed using {{variable_name}} syntax.
All events provide:
-
timestamp: ISO 8601 timestamp of the event
File operation events provide:
-
file_path: Path to the file -
old_path: Previous path (for rename/move events) -
new_path: New path (for rename/move events) -
directory_path: Path to the directory -
size: File size in bytes -
old_hash: Previous file hash (for modified events) -
new_hash: New file hash (for modified events)
System events provide event-specific variables. See event documentation above for details.
Use conditions to filter which events trigger hooks:
hooks:
- name: "Format TypeScript files"
event: "file_modified"
condition:
expression: "file_path.endsWith('.ts')"
action:
type: "command"
command: "prettier"
args:
- "--write"
- "{{file_path}}"Events are processed in the order they occur. If multiple hooks are registered for the same event, they execute in registration order.
- Events are guaranteed to be emitted for all operations
- Events are processed sequentially (not in parallel)
- Hook failures do not prevent other hooks from executing
- Events are not persisted (lost if ricecoder restarts)
Problem: Hook is configured for an event but not executing.
Solutions:
- Verify event name is correct (case-sensitive)
- Check hook is enabled:
ricecoder hooks inspect <hook-id> - Verify condition expression is correct
- Check logs for event emission:
ricecoder logs --filter events
Problem: Variables like {{file_path}} are not being substituted.
Solutions:
- Verify variable name is correct (case-sensitive)
- Check event type provides the variable
- Use
ricecoder hooks inspectto see available variables - See Hooks Variables Guide for complete reference
- Hooks System Guide - Main hooks guide
- Hooks Configuration Guide - Configuration options
- Hooks Actions Guide - Action types
- Hooks Variables Guide - Variable reference
- Troubleshooting Guide - General troubleshooting
Last updated: December 5, 2025