@abdullah-alnahas/claude-sdd 0.4.0 → 0.6.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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "claude-sdd",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Spec-Driven Development discipline system — behavioral guardrails, spec-first development, architecture awareness, TDD enforcement, iterative execution loops"
5
5
  }
package/README.md CHANGED
@@ -41,6 +41,9 @@ Red → Green → Refactor enforcement. Test traceability from behavior spec to
41
41
  ### Iterative Execution
42
42
  Disciplined delivery loops: implement with TDD → verify against spec → fix gaps → repeat. TDD is the inner discipline (how you write code), iterative execution is the outer cycle (how you deliver features).
43
43
 
44
+ ### Performance Optimization
45
+ Profile-first discipline for performance work. Defends against convenience bias (shallow, input-specific hacks), bottleneck mis-targeting, and correctness regressions during optimization.
46
+
44
47
  ## Commands
45
48
 
46
49
  | Command | Purpose |
@@ -61,6 +64,7 @@ Disciplined delivery loops: implement with TDD → verify against spec → fix g
61
64
  | **simplifier** | Complexity reducer — proposes simpler alternatives |
62
65
  | **spec-compliance** | Spec adherence checker — verifies traceability (spec → test → code) |
63
66
  | **security-reviewer** | Security analysis — OWASP Top 10, input validation, auth review |
67
+ | **performance-reviewer** | Performance optimization reviewer — validates patches for bottleneck targeting, convenience bias, measured improvement |
64
68
 
65
69
  ## Configuration
66
70
 
@@ -107,9 +111,9 @@ whitelist:
107
111
  ## Self-Test
108
112
 
109
113
  ```bash
110
- bash sdd/scripts/verify-hooks.sh
111
- bash sdd/scripts/verify-skills.sh
112
- bash sdd/scripts/verify-commands.sh
114
+ bash scripts/verify-hooks.sh
115
+ bash scripts/verify-skills.sh
116
+ bash scripts/verify-commands.sh
113
117
  ```
114
118
 
115
119
  ## Development Phases
package/agents/critic.md CHANGED
@@ -67,3 +67,7 @@ You are an adversarial reviewer. Your job is to find what's wrong, not confirm w
67
67
  - Be proportional: Don't nitpick formatting when there are logic bugs
68
68
  - Be constructive: Suggest fixes, not just problems
69
69
  - Be honest: If the code is good, say so briefly and move on
70
+
71
+ ## Performance Patch Review
72
+
73
+ When a patch includes performance changes, check for correctness regressions and logical errors as usual. For dedicated performance analysis (bottleneck targeting, convenience bias, measured speedup), defer to the **performance-reviewer** agent.
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: performance-reviewer
3
+ model: sonnet
4
+ color: magenta
5
+ description: >
6
+ Performance optimization reviewer that checks patches for bottleneck targeting accuracy, convenience bias,
7
+ measured improvement evidence, and correctness preservation.
8
+
9
+ <example>
10
+ Context: User has optimized code and wants validation.
11
+ user: "Review this optimization patch"
12
+ assistant: "I'll use the performance-reviewer agent to validate the optimization."
13
+ </example>
14
+
15
+ <example>
16
+ Context: User wants to verify a speedup claim.
17
+ user: "Is this actually faster?"
18
+ assistant: "Let me launch the performance-reviewer agent to check the evidence."
19
+ </example>
20
+
21
+ <example>
22
+ Context: User wants to check for convenience bias.
23
+ user: "Is this optimization solid or just a hack?"
24
+ assistant: "I'll use the performance-reviewer agent to evaluate the optimization quality."
25
+ </example>
26
+ allowed-tools:
27
+ - Read
28
+ - Glob
29
+ - Grep
30
+ - Bash
31
+ ---
32
+
33
+ # Performance Reviewer Agent
34
+
35
+ You review performance optimization patches for quality and correctness. Report findings only — do not modify code directly.
36
+
37
+ ## Review Process
38
+
39
+ 1. **Identify the claimed bottleneck**: What was supposed to be slow? Is there profiling evidence?
40
+ 2. **Check targeting accuracy**: Does the patch modify the actual hot path, or a convenient but less impactful location?
41
+ 3. **Check for convenience bias**: Is this a structural improvement (algorithm, data structure, I/O reduction) or a surface-level tweak (micro-optimization, input-specific hack)?
42
+ 4. **Check correctness**: Does the test suite still pass? Are there edge cases the optimization might break?
43
+ 5. **Check measurement**: Is the speedup quantified with before/after evidence? Multiple runs?
44
+ 6. **Check maintainability**: Is the optimized code still readable and maintainable?
45
+
46
+ ## Output Format
47
+
48
+ ```
49
+ ## Performance Review
50
+
51
+ ### Bottleneck Targeting
52
+ [Does the patch target the actual bottleneck? Evidence?]
53
+
54
+ ### Optimization Quality
55
+ [Structural improvement vs convenience bias. Explain.]
56
+
57
+ ### Correctness
58
+ [Test suite status. Edge cases at risk.]
59
+
60
+ ### Measured Improvement
61
+ [Before/after numbers. Methodology.]
62
+
63
+ ### Verdict
64
+ [SOLID — ship it / WEAK — iterate / BROKEN — revert]
65
+ ```
66
+
67
+ ## Red Flags
68
+
69
+ - No profiling evidence — "I think this is slow" is not evidence
70
+ - Patch modifies code not on the hot path — wrong target
71
+ - Speedup claimed but not measured — trust numbers, not intuition
72
+ - Tests removed or weakened to make the patch "work" — correctness regression
73
+ - Input-specific optimization that won't generalize — convenience bias
74
+ - Complexity increased significantly for marginal gain — poor tradeoff
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  name: sdd-adopt
3
3
  description: Adopt an existing project into the SDD discipline system
4
- argument-hint: ""
5
4
  allowed-tools:
6
5
  - Read
7
6
  - Write
@@ -75,7 +75,8 @@ Use the iterative execution outer loop: implement → verify → fix gaps → re
75
75
  2. Invoke **spec-compliance agent** — compare implementation against behavior-spec.md
76
76
  3. Invoke **critic agent** — find logical errors, assumption issues
77
77
  4. Invoke **security-reviewer agent** — check for vulnerabilities
78
- 5. Collect all findings
78
+ 5. If performance optimization was part of the spec, invoke **performance-reviewer agent**
79
+ 6. Collect all findings
79
80
 
80
81
  **Transition**: "Verify phase complete — N findings (X critical, Y high, Z medium). Entering Review phase."
81
82
 
@@ -45,7 +45,7 @@ Phase state is stored in `.sdd-phase` in the project root. This file contains a
45
45
  - `design` → architecture-aware skill
46
46
  - `implement` → TDD discipline + iterative execution skills
47
47
  - `verify` → iterative execution (verification step)
48
- - `review` → all agents (critic, simplifier, spec-compliance, security-reviewer)
48
+ - `review` → all agents (critic, simplifier, spec-compliance, security-reviewer, performance-reviewer)
49
49
 
50
50
  ## Output Format
51
51
 
@@ -54,6 +54,14 @@ SDD Phase: implement
54
54
  ─────────────────────
55
55
  Focus: TDD cycles within iterative execution — write tests first, then minimal code to pass
56
56
 
57
- Available skills: tdd-discipline, iterative-execution, guardrails
58
- Available agents: critic, simplifier, spec-compliance, security-reviewer
57
+ Available skills: tdd-discipline, iterative-execution, guardrails, performance-optimization
58
+ Recommended agents: critic, spec-compliance
59
+ All agents: critic, simplifier, spec-compliance, security-reviewer, performance-reviewer
59
60
  ```
61
+
62
+ Phase-specific agent recommendations:
63
+ - **specify**: spec-compliance (verify spec completeness)
64
+ - **design**: critic (architectural review), simplifier
65
+ - **implement**: spec-compliance (traceability), critic (logic review)
66
+ - **verify**: security-reviewer, performance-reviewer, spec-compliance
67
+ - **review**: all agents
@@ -27,10 +27,11 @@ Trigger an on-demand review of recent work using the critic and simplifier agent
27
27
  2. Run the **critic agent** — find logical errors, spec drift, assumption issues
28
28
  3. Run the **simplifier agent** — find unnecessary complexity
29
29
  4. If spec documents exist, run the **spec-compliance agent**
30
- 5. Present findings with severity levels
31
- 6. Offer to auto-fix issues found
32
- 7. If fixes are made (using TDD — write test for the fix first if applicable), re-review
33
- 8. Repeat until no critical issues remain or max iterations reached
30
+ 5. If the changes involve performance optimization, run the **performance-reviewer agent**
31
+ 6. Present findings with severity levels
32
+ 7. Offer to auto-fix issues found
33
+ 8. If fixes are made (using TDD write a test for the fix first), re-review
34
+ 9. Repeat until no critical issues remain or max iterations reached
34
35
 
35
36
  ## Output Format
36
37
 
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  name: sdd-yolo
3
3
  description: Temporarily disable all SDD guardrails for this session
4
- argument-hint: ""
5
4
  allowed-tools:
6
5
  - Write
7
6
  - Bash
package/hooks/hooks.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "hooks": [
7
7
  {
8
8
  "type": "command",
9
- "command": "bash $CLAUDE_PLUGIN_ROOT/hooks/scripts/session-init.sh",
9
+ "command": "bash \"$CLAUDE_PLUGIN_ROOT/hooks/scripts/session-init.sh\"",
10
10
  "timeout": 10
11
11
  }
12
12
  ]
@@ -29,7 +29,7 @@
29
29
  "hooks": [
30
30
  {
31
31
  "type": "command",
32
- "command": "bash $CLAUDE_PLUGIN_ROOT/hooks/scripts/post-edit-review.sh",
32
+ "command": "bash \"$CLAUDE_PLUGIN_ROOT/hooks/scripts/post-edit-review.sh\"",
33
33
  "timeout": 15
34
34
  }
35
35
  ]
@@ -10,24 +10,38 @@ if [ "${GUARDRAILS_DISABLED:-false}" = "true" ]; then
10
10
  fi
11
11
 
12
12
  PROJECT_DIR="${CLAUDE_PROJECT_DIR:-.}"
13
+ # Resolve to absolute path to avoid relative vs absolute mismatch
14
+ if command -v realpath &>/dev/null; then
15
+ PROJECT_DIR=$(realpath "$PROJECT_DIR" 2>/dev/null || echo "$PROJECT_DIR")
16
+ fi
13
17
 
14
18
  # Read tool input from stdin (JSON with file_path)
15
19
  INPUT=$(cat)
16
20
 
17
21
  # Use jq if available, fall back to sed
18
22
  if command -v jq &>/dev/null; then
19
- FILE_PATH=$(echo "$INPUT" | jq -r '.file_path // .filePath // empty' 2>/dev/null || echo "")
23
+ FILE_PATH=$(echo "$INPUT" | jq -r '.file_path // .filePath // empty' 2>/dev/null)
24
+ if [ $? -ne 0 ] || [ -z "$FILE_PATH" ]; then
25
+ echo "SDD: post-edit-review skipped — could not parse file_path from hook input" >&2
26
+ exit 0
27
+ fi
20
28
  else
21
- FILE_PATH=$(echo "$INPUT" | sed -n 's/.*"file_path"\s*:\s*"\([^"]*\)".*/\1/p' | head -1)
29
+ FILE_PATH=$(echo "$INPUT" | sed -n 's/.*"file_path"[ \t]*:[ \t]*"\([^"]*\)".*/\1/p' | head -1)
22
30
  if [ -z "$FILE_PATH" ]; then
23
- FILE_PATH=$(echo "$INPUT" | sed -n 's/.*"filePath"\s*:\s*"\([^"]*\)".*/\1/p' | head -1)
31
+ FILE_PATH=$(echo "$INPUT" | sed -n 's/.*"filePath"[ \t]*:[ \t]*"\([^"]*\)".*/\1/p' | head -1)
24
32
  fi
25
33
  fi
26
34
 
27
35
  if [ -z "$FILE_PATH" ]; then
36
+ echo "SDD: post-edit-review skipped — no file_path in hook input" >&2
28
37
  exit 0
29
38
  fi
30
39
 
40
+ # Resolve file path to absolute for consistent comparison
41
+ if command -v realpath &>/dev/null; then
42
+ FILE_PATH=$(realpath "$FILE_PATH" 2>/dev/null || echo "$FILE_PATH")
43
+ fi
44
+
31
45
  # Check if inside project directory
32
46
  case "$FILE_PATH" in
33
47
  "$PROJECT_DIR/"*|"$PROJECT_DIR") ;; # Inside project, OK
@@ -39,7 +53,7 @@ esac
39
53
 
40
54
  # Check git status for unrelated modifications
41
55
  if command -v git &>/dev/null && [ -d "$PROJECT_DIR/.git" ]; then
42
- MODIFIED_COUNT=$(cd "$PROJECT_DIR" && git diff --name-only 2>/dev/null | wc -l)
56
+ MODIFIED_COUNT=$(cd "$PROJECT_DIR" && git diff --name-only 2>/dev/null | wc -l | tr -d ' ')
43
57
  if [ "$MODIFIED_COUNT" -gt 10 ]; then
44
58
  echo "SDD SCOPE WARNING: $MODIFIED_COUNT files modified — possible scope creep. Review changes with 'git diff --stat'" >&2
45
59
  exit 2
@@ -13,7 +13,9 @@ YOLO_FLAG="$PROJECT_DIR/.sdd-yolo"
13
13
  if [ -f "$YOLO_FLAG" ]; then
14
14
  echo "SDD: Previous YOLO mode detected — clearing flag, guardrails disabled for this session" >&2
15
15
  # Remove yolo flag (auto-clears on session start)
16
- rm -f "$YOLO_FLAG"
16
+ if ! rm -f "$YOLO_FLAG" 2>/dev/null; then
17
+ echo "SDD WARNING: Could not remove yolo flag at $YOLO_FLAG — guardrails may remain disabled next session" >&2
18
+ fi
17
19
  if [ -n "$ENV_FILE" ]; then
18
20
  echo "GUARDRAILS_DISABLED=true" >> "$ENV_FILE"
19
21
  echo "SDD_YOLO_CLEARED=true" >> "$ENV_FILE"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abdullah-alnahas/claude-sdd",
3
- "version": "0.4.0",
3
+ "version": "0.6.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",
@@ -9,11 +9,13 @@ FAIL=0
9
9
  check() {
10
10
  local desc="$1"
11
11
  shift
12
- if "$@" >/dev/null 2>&1; then
12
+ local output
13
+ if output=$("$@" 2>&1); then
13
14
  echo " ✓ $desc"
14
15
  PASS=$((PASS + 1))
15
16
  else
16
17
  echo " ✗ $desc"
18
+ [ -n "$output" ] && echo " $output"
17
19
  FAIL=$((FAIL + 1))
18
20
  fi
19
21
  }
@@ -29,7 +31,7 @@ for cmd in "${COMMANDS[@]}"; do
29
31
  CMD_FILE="$PLUGIN_DIR/commands/$cmd.md"
30
32
 
31
33
  check "File exists" test -f "$CMD_FILE"
32
- check "Has frontmatter" grep -q "^---" "$CMD_FILE"
34
+ check "Has frontmatter" bash -c "sed -n '1p' \"$CMD_FILE\" | grep -q '^---'"
33
35
  check "Has name field" grep -q "^name:" "$CMD_FILE"
34
36
  check "Has description field" grep -q "^description:" "$CMD_FILE"
35
37
  check "Is non-empty (>100 chars)" test "$(wc -c < "$CMD_FILE")" -gt 100
@@ -45,7 +47,7 @@ check "All command names are unique" test "$(echo "$NAMES" | wc -l)" -eq "$(echo
45
47
  # Check agents referenced by commands exist
46
48
  echo ""
47
49
  echo "Agent references:"
48
- AGENTS=("critic" "simplifier" "spec-compliance" "security-reviewer")
50
+ AGENTS=("critic" "simplifier" "spec-compliance" "security-reviewer" "performance-reviewer")
49
51
  for agent in "${AGENTS[@]}"; do
50
52
  check "Agent: $agent.md exists" test -f "$PLUGIN_DIR/agents/$agent.md"
51
53
  done
@@ -9,11 +9,13 @@ FAIL=0
9
9
  check() {
10
10
  local desc="$1"
11
11
  shift
12
- if "$@" >/dev/null 2>&1; then
12
+ local output
13
+ if output=$("$@" 2>&1); then
13
14
  echo " ✓ $desc"
14
15
  PASS=$((PASS + 1))
15
16
  else
16
17
  echo " ✗ $desc"
18
+ [ -n "$output" ] && echo " $output"
17
19
  FAIL=$((FAIL + 1))
18
20
  fi
19
21
  }
@@ -25,32 +27,32 @@ echo "─────────────────────"
25
27
  echo ""
26
28
  echo "hooks.json:"
27
29
  check "File exists" test -f "$PLUGIN_DIR/hooks/hooks.json"
28
- check "Valid JSON" python3 -c "import json; json.load(open('$PLUGIN_DIR/hooks/hooks.json'))"
30
+ check "Valid JSON" python3 -c "import json, sys; json.load(open(sys.argv[1]))" "$PLUGIN_DIR/hooks/hooks.json"
29
31
  check "Has hooks wrapper" python3 -c "
30
- import json
31
- d = json.load(open('$PLUGIN_DIR/hooks/hooks.json'))
32
+ import json, sys
33
+ d = json.load(open(sys.argv[1]))
32
34
  assert 'hooks' in d, 'Missing hooks key'
33
- "
35
+ " "$PLUGIN_DIR/hooks/hooks.json"
34
36
  check "Has SessionStart hook" python3 -c "
35
- import json
36
- d = json.load(open('$PLUGIN_DIR/hooks/hooks.json'))
37
+ import json, sys
38
+ d = json.load(open(sys.argv[1]))
37
39
  assert 'SessionStart' in d['hooks']
38
- "
40
+ " "$PLUGIN_DIR/hooks/hooks.json"
39
41
  check "Has UserPromptSubmit hook" python3 -c "
40
- import json
41
- d = json.load(open('$PLUGIN_DIR/hooks/hooks.json'))
42
+ import json, sys
43
+ d = json.load(open(sys.argv[1]))
42
44
  assert 'UserPromptSubmit' in d['hooks']
43
- "
45
+ " "$PLUGIN_DIR/hooks/hooks.json"
44
46
  check "Has PostToolUse hook" python3 -c "
45
- import json
46
- d = json.load(open('$PLUGIN_DIR/hooks/hooks.json'))
47
+ import json, sys
48
+ d = json.load(open(sys.argv[1]))
47
49
  assert 'PostToolUse' in d['hooks']
48
- "
50
+ " "$PLUGIN_DIR/hooks/hooks.json"
49
51
  check "Has Stop hook" python3 -c "
50
- import json
51
- d = json.load(open('$PLUGIN_DIR/hooks/hooks.json'))
52
+ import json, sys
53
+ d = json.load(open(sys.argv[1]))
52
54
  assert 'Stop' in d['hooks']
53
- "
55
+ " "$PLUGIN_DIR/hooks/hooks.json"
54
56
 
55
57
  # Check scripts exist and are executable
56
58
  echo ""
@@ -9,11 +9,13 @@ FAIL=0
9
9
  check() {
10
10
  local desc="$1"
11
11
  shift
12
- if "$@" >/dev/null 2>&1; then
12
+ local output
13
+ if output=$("$@" 2>&1); then
13
14
  echo " ✓ $desc"
14
15
  PASS=$((PASS + 1))
15
16
  else
16
17
  echo " ✗ $desc"
18
+ [ -n "$output" ] && echo " $output"
17
19
  FAIL=$((FAIL + 1))
18
20
  fi
19
21
  }
@@ -21,7 +23,7 @@ check() {
21
23
  echo "SDD Skill Verification"
22
24
  echo "──────────────────────"
23
25
 
24
- SKILLS=("guardrails" "spec-first" "architecture-aware" "tdd-discipline" "iterative-execution")
26
+ SKILLS=("guardrails" "spec-first" "architecture-aware" "tdd-discipline" "iterative-execution" "performance-optimization")
25
27
 
26
28
  for skill in "${SKILLS[@]}"; do
27
29
  echo ""
@@ -30,7 +32,7 @@ for skill in "${SKILLS[@]}"; do
30
32
 
31
33
  check "Directory exists" test -d "$SKILL_DIR"
32
34
  check "SKILL.md exists" test -f "$SKILL_DIR/SKILL.md"
33
- check "SKILL.md has frontmatter" grep -q "^---" "$SKILL_DIR/SKILL.md"
35
+ check "SKILL.md has frontmatter" bash -c "sed -n '1p' \"$SKILL_DIR/SKILL.md\" | grep -q '^---'"
34
36
  check "SKILL.md has name field" grep -q "^name:" "$SKILL_DIR/SKILL.md"
35
37
  check "SKILL.md has description field" grep -q "^description:" "$SKILL_DIR/SKILL.md"
36
38
 
@@ -4,7 +4,8 @@ description: >
4
4
  This skill provides architecture consciousness during development, including integration patterns,
5
5
  anti-patterns, and ADR guidance. It should be used when the user asks how to structure or organize code,
6
6
  discusses architecture or design patterns, plans integrations between components, or asks
7
- "how should I structure this?", "what pattern should I use?", or "should I split this into services?"
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."
8
9
  ---
9
10
 
10
11
  # Architecture Awareness
@@ -22,13 +23,13 @@ Every pattern has trade-offs. State the specific benefit for THIS codebase, not
22
23
  ### Record Significant Decisions
23
24
  If a decision is hard to reverse or affects multiple components, it deserves an ADR (Architecture Decision Record).
24
25
 
25
- ## When to Engage
26
+ ## When an Architecture Question Arises
26
27
 
27
- - User asks "how should I structure this?"
28
- - Adding a new component to an existing system
29
- - Introducing a new technology or pattern
30
- - Changing how components communicate
31
- - Anything that touches 3+ modules/services
28
+ 1. **Survey existing patterns** read the codebase to understand current conventions, patterns, and structure
29
+ 2. **Evaluate fit** does the proposed approach align with or diverge from existing patterns? Divergence needs justification.
30
+ 3. **State trade-offs explicitly** every option has costs and benefits. Name them concretely for this codebase.
31
+ 4. **Decide whether an ADR is warranted** — write one if the decision is hard to reverse or affects multiple components
32
+ 5. **Document if yes** use the ADR template from `references/adr-guide.md`
32
33
 
33
34
  ## What to Check
34
35
 
@@ -37,6 +38,11 @@ If a decision is hard to reverse or affects multiple components, it deserves an
37
38
  3. **Coupling**: Are we creating tight coupling between components?
38
39
  4. **Consistency**: Does this follow or violate established conventions?
39
40
 
41
+ ## Related Skills
42
+
43
+ - **spec-first** — architecture decisions emerge during Stage 4 (Architecture)
44
+ - **guardrails** — enforces architectural consistency as part of scope discipline
45
+
40
46
  ## References
41
47
 
42
48
  See: `references/integration-patterns.md`
@@ -49,6 +49,10 @@ Before writing ANY implementation code, you MUST:
49
49
  - Do not create abstractions for single-use patterns
50
50
  - Track every file you modify — justify each one
51
51
 
52
+ ## Performance Changes
53
+
54
+ For performance optimization tasks, follow the **performance-optimization** skill for the full workflow (profile-first discipline, convenience bias detection, measured improvement). The core rule: never sacrifice correctness for speed.
55
+
52
56
  ## Completion Review
53
57
 
54
58
  Before claiming work is done:
@@ -56,7 +60,7 @@ Before claiming work is done:
56
60
  1. Re-read the original request
57
61
  2. Verify every requirement is met
58
62
  3. Check for dead code you introduced
59
- 4. Check function/file length limits (50/500 lines)
63
+ 4. Check function/file length guidelines (aim for ~50/~500 lines — adapt to project conventions)
60
64
  5. Verify no unrelated files were modified
61
65
  6. Run available tests
62
66
 
@@ -64,5 +68,15 @@ Before claiming work is done:
64
68
 
65
69
  Consult the failure patterns reference for detailed detection and response guidance for all 12 failure modes.
66
70
 
71
+ ## Related Skills
72
+
73
+ - **spec-first** — for the pre-implementation spec check (step 6 above)
74
+ - **tdd-discipline** — for the TDD inner discipline during implementation
75
+ - **iterative-execution** — for the implement-verify-fix outer cycle
76
+ - **performance-optimization** — for performance-specific guardrails
77
+ - **architecture-aware** — for architectural consistency checks
78
+
79
+ ## References
80
+
67
81
  See: `references/failure-patterns.md`
68
82
  See: `references/pushback-guide.md`
@@ -52,6 +52,10 @@ Use whatever is available, in order of preference:
52
52
  4. **External tools** (MCP servers, other plugins the user has configured)
53
53
  5. **Manual inspection** (read the code, trace the logic)
54
54
 
55
+ ## Performance Optimization Tasks
56
+
57
+ For performance optimization tasks, the verification step must additionally include timing comparison, profile comparison, and convenience bias checks. Follow the **performance-optimization** skill for the full workflow.
58
+
55
59
  ## Honesty Rules
56
60
 
57
61
  - **Never claim done when tests fail.** If tests fail, you're not done.
@@ -61,5 +65,14 @@ Use whatever is available, in order of preference:
61
65
 
62
66
  ## References
63
67
 
68
+ ## Related Skills
69
+
70
+ - **tdd-discipline** — the inner discipline used within each implementation step
71
+ - **spec-first** — produces the specs that define completion criteria
72
+ - **guardrails** — the overarching discipline layer
73
+ - **performance-optimization** — specialized verification for performance tasks
74
+
75
+ ## References
76
+
64
77
  See: `references/loop-patterns.md`
65
78
  See: `references/completion-criteria.md`
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: Performance Optimization
3
+ description: >
4
+ This skill enforces disciplined performance optimization practices defending against convenience bias,
5
+ bottleneck mis-targeting, and correctness regressions. It should be used when the user asks to optimize,
6
+ speed up, improve performance, reduce runtime, or make code faster — any task where the goal is better
7
+ performance without breaking correctness.
8
+ ---
9
+
10
+ # Performance Optimization Discipline
11
+
12
+ Performance optimization is investigative work. You must understand the problem before changing any code. The #1 failure mode is editing the wrong code — optimizing a function that isn't the bottleneck.
13
+
14
+ ## Before Touching Code
15
+
16
+ 1. **Understand the workload** — what is slow? Get a concrete, reproducible example.
17
+ 2. **Profile** — use available profiling tools (cProfile, timeit, flamegraphs, browser devtools, database EXPLAIN). Identify the actual bottleneck with evidence.
18
+ 3. **Establish a baseline** — measure current performance quantitatively. Record the number.
19
+ 4. **Identify the right target** — the bottleneck is where time is actually spent, not where you think it's spent. Trust the profiler, not intuition.
20
+
21
+ ## During Implementation
22
+
23
+ 1. **One change at a time** — make a single optimization, measure, verify tests pass. Then move to the next.
24
+ 2. **Prefer structural improvements**:
25
+ - Algorithm changes (O(n^2) → O(n log n))
26
+ - Data structure changes (list → set for lookups)
27
+ - Eliminating redundant computation (caching, memoization)
28
+ - Reducing I/O (batching, buffering)
29
+ 3. **Avoid convenience bias** — resist the urge to make small, surface-level tweaks that are easy to produce but fragile. If the fix is a one-liner that "should help," verify it actually does.
30
+ 4. **Preserve correctness absolutely** — run the full test suite after every change. Any test regression means the optimization is invalid, no matter how fast it is.
31
+ 5. **Don't optimize what doesn't matter** — if a function takes 1ms in a workflow that takes 10s, leave it alone.
32
+
33
+ ## After Each Change
34
+
35
+ 1. **Measure** — compare against baseline. Quantify the improvement (e.g., "2.3x faster" or "reduced from 4.2s to 1.8s").
36
+ 2. **Test** — full test suite passes.
37
+ 3. **Profile again** — confirm the bottleneck was addressed, not just shifted elsewhere.
38
+ 4. **Evaluate** — is the improvement sufficient? If not, iterate on the next bottleneck.
39
+
40
+ ## What NOT to Do
41
+
42
+ - Don't guess at bottlenecks — profile first
43
+ - Don't sacrifice readability for marginal gains
44
+ - Don't optimize code paths that run once at startup
45
+ - Don't add caching without understanding invalidation
46
+ - Don't parallelize without understanding thread safety
47
+ - Don't claim "faster" without measurements
48
+
49
+ ## Convenience Bias Checklist
50
+
51
+ Before submitting a performance patch, verify it is NOT:
52
+ - An input-specific hack that only helps one case
53
+ - A micro-optimization with unmeasurable impact
54
+ - A change that trades correctness risk for speed
55
+ - A surface-level tweak when a deeper structural fix exists
56
+
57
+ ## Related Skills
58
+
59
+ - **guardrails** — enforces correctness-first and verify-before-claiming during optimization
60
+ - **iterative-execution** — the outer verify-fix cycle for measuring and iterating on improvements
61
+ - **tdd-discipline** — ensures test suite is maintained through optimization changes
62
+
63
+ ## References
64
+
65
+ See: `references/profiling-checklist.md`
66
+ See: `references/optimization-patterns.md`
@@ -0,0 +1,32 @@
1
+ # Optimization Patterns
2
+
3
+ Prefer structural improvements over micro-optimizations. Ordered by typical impact.
4
+
5
+ ## High Impact (Algorithmic)
6
+
7
+ - **Better algorithm**: Replace O(n^2) with O(n log n) or O(n)
8
+ - **Better data structure**: list → set/dict for lookups, array → heap for priority
9
+ - **Eliminate redundant work**: cache expensive computations, memoize pure functions
10
+ - **Batch operations**: replace N individual calls with one batch call (DB queries, API requests, file I/O)
11
+
12
+ ## Medium Impact (Architectural)
13
+
14
+ - **Reduce I/O**: buffer writes, read in chunks, avoid unnecessary disk/network roundtrips
15
+ - **Lazy evaluation**: defer expensive computation until actually needed
16
+ - **Precomputation**: compute once at init instead of on every call
17
+ - **Connection pooling**: reuse expensive resources (DB connections, HTTP clients)
18
+
19
+ ## Low Impact (Micro)
20
+
21
+ - **Loop optimization**: move invariants outside loops, use generators for large sequences
22
+ - **String building**: use join/buffer instead of concatenation in loops
23
+ - **Avoid unnecessary copies**: pass by reference where safe, use views/slices
24
+
25
+ ## Anti-Patterns (Convenience Bias)
26
+
27
+ These look like optimizations but are fragile or misleading:
28
+
29
+ - **Input-specific shortcuts**: fast for one input, no help (or slower) for others
30
+ - **Premature caching**: cache without invalidation strategy — trades speed for correctness risk
31
+ - **Parallelism without need**: adds complexity when the bottleneck is algorithmic, not CPU
32
+ - **Removing safety checks**: faster but introduces silent corruption risk
@@ -0,0 +1,29 @@
1
+ # Profiling Checklist
2
+
3
+ Before optimizing, confirm you have:
4
+
5
+ ## 1. Reproducible Workload
6
+ - [ ] A concrete script/command that demonstrates the slowness
7
+ - [ ] Input data that triggers the slow path
8
+ - [ ] Expected vs actual runtime
9
+
10
+ ## 2. Profiling Evidence
11
+ - [ ] Profiler output identifying the hot path (function-level timing)
12
+ - [ ] Confirmation that the bottleneck is in code you control (not external I/O, network, etc.)
13
+ - [ ] If I/O-bound: evidence of unnecessary or redundant I/O operations
14
+
15
+ ## 3. Baseline Measurement
16
+ - [ ] Exact timing of the current implementation on the workload
17
+ - [ ] Multiple runs to confirm consistency (not a fluke)
18
+ - [ ] Environment noted (machine, load, relevant config)
19
+
20
+ ## Common Profiling Tools by Language
21
+
22
+ | Language | Profiling | Timing |
23
+ |----------|-----------|--------|
24
+ | Python | cProfile, py-spy, line_profiler | timeit, time.perf_counter |
25
+ | JavaScript | Chrome DevTools, node --prof | console.time, performance.now |
26
+ | Rust | cargo flamegraph, perf | criterion, std::time::Instant |
27
+ | Go | pprof, trace | testing.B (benchmarks) |
28
+ | Java | JFR, async-profiler | JMH |
29
+ | SQL | EXPLAIN ANALYZE | query timing |
@@ -60,6 +60,12 @@ For existing projects, use the adoption flow instead of starting from scratch. S
60
60
  - **Documents are living**: Specs evolve. That's fine. But they must exist before code.
61
61
  - **Lean templates**: The templates are starting points, not forms to fill out
62
62
 
63
+ ## Related Skills
64
+
65
+ - **architecture-aware** — for deeper architectural guidance during Stage 4
66
+ - **tdd-discipline** — for test planning from behavior specs (use `references/templates/test-plan.md`)
67
+ - **guardrails** — enforces spec-first as a pre-implementation check
68
+
63
69
  ## References
64
70
 
65
71
  See: `references/interactive-spec-process.md` — Detailed questioning flow
@@ -3,7 +3,8 @@ name: TDD Discipline
3
3
  description: >
4
4
  This skill enforces test-driven development discipline with the Red/Green/Refactor cycle and traceability
5
5
  from behavior spec to test to code. It should be used when the user asks to write tests, add test coverage,
6
- discuss testing strategy, or says "how should I test this?", "add tests for this," or "write tests first."
6
+ discuss testing strategy, fix a bug, or says "how should I test this?", "add tests for this," "write tests first,"
7
+ "fix this bug," or "debug this."
7
8
  ---
8
9
 
9
10
  # TDD Discipline
@@ -20,7 +21,7 @@ This cycle applies at every level: unit, integration, e2e.
20
21
 
21
22
  ## Relationship to Iterative Execution
22
23
 
23
- TDD is the **inner discipline** — how you write each piece of code. Iterative execution is the **outer cycle** — how you deliver a complete feature against a spec. Every "implement" step in the iterative execution cycle uses TDD internally. They are complementary: TDD ensures code correctness at the unit level; iterative execution ensures spec satisfaction at the feature level.
24
+ TDD is the **inner discipline** — how you write each piece of code. Iterative execution is the **outer cycle** — how you deliver a complete feature against a spec. They are complementary: TDD ensures correctness at the unit level; iterative execution ensures spec satisfaction at the feature level. See the **iterative-execution** skill for the full outer cycle.
24
25
 
25
26
  ## When TDD Adds Value
26
27
 
@@ -51,5 +52,13 @@ This chain ensures nothing is built without a reason and nothing specified goes
51
52
 
52
53
  ## References
53
54
 
55
+ ## Related Skills
56
+
57
+ - **iterative-execution** — the outer delivery cycle that uses TDD internally
58
+ - **spec-first** — produces behavior specs that drive test design (see `spec-first/references/templates/test-plan.md`)
59
+ - **guardrails** — enforces TDD during implementation
60
+
61
+ ## References
62
+
54
63
  See: `references/test-strategies.md`
55
64
  See: `references/traceability.md`