Spec-Hook-Test-Driven workflow enforcement for Claude Code. One command installs the entire spec→hook→test→PR pipeline with full audit trail.
SHTD Flow enforces a disciplined development workflow through Claude Code hooks:
- Write specs first — no code without a spec
- Write tests first — no implementation without a test
- Feature branches — no code on main
- One PR per task — task ID required in PR title
- E2E before merge — integration test evidence required
- Secret scan — blocks push without CI scan
- Multi-tab negotiation — auto-claims tasks, prevents duplicate work
- Enforceable workflows — ordered step pipelines with gate conditions
- Full audit trail — every workflow event logged to JSONL
Requires: Node.js, Python 3, git
git clone https://github.com/grobomo/spec-hook.git
cd spec-hook
bash install.shThe installer auto-bootstraps hook-runner if not already installed.
bash install.sh --checkbash install.sh --uninstall| Module | Enforces |
|---|---|
shtd_spec-gate |
Specs must exist before code edits |
shtd_test-first-gate |
Test file before implementation |
shtd_branch-gate |
No code on main branch |
shtd_pr-per-task-gate |
Task ID in PR title |
shtd_e2e-merge-gate |
E2E evidence before feature merge |
shtd_remote-tracking-gate |
Branch must track remote |
shtd_secret-scan-gate |
CI scan required for push |
shtd_task-claim |
Auto-claim tasks, prevent tab duplication |
shtd_workflow-gate |
Enforce workflow step order |
shtd_audit-logger |
Log all workflow events |
shtd_task-release |
Release task claim on exit |
Workflows are enforceable step pipelines defined in YAML. Unlike Claude Code skills (advisory), workflows block out-of-order work.
# List available workflows
bash ~/.claude/shtd-flow/scripts/shtd-workflow.sh list
# Start a workflow
bash ~/.claude/shtd-flow/scripts/shtd-workflow.sh start <name>
# Check current step
bash ~/.claude/shtd-flow/scripts/shtd-workflow.sh status
# Mark step complete
bash ~/.claude/shtd-flow/scripts/shtd-workflow.sh complete <step-id>Add YAML files to workflows/ in your project or ~/.claude/shtd-flow/workflows/ globally:
name: deploy-pipeline
steps:
- id: build
name: Build artifacts
gate:
require_files: []
completion:
require_files: ["dist/bundle.js"]
- id: test
name: Run tests
gate:
require_step: build
completion:
require_files: [".test-results/e2e.passed"]
- id: deploy
name: Deploy to production
gate:
require_step: test
completion:
require_files: ["deploy-receipt.txt"]Pre-built workflows for common project types in workflows/templates/:
| Template | Use Case |
|---|---|
api-wrapper.yml |
REST API client library (auth, endpoints, tests, docs) |
k8s-service.yml |
Containerized K8s service (Dockerfile, manifests, CI) |
cli-tool.yml |
Command-line tool (arg parsing, output, tests, packaging) |
project-onboarding.yml |
Bootstrap new project (git, CI, publish.json, first spec) |
# Start from a template
cp workflows/templates/api-wrapper.yml workflows/my-api.yml
bash ~/.claude/shtd-flow/scripts/shtd-workflow.sh start my-apiWhen multiple Claude Code sessions work on the same project:
- Each session auto-claims the next unchecked task from TODO.md
- Other sessions see the claim and work on different tasks
- Claims auto-release when sessions end or processes die
- Dead session cleanup via PID checking
# Check claim status
python ~/.claude/shtd-flow/lib/task_claims.py status --project-dir .For fleet scenarios with multiple machines, distributed_claims.py extends local claims with:
- S3-based locking — claims stored in S3, visible to all instances
- Spec claims — claim exclusive spec generation rights for a feature
- Race detection — detects when two instances claim the same task within a configurable window
- Heartbeat/lease expiry — stale claims auto-release after timeout (default 10min)
- Metrics — contention rate, task completion time, per-instance activity
export SHTD_S3_BUCKET=my-bucket
export SHTD_INSTANCE_ID=worker-1
# Claim a task
python lib/distributed_claims.py claim T001 --project my-project --session abc123
# Claim spec generation rights
python lib/distributed_claims.py spec-claim 042-feature --project my-project --session abc123
# Refresh heartbeat (run every few minutes)
python lib/distributed_claims.py heartbeat --project my-project
# View all claims and instances
python lib/distributed_claims.py status --project my-project
# View coordination metrics
python lib/distributed_claims.py metrics --project my-projectRequires boto3 and AWS credentials with S3 read/write access.
All workflow events are logged to ~/.claude/shtd-flow/audit.jsonl:
bash ~/.claude/shtd-flow/scripts/shtd-status.sh /path/to/projectTested on:
- Windows (Git Bash)
- Linux (Ubuntu, Docker containers)
- CCC worker instances (Docker + native)
MIT