Hooks
The SDD Plugin includes 4 automated hooks that run during your Claude Code sessions. These hooks enforce guardrails, inject context, and maintain pipeline state without manual intervention.All hooks are configured in
hooks/hooks.json and run automatically — no setup required.H1: Session start pipeline injection
Trigger: At the start of every Claude Code sessionType: PreToolUse (SessionStart)
Timeout: 10 seconds
Script:
scripts/sdd-session-start.sh
Purpose
Injects current pipeline status into the session context so Claude always knows:- Which stage you’re at
- How many stages are complete (e.g., “3/7 done”)
- Which stages are stale, running, or have errors
- What the next recommended action is
Example output
H2: Upstream artifact immutability guard
Trigger: Before any Edit or Write operationType: PreToolUse (Edit, Write)
Timeout: 5 seconds
Script:
scripts/sdd-upstream-guard.sh
Purpose
Enforces Article 4 of the SDD Constitution: downstream skills cannot modify upstream artifacts. This maintains traceability integrity by preventing, for example,task-implementer from editing requirements or specs.
Immutability rules
When a stage is running, these paths are prohibited:| Running stage | Prohibited paths |
|---|---|
| test-planner | requirements/, spec/, audits/ |
| plan-architect | requirements/, spec/, audits/, test/ |
| task-generator | requirements/, spec/, audits/, test/, plan/ |
| task-implementer | requirements/, spec/, audits/, test/, plan/, task/ |
| spec-auditor | requirements/ (spec/ is allowed in Fix mode) |
| specifications-engineer | requirements/ |
Exceptions
req-changeskill: Can modify requirements/ and spec/ (lateral skill)pipeline-state.json: Always allowed (infrastructure, not artifact)- No running stage: Permissive mode (allow all)
.claude/,changes/,feedback/: Always allowed
H3: Context augmentation hook
Trigger: Before any Grep, Glob, Read, Edit, or Write operationType: PreToolUse (Grep, Glob, Read, Edit, Write)
Timeout: 5 seconds
Script:
hooks/sdd-augment-hook.js
Purpose
Automatically injects SDD traceability context when you search, read, or edit files. This hook enriches file operations with information about which requirements, use cases, and tasks a file implements.How it works
The hook matches files by:- File path — Checks
codeRefsin the traceability graph - Artifact ID patterns — Regex matching for REQ-, UC-, TASK-* annotations
- Symbols — Code intelligence (when available via
/sdd:code-index)
Context injected
For each matched file, the hook adds:- Traceability chain (REQ → UC → WF → API → BDD → INV → ADR → TASK → CODE)
- Coverage status (Complete, In Progress, Specified, Not Started)
- Last commit SHA (if Git repository)
- Callers/callees/processes (when code intelligence is available)
Silent failure
If the traceability graph doesn’t exist or the hook encounters an error, it silently returns no context. Tool calls are never blocked.H4: Pipeline state auto-updater
Trigger: After any successful Write operationType: PostToolUse (Write)
Timeout: 10 seconds
Async: true
Script:
scripts/sdd-pipeline-state-updater.sh
Purpose
Automatically updatespipeline-state.json when artifacts are written to pipeline directories. This keeps the pipeline state synchronized without manual intervention.
Detection logic
When a file is written, the hook maps the path to a pipeline stage:| Path | Maps to stage |
|---|---|
| requirements/* | requirements-engineer |
| spec/* | specifications-engineer |
| audits/* | spec-auditor |
| test/* | test-planner |
| plan/* | plan-architect |
| task/* | task-generator |
| src/, tests/ | task-implementer |
| feedback/* | task-implementer |
State transitions
The hook only transitions stages frompending or stale to running. It does not mark stages as done — that’s the skill’s responsibility.
If
pipeline-state.json doesn’t exist, the hook initializes it with all stages set to pending.Hook configuration
All hooks are defined inhooks/hooks.json. The configuration uses matchers to determine when hooks fire:
Related
Agents
Learn about the 8 specialized agents
Guardrails
Overview of automated guardrails