Guardrails
The SDD Plugin runs automated guardrails every session — no manual setup required. These guardrails maintain pipeline integrity, enforce the SDD Constitution, and help you avoid common mistakes.Guardrails consist of 4 hooks that run automatically and 8 agents that can be invoked on demand or delegated by Claude.
Overview
The SDD guardrail system has two layers:- Hooks — Automated checks that run at specific points in your workflow
- Agents — Specialized validators that analyze pipeline state and artifacts
- Pipeline state stays synchronized
- Upstream artifacts remain immutable during downstream execution
- Traceability chain stays intact
- Constitution rules are followed
- Drift between specs and code is detected
How guardrails work
Hooks (H1-H4)
Hooks are lightweight, fast checks that run automatically:| Hook | When it runs | What it does | Time |
|---|---|---|---|
| H1 | Session start | Injects pipeline status into context | 10s |
| H2 | Before Edit/Write | Blocks writes to upstream artifacts | 5s |
| H3 | After Write | Auto-updates pipeline-state.json | 10s |
| H4 | Session end | Reserved for future consistency checks | 5s |
- Stateless — No memory between runs
- Idempotent — Safe to run multiple times
- Fast — Complete in seconds
Agents (A1-A8)
Agents are deeper, analytical tools that can be invoked when needed:| Agent | Role | Model |
|---|---|---|
| A1 | Constitution enforcer | Haiku |
| A2 | Cross-auditor (skill consistency) | Sonnet |
| A3 | Context keeper (informal notes) | Haiku |
| A4 | Requirements watcher (change detection) | Haiku |
| A5 | Spec compliance checker | Sonnet |
| A6 | Test coverage monitor | Haiku |
| A7 | Traceability validator (suspect links) | Haiku |
| A8 | Pipeline health monitor | Haiku |
- Stateful (some) — Can use project memory for delta reporting
- Analytical — Produce detailed reports
- Delegated or direct — Run automatically by Claude or invoked by you
Key guardrail scenarios
1. Preventing upstream contamination
Problem: You’re implementing code but accidentally modify a spec file, breaking traceability. Guardrail: H2 (Upstream Guard) blocks the write before it happens:2. Detecting requirement changes
Problem: Someone modified requirements, but you don’t know which ones changed or what downstream artifacts are affected. Guardrail: A4 (Requirements Watcher) diffs current requirements against the baseline:3. Verifying spec-code alignment
Problem: You implemented features but aren’t sure if they match the specs. Guardrail: A5 (Spec Compliance Checker) cross-references implementation against specifications:4. Finding broken traceability links
Problem: You changed several files, and now you’re worried about broken references. Guardrail: A7 (Traceability Validator) detects suspect and broken links:5. Assessing pipeline health
Problem: You want a quick overview of how healthy the pipeline is. Guardrail: A8 (Pipeline Health Monitor) calculates a composite health score:The SDD Constitution
All guardrails enforce the 11 articles of the SDD Constitution:| Article | Principle |
|---|---|
| Art. 1 | Spec is source of truth — code derives from specifications |
| Art. 2 | Traceability chain must be maintained |
| Art. 3 | Clarification before assumption — never guess |
| Art. 4 | Upstream immutability — downstream cannot modify upstream |
| Art. 5 | Atomic reversibility — each task = 1 commit |
| Art. 6 | Baseline auditing — only report new findings |
| Art. 7 | Conventional Commits with Refs: and Task: trailers |
| Art. 8 | Pipeline state integrity — pipeline-state.json is authoritative |
| Art. 9 | Separation of concerns — each skill owns its directory |
| Art. 10 | Change through process — use req-change for all requirement modifications |
| Art. 11 | Formal over informal — document decisions in ADRs |
Guardrail configuration
Guardrails are pre-configured and require no setup. However, you can customize behavior:Disabling hooks (not recommended)
Hooks are defined inhooks/hooks.json. To disable a hook, remove its entry. However, this is strongly discouraged as it removes critical safety checks.
Adjusting timeouts
Each hook has a timeout (5-10 seconds). You can adjust these inhooks/hooks.json:
Invoking agents manually
You can invoke any agent directly by describing what you want:Guardrail philosophy
Prevention over detection
Guardrails prevent mistakes before they happen rather than detecting them afterward:- H2 blocks upstream writes before they occur
- H1 injects context before you make decisions
- H3 updates state immediately after writes
Fast feedback
Guardrails provide instant feedback:- Hooks complete in 5-10 seconds
- Agents produce reports in under a minute
- No waiting for CI/CD to find issues
Auditable and transparent
All guardrail actions are:- Logged in hook output
- Visible in agent reports
- Traceable via pipeline-state.json updates
Non-intrusive
Guardrails operate silently when everything is correct:- H1 only shows status, doesn’t block
- H2 only denies prohibited operations
- H3 runs asynchronously in the background
- Agents only run when invoked or delegated
Best practices
Let hooks run — don't bypass them
Let hooks run — don't bypass them
Hooks are designed to be fast and unobtrusive. Disabling them removes critical safety checks. If a hook is blocking you, it’s usually because of a real issue that needs fixing.
Run health checks regularly
Run health checks regularly
Invoke A8 (Pipeline Health Monitor) at the start of each work session to get a quick assessment of pipeline state and prioritize your work.
Review suspect links before release
Review suspect links before release
Use A7 (Traceability Validator) before releases to ensure that recent file changes haven’t broken traceability relationships.
Check spec compliance after implementation
Check spec compliance after implementation
Run A5 (Spec Compliance Checker) after implementing features to verify that code aligns with specifications.
Monitor test coverage continuously
Monitor test coverage continuously
Use A6 (Test Coverage Monitor) to track which requirements lack test coverage, especially Must Have requirements.
Troubleshooting
Hook timeouts
Problem: A hook times out (>10 seconds). Solution:- Check that
pipeline-state.jsonis valid JSON - Ensure project paths don’t contain unusual characters
- Verify that
jqornodeis available on your system
False positives from H2 (Upstream Guard)
Problem: H2 blocks a write that should be allowed. Solution:- Verify that no pipeline stage is marked as “running” in
pipeline-state.json - If you need to modify upstream artifacts, first complete the current stage or use
/sdd:req-change - For infrastructure files (
.claude/,changes/), ensure they match the exception patterns
Agent reports missing data
Problem: An agent reports “No baseline exists” or “File not found”. Solution:- Run
/sdd:dashboardto generate the traceability graph baseline - Ensure pipeline stages have been run at least once
- Check that artifact directories exist (
requirements/,spec/, etc.)
Related
Hooks
Detailed reference for all 4 hooks
Agents
Detailed reference for all 8 agents
Pipeline stages
Learn about the 7-stage pipeline
Constitution
Read the 11 articles of the SDD Constitution