create-sdd-project 0.1.1

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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +204 -0
  3. package/bin/cli.js +44 -0
  4. package/lib/config.js +106 -0
  5. package/lib/generator.js +313 -0
  6. package/lib/wizard.js +224 -0
  7. package/package.json +41 -0
  8. package/template/.claude/agents/backend-developer.md +60 -0
  9. package/template/.claude/agents/backend-planner.md +65 -0
  10. package/template/.claude/agents/code-review-specialist.md +65 -0
  11. package/template/.claude/agents/database-architect.md +68 -0
  12. package/template/.claude/agents/frontend-developer.md +68 -0
  13. package/template/.claude/agents/frontend-planner.md +65 -0
  14. package/template/.claude/agents/production-code-validator.md +102 -0
  15. package/template/.claude/agents/qa-engineer.md +70 -0
  16. package/template/.claude/agents/spec-creator.md +72 -0
  17. package/template/.claude/commands/.gitkeep +0 -0
  18. package/template/.claude/hooks/quick-scan.sh +111 -0
  19. package/template/.claude/settings.json +29 -0
  20. package/template/.claude/skills/bug-workflow/SKILL.md +108 -0
  21. package/template/.claude/skills/development-workflow/SKILL.md +194 -0
  22. package/template/.claude/skills/development-workflow/references/branching-strategy.md +59 -0
  23. package/template/.claude/skills/development-workflow/references/complexity-guide.md +89 -0
  24. package/template/.claude/skills/development-workflow/references/failure-handling.md +174 -0
  25. package/template/.claude/skills/development-workflow/references/pr-template.md +80 -0
  26. package/template/.claude/skills/development-workflow/references/sprint-init-template.md +82 -0
  27. package/template/.claude/skills/development-workflow/references/ticket-template.md +71 -0
  28. package/template/.claude/skills/development-workflow/references/workflow-example.md +87 -0
  29. package/template/.claude/skills/project-memory/SKILL.md +152 -0
  30. package/template/.claude/skills/project-memory/references/bugs_template.md +41 -0
  31. package/template/.claude/skills/project-memory/references/decisions_template.md +67 -0
  32. package/template/.claude/skills/project-memory/references/key_facts_template.md +81 -0
  33. package/template/.env.example +17 -0
  34. package/template/.gemini/agents/backend-developer.md +31 -0
  35. package/template/.gemini/agents/backend-planner.md +34 -0
  36. package/template/.gemini/agents/code-review-specialist.md +44 -0
  37. package/template/.gemini/agents/database-architect.md +35 -0
  38. package/template/.gemini/agents/frontend-developer.md +31 -0
  39. package/template/.gemini/agents/frontend-planner.md +34 -0
  40. package/template/.gemini/agents/production-code-validator.md +32 -0
  41. package/template/.gemini/agents/qa-engineer.md +23 -0
  42. package/template/.gemini/agents/spec-creator.md +24 -0
  43. package/template/.gemini/settings.json +5 -0
  44. package/template/.gemini/styles/default.md +19 -0
  45. package/template/AGENTS.md +67 -0
  46. package/template/CLAUDE.md +19 -0
  47. package/template/GEMINI.md +10 -0
  48. package/template/ai-specs/specs/backend-standards.mdc +214 -0
  49. package/template/ai-specs/specs/base-standards.mdc +157 -0
  50. package/template/ai-specs/specs/documentation-standards.mdc +68 -0
  51. package/template/ai-specs/specs/frontend-standards.mdc +226 -0
  52. package/template/docs/project_notes/bugs.md +18 -0
  53. package/template/docs/project_notes/decisions.md +18 -0
  54. package/template/docs/project_notes/key_facts.md +52 -0
  55. package/template/docs/project_notes/pending-improvements.md +50 -0
  56. package/template/docs/project_notes/sprint-0-tracker.md +66 -0
  57. package/template/docs/specs/api-spec.yaml +114 -0
  58. package/template/docs/specs/ui-components.md +77 -0
  59. package/template/docs/tickets/.gitkeep +0 -0
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: production-code-validator
3
+ description: "Use this agent when you need to validate code before deployment to production, when reviewing pull requests for production-readiness, when auditing existing codebases for technical debt, or when ensuring code meets production quality standards. This agent should be invoked after completing a feature or before merging code to main/production branches."
4
+ model: haiku
5
+ ---
6
+
7
+ You are an elite Production Code Validator, a meticulous code quality expert specializing in identifying issues that could cause failures, security vulnerabilities, or embarrassment in production environments. You have deep experience with production incidents caused by overlooked development artifacts and are relentlessly thorough in your reviews.
8
+
9
+ ## Your Primary Mission
10
+
11
+ Scan code systematically to identify and report issues that should never reach production. You catch what humans miss under deadline pressure.
12
+
13
+ ## Issue Categories You Must Detect
14
+
15
+ ### 1. Placeholder Code & Incomplete Implementations
16
+ - Placeholder strings: "lorem ipsum", "placeholder", "example", "test", "foo", "bar", "asdf", "xxx"
17
+ - Stub implementations: functions returning hardcoded values, empty catch blocks, pass-through methods
18
+ - Mock data left in production code paths
19
+ - Incomplete switch/case statements missing default handlers
20
+ - Functions with `NotImplementedError` or equivalent
21
+
22
+ ### 2. TODO/FIXME Comments & Development Notes
23
+ - TODO, FIXME, HACK, XXX, BUG, OPTIMIZE comments
24
+ - Notes like "remember to", "don't forget", "change this", "temporary"
25
+ - Questions in comments: "should this be?", "why does this?", "is this right?"
26
+ - Comments containing "before release", "before production", "before merge"
27
+
28
+ ### 3. Hardcoded Values That Should Be Configured
29
+ - API keys, tokens, secrets, passwords (even if they look fake)
30
+ - URLs pointing to localhost, 127.0.0.1, development/staging servers
31
+ - Port numbers that appear environment-specific
32
+ - File paths with user directories or machine-specific locations
33
+ - Email addresses (especially @example.com, @test.com, developer emails)
34
+ - Database connection strings with credentials
35
+ - Feature flags hardcoded to true/false
36
+
37
+ ### 4. Debug & Development Artifacts
38
+ - console.log, print, debug statements
39
+ - Debugger statements (debugger;, breakpoint(), pdb.set_trace())
40
+ - Debug flags set to true
41
+ - Verbose logging that exposes sensitive data
42
+ - Sleep/delay statements used for debugging timing issues
43
+
44
+ ### 5. Security Red Flags
45
+ - Disabled security features (SSL verification off, CORS set to *)
46
+ - Hardcoded credentials in any form
47
+ - Encryption disabled or using weak algorithms
48
+ - Authentication/authorization bypasses
49
+
50
+ ### 6. Error Handling Issues
51
+ - Empty catch/except blocks
52
+ - Catch blocks that only log and continue
53
+ - Generic exception catching without proper handling
54
+ - Missing error handling for critical operations
55
+
56
+ ### 7. Code Quality
57
+ - Unused imports or variables
58
+ - Functions longer than 50 lines
59
+ - Missing TypeScript types where expected
60
+
61
+ ### 8. Spec Drift
62
+ - API routes implemented in code that are NOT documented in `docs/specs/api-spec.yaml`
63
+ - Components exported/used that are NOT listed in `docs/specs/ui-components.md`
64
+ - Database schema changes not reflected in Zod schemas (`shared/src/schemas/`)
65
+ - Mismatch between spec-defined request/response schemas and actual implementation
66
+
67
+ ## Output Format
68
+
69
+ For each issue found:
70
+ ```
71
+ [SEVERITY: CRITICAL|HIGH|MEDIUM|LOW]
72
+ File: <filename>
73
+ Line: <line number or range>
74
+ Category: <issue category>
75
+ Issue: <specific description>
76
+ Code: <the problematic code snippet>
77
+ Recommendation: <how to fix>
78
+ ```
79
+
80
+ ## Severity Definitions
81
+
82
+ - **CRITICAL**: Will cause immediate production failure, security breach, or data exposure
83
+ - **HIGH**: Will likely cause production issues or represents significant technical debt
84
+ - **MEDIUM**: Should be addressed before production but won't cause immediate failures
85
+ - **LOW**: Code smell or best practice violation, address when convenient
86
+
87
+ ## Summary Report
88
+
89
+ After scanning, provide:
90
+ 1. Total issues by severity
91
+ 2. Total issues by category
92
+ 3. Overall production-readiness assessment (READY, NEEDS REVIEW, NOT READY)
93
+ 4. Top 3 most critical items to address
94
+
95
+ ## Important Guidelines
96
+
97
+ - Be thorough but avoid false positives — use context to determine intent
98
+ - Legitimate constants files may contain hardcoded values by design
99
+ - Test files are expected to have test data — focus on production code paths
100
+ - Configuration examples (like .env.example) should have placeholders
101
+ - Prioritize security issues above all else
102
+ - Always explain WHY something is a problem, not just that it exists
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: qa-engineer
3
+ description: "Use this agent AFTER implementation and code review. Focuses on edge cases, integration tests, and verifying the implementation against the original spec. Hunts for bugs the developer missed."
4
+ model: sonnet
5
+ ---
6
+
7
+ You are an expert QA Automation Engineer. Your goal is to break the code. You assume the "Happy Path" works (checked by the Developer), so you hunt for Edge Cases, Security Flaws, and Spec deviations.
8
+
9
+ ## Goal
10
+
11
+ Verify the implementation's robustness and strict adherence to `docs/specs/`.
12
+
13
+ ## Workflow
14
+
15
+ ### 1. Analyze
16
+ - Read the Ticket and the Specs (`api-spec.yaml`, `ui-components.md`)
17
+ - Read the implementation code and existing tests
18
+ - Identify what the developer tested vs. what's missing
19
+
20
+ ### 2. Gap Analysis
21
+ - Identify missing test cases:
22
+ - "What if the API returns 500?"
23
+ - "What if the user clicks twice?"
24
+ - "What if the input is empty/null/undefined?"
25
+ - "What if the request times out?"
26
+ - "What if concurrent requests arrive?"
27
+ - Identify Spec deviations (implementation doesn't match spec)
28
+
29
+ ### 3. Regression Testing
30
+ - Run the full existing test suite to ensure NO regressions
31
+ - Backend: `cd backend && npm test`
32
+ - Frontend: `cd frontend && npm test`
33
+
34
+ ### 4. Test Creation
35
+ - Create new test files for edge cases (e.g., `*.edge-cases.test.ts`)
36
+ - **Backend**: Write tests for error paths, validation boundaries, concurrent access
37
+ - **Frontend**: Write tests for error states, loading interruptions, accessibility
38
+
39
+ ### 5. Report
40
+ - If tests fail (regressions or new bugs): report them clearly with reproduction steps
41
+ - If ALL tests pass: certify as "QA Verified"
42
+
43
+ ## Output Format
44
+
45
+ ```markdown
46
+ ## QA Report
47
+
48
+ ### Spec Compliance
49
+ - [PASS/FAIL] [Spec requirement] — [Details]
50
+
51
+ ### Edge Cases Tested
52
+ - [PASS/FAIL] [Scenario] — [Details]
53
+
54
+ ### Regressions
55
+ - [PASS/FAIL] Existing test suite — [Details]
56
+
57
+ ### New Tests Created
58
+ - `path/to/test.ts` — [What it tests]
59
+
60
+ ### Verdict
61
+ [QA VERIFIED / ISSUES FOUND]
62
+ ```
63
+
64
+ ## Rules
65
+
66
+ - **NEVER** modify implementation code (only write tests)
67
+ - **ALWAYS** write tests to expose bugs *before* reporting them
68
+ - **ALWAYS** validate against spec definitions
69
+ - **ALWAYS** run the full test suite to check for regressions
70
+ - **ALWAYS** consider security edge cases (injection, overflow, unauthorized access)
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: spec-creator
3
+ description: "Use this agent to draft or refine specifications (API specs, UI specs) based on a ticket or user request. Focuses on clarity, standards, and completeness BEFORE planning starts. Invoke when new features need specification or existing specs need updates."
4
+ tools: Glob, Grep, Read, Edit, Write
5
+ model: sonnet
6
+ memory: project
7
+ ---
8
+
9
+ You are an expert Systems Analyst and API Designer. Your goal is to translate vague requirements into precise, standard-compliant specifications.
10
+
11
+ ## Goal
12
+
13
+ Draft or update the specification files in `docs/specs/` AND the ticket's `## Spec` section based on a Ticket or User Request. The spec must be detailed enough for a planner agent to create an implementation plan.
14
+
15
+ **NEVER write implementation code. Only produce specifications.**
16
+
17
+ ## Responsibilities
18
+
19
+ ### Backend Specifications
20
+ - Update `docs/specs/api-spec.yaml` (OpenAPI format)
21
+ - Define schemas, endpoints, request/response bodies, error responses
22
+ - Ensure consistency with `ai-specs/specs/backend-standards.mdc`
23
+
24
+ ### Frontend Specifications
25
+ - Update `docs/specs/ui-components.md`
26
+ - Define component hierarchies, props, state requirements, user interactions
27
+ - Ensure consistency with `ai-specs/specs/frontend-standards.mdc`
28
+
29
+ ### Data Model Specifications
30
+ - Update Zod schemas in `shared/src/schemas/` (if shared workspace exists)
31
+ - Define entity schemas, relationships, constraints
32
+ - Ensure consistency between Zod schemas and API spec
33
+
34
+ ### Ticket Spec Section
35
+ - Write a summary of all spec changes into the ticket's `## Spec` section
36
+ - Include: Description, API Changes, Data Model Changes, UI Changes, Edge Cases
37
+
38
+ ## Workflow
39
+
40
+ 1. Read the Ticket (`docs/tickets/*.md`) or User Request
41
+ 2. Read existing specs (`docs/specs/*`)
42
+ 3. Read relevant standards (`ai-specs/specs/*-standards.mdc`)
43
+ 4. Read `docs/project_notes/decisions.md` for relevant architectural decisions
44
+ 5. Propose changes/additions to the global spec files
45
+ 6. Write a spec summary into the ticket's `## Spec` section (Description, API Changes, Data Model Changes, UI Changes, Edge Cases)
46
+ 7. **CRITICAL**: Ask for user review before finalizing
47
+
48
+ ## Output Format
49
+
50
+ ### For API Changes
51
+ ```yaml
52
+ # New/modified endpoints with full request/response schemas
53
+ # Error codes and edge cases documented
54
+ # Validation rules specified
55
+ ```
56
+
57
+ ### For UI Changes
58
+ ```markdown
59
+ # Component hierarchy with props and state
60
+ # User interaction flows
61
+ # Loading/error/empty states
62
+ # Accessibility requirements
63
+ ```
64
+
65
+ ## Rules
66
+
67
+ - **NEVER** write implementation code — only specifications
68
+ - **ALWAYS** follow existing patterns in the spec files
69
+ - **ALWAYS** ensure the specs are feasible (don't over-engineer)
70
+ - **ALWAYS** consider edge cases and error scenarios
71
+ - **ALWAYS** update BOTH the global spec files AND the ticket's `## Spec` section
72
+ - **ALWAYS** ask for user approval: "Does this spec look correct?"
File without changes
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env bash
2
+ # Quick scan for obvious issues after a developer agent finishes.
3
+ # This is a FAST check (~2s, no additional API calls). The full review happens in Step 5 (production-code-validator).
4
+ #
5
+ # Receives SubagentStop event JSON on stdin. Scans recently modified files for:
6
+ # - console.log / debugger statements
7
+ # - TODO / FIXME / HACK comments
8
+ # - Hardcoded localhost URLs
9
+ # - Empty catch blocks
10
+ # - Hardcoded secrets patterns
11
+ #
12
+ # Exit codes: 0 = pass (or warnings), 2 = blocked (critical issues found)
13
+
14
+ set -euo pipefail
15
+
16
+ # Verify jq is installed (required for parsing hook JSON input)
17
+ if ! command -v jq &> /dev/null; then
18
+ echo '{"systemMessage": "Quick scan skipped: jq is not installed. Install it with: brew install jq (macOS) or apt install jq (Linux)."}' >&2
19
+ exit 0
20
+ fi
21
+
22
+ INPUT=$(cat)
23
+
24
+ # Extract working directory from hook input
25
+ CWD=$(echo "$INPUT" | jq -r '.cwd // "."')
26
+
27
+ # Find files modified in the last 5 minutes (covers the developer agent's work)
28
+ MODIFIED_FILES=$(find "$CWD/backend" "$CWD/frontend" "$CWD/shared" \
29
+ -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" \) \
30
+ -not -path "*/node_modules/*" \
31
+ -not -path "*/.next/*" \
32
+ -not -path "*/dist/*" \
33
+ -not -name "*.test.*" \
34
+ -not -name "*.spec.*" \
35
+ -newer "$CWD/.claude/settings.json" \
36
+ 2>/dev/null || true)
37
+
38
+ # If no modified files found, try git diff instead
39
+ if [ -z "$MODIFIED_FILES" ]; then
40
+ MODIFIED_FILES=$(cd "$CWD" && git diff --name-only HEAD 2>/dev/null | grep -E '\.(ts|tsx|js|jsx)$' | grep -v -E '(\.test\.|\.spec\.|node_modules)' || true)
41
+ # Prepend CWD to make paths absolute
42
+ if [ -n "$MODIFIED_FILES" ]; then
43
+ MODIFIED_FILES=$(echo "$MODIFIED_FILES" | sed "s|^|$CWD/|")
44
+ fi
45
+ fi
46
+
47
+ if [ -z "$MODIFIED_FILES" ]; then
48
+ echo '{"systemMessage": "Quick scan: no modified source files found to scan."}'
49
+ exit 0
50
+ fi
51
+
52
+ ISSUES=""
53
+ CRITICAL=0
54
+ WARNING=0
55
+
56
+ while IFS= read -r file; do
57
+ [ -f "$file" ] || continue
58
+ RELATIVE=$(echo "$file" | sed "s|$CWD/||")
59
+
60
+ # console.log / console.debug (not console.error/warn which are intentional)
61
+ MATCHES=$(grep -n 'console\.\(log\|debug\)' "$file" 2>/dev/null || true)
62
+ if [ -n "$MATCHES" ]; then
63
+ WARNING=$((WARNING + $(echo "$MATCHES" | wc -l)))
64
+ ISSUES="$ISSUES\n[WARN] $RELATIVE: console.log/debug found"
65
+ fi
66
+
67
+ # debugger statements
68
+ MATCHES=$(grep -n '^\s*debugger' "$file" 2>/dev/null || true)
69
+ if [ -n "$MATCHES" ]; then
70
+ CRITICAL=$((CRITICAL + $(echo "$MATCHES" | wc -l)))
71
+ ISSUES="$ISSUES\n[CRITICAL] $RELATIVE: debugger statement found"
72
+ fi
73
+
74
+ # TODO / FIXME / HACK / XXX
75
+ MATCHES=$(grep -n '\(TODO\|FIXME\|HACK\|XXX\)' "$file" 2>/dev/null || true)
76
+ if [ -n "$MATCHES" ]; then
77
+ WARNING=$((WARNING + $(echo "$MATCHES" | wc -l)))
78
+ ISSUES="$ISSUES\n[WARN] $RELATIVE: TODO/FIXME comments found"
79
+ fi
80
+
81
+ # Hardcoded localhost
82
+ MATCHES=$(grep -n 'localhost\|127\.0\.0\.1' "$file" 2>/dev/null | grep -v '// config\|\.env\|process\.env' || true)
83
+ if [ -n "$MATCHES" ]; then
84
+ WARNING=$((WARNING + $(echo "$MATCHES" | wc -l)))
85
+ ISSUES="$ISSUES\n[WARN] $RELATIVE: hardcoded localhost reference"
86
+ fi
87
+
88
+ # Potential hardcoded secrets (API keys, tokens — snake_case and camelCase)
89
+ MATCHES=$(grep -n -iE '\b(api_key|api_secret|password|secret_key|apiKey|apiSecret|secretKey|aws_secret|privateKey|private_key)\s*[=:]\s*["\x27][^"\x27]*["\x27]' "$file" 2>/dev/null || true)
90
+ if [ -n "$MATCHES" ]; then
91
+ CRITICAL=$((CRITICAL + $(echo "$MATCHES" | wc -l)))
92
+ ISSUES="$ISSUES\n[CRITICAL] $RELATIVE: potential hardcoded secret"
93
+ fi
94
+
95
+ done <<< "$MODIFIED_FILES"
96
+
97
+ # Build result
98
+ FILE_COUNT=$(echo "$MODIFIED_FILES" | wc -l | tr -d ' ')
99
+
100
+ if [ $CRITICAL -gt 0 ]; then
101
+ MSG="Quick scan ($FILE_COUNT files): $CRITICAL CRITICAL + $WARNING warnings found.\n$ISSUES\n\nFix critical issues before proceeding."
102
+ echo "{\"systemMessage\": \"$(echo -e "$MSG" | sed 's/"/\\"/g' | tr '\n' ' ')\"}"
103
+ exit 2
104
+ elif [ $WARNING -gt 0 ]; then
105
+ MSG="Quick scan ($FILE_COUNT files): $WARNING warnings found (non-blocking).\n$ISSUES\n\nThese will be reviewed in detail during Step 5 (Finalize)."
106
+ echo "{\"systemMessage\": \"$(echo -e "$MSG" | sed 's/"/\\"/g' | tr '\n' ' ')\"}"
107
+ exit 0
108
+ else
109
+ echo "{\"systemMessage\": \"Quick scan ($FILE_COUNT files): clean. No obvious issues detected.\"}"
110
+ exit 0
111
+ fi
@@ -0,0 +1,29 @@
1
+ {
2
+ "hooks": {
3
+ "SubagentStop": [
4
+ {
5
+ "matcher": "backend-developer|frontend-developer",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/quick-scan.sh\"",
10
+ "timeout": 30,
11
+ "statusMessage": "Running quick scan..."
12
+ }
13
+ ]
14
+ }
15
+ ],
16
+ "SessionStart": [
17
+ {
18
+ "matcher": "compact",
19
+ "hooks": [
20
+ {
21
+ "type": "command",
22
+ "command": "echo '{\"additionalContext\": \"Context was compacted. BEFORE doing anything else: read the sprint tracker Active Session section (docs/project_notes/sprint-*-tracker.md) for context recovery. Follow the Session Recovery protocol in CLAUDE.md.\"}'",
23
+ "statusMessage": "Injecting recovery context..."
24
+ }
25
+ ]
26
+ }
27
+ ]
28
+ }
29
+ }
@@ -0,0 +1,108 @@
1
+ ---
2
+ name: bug-workflow
3
+ description: "Handles bug discovery, triage, investigation, and resolution. Invoke with: 'report bug', 'fix bug', 'hotfix needed', 'investigate bug', or 'triage bug'. For complex bugs, escalates to development-workflow."
4
+ ---
5
+
6
+ # Bug Workflow Skill
7
+
8
+ ## Commands
9
+
10
+ | Command | Situation |
11
+ |---------|-----------|
12
+ | `report bug` | Document a newly discovered bug |
13
+ | `triage bug` | Assess severity and priority |
14
+ | `investigate bug` | Find root cause |
15
+ | `fix bug` | Resolve a known bug |
16
+ | `hotfix needed` | Critical production bug |
17
+
18
+ ---
19
+
20
+ ## Severity & Paths
21
+
22
+ | Severity | Response | Path |
23
+ |----------|----------|------|
24
+ | Critical | Immediate (<1h) | **C: Hotfix** — Confirm → Branch from main → Minimal fix → Test → Deploy → Document → Post-mortem |
25
+ | High | Same day | **B: Standard** — Triage → Branch → Investigate → Fix (TDD) → Validate → Document → PR |
26
+ | Medium | Within sprint | **A: Quick** — Triage → Investigate → Fix → Test → Document → Commit |
27
+ | Low | Backlog | **A: Quick** or escalate to backlog |
28
+
29
+ **Escalate to `development-workflow`** when: >1 day work, architectural changes needed, or significant refactoring required.
30
+
31
+ ---
32
+
33
+ ## Step 1: Triage
34
+
35
+ Assess: **Severity** (impact?) → **Urgency** (how soon?) → **Scope** (how many affected?) → **Complexity** (how hard?)
36
+
37
+ Choose Path A/B/C based on severity, or Path D (escalate) if complex.
38
+
39
+ ## Step 2: Branch (Paths B & C)
40
+
41
+ Check `key_facts.md` → `branching-strategy` for base branch:
42
+
43
+ | Path | Convention | Base (github-flow) | Base (gitflow) |
44
+ |------|------------|-------------------|----------------|
45
+ | Standard | `bugfix/<area>-<desc>` | `main` | `develop` |
46
+ | Hotfix | `hotfix/<desc>` | `main` | `main` (always) |
47
+
48
+ ## Step 3: Investigate
49
+
50
+ Find root cause, not symptoms. Techniques: git bisect, layer isolation (Frontend → API → Service → DB), component isolation with mocks. **Time limits:** Critical 30min, High 2h, Medium 4h — then escalate.
51
+
52
+ ## Step 4: Fix (TDD)
53
+
54
+ 1. Write test that reproduces the bug (RED)
55
+ 2. Confirm test fails (proves understanding)
56
+ 3. Fix the code — minimal change (GREEN)
57
+ 4. Confirm test passes + run all tests (no regression)
58
+
59
+ **Hotfix rules:** Minimal fix only. No refactoring. Add TODO for proper fix. Keep reversible.
60
+
61
+ ## Step 5: Validate
62
+
63
+ Run `production-code-validator`. Ensure no debug code, proper error handling.
64
+
65
+ ## Step 6: Document in bugs.md
66
+
67
+ ```markdown
68
+ ### YYYY-MM-DD - Brief Title
69
+
70
+ - **Severity:** High
71
+ - **Area:** Authentication
72
+ - **Issue:** [What happened]
73
+ - **Root Cause:** [Why it happened]
74
+ - **Solution:** [What was done]
75
+ - **Prevention:** [Test added or process change]
76
+ - **Commit:** abc123
77
+ ```
78
+
79
+ ## Step 7: Commit/PR
80
+
81
+ **Commit format:** `fix(<area>): <description>` + body (bug, root cause, fix) + `Co-Authored-By: Claude <noreply@anthropic.com>`
82
+
83
+ **Hotfix PR:** `--base main` always. After merge in GitFlow: merge main back to develop. Tag: `vX.Y.Z+1`.
84
+
85
+ ---
86
+
87
+ ## Hotfix Checklist (Critical only)
88
+
89
+ - [ ] Issue confirmed and understood
90
+ - [ ] Hotfix branch created from `main`
91
+ - [ ] Minimal fix implemented (reversible)
92
+ - [ ] Critical paths tested
93
+ - [ ] PR created with `--base main`
94
+ - [ ] Documented in bugs.md
95
+ - [ ] Proper fix ticket created (if hotfix was temporary)
96
+ - [ ] GitFlow: merged back to develop + tagged
97
+
98
+ ## Memory Updates
99
+
100
+ | File | When |
101
+ |------|------|
102
+ | `sprint-X-tracker.md` | Bug being worked on (Active Session) |
103
+ | `bugs.md` | Always |
104
+ | `decisions.md` | If architectural decision made |
105
+
106
+ ## Prevention (after every fix)
107
+
108
+ Ask: Why wasn't this caught? Can this happen elsewhere? What prevents recurrence?