Claude Octopus uses a hook system to inject custom logic at key points in the workflow lifecycle. Hooks enable quality gates, phase transitions, telemetry, and custom validations.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nyldn/claude-octopus/llms.txt
Use this file to discover all available pages before exploring further.
Available hooks
Claude Octopus provides hooks for the following lifecycle events:| Event | When it fires | Use case |
|---|---|---|
PreToolUse | Before Claude executes a tool (Bash, Write, Edit) | Quality gates, validation checks |
PostToolUse | After a tool completes | Architecture validation, security scans |
TaskCompleted | When a workflow task finishes | Phase transitions, metrics collection |
TeammateIdle | When an agent finishes and awaits next task | Agent scheduling, work distribution |
SessionSync | When conversation state changes | State persistence, backup |
SetupComplete | After /octo:setup finishes | Custom initialization |
Hook execution order
For a typical workflow command like/octo:embrace, hooks fire in this sequence:
PreToolUse to block execution, while validation hooks use PostToolUse to analyze output.
Creating custom hooks
Step 1: Choose the event
Decide which lifecycle event your hook should respond to. See the table above.Step 2: Create the hook script
Hooks live inhooks/ or .claude/hooks/. Create a new executable script:
Step 3: Write the hook logic
PreToolUse hook example
PreToolUse hooks validate before tool execution:
PostToolUse hook example
PostToolUse hooks analyze tool output:
TaskCompleted hook example
TaskCompleted hooks trigger phase transitions:
Step 4: Register the hook
Hooks are registered via:-
Filename convention (automatic):
*-gate.sh→PreToolUse*-hook.md→ Documentation (with frontmatter registration)
- Persona frontmatter (persona-specific):
- Global registration (all personas):
hooks/quality-gate-hook.md in source code:~/workspace/source/hooks/quality-gate-hook.md
Built-in hooks
Claude Octopus ships with these hooks:Quality gates
quality-gate.sh— Validates tangle output quality score (75% threshold)security-gate.sh— Validates OWASP coverage in security auditsarchitecture-gate.sh— Checks architecture decisions against principlescode-quality-gate.sh— Enforces coding standardsbudget-gate.sh— Blocks execution if token budget exceededperf-gate.sh— Validates performance benchmarks
Phase management
task-completion-checkpoint.sh— Records task completion metricstask-completed-transition.sh— Triggers phase transitionstask-dependency-validator.sh— Validates task dependencies
Session management
session-sync.sh— Persists conversation statecontext-reinforcement.sh— Injects workflow contextconfig-change-handler.sh— Reloads config on changes
Safety and validation
sysadmin-safety-gate.sh— Blocks dangerous system commandsscheduler-security-gate.sh— Validates scheduled task safetyprovider-routing-validator.sh— Validates multi-AI routing decisions
Telemetry
telemetry-webhook.sh— Sends events to external webhooksoctopus-statusline.sh— Updates CLI status displayoctopus-hud.mjs— Visual HUD for active workflows
Worktree isolation (v8.26+)
worktree-setup.sh— Creates isolated git worktrees for agentsworktree-teardown.sh— Cleans up worktrees after completion
hooks/ directory: ~/workspace/source/hooks/
Hook return values
PreToolUse hooks
Must return JSON:PostToolUse hooks
Can analyze output and return validation results:TaskCompleted hooks
Usually return phase transition data:Hook environment variables
Hooks have access to:| Variable | Description |
|---|---|
OCTOPUS_PHASE | Current phase: probe, grasp, tangle, ink |
OCTOPUS_WORKFLOW | Workflow type: embrace, debate, review, etc. |
CLAUDE_PLUGIN_ROOT | Plugin installation directory |
WORKSPACE_DIR | Current workspace: ~/.claude-octopus |
PROJECT_ROOT | Project root directory |
OCTOPUS_DEBUG | Debug mode enabled (true/false) |
Best practices
- Fail fast — Exit with non-zero status if critical validation fails
- Idempotent — Hooks may run multiple times; design accordingly
- Minimal dependencies — Use standard bash utilities (jq, grep, awk)
- Timeout awareness — Keep hooks fast (under 1 second) to avoid workflow delays
- Security — Never log sensitive data (API keys, tokens)
- Error messages — Provide actionable error messages to users
Debugging hooks
Enable debug mode to see hook execution:Source code reference
- Hook scripts:
hooks/*.shin source code:~/workspace/source/hooks/ - Hook documentation:
hooks/*-hook.mdin source code:~/workspace/source/hooks/ - Claude Code hooks:
.claude/hooks/for IDE-specific hooks
Related documentation
- Creating personas — Persona-specific hooks
- Debugging guide — Troubleshooting hook issues
- Workflow phases — Understanding phase transitions
