hook
Claude Code hook commands for Calor-first enforcement
Internal commands for Claude Code hook integration. These commands are called automatically by Claude Code hooks and are not typically invoked directly.
calor hook <subcommand> [args]Overview
The hook command provides subcommands that integrate with Claude Code's hook system to enforce Calor-first development. When you run calor init --ai claude, it configures these hooks automatically.
Subcommands
validate-write
Validates Write tool calls to enforce Calor-first development.
calor hook validate-write <tool-input-json>Behavior:
| File Type | Action |
|---|---|
.calr files | Allowed (exit 0) |
.g.cs generated files | Allowed (exit 0) |
Files in obj/ directory | Allowed (exit 0) |
Other .cs files | Blocked (exit 1) |
Example:
# This will be blocked (exit 1)
calor hook validate-write '{"file_path": "MyClass.cs"}'
# Output:
# BLOCKED: Cannot create C# file 'MyClass.cs'
#
# This is an Calor-first project. Create an .calr file instead:
# MyClass.calr
#
# Use /calor skill for Calor syntax help.
# This will be allowed (exit 0)
calor hook validate-write '{"file_path": "MyClass.calr"}'How Hooks Work
When you initialize a project with calor init --ai claude, it creates .claude/settings.json with hook configuration:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"command": "calor hook validate-write $TOOL_INPUT"
}
]
}
]
}
}This hook runs before every Write tool call. If the hook returns exit code 1, Claude Code blocks the operation and shows the error message to Claude, who will then retry with an .calr file.
User Experience
When Claude tries to create a .cs file in an Calor-initialized project:
- Claude calls the Write tool with a
.csfile path - The hook intercepts the call and validates the path
- Hook returns exit 1 with guidance message
- Claude Code blocks the write operation
- Claude sees the error and creates an
.calrfile instead
This enforcement happens automatically - no user intervention required.
Troubleshooting
Hook Not Blocking .cs Files
-
Verify hooks are configured:
Bashcat .claude/settings.jsonShould contain
PreToolUsehook forWrite -
Verify calor is in PATH:
Bashwhich calor calor hook validate-write '{"file_path": "test.cs"}' echo $? # Should be 1 -
Restart Claude Code - hooks are loaded at session start
Re-enable Hooks After Manual Removal
calor init --ai claude --forceSee Also
- calor init - Initialize Calor with hook configuration
- Claude Integration - Using Calor with Claude