@abdullah-alnahas/claude-sdd 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +23 -1
- package/agents/planner.md +78 -0
- package/commands/sdd-mode.md +42 -0
- package/commands/sdd-orchestrate.md +103 -0
- package/commands/sdd-verify.md +87 -0
- package/contexts/dev.md +25 -0
- package/contexts/research.md +26 -0
- package/contexts/review.md +25 -0
- package/hooks/hooks.json +12 -2
- package/hooks/scripts/compaction-counter.sh +31 -0
- package/hooks/scripts/post-edit-review.sh +4 -1
- package/hooks/scripts/session-init.sh +29 -2
- package/package.json +1 -1
- package/scripts/verify-commands.sh +2 -2
- package/scripts/verify-hooks.sh +2 -0
- package/skills/iterative-execution/SKILL.md +1 -0
- package/skills/iterative-execution/references/retrieval-pattern.md +65 -0
- package/skills/using-sdd/SKILL.md +10 -0
package/README.md
CHANGED
|
@@ -51,7 +51,10 @@ Profile-first discipline for performance work. Defends against convenience bias
|
|
|
51
51
|
| `/sdd-guardrails` | Show/toggle guardrail status |
|
|
52
52
|
| `/sdd-yolo` | Disable all guardrails (auto-clears next session) |
|
|
53
53
|
| `/sdd-phase` | Show/set development phase |
|
|
54
|
-
| `/sdd-
|
|
54
|
+
| `/sdd-mode` | Switch context mode (dev/review/research) |
|
|
55
|
+
| `/sdd-review` | Two-stage review — spec compliance then code quality |
|
|
56
|
+
| `/sdd-verify` | Automated checks — build, types, lint, tests, security scans |
|
|
57
|
+
| `/sdd-orchestrate` | Agent pipelines — feature, bugfix, refactor, security, or custom |
|
|
55
58
|
| `/sdd-adopt` | Adopt an existing project into SDD |
|
|
56
59
|
| `/sdd-execute` | Start iterative execution loop against a spec |
|
|
57
60
|
| `/sdd-autopilot` | Full autonomous lifecycle: specify → design → implement → verify → review |
|
|
@@ -65,6 +68,23 @@ Profile-first discipline for performance work. Defends against convenience bias
|
|
|
65
68
|
| **spec-compliance** | Spec adherence checker — verifies traceability (spec → test → code) |
|
|
66
69
|
| **security-reviewer** | Security analysis — OWASP Top 10, input validation, auth review |
|
|
67
70
|
| **performance-reviewer** | Performance optimization reviewer — validates patches for bottleneck targeting, convenience bias, measured improvement |
|
|
71
|
+
| **planner** | Implementation planner — reads specs/architecture and produces ordered steps |
|
|
72
|
+
|
|
73
|
+
## Context Modes
|
|
74
|
+
|
|
75
|
+
SDD supports three context modes that adjust which guardrails are active:
|
|
76
|
+
|
|
77
|
+
| Mode | Focus | Pre-Implementation | Completion Review | Scope Guard |
|
|
78
|
+
|------|-------|-------------------|-------------------|-------------|
|
|
79
|
+
| **dev** (default) | Build correctly | Active | Active | Strict |
|
|
80
|
+
| **review** | Verify and critique | Skipped | Active | Normal |
|
|
81
|
+
| **research** | Explore freely | Skipped | Skipped | Relaxed |
|
|
82
|
+
|
|
83
|
+
Set mode with `/sdd-mode <mode>` or set a default in `.sdd.yaml`:
|
|
84
|
+
|
|
85
|
+
```yaml
|
|
86
|
+
mode: dev # dev | review | research
|
|
87
|
+
```
|
|
68
88
|
|
|
69
89
|
## Configuration
|
|
70
90
|
|
|
@@ -73,6 +93,8 @@ Create `.sdd.yaml` in your project root:
|
|
|
73
93
|
```yaml
|
|
74
94
|
verbosity: standard # minimal | standard | verbose
|
|
75
95
|
enabled: true
|
|
96
|
+
mode: dev # dev | review | research
|
|
97
|
+
compaction_threshold: 50 # tool invocations before suggesting /compact
|
|
76
98
|
|
|
77
99
|
guardrails:
|
|
78
100
|
pre-implementation:
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: planner
|
|
3
|
+
model: sonnet
|
|
4
|
+
color: blue
|
|
5
|
+
description: >
|
|
6
|
+
Reads specs, architecture docs, and codebase structure to produce ordered implementation steps.
|
|
7
|
+
Use when starting a feature, breaking down a task, or needing an implementation roadmap.
|
|
8
|
+
|
|
9
|
+
<example>
|
|
10
|
+
Context: User has a spec and wants to know what to implement first.
|
|
11
|
+
user: "Break down this feature into implementation steps"
|
|
12
|
+
assistant: "I'll use the planner agent to analyze the spec and produce an ordered implementation plan."
|
|
13
|
+
</example>
|
|
14
|
+
|
|
15
|
+
<example>
|
|
16
|
+
Context: User is starting a new feature from a behavior spec.
|
|
17
|
+
user: "Plan the implementation for this spec"
|
|
18
|
+
assistant: "Let me launch the planner agent to create an implementation roadmap."
|
|
19
|
+
</example>
|
|
20
|
+
|
|
21
|
+
<example>
|
|
22
|
+
Context: User needs to understand implementation order and dependencies.
|
|
23
|
+
user: "What should I build first?"
|
|
24
|
+
assistant: "I'll use the planner agent to analyze dependencies and suggest an implementation order."
|
|
25
|
+
</example>
|
|
26
|
+
allowed-tools:
|
|
27
|
+
- Read
|
|
28
|
+
- Glob
|
|
29
|
+
- Grep
|
|
30
|
+
- Bash
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
# Planner Agent
|
|
34
|
+
|
|
35
|
+
You analyze specs, architecture, and codebase structure to produce ordered implementation steps. You plan — you do not implement.
|
|
36
|
+
|
|
37
|
+
## Planning Process
|
|
38
|
+
|
|
39
|
+
1. **Read the spec** — understand what needs to be built (behavior spec, acceptance criteria)
|
|
40
|
+
2. **Read architecture docs** — understand the system structure (if available)
|
|
41
|
+
3. **Scan the codebase** — identify existing patterns, conventions, relevant files
|
|
42
|
+
4. **Identify dependencies** — what must exist before other things can be built
|
|
43
|
+
5. **Produce ordered steps** — a sequence that respects dependencies and enables incremental testing
|
|
44
|
+
|
|
45
|
+
## Output Format
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
## Implementation Plan
|
|
49
|
+
|
|
50
|
+
### Prerequisites
|
|
51
|
+
[What must be true before starting — dependencies, setup, existing code to understand]
|
|
52
|
+
|
|
53
|
+
### Steps
|
|
54
|
+
|
|
55
|
+
1. **Step title** — Brief description
|
|
56
|
+
- Files: `path/to/file.ts` (create | modify)
|
|
57
|
+
- Depends on: (none | step N)
|
|
58
|
+
- Test: How to verify this step works
|
|
59
|
+
|
|
60
|
+
2. **Step title** — Brief description
|
|
61
|
+
- Files: `path/to/file.ts` (create | modify)
|
|
62
|
+
- Depends on: Step 1
|
|
63
|
+
- Test: How to verify this step works
|
|
64
|
+
|
|
65
|
+
### Risks
|
|
66
|
+
[Potential issues, ambiguities in the spec, architectural concerns]
|
|
67
|
+
|
|
68
|
+
### Suggested Order
|
|
69
|
+
[If steps can be parallelized, note which can run concurrently]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Planning Standards
|
|
73
|
+
|
|
74
|
+
- **Respect existing patterns** — don't suggest new conventions when the codebase has established ones
|
|
75
|
+
- **Small steps** — each step should be independently testable
|
|
76
|
+
- **Dependencies are explicit** — never assume step order is obvious
|
|
77
|
+
- **Tests at every step** — every step includes how to verify it
|
|
78
|
+
- **Be honest about unknowns** — flag ambiguities, don't paper over them
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sdd-mode
|
|
3
|
+
description: Switch SDD context mode (dev/review/research). Controls which guardrails are active.
|
|
4
|
+
argument-hint: "[dev|review|research]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Bash
|
|
7
|
+
- Read
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# /sdd-mode
|
|
11
|
+
|
|
12
|
+
Switch the active SDD context mode. Each mode adjusts which guardrails, hooks, and checks are active.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
- `/sdd-mode` — Show current mode
|
|
17
|
+
- `/sdd-mode dev` — Full guardrails (default)
|
|
18
|
+
- `/sdd-mode review` — Review/verification focus
|
|
19
|
+
- `/sdd-mode research` — Exploration focus, relaxed guardrails
|
|
20
|
+
|
|
21
|
+
## Modes
|
|
22
|
+
|
|
23
|
+
| Mode | Pre-Implementation Checkpoint | Completion Review | Scope Guard | Focus |
|
|
24
|
+
|------|------------------------------|-------------------|-------------|-------|
|
|
25
|
+
| **dev** | Active | Active | Strict | Build correctly — TDD, spec compliance, full discipline |
|
|
26
|
+
| **review** | Skipped | Active | Normal | Verify and critique — find issues, check quality |
|
|
27
|
+
| **research** | Skipped | Skipped | Relaxed | Explore and understand — read code, trace flows, prototype |
|
|
28
|
+
|
|
29
|
+
## Behavior
|
|
30
|
+
|
|
31
|
+
When invoked with an argument:
|
|
32
|
+
1. Write `SDD_MODE=<mode>` to `$CLAUDE_ENV_FILE`
|
|
33
|
+
2. Read the corresponding context file from `contexts/<mode>.md`
|
|
34
|
+
3. Report the mode switch and what changed
|
|
35
|
+
|
|
36
|
+
When invoked without an argument:
|
|
37
|
+
1. Read `$SDD_MODE` (default: `dev`)
|
|
38
|
+
2. Report current mode and its settings
|
|
39
|
+
|
|
40
|
+
## Context Files
|
|
41
|
+
|
|
42
|
+
Each mode has a context file at `contexts/<mode>.md` that is loaded by the session init hook. These define the behavioral adjustments for that mode. See `.sdd.yaml` to set a default mode per project.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sdd-orchestrate
|
|
3
|
+
description: Run named agent pipelines with structured handoffs — feature, bugfix, refactor, security, or custom.
|
|
4
|
+
argument-hint: "<pipeline> [agent1,agent2,...]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Glob
|
|
10
|
+
- Grep
|
|
11
|
+
- Bash
|
|
12
|
+
- Task
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# /sdd-orchestrate
|
|
16
|
+
|
|
17
|
+
Run a named pipeline of agents with structured handoffs. Each agent receives the previous agent's findings and builds on them.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
- `/sdd-orchestrate feature` — Full feature review pipeline
|
|
22
|
+
- `/sdd-orchestrate bugfix` — Bug-focused pipeline
|
|
23
|
+
- `/sdd-orchestrate refactor` — Refactoring review pipeline
|
|
24
|
+
- `/sdd-orchestrate security` — Security-focused pipeline
|
|
25
|
+
- `/sdd-orchestrate custom agent1,agent2,...` — User-specified agent sequence
|
|
26
|
+
|
|
27
|
+
## Named Pipelines
|
|
28
|
+
|
|
29
|
+
| Pipeline | Agent Sequence | Focus |
|
|
30
|
+
|----------|---------------|-------|
|
|
31
|
+
| **feature** | spec-compliance → planner → critic → security-reviewer | Complete feature validation |
|
|
32
|
+
| **bugfix** | critic → spec-compliance → simplifier | Find root cause, check spec, simplify fix |
|
|
33
|
+
| **refactor** | simplifier → critic → spec-compliance | Simplify, verify correctness, check spec |
|
|
34
|
+
| **security** | security-reviewer → critic → simplifier | Security first, then correctness, then cleanup |
|
|
35
|
+
|
|
36
|
+
### custom
|
|
37
|
+
|
|
38
|
+
Specify agents as a comma-separated list:
|
|
39
|
+
```
|
|
40
|
+
/sdd-orchestrate custom critic,simplifier,performance-reviewer
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Available agents: `critic`, `simplifier`, `spec-compliance`, `security-reviewer`, `performance-reviewer`, `planner`
|
|
44
|
+
|
|
45
|
+
## Handoff Format
|
|
46
|
+
|
|
47
|
+
Each agent produces a structured handoff:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
## Agent: <name>
|
|
51
|
+
|
|
52
|
+
### Findings
|
|
53
|
+
[Structured findings from this agent]
|
|
54
|
+
|
|
55
|
+
### Handoff
|
|
56
|
+
[Key information the next agent needs]
|
|
57
|
+
|
|
58
|
+
### Status: PASS | FAIL | NEEDS-ATTENTION
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Pipeline Behavior
|
|
62
|
+
|
|
63
|
+
1. Run each agent in sequence
|
|
64
|
+
2. Pass previous agent's findings as context to the next agent
|
|
65
|
+
3. **On FAIL**: Pause the pipeline and ask the user:
|
|
66
|
+
- Fix issues and re-run from the failed agent
|
|
67
|
+
- Continue to the next agent anyway
|
|
68
|
+
- Abort the pipeline
|
|
69
|
+
4. After all agents complete, produce a summary
|
|
70
|
+
|
|
71
|
+
## Summary Output
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
SDD Orchestrate — feature pipeline
|
|
75
|
+
────────────────────────────────────
|
|
76
|
+
|
|
77
|
+
✓ spec-compliance ............... PASS
|
|
78
|
+
✓ planner ....................... PASS (spec-compliance findings applied)
|
|
79
|
+
✗ critic ........................ FAIL (2 critical issues)
|
|
80
|
+
⊘ security-reviewer ............ SKIPPED (pipeline paused)
|
|
81
|
+
|
|
82
|
+
Pipeline: PAUSED at critic — 2 critical issues found
|
|
83
|
+
Action required: Fix issues before continuing
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Agent Prompt Template
|
|
87
|
+
|
|
88
|
+
When launching each agent, include:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
You are running as part of an SDD orchestration pipeline.
|
|
92
|
+
Pipeline: <pipeline-name>
|
|
93
|
+
Your position: Agent <N> of <total>
|
|
94
|
+
Previous findings:
|
|
95
|
+
<handoff from previous agent, or "First agent — no prior findings">
|
|
96
|
+
|
|
97
|
+
Your task: <agent's standard task>
|
|
98
|
+
Output your findings in the structured handoff format.
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## References
|
|
102
|
+
|
|
103
|
+
See agent definitions in `agents/` for each agent's review standards and output format.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sdd-verify
|
|
3
|
+
description: Run automated verification checks — build, types, lint, tests, security scans. Distinct from /sdd-review (agent-based).
|
|
4
|
+
argument-hint: "[quick|full|pre-commit|pre-pr]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Bash
|
|
7
|
+
- Read
|
|
8
|
+
- Glob
|
|
9
|
+
- Grep
|
|
10
|
+
- Task
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# /sdd-verify
|
|
14
|
+
|
|
15
|
+
Run automated verification checks against the codebase. This is the **automated checks** complement to `/sdd-review` (which uses agent-based analysis).
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
- `/sdd-verify` — Run full verification (default)
|
|
20
|
+
- `/sdd-verify quick` — Build + type check only
|
|
21
|
+
- `/sdd-verify full` — Build + types + lint + test suite + coverage
|
|
22
|
+
- `/sdd-verify pre-commit` — Quick + lint + debug statement scan + git status check
|
|
23
|
+
- `/sdd-verify pre-pr` — Full + security-reviewer agent + diff review + TODO/secrets scan
|
|
24
|
+
|
|
25
|
+
## Modes
|
|
26
|
+
|
|
27
|
+
### quick
|
|
28
|
+
Fast feedback loop during development.
|
|
29
|
+
1. Build / compile check
|
|
30
|
+
2. Type check (tsc, mypy, etc.)
|
|
31
|
+
|
|
32
|
+
### full (default)
|
|
33
|
+
Comprehensive automated verification.
|
|
34
|
+
1. Build / compile check
|
|
35
|
+
2. Type check
|
|
36
|
+
3. Lint (eslint, ruff, etc.)
|
|
37
|
+
4. Full test suite
|
|
38
|
+
5. Coverage report (if configured)
|
|
39
|
+
|
|
40
|
+
### pre-commit
|
|
41
|
+
Everything needed before committing.
|
|
42
|
+
1. All `quick` checks
|
|
43
|
+
2. Lint
|
|
44
|
+
3. Debug statement scan (`console.log`, `debugger`, `print(`, `TODO`, `FIXME`, `HACK`)
|
|
45
|
+
4. Git status — ensure no unintended files staged
|
|
46
|
+
|
|
47
|
+
### pre-pr
|
|
48
|
+
Everything needed before opening a PR.
|
|
49
|
+
1. All `full` checks
|
|
50
|
+
2. Launch **security-reviewer** agent on changed files
|
|
51
|
+
3. Diff review — scan for TODO, FIXME, secrets patterns, hardcoded values
|
|
52
|
+
4. Generate summary
|
|
53
|
+
|
|
54
|
+
## Output Format
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
SDD Verify — [mode]
|
|
58
|
+
───────────────────
|
|
59
|
+
|
|
60
|
+
✓ Build .......................... PASS
|
|
61
|
+
✓ Type check .................... PASS
|
|
62
|
+
✗ Lint .......................... FAIL (3 errors)
|
|
63
|
+
✓ Tests ......................... PASS (42/42)
|
|
64
|
+
✓ Coverage ...................... 87%
|
|
65
|
+
✗ Debug statements .............. FAIL (2 found)
|
|
66
|
+
✓ Secrets scan .................. PASS
|
|
67
|
+
|
|
68
|
+
──────────────────────────────────
|
|
69
|
+
Summary: 5/7 passed, 2 failed
|
|
70
|
+
Ready for PR: NO
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## How to Detect Project Tools
|
|
74
|
+
|
|
75
|
+
1. Check `package.json` for scripts (build, test, lint, typecheck)
|
|
76
|
+
2. Check for `Makefile`, `pyproject.toml`, `Cargo.toml`, `go.mod`
|
|
77
|
+
3. Check for config files (`.eslintrc`, `tsconfig.json`, `ruff.toml`, `mypy.ini`)
|
|
78
|
+
4. If no tools detected, report what's missing and skip those checks
|
|
79
|
+
|
|
80
|
+
## Difference from /sdd-review
|
|
81
|
+
|
|
82
|
+
| | /sdd-verify | /sdd-review |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| **Type** | Automated checks | Agent-based analysis |
|
|
85
|
+
| **Speed** | Fast (runs tools) | Slower (launches agents) |
|
|
86
|
+
| **Finds** | Build errors, type errors, lint issues, test failures | Logic errors, spec drift, unnecessary complexity |
|
|
87
|
+
| **When** | During development, before commit/PR | After implementation, before merge |
|
package/contexts/dev.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# SDD Context: Dev Mode
|
|
2
|
+
|
|
3
|
+
Full guardrails active. This is the default mode for implementation work.
|
|
4
|
+
|
|
5
|
+
## Active Guardrails
|
|
6
|
+
|
|
7
|
+
- **Pre-implementation checkpoint**: ON — enumerate assumptions, flag ambiguity, surface alternatives, push back on bad ideas, define scope, check for spec, plan TDD approach
|
|
8
|
+
- **Completion review**: ON — spec adherence, test coverage, complexity audit, dead code check, scope creep check
|
|
9
|
+
- **Scope guard**: STRICT — reject changes outside defined scope without explicit approval
|
|
10
|
+
- **TDD enforcement**: ON — tests before implementation
|
|
11
|
+
- **Post-edit review**: ON — review after each write/edit
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
- Implementing features from specs
|
|
16
|
+
- Fixing bugs
|
|
17
|
+
- Refactoring code
|
|
18
|
+
- Any task where correctness and discipline matter
|
|
19
|
+
|
|
20
|
+
## Principles
|
|
21
|
+
|
|
22
|
+
- Every change starts with understanding the spec
|
|
23
|
+
- Every implementation starts with a test
|
|
24
|
+
- Every completion is verified against criteria
|
|
25
|
+
- Scope is defended — no drive-by improvements
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# SDD Context: Research Mode
|
|
2
|
+
|
|
3
|
+
Exploration focus. Guardrails are relaxed to allow free investigation without implementation ceremony.
|
|
4
|
+
|
|
5
|
+
## Active Guardrails
|
|
6
|
+
|
|
7
|
+
- **Pre-implementation checkpoint**: OFF — you're exploring, not committing to implementation
|
|
8
|
+
- **Completion review**: OFF — research doesn't have a "done" in the spec-compliance sense
|
|
9
|
+
- **Scope guard**: RELAXED — follow the investigation wherever it leads
|
|
10
|
+
- **TDD enforcement**: OFF for prototypes — but ON if research produces code intended for production
|
|
11
|
+
- **Post-edit review**: OFF — prototypes and experiments don't need review
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
- Understanding unfamiliar codebases
|
|
16
|
+
- Investigating bugs (root cause analysis)
|
|
17
|
+
- Prototyping and experimentation
|
|
18
|
+
- Architecture exploration and spike work
|
|
19
|
+
- Reading documentation and tracing flows
|
|
20
|
+
|
|
21
|
+
## Principles
|
|
22
|
+
|
|
23
|
+
- Follow curiosity — explore freely
|
|
24
|
+
- Take notes — capture findings for later
|
|
25
|
+
- Don't ship research code — if it becomes production code, switch to dev mode
|
|
26
|
+
- Time-box — set a goal for what you want to learn
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# SDD Context: Review Mode
|
|
2
|
+
|
|
3
|
+
Critic and verification focus. Pre-implementation checkpoint is skipped since you're reviewing, not building.
|
|
4
|
+
|
|
5
|
+
## Active Guardrails
|
|
6
|
+
|
|
7
|
+
- **Pre-implementation checkpoint**: OFF — you're reviewing existing code, not starting new work
|
|
8
|
+
- **Completion review**: ON — ensure review findings are complete and actionable
|
|
9
|
+
- **Scope guard**: NORMAL — stay focused on what you're reviewing
|
|
10
|
+
- **TDD enforcement**: ON for any fixes — if review leads to fixes, tests come first
|
|
11
|
+
- **Post-edit review**: ON — verify any fixes made during review
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
- Code review (PRs, post-implementation)
|
|
16
|
+
- Auditing existing code for quality
|
|
17
|
+
- Security reviews
|
|
18
|
+
- Running `/sdd-review` or agent-based reviews
|
|
19
|
+
|
|
20
|
+
## Principles
|
|
21
|
+
|
|
22
|
+
- Find what's wrong, not confirm what's right
|
|
23
|
+
- Be specific and evidence-based
|
|
24
|
+
- Report findings honestly — don't soften
|
|
25
|
+
- If fixing, follow TDD discipline
|
package/hooks/hooks.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"hooks": [
|
|
20
20
|
{
|
|
21
21
|
"type": "prompt",
|
|
22
|
-
"prompt": "If this message is a trivial acknowledgment (e.g. 'yes', 'no', 'thanks', 'ok', 'continue'), skip and respond normally. Otherwise, apply the SDD pre-implementation checkpoint from the guardrails skill (enumerate assumptions, flag ambiguity, surface alternatives, push back on bad ideas, define scope, check for spec, plan TDD approach) before proceeding. If GUARDRAILS_DISABLED=true, skip."
|
|
22
|
+
"prompt": "If this message is a trivial acknowledgment (e.g. 'yes', 'no', 'thanks', 'ok', 'continue'), skip and respond normally. If SDD_MODE=review or SDD_MODE=research, skip. Otherwise, apply the SDD pre-implementation checkpoint from the guardrails skill (enumerate assumptions, flag ambiguity, surface alternatives, push back on bad ideas, define scope, check for spec, plan TDD approach) before proceeding. If GUARDRAILS_DISABLED=true, skip."
|
|
23
23
|
}
|
|
24
24
|
]
|
|
25
25
|
}
|
|
@@ -34,6 +34,16 @@
|
|
|
34
34
|
"timeout": 15
|
|
35
35
|
}
|
|
36
36
|
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"matcher": "",
|
|
40
|
+
"hooks": [
|
|
41
|
+
{
|
|
42
|
+
"type": "command",
|
|
43
|
+
"command": "bash \"$CLAUDE_PLUGIN_ROOT/hooks/scripts/compaction-counter.sh\"",
|
|
44
|
+
"timeout": 5
|
|
45
|
+
}
|
|
46
|
+
]
|
|
37
47
|
}
|
|
38
48
|
],
|
|
39
49
|
"Stop": [
|
|
@@ -42,7 +52,7 @@
|
|
|
42
52
|
"hooks": [
|
|
43
53
|
{
|
|
44
54
|
"type": "prompt",
|
|
45
|
-
"prompt": "Before finalizing, perform the SDD completion review from the guardrails skill (spec adherence, test coverage, complexity audit, dead code check, scope creep check, conceptual error scan). Report findings concisely. If GUARDRAILS_DISABLED=true, skip."
|
|
55
|
+
"prompt": "Before finalizing, perform the SDD completion review from the guardrails skill (spec adherence, test coverage, complexity audit, dead code check, scope creep check, conceptual error scan). Report findings concisely. If GUARDRAILS_DISABLED=true or SDD_MODE=research, skip."
|
|
46
56
|
}
|
|
47
57
|
]
|
|
48
58
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# SDD Strategic Compaction Counter
|
|
3
|
+
# Counts tool invocations per session and suggests compaction at threshold.
|
|
4
|
+
# Runs as PostToolUse hook — must be fast and silent on stdout.
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
THRESHOLD="${SDD_COMPACTION_THRESHOLD:-50}"
|
|
9
|
+
COUNTER_FILE="/tmp/sdd-compaction-$$"
|
|
10
|
+
|
|
11
|
+
# Use parent PID to scope counter to the Claude session
|
|
12
|
+
if [ -n "${PPID:-}" ]; then
|
|
13
|
+
COUNTER_FILE="/tmp/sdd-compaction-$PPID"
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
# Increment counter
|
|
17
|
+
COUNT=0
|
|
18
|
+
if [ -f "$COUNTER_FILE" ]; then
|
|
19
|
+
COUNT=$(cat "$COUNTER_FILE" 2>/dev/null || echo "0")
|
|
20
|
+
fi
|
|
21
|
+
COUNT=$((COUNT + 1))
|
|
22
|
+
echo "$COUNT" > "$COUNTER_FILE"
|
|
23
|
+
|
|
24
|
+
# Check threshold
|
|
25
|
+
if [ "$COUNT" -ge "$THRESHOLD" ]; then
|
|
26
|
+
echo "SDD: $COUNT tool invocations since last compaction suggestion. Consider running /compact to free context window space. Key information to preserve: current task, spec criteria, files modified, test status." >&2
|
|
27
|
+
# Reset counter after suggesting
|
|
28
|
+
echo "0" > "$COUNTER_FILE"
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
exit 0
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
set -euo pipefail
|
|
6
6
|
|
|
7
|
-
# Skip if guardrails disabled
|
|
7
|
+
# Skip if guardrails disabled or in research mode
|
|
8
8
|
if [ "${GUARDRAILS_DISABLED:-false}" = "true" ]; then
|
|
9
9
|
exit 0
|
|
10
10
|
fi
|
|
11
|
+
if [ "${SDD_MODE:-dev}" = "research" ]; then
|
|
12
|
+
exit 0
|
|
13
|
+
fi
|
|
11
14
|
|
|
12
15
|
PROJECT_DIR="${CLAUDE_PROJECT_DIR:-.}"
|
|
13
16
|
# Resolve to absolute path (POSIX-compatible fallback when realpath unavailable)
|
|
@@ -34,12 +34,24 @@ if [ -n "$ENV_FILE" ]; then
|
|
|
34
34
|
echo "SDD_ACTIVE=true" >> "$ENV_FILE"
|
|
35
35
|
fi
|
|
36
36
|
|
|
37
|
-
# Check for config file
|
|
37
|
+
# Check for config file and read settings
|
|
38
|
+
SDD_DEFAULT_MODE="dev"
|
|
39
|
+
SDD_COMPACTION_THRESHOLD="50"
|
|
38
40
|
if [ -f "$CONFIG_FILE" ]; then
|
|
39
41
|
echo "SDD: Config file found at $CONFIG_FILE" >&2
|
|
40
42
|
if [ -n "$ENV_FILE" ]; then
|
|
41
43
|
echo "SDD_CONFIG_FOUND=true" >> "$ENV_FILE"
|
|
42
44
|
fi
|
|
45
|
+
# Read mode from config (grep-based, no yaml parser needed)
|
|
46
|
+
CONFIG_MODE=$(grep -E '^\s*mode\s*:' "$CONFIG_FILE" 2>/dev/null | head -1 | sed 's/.*:\s*//' | tr -d '[:space:]"'"'" || true)
|
|
47
|
+
if [ -n "$CONFIG_MODE" ] && echo "$CONFIG_MODE" | grep -qE '^(dev|review|research)$'; then
|
|
48
|
+
SDD_DEFAULT_MODE="$CONFIG_MODE"
|
|
49
|
+
fi
|
|
50
|
+
# Read compaction threshold from config
|
|
51
|
+
CONFIG_THRESHOLD=$(grep -E '^\s*compaction_threshold\s*:' "$CONFIG_FILE" 2>/dev/null | head -1 | sed 's/.*:\s*//' | tr -d '[:space:]"'"'" || true)
|
|
52
|
+
if [ -n "$CONFIG_THRESHOLD" ] && echo "$CONFIG_THRESHOLD" | grep -qE '^[0-9]+$'; then
|
|
53
|
+
SDD_COMPACTION_THRESHOLD="$CONFIG_THRESHOLD"
|
|
54
|
+
fi
|
|
43
55
|
else
|
|
44
56
|
echo "SDD: No .sdd.yaml found — using defaults" >&2
|
|
45
57
|
if [ -n "$ENV_FILE" ]; then
|
|
@@ -47,6 +59,12 @@ else
|
|
|
47
59
|
fi
|
|
48
60
|
fi
|
|
49
61
|
|
|
62
|
+
# Set mode and compaction threshold in env
|
|
63
|
+
if [ -n "$ENV_FILE" ]; then
|
|
64
|
+
echo "SDD_MODE=$SDD_DEFAULT_MODE" >> "$ENV_FILE"
|
|
65
|
+
echo "SDD_COMPACTION_THRESHOLD=$SDD_COMPACTION_THRESHOLD" >> "$ENV_FILE"
|
|
66
|
+
fi
|
|
67
|
+
|
|
50
68
|
# Inject using-sdd skill as additionalContext
|
|
51
69
|
USING_SDD_PATH="${CLAUDE_PLUGIN_ROOT:-}/skills/using-sdd/SKILL.md"
|
|
52
70
|
if [ -f "$USING_SDD_PATH" ]; then
|
|
@@ -56,5 +74,14 @@ else
|
|
|
56
74
|
echo "SDD WARNING: using-sdd skill not found at $USING_SDD_PATH" >&2
|
|
57
75
|
fi
|
|
58
76
|
|
|
59
|
-
|
|
77
|
+
# Inject context mode file
|
|
78
|
+
CONTEXT_PATH="${CLAUDE_PLUGIN_ROOT:-}/contexts/${SDD_DEFAULT_MODE}.md"
|
|
79
|
+
if [ -f "$CONTEXT_PATH" ]; then
|
|
80
|
+
echo ""
|
|
81
|
+
cat "$CONTEXT_PATH"
|
|
82
|
+
else
|
|
83
|
+
echo "SDD WARNING: context file not found at $CONTEXT_PATH" >&2
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
echo "SDD: Session initialized — mode=$SDD_DEFAULT_MODE, guardrails active" >&2
|
|
60
87
|
exit 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abdullah-alnahas/claude-sdd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Spec-Driven Development discipline system for Claude Code — behavioral guardrails, spec-first development, architecture awareness, TDD enforcement, iterative execution loops",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code-plugin",
|
|
@@ -23,7 +23,7 @@ check() {
|
|
|
23
23
|
echo "SDD Command Verification"
|
|
24
24
|
echo "────────────────────────"
|
|
25
25
|
|
|
26
|
-
COMMANDS=("sdd-guardrails" "sdd-yolo" "sdd-phase" "sdd-review" "sdd-adopt" "sdd-execute" "sdd-autopilot")
|
|
26
|
+
COMMANDS=("sdd-guardrails" "sdd-yolo" "sdd-phase" "sdd-review" "sdd-adopt" "sdd-execute" "sdd-autopilot" "sdd-mode" "sdd-verify" "sdd-orchestrate")
|
|
27
27
|
|
|
28
28
|
for cmd in "${COMMANDS[@]}"; do
|
|
29
29
|
echo ""
|
|
@@ -47,7 +47,7 @@ check "All command names are unique" test "$(echo "$NAMES" | wc -l)" -eq "$(echo
|
|
|
47
47
|
# Check agents referenced by commands exist
|
|
48
48
|
echo ""
|
|
49
49
|
echo "Agent references:"
|
|
50
|
-
AGENTS=("critic" "simplifier" "spec-compliance" "security-reviewer" "performance-reviewer")
|
|
50
|
+
AGENTS=("critic" "simplifier" "spec-compliance" "security-reviewer" "performance-reviewer" "planner")
|
|
51
51
|
for agent in "${AGENTS[@]}"; do
|
|
52
52
|
check "Agent: $agent.md exists" test -f "$PLUGIN_DIR/agents/$agent.md"
|
|
53
53
|
done
|
package/scripts/verify-hooks.sh
CHANGED
|
@@ -73,8 +73,10 @@ echo ""
|
|
|
73
73
|
echo "Hook scripts:"
|
|
74
74
|
check "session-init.sh exists" test -f "$PLUGIN_DIR/hooks/scripts/session-init.sh"
|
|
75
75
|
check "post-edit-review.sh exists" test -f "$PLUGIN_DIR/hooks/scripts/post-edit-review.sh"
|
|
76
|
+
check "compaction-counter.sh exists" test -f "$PLUGIN_DIR/hooks/scripts/compaction-counter.sh"
|
|
76
77
|
check "session-init.sh is executable or bash-runnable" bash -n "$PLUGIN_DIR/hooks/scripts/session-init.sh"
|
|
77
78
|
check "post-edit-review.sh is executable or bash-runnable" bash -n "$PLUGIN_DIR/hooks/scripts/post-edit-review.sh"
|
|
79
|
+
check "compaction-counter.sh is executable or bash-runnable" bash -n "$PLUGIN_DIR/hooks/scripts/compaction-counter.sh"
|
|
78
80
|
|
|
79
81
|
# Test session-init.sh runs without error (in isolated temp dir to avoid side effects)
|
|
80
82
|
echo ""
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Iterative Retrieval Pattern
|
|
2
|
+
|
|
3
|
+
A disciplined approach for subagents gathering context before acting. Prevents both under-researching (acting on incomplete information) and over-researching (reading everything "just in case").
|
|
4
|
+
|
|
5
|
+
## The Pattern: DISPATCH → EVALUATE → REFINE → LOOP
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
1. DISPATCH — Send a focused query (search, read, find_symbol)
|
|
9
|
+
2. EVALUATE — Is this enough to act? Do I know what I need?
|
|
10
|
+
3. REFINE — If not, narrow or broaden the query based on what I learned
|
|
11
|
+
4. LOOP — Repeat until confident or max iterations reached
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
- Subagents exploring unfamiliar code before making changes
|
|
17
|
+
- Gathering context across multiple files for a review
|
|
18
|
+
- Understanding how a feature works before extending it
|
|
19
|
+
- Investigating a bug's root cause across layers
|
|
20
|
+
|
|
21
|
+
## When NOT to Use
|
|
22
|
+
|
|
23
|
+
- You already know the exact file and symbol
|
|
24
|
+
- The task is a single-file edit with clear instructions
|
|
25
|
+
- You're running automated checks (tests, lint) — just run them
|
|
26
|
+
|
|
27
|
+
## Example: Finding Where Auth Is Handled
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
DISPATCH: Search for "authenticate" in src/
|
|
31
|
+
EVALUATE: Found 3 files. middleware/auth.ts looks like the entry point.
|
|
32
|
+
DISPATCH: Read auth.ts symbols overview
|
|
33
|
+
EVALUATE: Has validateToken(), refreshSession(), authMiddleware(). Need to understand validateToken.
|
|
34
|
+
DISPATCH: Read validateToken body
|
|
35
|
+
EVALUATE: Now I know the auth flow. Sufficient to proceed.
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Anti-Patterns
|
|
39
|
+
|
|
40
|
+
| Anti-Pattern | Problem | Fix |
|
|
41
|
+
|-------------|---------|-----|
|
|
42
|
+
| **Shotgun read** — read every file in the directory | Wastes context window, buries signal in noise | Start narrow, broaden only if needed |
|
|
43
|
+
| **Single-shot guess** — read one file and assume that's enough | Misses critical context, produces wrong fixes | Always EVALUATE before acting |
|
|
44
|
+
| **Infinite refinement** — keep searching "just one more thing" | Never starts the actual work | Set max iterations (3-5 for context gathering) |
|
|
45
|
+
| **Keyword tunnel vision** — only search for one term | Misses related code using different names | Try synonyms, check imports/references |
|
|
46
|
+
| **Depth-first rabbit hole** — follow every reference chain to the bottom | Loses sight of the original task | Stay focused on what you need to know for THIS task |
|
|
47
|
+
|
|
48
|
+
## Integration with Iterative Execution
|
|
49
|
+
|
|
50
|
+
The retrieval pattern is the **information-gathering phase** that precedes the execution cycle. Use it to:
|
|
51
|
+
1. Understand the current state before defining completion criteria
|
|
52
|
+
2. Find the spec and acceptance criteria
|
|
53
|
+
3. Map the code that needs to change
|
|
54
|
+
4. Identify test files and patterns
|
|
55
|
+
|
|
56
|
+
Then hand off to the main iterative execution cycle: implement → verify → fix gaps → repeat.
|
|
57
|
+
|
|
58
|
+
## Bounded Retrieval
|
|
59
|
+
|
|
60
|
+
Always set bounds:
|
|
61
|
+
- **Max queries**: 5-8 for context gathering before acting
|
|
62
|
+
- **Max depth**: 2-3 levels of reference following
|
|
63
|
+
- **Sufficiency check**: After each query, ask "Can I act now?"
|
|
64
|
+
|
|
65
|
+
The goal is **sufficient context**, not **complete context**. You will never know everything. Act when you know enough.
|
|
@@ -51,6 +51,16 @@ These thoughts mean STOP — you're rationalizing skipping a skill:
|
|
|
51
51
|
| "The user said to skip guardrails" | Only `/sdd-yolo` disables guardrails. Verbal requests don't count. |
|
|
52
52
|
| "I already know what to do" | Knowing the task ≠ following the discipline. |
|
|
53
53
|
|
|
54
|
+
## Context Modes
|
|
55
|
+
|
|
56
|
+
SDD supports three context modes that adjust which guardrails are active. Switch with `/sdd-mode <mode>`.
|
|
57
|
+
|
|
58
|
+
| Mode | Pre-Implementation | Completion Review | Scope Guard | Use For |
|
|
59
|
+
|------|-------------------|-------------------|-------------|---------|
|
|
60
|
+
| **dev** (default) | Active | Active | Strict | Building, implementing, fixing |
|
|
61
|
+
| **review** | Skipped | Active | Normal | Code review, auditing, verification |
|
|
62
|
+
| **research** | Skipped | Skipped | Relaxed | Exploring, investigating, prototyping |
|
|
63
|
+
|
|
54
64
|
## Skill Classification
|
|
55
65
|
|
|
56
66
|
**Rigid skills** (follow exactly, don't adapt away discipline):
|