@abdullah-alnahas/claude-sdd 0.6.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-autopilot.md +19 -7
- package/commands/sdd-execute.md +18 -0
- package/commands/sdd-mode.md +42 -0
- package/commands/sdd-orchestrate.md +103 -0
- package/commands/sdd-phase.md +1 -1
- package/commands/sdd-review.md +52 -18
- 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 +14 -3
- package/hooks/scripts/compaction-counter.sh +31 -0
- package/hooks/scripts/post-edit-review.sh +11 -4
- package/hooks/scripts/session-init.sh +44 -3
- package/package.json +1 -1
- package/scripts/verify-commands.sh +2 -2
- package/scripts/verify-hooks.sh +30 -8
- package/scripts/verify-skills.sh +1 -1
- package/skills/architecture-aware/SKILL.md +4 -5
- package/skills/guardrails/SKILL.md +51 -5
- package/skills/guardrails/references/failure-patterns.md +5 -0
- package/skills/iterative-execution/SKILL.md +21 -6
- package/skills/iterative-execution/references/retrieval-pattern.md +65 -0
- package/skills/iterative-execution/references/review-prompts.md +69 -0
- package/skills/performance-optimization/SKILL.md +5 -4
- package/skills/spec-first/SKILL.md +4 -4
- package/skills/tdd-discipline/SKILL.md +23 -6
- package/skills/using-sdd/SKILL.md +82 -0
- package/skills/using-sdd/references/skill-creation-process.md +54 -0
package/hooks/hooks.json
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
{
|
|
8
8
|
"type": "command",
|
|
9
9
|
"command": "bash \"$CLAUDE_PLUGIN_ROOT/hooks/scripts/session-init.sh\"",
|
|
10
|
-
"timeout": 10
|
|
10
|
+
"timeout": 10,
|
|
11
|
+
"additionalContext": true
|
|
11
12
|
}
|
|
12
13
|
]
|
|
13
14
|
}
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
"hooks": [
|
|
19
20
|
{
|
|
20
21
|
"type": "prompt",
|
|
21
|
-
"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."
|
|
22
23
|
}
|
|
23
24
|
]
|
|
24
25
|
}
|
|
@@ -33,6 +34,16 @@
|
|
|
33
34
|
"timeout": 15
|
|
34
35
|
}
|
|
35
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
|
+
]
|
|
36
47
|
}
|
|
37
48
|
],
|
|
38
49
|
"Stop": [
|
|
@@ -41,7 +52,7 @@
|
|
|
41
52
|
"hooks": [
|
|
42
53
|
{
|
|
43
54
|
"type": "prompt",
|
|
44
|
-
"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."
|
|
45
56
|
}
|
|
46
57
|
]
|
|
47
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,15 +4,20 @@
|
|
|
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
|
-
# Resolve to absolute path
|
|
16
|
+
# Resolve to absolute path (POSIX-compatible fallback when realpath unavailable)
|
|
14
17
|
if command -v realpath &>/dev/null; then
|
|
15
18
|
PROJECT_DIR=$(realpath "$PROJECT_DIR" 2>/dev/null || echo "$PROJECT_DIR")
|
|
19
|
+
else
|
|
20
|
+
PROJECT_DIR=$(cd "$PROJECT_DIR" 2>/dev/null && pwd || echo "$PROJECT_DIR")
|
|
16
21
|
fi
|
|
17
22
|
|
|
18
23
|
# Read tool input from stdin (JSON with file_path)
|
|
@@ -20,8 +25,8 @@ INPUT=$(cat)
|
|
|
20
25
|
|
|
21
26
|
# Use jq if available, fall back to sed
|
|
22
27
|
if command -v jq &>/dev/null; then
|
|
23
|
-
FILE_PATH=$(echo "$INPUT" | jq -r '.file_path // .filePath // empty' 2>/dev/null)
|
|
24
|
-
if [
|
|
28
|
+
FILE_PATH=$(echo "$INPUT" | jq -r '.file_path // .filePath // empty' 2>/dev/null || true)
|
|
29
|
+
if [ -z "$FILE_PATH" ]; then
|
|
25
30
|
echo "SDD: post-edit-review skipped — could not parse file_path from hook input" >&2
|
|
26
31
|
exit 0
|
|
27
32
|
fi
|
|
@@ -40,6 +45,8 @@ fi
|
|
|
40
45
|
# Resolve file path to absolute for consistent comparison
|
|
41
46
|
if command -v realpath &>/dev/null; then
|
|
42
47
|
FILE_PATH=$(realpath "$FILE_PATH" 2>/dev/null || echo "$FILE_PATH")
|
|
48
|
+
elif [ -f "$FILE_PATH" ]; then
|
|
49
|
+
FILE_PATH=$(cd "$(dirname "$FILE_PATH")" 2>/dev/null && echo "$(pwd)/$(basename "$FILE_PATH")" || echo "$FILE_PATH")
|
|
43
50
|
fi
|
|
44
51
|
|
|
45
52
|
# Check if inside project directory
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
# SDD Session Initialization Hook
|
|
3
|
-
# Loads .sdd.yaml config, sets environment variables, checks yolo flag
|
|
3
|
+
# Loads .sdd.yaml config, sets environment variables, checks yolo flag, injects using-sdd skill
|
|
4
4
|
|
|
5
5
|
set -euo pipefail
|
|
6
6
|
|
|
7
|
+
# Validate plugin environment
|
|
8
|
+
if [ -z "${CLAUDE_PLUGIN_ROOT:-}" ]; then
|
|
9
|
+
echo "SDD WARNING: CLAUDE_PLUGIN_ROOT is not set — hooks may not locate plugin resources" >&2
|
|
10
|
+
fi
|
|
11
|
+
|
|
7
12
|
PROJECT_DIR="${CLAUDE_PROJECT_DIR:-.}"
|
|
8
13
|
ENV_FILE="${CLAUDE_ENV_FILE:-}"
|
|
9
14
|
CONFIG_FILE="$PROJECT_DIR/.sdd.yaml"
|
|
@@ -29,12 +34,24 @@ if [ -n "$ENV_FILE" ]; then
|
|
|
29
34
|
echo "SDD_ACTIVE=true" >> "$ENV_FILE"
|
|
30
35
|
fi
|
|
31
36
|
|
|
32
|
-
# Check for config file
|
|
37
|
+
# Check for config file and read settings
|
|
38
|
+
SDD_DEFAULT_MODE="dev"
|
|
39
|
+
SDD_COMPACTION_THRESHOLD="50"
|
|
33
40
|
if [ -f "$CONFIG_FILE" ]; then
|
|
34
41
|
echo "SDD: Config file found at $CONFIG_FILE" >&2
|
|
35
42
|
if [ -n "$ENV_FILE" ]; then
|
|
36
43
|
echo "SDD_CONFIG_FOUND=true" >> "$ENV_FILE"
|
|
37
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
|
|
38
55
|
else
|
|
39
56
|
echo "SDD: No .sdd.yaml found — using defaults" >&2
|
|
40
57
|
if [ -n "$ENV_FILE" ]; then
|
|
@@ -42,5 +59,29 @@ else
|
|
|
42
59
|
fi
|
|
43
60
|
fi
|
|
44
61
|
|
|
45
|
-
|
|
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
|
+
|
|
68
|
+
# Inject using-sdd skill as additionalContext
|
|
69
|
+
USING_SDD_PATH="${CLAUDE_PLUGIN_ROOT:-}/skills/using-sdd/SKILL.md"
|
|
70
|
+
if [ -f "$USING_SDD_PATH" ]; then
|
|
71
|
+
# Strip frontmatter and output as additionalContext
|
|
72
|
+
sed '1{/^---$/!q;};1,/^---$/d' "$USING_SDD_PATH"
|
|
73
|
+
else
|
|
74
|
+
echo "SDD WARNING: using-sdd skill not found at $USING_SDD_PATH" >&2
|
|
75
|
+
fi
|
|
76
|
+
|
|
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
|
|
46
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
|
@@ -23,49 +23,71 @@ check() {
|
|
|
23
23
|
echo "SDD Hook Verification"
|
|
24
24
|
echo "─────────────────────"
|
|
25
25
|
|
|
26
|
+
# Detect Python interpreter
|
|
27
|
+
PYTHON=""
|
|
28
|
+
for candidate in python3 python; do
|
|
29
|
+
if command -v "$candidate" &>/dev/null; then
|
|
30
|
+
PYTHON="$candidate"
|
|
31
|
+
break
|
|
32
|
+
fi
|
|
33
|
+
done
|
|
34
|
+
|
|
26
35
|
# Check hooks.json exists and is valid JSON
|
|
27
36
|
echo ""
|
|
28
37
|
echo "hooks.json:"
|
|
29
38
|
check "File exists" test -f "$PLUGIN_DIR/hooks/hooks.json"
|
|
30
|
-
|
|
31
|
-
check "
|
|
39
|
+
if [ -n "$PYTHON" ]; then
|
|
40
|
+
check "Valid JSON" "$PYTHON" -c "import json, sys; json.load(open(sys.argv[1]))" "$PLUGIN_DIR/hooks/hooks.json"
|
|
41
|
+
check "Has hooks wrapper" "$PYTHON" -c "
|
|
32
42
|
import json, sys
|
|
33
43
|
d = json.load(open(sys.argv[1]))
|
|
34
44
|
assert 'hooks' in d, 'Missing hooks key'
|
|
35
45
|
" "$PLUGIN_DIR/hooks/hooks.json"
|
|
36
|
-
check "Has SessionStart hook"
|
|
46
|
+
check "Has SessionStart hook" "$PYTHON" -c "
|
|
37
47
|
import json, sys
|
|
38
48
|
d = json.load(open(sys.argv[1]))
|
|
39
49
|
assert 'SessionStart' in d['hooks']
|
|
40
50
|
" "$PLUGIN_DIR/hooks/hooks.json"
|
|
41
|
-
check "Has UserPromptSubmit hook"
|
|
51
|
+
check "Has UserPromptSubmit hook" "$PYTHON" -c "
|
|
42
52
|
import json, sys
|
|
43
53
|
d = json.load(open(sys.argv[1]))
|
|
44
54
|
assert 'UserPromptSubmit' in d['hooks']
|
|
45
55
|
" "$PLUGIN_DIR/hooks/hooks.json"
|
|
46
|
-
check "Has PostToolUse hook"
|
|
56
|
+
check "Has PostToolUse hook" "$PYTHON" -c "
|
|
47
57
|
import json, sys
|
|
48
58
|
d = json.load(open(sys.argv[1]))
|
|
49
59
|
assert 'PostToolUse' in d['hooks']
|
|
50
60
|
" "$PLUGIN_DIR/hooks/hooks.json"
|
|
51
|
-
check "Has Stop hook"
|
|
61
|
+
check "Has Stop hook" "$PYTHON" -c "
|
|
52
62
|
import json, sys
|
|
53
63
|
d = json.load(open(sys.argv[1]))
|
|
54
64
|
assert 'Stop' in d['hooks']
|
|
55
65
|
" "$PLUGIN_DIR/hooks/hooks.json"
|
|
66
|
+
else
|
|
67
|
+
echo " ⚠ Python not found — skipping JSON validation (install python3 or activate a venv)"
|
|
68
|
+
FAIL=$((FAIL + 1))
|
|
69
|
+
fi
|
|
56
70
|
|
|
57
71
|
# Check scripts exist and are executable
|
|
58
72
|
echo ""
|
|
59
73
|
echo "Hook scripts:"
|
|
60
74
|
check "session-init.sh exists" test -f "$PLUGIN_DIR/hooks/scripts/session-init.sh"
|
|
61
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"
|
|
62
77
|
check "session-init.sh is executable or bash-runnable" bash -n "$PLUGIN_DIR/hooks/scripts/session-init.sh"
|
|
63
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"
|
|
64
80
|
|
|
65
|
-
# Test session-init.sh runs without error
|
|
81
|
+
# Test session-init.sh runs without error (in isolated temp dir to avoid side effects)
|
|
66
82
|
echo ""
|
|
67
83
|
echo "Script execution:"
|
|
68
|
-
check "session-init.sh runs without error" bash
|
|
84
|
+
check "session-init.sh runs without error" bash -c "
|
|
85
|
+
TMPDIR=\$(mktemp -d)
|
|
86
|
+
CLAUDE_PROJECT_DIR=\"\$TMPDIR\" CLAUDE_ENV_FILE=\"\" bash \"$PLUGIN_DIR/hooks/scripts/session-init.sh\" 2>/dev/null
|
|
87
|
+
rc=\$?
|
|
88
|
+
rm -rf \"\$TMPDIR\"
|
|
89
|
+
exit \$rc
|
|
90
|
+
"
|
|
69
91
|
|
|
70
92
|
echo ""
|
|
71
93
|
echo "─────────────────────"
|
package/scripts/verify-skills.sh
CHANGED
|
@@ -23,7 +23,7 @@ check() {
|
|
|
23
23
|
echo "SDD Skill Verification"
|
|
24
24
|
echo "──────────────────────"
|
|
25
25
|
|
|
26
|
-
SKILLS=("guardrails" "spec-first" "architecture-aware" "tdd-discipline" "iterative-execution" "performance-optimization")
|
|
26
|
+
SKILLS=("guardrails" "spec-first" "architecture-aware" "tdd-discipline" "iterative-execution" "performance-optimization" "using-sdd")
|
|
27
27
|
|
|
28
28
|
for skill in "${SKILLS[@]}"; do
|
|
29
29
|
echo ""
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: Architecture Awareness
|
|
3
3
|
description: >
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"how should I structure this?", "what pattern should I use?", "should I split this into services?",
|
|
8
|
-
"should I write an ADR?", or "document this decision."
|
|
4
|
+
Use when structuring or organizing code, discussing architecture or design patterns, planning
|
|
5
|
+
integrations between components, or when the user asks "how should I structure this?", "what
|
|
6
|
+
pattern should I use?", "should I split this into services?", or "document this decision."
|
|
9
7
|
---
|
|
10
8
|
|
|
11
9
|
# Architecture Awareness
|
|
@@ -41,6 +39,7 @@ If a decision is hard to reverse or affects multiple components, it deserves an
|
|
|
41
39
|
## Related Skills
|
|
42
40
|
|
|
43
41
|
- **spec-first** — architecture decisions emerge during Stage 4 (Architecture)
|
|
42
|
+
- **iterative-execution** — architectural context guides integration during implementation
|
|
44
43
|
- **guardrails** — enforces architectural consistency as part of scope discipline
|
|
45
44
|
|
|
46
45
|
## References
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: SDD Guardrails
|
|
3
3
|
description: >
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
discipline, simplicity, and verification before claiming completion.
|
|
4
|
+
Use when implementing, building, fixing, refactoring, adding, changing, or modifying code.
|
|
5
|
+
Use when reviewing code or claiming work is complete. Use when you notice yourself agreeing
|
|
6
|
+
without critical evaluation or adding code beyond what was requested.
|
|
8
7
|
---
|
|
9
8
|
|
|
10
9
|
# SDD Behavioral Guardrails
|
|
11
10
|
|
|
12
11
|
Operate under the SDD (Spec-Driven Development) discipline system. These guardrails defend against known LLM failure patterns in software development.
|
|
13
12
|
|
|
13
|
+
## Spirit vs. Letter
|
|
14
|
+
|
|
15
|
+
Follow the **spirit** of these guardrails, not just their checklists. The goal is disciplined development that produces correct, simple, spec-compliant code. If following a checklist item mechanically would produce worse results than thoughtful application of the principle behind it, follow the principle. But this is **never** an excuse to skip steps — it's a reason to apply them thoughtfully.
|
|
16
|
+
|
|
14
17
|
## Core Principles
|
|
15
18
|
|
|
16
19
|
### 1. Honesty Over Agreement
|
|
@@ -26,7 +29,50 @@ The right solution is the simplest one that works. Before writing any code, ask:
|
|
|
26
29
|
Every assumption you make is a potential bug. Enumerate your assumptions explicitly. If you're uncertain about intent, ask. If you're uncertain about behavior, test. Never silently guess.
|
|
27
30
|
|
|
28
31
|
### 5. Verify Before Claiming
|
|
29
|
-
Never say "done" until you've verified.
|
|
32
|
+
Never say "done" until you've verified. This is a formal gate:
|
|
33
|
+
|
|
34
|
+
1. **IDENTIFY** the command or check needed to verify
|
|
35
|
+
2. **RUN** the command (test suite, linter, type checker)
|
|
36
|
+
3. **READ** the output — actually read it, don't skim
|
|
37
|
+
4. **VERIFY** the claim against the output — does the evidence support "done"?
|
|
38
|
+
5. **THEN** claim completion, citing the evidence
|
|
39
|
+
|
|
40
|
+
A completion claim without verification is a lie.
|
|
41
|
+
|
|
42
|
+
**Common verification failures:**
|
|
43
|
+
|
|
44
|
+
| Failure | What Actually Happened |
|
|
45
|
+
|---------|----------------------|
|
|
46
|
+
| "Tests pass" without running them | You guessed. Run them. |
|
|
47
|
+
| Ran tests but didn't read output | A failure was buried in the output. Read it. |
|
|
48
|
+
| Tests pass but don't cover the change | You tested the wrong thing. Check coverage. |
|
|
49
|
+
| "Looks correct" from reading code | Reading is not testing. Execute it. |
|
|
50
|
+
| Verified one case, claimed all cases | Edge cases exist. Test them. |
|
|
51
|
+
|
|
52
|
+
## Rationalization Red Flags
|
|
53
|
+
|
|
54
|
+
These thoughts mean STOP — you're about to violate a guardrail:
|
|
55
|
+
|
|
56
|
+
| Thought | Reality |
|
|
57
|
+
|---------|---------|
|
|
58
|
+
| "This small fix doesn't need the full checkpoint" | Small fixes are where scope creep starts. |
|
|
59
|
+
| "The user seems to want me to just do it" | Discipline is not optional based on tone. |
|
|
60
|
+
| "I'll verify at the end" | Verify continuously. End-of-task verification catches less. |
|
|
61
|
+
| "This is obviously correct" | Obvious code has bugs too. Test it. |
|
|
62
|
+
| "Adding this extra thing will help" | That's scope creep. Mention it, don't do it. |
|
|
63
|
+
| "I'm sure this test passes" | Run it. Being sure is not evidence. |
|
|
64
|
+
| "The user won't notice this improvement" | Unasked changes are defects regardless. |
|
|
65
|
+
| "This is a standard pattern, no need to verify" | Standard patterns fail in specific contexts. Verify. |
|
|
66
|
+
|
|
67
|
+
## Escalation Rule
|
|
68
|
+
|
|
69
|
+
After 3 failed attempts to fix the same issue, **STOP**. Do not attempt a 4th fix. Instead:
|
|
70
|
+
|
|
71
|
+
1. State what you've tried and why each attempt failed
|
|
72
|
+
2. Question whether the approach or architecture is wrong
|
|
73
|
+
3. Suggest an alternative approach or ask the user for direction
|
|
74
|
+
|
|
75
|
+
Repeated failures on the same issue usually indicate a wrong approach, not insufficient effort.
|
|
30
76
|
|
|
31
77
|
## Pre-Implementation Checkpoint
|
|
32
78
|
|
|
@@ -61,3 +61,8 @@
|
|
|
61
61
|
**Detection**: You've been coding for a while and haven't re-read the original requirement.
|
|
62
62
|
**Response**: Periodically re-read the request. Check that your solution actually solves the stated problem, not a related but different one.
|
|
63
63
|
**Example**: User asks to "sort by date" and you implement alphabetical sort because you started coding before fully reading.
|
|
64
|
+
|
|
65
|
+
### 13. Fix Thrashing
|
|
66
|
+
**Detection**: You've attempted 3+ fixes for the same issue and it's still broken. Each fix introduces a new problem or reverts to a previous failure.
|
|
67
|
+
**Response**: Stop fixing. Step back and question the approach. State what you've tried, why each failed, and propose an alternative architecture or ask the user for direction.
|
|
68
|
+
**Example**: A test keeps failing despite three different fixes to the handler. The real problem is the test assumes synchronous behavior but the handler is async. The fix isn't in the handler — it's in the test setup or the architectural approach.
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: Iterative Execution
|
|
3
3
|
description: >
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
tests pass," or "it's not matching the spec yet."
|
|
4
|
+
Use when implementing a feature from a spec, when implementation needs iterating to match
|
|
5
|
+
requirements, or when delivering any non-trivial change. Use when the user says "make this work,"
|
|
6
|
+
"implement this spec," "keep going until all tests pass," or "it's not matching the spec yet."
|
|
8
7
|
---
|
|
9
8
|
|
|
10
9
|
# Iterative Execution
|
|
@@ -36,6 +35,21 @@ They are complementary, not competing. TDD governs how you write code. Iterative
|
|
|
36
35
|
7. Report honest completion status
|
|
37
36
|
```
|
|
38
37
|
|
|
38
|
+
## Rationalization Red Flags
|
|
39
|
+
|
|
40
|
+
These thoughts mean STOP — you're about to skip verification:
|
|
41
|
+
|
|
42
|
+
| Thought | Reality |
|
|
43
|
+
|---------|---------|
|
|
44
|
+
| "I'll verify everything at the end" | Verify after each change. End-of-task catches less. |
|
|
45
|
+
| "The code looks right, no need to run tests" | Looking right is not evidence. Run the tests. |
|
|
46
|
+
| "I fixed the issue, moving on" | Did you verify the fix? Run the test again. |
|
|
47
|
+
| "Only one small thing changed" | Small changes cause big failures. Verify. |
|
|
48
|
+
| "I already know this passes" | You knew the previous version passed. This is a new version. |
|
|
49
|
+
| "Verification would take too long" | Shipping a bug takes longer. Verify. |
|
|
50
|
+
| "The spec is satisfied, I can see it" | Seeing is not testing. Run the criteria checks. |
|
|
51
|
+
| "I'll skip this iteration's verification" | Skipping once becomes skipping always. Never skip. |
|
|
52
|
+
|
|
39
53
|
## Completion Criteria
|
|
40
54
|
|
|
41
55
|
Good completion criteria are:
|
|
@@ -63,16 +77,17 @@ For performance optimization tasks, the verification step must additionally incl
|
|
|
63
77
|
- **Never weaken criteria to match output.** The spec defines done, not the implementation.
|
|
64
78
|
- **Be honest about partial completion.** "3 of 5 criteria met, blocked on X" is better than a false "done."
|
|
65
79
|
|
|
66
|
-
## References
|
|
67
|
-
|
|
68
80
|
## Related Skills
|
|
69
81
|
|
|
70
82
|
- **tdd-discipline** — the inner discipline used within each implementation step
|
|
71
83
|
- **spec-first** — produces the specs that define completion criteria
|
|
72
84
|
- **guardrails** — the overarching discipline layer
|
|
85
|
+
- **architecture-aware** — architectural context for integration decisions during implementation
|
|
73
86
|
- **performance-optimization** — specialized verification for performance tasks
|
|
74
87
|
|
|
75
88
|
## References
|
|
76
89
|
|
|
77
90
|
See: `references/loop-patterns.md`
|
|
78
91
|
See: `references/completion-criteria.md`
|
|
92
|
+
See: `references/review-prompts.md`
|
|
93
|
+
See: `references/retrieval-pattern.md`
|
|
@@ -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.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Review Prompt Templates
|
|
2
|
+
|
|
3
|
+
Subagent prompt templates for the two-stage review process.
|
|
4
|
+
|
|
5
|
+
## Stage 1: Spec Compliance Reviewer
|
|
6
|
+
|
|
7
|
+
Use this prompt for the spec-compliance review subagent:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
You are reviewing an implementation against its behavior specification.
|
|
11
|
+
|
|
12
|
+
DO NOT trust the implementer's report of what was done. Read the actual code and actual test output.
|
|
13
|
+
|
|
14
|
+
Your job:
|
|
15
|
+
1. Read the behavior spec (acceptance criteria)
|
|
16
|
+
2. Read the implementation code
|
|
17
|
+
3. Run or read test results
|
|
18
|
+
4. For EACH acceptance criterion, independently verify:
|
|
19
|
+
- Is there a test that covers this criterion?
|
|
20
|
+
- Does the test actually test what the criterion specifies?
|
|
21
|
+
- Does the test pass? (Read the output, don't trust claims)
|
|
22
|
+
- Does the implementation match the criterion's intent, not just its letter?
|
|
23
|
+
|
|
24
|
+
Report format:
|
|
25
|
+
- For each criterion: PASS / FAIL / PARTIAL with evidence
|
|
26
|
+
- Overall: X of Y criteria satisfied
|
|
27
|
+
- Blocking issues (must fix before proceeding)
|
|
28
|
+
- Non-blocking observations
|
|
29
|
+
|
|
30
|
+
DO NOT soften findings. DO NOT say "mostly works" when a criterion fails.
|
|
31
|
+
A criterion either passes with evidence or it doesn't.
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Stage 2: Code Quality Reviewer
|
|
35
|
+
|
|
36
|
+
Use this prompt for the code quality review subagent (only run after Stage 1 passes):
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
You are reviewing code quality after spec compliance has been verified.
|
|
40
|
+
|
|
41
|
+
Review the implementation for:
|
|
42
|
+
1. Unnecessary complexity (could this be simpler?)
|
|
43
|
+
2. Dead code introduced by the changes
|
|
44
|
+
3. Scope creep (changes beyond what the spec required)
|
|
45
|
+
4. Missing error handling at system boundaries
|
|
46
|
+
5. Naming clarity
|
|
47
|
+
6. Function/file length (aim ~50/~500 lines)
|
|
48
|
+
|
|
49
|
+
For each finding, classify:
|
|
50
|
+
- [Critical] — must fix (bugs, security issues)
|
|
51
|
+
- [Simplification] — should fix (unnecessary complexity)
|
|
52
|
+
- [Observation] — consider fixing (style, minor improvements)
|
|
53
|
+
|
|
54
|
+
DO NOT invent requirements. Only flag issues that make the code worse.
|
|
55
|
+
DO NOT suggest adding features, abstractions, or patterns not needed by the spec.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Implementer Self-Review Checklist
|
|
59
|
+
|
|
60
|
+
Before requesting external review, the implementer should verify:
|
|
61
|
+
|
|
62
|
+
1. [ ] Re-read the original request/spec
|
|
63
|
+
2. [ ] Every acceptance criterion has a corresponding test
|
|
64
|
+
3. [ ] All tests pass (actually ran them, read the output)
|
|
65
|
+
4. [ ] No unrelated files were modified
|
|
66
|
+
5. [ ] No dead code was introduced
|
|
67
|
+
6. [ ] No abstractions for single-use patterns
|
|
68
|
+
7. [ ] Function lengths are reasonable
|
|
69
|
+
8. [ ] Changes are the minimum needed to satisfy the spec
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: Performance Optimization
|
|
3
3
|
description: >
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
performance without breaking correctness.
|
|
4
|
+
Use when optimizing, speeding up, profiling, reducing memory usage, or improving performance.
|
|
5
|
+
Use when the user says "profile this," "find the bottleneck," "speed up," or "optimize."
|
|
6
|
+
Use when any change targets performance without breaking correctness.
|
|
8
7
|
---
|
|
9
8
|
|
|
10
9
|
# Performance Optimization Discipline
|
|
@@ -59,6 +58,8 @@ Before submitting a performance patch, verify it is NOT:
|
|
|
59
58
|
- **guardrails** — enforces correctness-first and verify-before-claiming during optimization
|
|
60
59
|
- **iterative-execution** — the outer verify-fix cycle for measuring and iterating on improvements
|
|
61
60
|
- **tdd-discipline** — ensures test suite is maintained through optimization changes
|
|
61
|
+
- **spec-first** — performance requirements originate in specs (stack.md, behavior-spec.md)
|
|
62
|
+
- **architecture-aware** — structural optimizations require architectural context
|
|
62
63
|
|
|
63
64
|
## References
|
|
64
65
|
|