sequant 1.0.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.
Files changed (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +237 -0
  3. package/dist/bin/cli.d.ts +8 -0
  4. package/dist/bin/cli.d.ts.map +1 -0
  5. package/dist/bin/cli.js +70 -0
  6. package/dist/bin/cli.js.map +1 -0
  7. package/dist/src/commands/doctor.d.ts +8 -0
  8. package/dist/src/commands/doctor.d.ts.map +1 -0
  9. package/dist/src/commands/doctor.js +171 -0
  10. package/dist/src/commands/doctor.js.map +1 -0
  11. package/dist/src/commands/init.d.ts +11 -0
  12. package/dist/src/commands/init.d.ts.map +1 -0
  13. package/dist/src/commands/init.js +124 -0
  14. package/dist/src/commands/init.js.map +1 -0
  15. package/dist/src/commands/run.d.ts +18 -0
  16. package/dist/src/commands/run.d.ts.map +1 -0
  17. package/dist/src/commands/run.js +229 -0
  18. package/dist/src/commands/run.js.map +1 -0
  19. package/dist/src/commands/status.d.ts +5 -0
  20. package/dist/src/commands/status.d.ts.map +1 -0
  21. package/dist/src/commands/status.js +45 -0
  22. package/dist/src/commands/status.js.map +1 -0
  23. package/dist/src/commands/update.d.ts +10 -0
  24. package/dist/src/commands/update.d.ts.map +1 -0
  25. package/dist/src/commands/update.js +124 -0
  26. package/dist/src/commands/update.js.map +1 -0
  27. package/dist/src/index.d.ts +15 -0
  28. package/dist/src/index.d.ts.map +1 -0
  29. package/dist/src/index.js +13 -0
  30. package/dist/src/index.js.map +1 -0
  31. package/dist/src/lib/fs.d.ts +10 -0
  32. package/dist/src/lib/fs.d.ts.map +1 -0
  33. package/dist/src/lib/fs.js +44 -0
  34. package/dist/src/lib/fs.js.map +1 -0
  35. package/dist/src/lib/manifest.d.ts +14 -0
  36. package/dist/src/lib/manifest.d.ts.map +1 -0
  37. package/dist/src/lib/manifest.js +37 -0
  38. package/dist/src/lib/manifest.js.map +1 -0
  39. package/dist/src/lib/stacks.d.ts +22 -0
  40. package/dist/src/lib/stacks.d.ts.map +1 -0
  41. package/dist/src/lib/stacks.js +131 -0
  42. package/dist/src/lib/stacks.js.map +1 -0
  43. package/dist/src/lib/templates.d.ts +16 -0
  44. package/dist/src/lib/templates.d.ts.map +1 -0
  45. package/dist/src/lib/templates.js +118 -0
  46. package/dist/src/lib/templates.js.map +1 -0
  47. package/dist/src/lib/workflow/cli-args.d.ts +138 -0
  48. package/dist/src/lib/workflow/cli-args.d.ts.map +1 -0
  49. package/dist/src/lib/workflow/cli-args.js +210 -0
  50. package/dist/src/lib/workflow/cli-args.js.map +1 -0
  51. package/dist/src/lib/workflow/execute-issues.d.ts +42 -0
  52. package/dist/src/lib/workflow/execute-issues.d.ts.map +1 -0
  53. package/dist/src/lib/workflow/execute-issues.js +463 -0
  54. package/dist/src/lib/workflow/execute-issues.js.map +1 -0
  55. package/dist/src/lib/workflow/logger.d.ts +168 -0
  56. package/dist/src/lib/workflow/logger.d.ts.map +1 -0
  57. package/dist/src/lib/workflow/logger.js +249 -0
  58. package/dist/src/lib/workflow/logger.js.map +1 -0
  59. package/dist/src/lib/workflow/types.d.ts +89 -0
  60. package/dist/src/lib/workflow/types.d.ts.map +1 -0
  61. package/dist/src/lib/workflow/types.js +23 -0
  62. package/dist/src/lib/workflow/types.js.map +1 -0
  63. package/package.json +69 -0
  64. package/stacks/go.yaml +22 -0
  65. package/stacks/nextjs.yaml +28 -0
  66. package/stacks/python.yaml +24 -0
  67. package/stacks/rust.yaml +23 -0
  68. package/templates/hooks/post-tool.sh +301 -0
  69. package/templates/hooks/pre-tool.sh +350 -0
  70. package/templates/memory/constitution.md +60 -0
  71. package/templates/scripts/cleanup-worktree.sh +78 -0
  72. package/templates/scripts/list-worktrees.sh +50 -0
  73. package/templates/scripts/new-feature.sh +156 -0
  74. package/templates/settings.json +26 -0
  75. package/templates/skills/assess/SKILL.md +428 -0
  76. package/templates/skills/clean/SKILL.md +196 -0
  77. package/templates/skills/docs/SKILL.md +323 -0
  78. package/templates/skills/exec/SKILL.md +426 -0
  79. package/templates/skills/fullsolve/SKILL.md +479 -0
  80. package/templates/skills/loop/SKILL.md +310 -0
  81. package/templates/skills/qa/SKILL.md +261 -0
  82. package/templates/skills/qa/references/code-quality-exemplars.md +112 -0
  83. package/templates/skills/qa/references/code-review-checklist.md +77 -0
  84. package/templates/skills/qa/references/quality-gates.md +95 -0
  85. package/templates/skills/qa/references/testing-requirements.md +109 -0
  86. package/templates/skills/qa/scripts/quality-checks.sh +109 -0
  87. package/templates/skills/reflect/SKILL.md +159 -0
  88. package/templates/skills/reflect/references/documentation-tiers.md +70 -0
  89. package/templates/skills/reflect/references/phase-reflection.md +95 -0
  90. package/templates/skills/reflect/scripts/workflow-queries.ts +165 -0
  91. package/templates/skills/security-review/SKILL.md +344 -0
  92. package/templates/skills/security-review/references/security-checklists.md +377 -0
  93. package/templates/skills/solve/SKILL.md +242 -0
  94. package/templates/skills/spec/SKILL.md +169 -0
  95. package/templates/skills/spec/references/parallel-groups.md +72 -0
  96. package/templates/skills/spec/references/verification-criteria.md +104 -0
  97. package/templates/skills/test/SKILL.md +508 -0
  98. package/templates/skills/testgen/SKILL.md +561 -0
  99. package/templates/skills/verify/SKILL.md +266 -0
@@ -0,0 +1,95 @@
1
+ # Phase-Specific Reflection
2
+
3
+ ## Planning Phase (`/reflect planning`)
4
+
5
+ Focus on planning effectiveness after `/spec`:
6
+
7
+ **Key Questions:**
8
+ - Did context gathering find similar patterns efficiently?
9
+ - Were architectural decisions well-reasoned with clear options?
10
+ - Did Sequential Thinking help or add overhead?
11
+ - Were open questions actionable (question + recommendation + impact)?
12
+ - Was the plan specific enough to implement without re-planning?
13
+
14
+ **Common Friction Points:**
15
+ - Missing component patterns in docs
16
+ - Unclear which dependencies are already installed
17
+ - Database schema not matching assumptions
18
+ - Too many iterations on same decision
19
+
20
+ **Improvement Areas:**
21
+ - Add missing patterns to CLAUDE.md "Finding Similar Components"
22
+ - Update command with better decision frameworks
23
+ - Archive obsolete examples
24
+
25
+ ## Implementation Phase (`/reflect implementation`)
26
+
27
+ Focus on implementation effectiveness after `/exec`:
28
+
29
+ **Key Questions:**
30
+ - Did implementation follow the agreed plan or deviate significantly?
31
+ - How many test failures before success? (Target: <3)
32
+ - Were there repeated context re-reads? (inefficient)
33
+ - Did type errors reveal missing/incorrect types in types/ folder?
34
+ - Were there missing patterns that could be documented?
35
+
36
+ **Common Friction Points:**
37
+ - Plan was too vague, required re-planning during implementation
38
+ - Missing utility functions (kept reimplementing same logic)
39
+ - Unclear testing patterns (what to test, how to structure tests)
40
+ - Type mismatches between database and TypeScript types
41
+
42
+ **Improvement Areas:**
43
+ - Update planning command to require more specificity
44
+ - Extract repeated logic into lib/utils/
45
+ - Document testing patterns in docs/TESTING_PATTERNS.md
46
+ - Run type generation more frequently
47
+
48
+ ## QA Phase (`/reflect qa`)
49
+
50
+ Focus on QA/review effectiveness after `/qa`:
51
+
52
+ **Key Questions:**
53
+ - Did QA catch issues that should have been caught earlier?
54
+ - Were AC clear enough to validate objectively?
55
+ - Did the review identify missing edge cases?
56
+ - Were there repeated issues across similar features? (pattern opportunity)
57
+ - Was the A+ assessment criteria clear and consistent?
58
+
59
+ **Common Friction Points:**
60
+ - AC were too vague to validate objectively
61
+ - Missing test cases for edge cases
62
+ - Inconsistent code style across similar components
63
+ - Performance issues not caught until QA
64
+
65
+ **Improvement Areas:**
66
+ - Update AC templates with more specificity
67
+ - Add edge case checklist to `/qa` command
68
+ - Create style guide for recurring patterns
69
+ - Add performance check reminders
70
+
71
+ ## Good Reflection Examples
72
+
73
+ ### Documentation Improvement
74
+
75
+ > **Friction Point:** Spent 10 minutes searching for how neighborhood extraction works across multiple files.
76
+ >
77
+ > **Root Cause:** Process is documented in docs/AUTO_NEIGHBORHOOD_ENRICHMENT.md (tier 2) but not referenced in CLAUDE.md's discovery pipeline section (tier 1).
78
+ >
79
+ > **Proposal:**
80
+ > - **Type:** Add
81
+ > - **Target:** CLAUDE.md, line 230 (Discovery Methods section)
82
+ > - **Content:** Add one-line reference: "Neighborhoods auto-extracted via ZIP mapping (see docs/AUTO_NEIGHBORHOOD_ENRICHMENT.md)"
83
+ > - **Priority:** Medium
84
+ > - **Risk:** Low (just adding a signpost)
85
+
86
+ ### Documentation Pruning
87
+
88
+ > **Bloat:** CLAUDE.md has 150 lines on Mapbox troubleshooting that solved a one-time issue 6 months ago.
89
+ >
90
+ > **Proposal:**
91
+ > - **Type:** Remove + Archive
92
+ > - **Target:** CLAUDE.md lines 450-600
93
+ > - **Action:** Move to docs/archive/mapbox-troubleshooting-2024.md with note "Archived: Issue resolved in react-map-gl v7.1.0"
94
+ > - **Priority:** High (saves 150 lines in hot path)
95
+ > - **Risk:** Low (still searchable if issue recurs)
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Workflow Analytics SQL Queries
3
+ *
4
+ * Use with Supabase MCP's execute_sql for /reflect workflow analysis.
5
+ * The workflow_runs table stores phase completion data with duration, verdict, and errors.
6
+ */
7
+
8
+ export const WORKFLOW_QUERIES = {
9
+ /**
10
+ * Success rate by phase (last 30 days)
11
+ */
12
+ successRateByPhase: `
13
+ SELECT
14
+ phase,
15
+ COUNT(*) as total_runs,
16
+ COUNT(*) FILTER (WHERE status = 'completed' AND verdict IN ('pass', 'pass_with_notes')) as successful,
17
+ ROUND(COUNT(*) FILTER (WHERE status = 'completed' AND verdict IN ('pass', 'pass_with_notes')) * 100.0 / NULLIF(COUNT(*), 0), 1) as success_rate,
18
+ ROUND(AVG(duration_seconds) FILTER (WHERE status = 'completed'), 0) as avg_duration_sec
19
+ FROM workflow_runs
20
+ WHERE started_at > now() - INTERVAL '30 days'
21
+ GROUP BY phase
22
+ ORDER BY phase;
23
+ `,
24
+
25
+ /**
26
+ * Most common error categories
27
+ */
28
+ errorCategories: `
29
+ SELECT
30
+ error_category,
31
+ COUNT(*) as occurrences,
32
+ ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM workflow_runs WHERE error_category IS NOT NULL), 1) as percentage
33
+ FROM workflow_runs
34
+ WHERE error_category IS NOT NULL
35
+ AND started_at > now() - INTERVAL '30 days'
36
+ GROUP BY error_category
37
+ ORDER BY occurrences DESC
38
+ LIMIT 10;
39
+ `,
40
+
41
+ /**
42
+ * Issues requiring most loop iterations
43
+ */
44
+ highIterationIssues: `
45
+ SELECT
46
+ issue_number,
47
+ COUNT(*) as total_loop_runs,
48
+ MAX(iteration_number) as max_iterations_used,
49
+ COUNT(*) FILTER (WHERE verdict = 'pass') as eventually_passed
50
+ FROM workflow_runs
51
+ WHERE retry_type = 'loop'
52
+ AND started_at > now() - INTERVAL '30 days'
53
+ GROUP BY issue_number
54
+ ORDER BY total_loop_runs DESC
55
+ LIMIT 10;
56
+ `,
57
+
58
+ /**
59
+ * /exec verification failure rate
60
+ */
61
+ execVerificationRate: `
62
+ SELECT
63
+ verification_result,
64
+ COUNT(*) as occurrences,
65
+ ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM workflow_runs WHERE phase = 'exec' AND verification_result IS NOT NULL), 1) as percentage
66
+ FROM workflow_runs
67
+ WHERE phase = 'exec'
68
+ AND verification_result IS NOT NULL
69
+ AND started_at > now() - INTERVAL '30 days'
70
+ GROUP BY verification_result
71
+ ORDER BY occurrences DESC;
72
+ `,
73
+
74
+ /**
75
+ * Average time to completion by issue labels
76
+ */
77
+ durationByLabel: `
78
+ SELECT
79
+ unnest(labels) as label,
80
+ COUNT(*) as issues_with_label,
81
+ ROUND(AVG(duration_seconds) FILTER (WHERE status = 'completed'), 0) as avg_duration_sec
82
+ FROM workflow_runs
83
+ WHERE phase = 'exec'
84
+ AND status = 'completed'
85
+ AND labels IS NOT NULL
86
+ AND started_at > now() - INTERVAL '30 days'
87
+ GROUP BY label
88
+ HAVING COUNT(*) > 2
89
+ ORDER BY avg_duration_sec DESC;
90
+ `,
91
+
92
+ /**
93
+ * Daily workflow volume (trend analysis)
94
+ */
95
+ dailyVolume: `
96
+ SELECT
97
+ DATE(started_at) as date,
98
+ COUNT(*) as total_runs,
99
+ COUNT(*) FILTER (WHERE verdict IN ('pass', 'pass_with_notes')) as passed,
100
+ COUNT(*) FILTER (WHERE verdict = 'fail') as failed
101
+ FROM workflow_runs
102
+ WHERE started_at > now() - INTERVAL '14 days'
103
+ GROUP BY DATE(started_at)
104
+ ORDER BY date DESC;
105
+ `,
106
+ };
107
+
108
+ /**
109
+ * Example usage in /reflect workflow:
110
+ *
111
+ * 1. Run the analysis script (preferred):
112
+ * npx tsx --env-file=.env.local scripts/dev/analyze-workflow-patterns.ts --days 7 --skip-issue-creation
113
+ *
114
+ * 2. Or run queries individually via Supabase MCP:
115
+ * mcp__supabase__execute_sql({ query: WORKFLOW_QUERIES.successRateByPhase })
116
+ */
117
+
118
+ export function formatWorkflowReport(results: {
119
+ successRates: Array<{
120
+ phase: string;
121
+ success_rate: number;
122
+ total_runs: number;
123
+ }>;
124
+ errorCategories: Array<{ error_category: string; occurrences: number }>;
125
+ highIterationIssues: Array<{
126
+ issue_number: number;
127
+ total_loop_runs: number;
128
+ eventually_passed: number;
129
+ }>;
130
+ }): string {
131
+ const lines: string[] = [];
132
+
133
+ lines.push("📊 Workflow Analysis (Last 7 days)");
134
+ lines.push("");
135
+ lines.push("Success Rates:");
136
+
137
+ for (const row of results.successRates) {
138
+ const passCount = Math.round((row.total_runs * row.success_rate) / 100);
139
+ lines.push(
140
+ ` /${row.phase}: ${row.success_rate}% (${passCount}/${row.total_runs})`,
141
+ );
142
+ }
143
+
144
+ lines.push("");
145
+ lines.push("Top Failure Categories:");
146
+
147
+ for (let i = 0; i < Math.min(results.errorCategories.length, 5); i++) {
148
+ const row = results.errorCategories[i];
149
+ lines.push(
150
+ ` ${i + 1}. ${row.error_category} (${row.occurrences} occurrences)`,
151
+ );
152
+ }
153
+
154
+ lines.push("");
155
+ lines.push("Issues Requiring Most Retries:");
156
+
157
+ for (const row of results.highIterationIssues.slice(0, 5)) {
158
+ const status = row.eventually_passed > 0 ? "passed" : "failed";
159
+ lines.push(
160
+ ` #${row.issue_number} - ${row.total_loop_runs} iterations (${status})`,
161
+ );
162
+ }
163
+
164
+ return lines.join("\n");
165
+ }
@@ -0,0 +1,344 @@
1
+ ---
2
+ name: security-review
3
+ description: "Deep security analysis for sensitive features (auth, payments, admin, API routes, file operations)."
4
+ license: MIT
5
+ metadata:
6
+ author: sequant
7
+ version: "1.0"
8
+ allowed-tools:
9
+ - Read
10
+ - Glob
11
+ - Grep
12
+ - Task
13
+ - Bash(git diff:*)
14
+ - Bash(git status:*)
15
+ - Bash(git log:*)
16
+ - Bash(npm test:*)
17
+ - Bash(gh issue view:*)
18
+ - Bash(gh issue comment:*)
19
+ ---
20
+
21
+ # Security Review Command
22
+
23
+ You are the Security Review Agent for the current repository.
24
+
25
+ ## Purpose
26
+
27
+ When invoked as `/security-review`, perform a comprehensive security analysis focused on the specific security domain of the feature being implemented.
28
+
29
+ ## When to Use
30
+
31
+ | Feature Type | Use /security-review? | Focus Areas |
32
+ |-------------|----------------------|-------------|
33
+ | Auth flows | Yes | Session handling, token security, password hashing |
34
+ | Payment | Yes | PCI compliance, data handling, error messages |
35
+ | Admin features | Yes | Privilege escalation, IDOR, access control |
36
+ | API routes (user data) | Yes | Input validation, auth checks, rate limiting |
37
+ | File operations | Yes | Path traversal, file type validation, size limits |
38
+ | UI-only changes | No | Use /qa security checks |
39
+ | Content updates | No | No security surface |
40
+
41
+ **For lightweight security checks on every issue, use `/qa` instead.**
42
+
43
+ ## Behavior
44
+
45
+ Invocation:
46
+
47
+ - `/security-review 123`:
48
+ - Treat `123` as the GitHub issue number.
49
+ - Analyze the feature being implemented for that issue.
50
+ - `/security-review --domain auth`:
51
+ - Perform review focused on authentication domain.
52
+ - `/security-review --domain api`:
53
+ - Perform review focused on API security domain.
54
+ - `/security-review --domain admin`:
55
+ - Perform review focused on admin/authorization domain.
56
+
57
+ ## Process
58
+
59
+ ### 1. Identify Security Domain
60
+
61
+ Analyze the feature being implemented to determine which security domain(s) apply:
62
+
63
+ **Auto-detection signals:**
64
+ - **Authentication:** Issue mentions "login", "password", "session", "token", "auth", "logout"
65
+ - **Authorization:** Files in `app/admin/`, mentions "role", "permission", "access control"
66
+ - **API Security:** Files in `app/api/`, mentions "endpoint", "request", "validation"
67
+ - **Data Protection:** Mentions "PII", "sensitive", "encrypt", "GDPR", "privacy"
68
+ - **Infrastructure:** Mentions "env", "secret", "config", "headers", "CSP"
69
+ - **File Operations:** Mentions "upload", "download", "file", "path"
70
+
71
+ ### 2. Gather Context
72
+
73
+ - Read the GitHub issue for feature details
74
+ - Identify files changed (worktree or PR diff)
75
+ - Determine which security checklists apply
76
+
77
+ ### 3. Apply Domain-Specific Checklists
78
+
79
+ Run through the relevant security checklists, marking each item as:
80
+ - Passed (verified secure)
81
+ - Failed (security issue found)
82
+ - Needs Manual Review (cannot verify automatically)
83
+ - N/A (not applicable to this feature)
84
+
85
+ See [references/security-checklists.md](references/security-checklists.md) for detailed checklist by domain.
86
+
87
+ ## Security Checklists by Domain
88
+
89
+ ### Authentication (8 items)
90
+
91
+ | # | Check | How to Verify |
92
+ |---|-------|---------------|
93
+ | AUTH-1 | Password hashing uses bcrypt/argon2 with appropriate cost | Look for password handling in auth code |
94
+ | AUTH-2 | Session tokens are cryptographically random | Check token generation method |
95
+ | AUTH-3 | Sessions expire appropriately | Check session TTL configuration |
96
+ | AUTH-4 | Logout invalidates session server-side | Verify session deletion on logout |
97
+ | AUTH-5 | Password reset tokens are single-use and expire | Check reset token handling |
98
+ | AUTH-6 | Rate limiting on login attempts | Look for rate limiter on auth endpoints |
99
+ | AUTH-7 | No timing attacks in password comparison | Check for constant-time comparison |
100
+ | AUTH-8 | MFA implementation (if applicable) | Review MFA flow if present |
101
+
102
+ ### Authorization (6 items)
103
+
104
+ | # | Check | How to Verify |
105
+ |---|-------|---------------|
106
+ | AUTHZ-1 | Every endpoint checks authentication | Review middleware/guards on routes |
107
+ | AUTHZ-2 | Role-based access control properly enforced | Check RBAC implementation |
108
+ | AUTHZ-3 | No IDOR vulnerabilities (direct object references) | Review ID handling in queries |
109
+ | AUTHZ-4 | Horizontal privilege escalation prevented | Check user scoping in queries |
110
+ | AUTHZ-5 | Vertical privilege escalation prevented | Check role checks before actions |
111
+ | AUTHZ-6 | Admin actions logged for audit | Verify audit logging exists |
112
+
113
+ ### API Security (7 items)
114
+
115
+ | # | Check | How to Verify |
116
+ |---|-------|---------------|
117
+ | API-1 | Input validation on all parameters | Check validation schemas (Zod, etc.) |
118
+ | API-2 | Output encoding to prevent XSS | Review response sanitization |
119
+ | API-3 | SQL injection prevention (parameterized queries) | Check for raw SQL, string concat |
120
+ | API-4 | Rate limiting configured | Look for rate limiter middleware |
121
+ | API-5 | CORS properly configured | Check CORS headers/config |
122
+ | API-6 | Error messages don't leak sensitive info | Review error responses |
123
+ | API-7 | File uploads validated (type, size, name) | Check upload handling |
124
+
125
+ ### Data Protection (5 items)
126
+
127
+ | # | Check | How to Verify |
128
+ |---|-------|---------------|
129
+ | DATA-1 | Sensitive data encrypted at rest | Check database encryption settings |
130
+ | DATA-2 | Sensitive data encrypted in transit | Verify HTTPS enforcement |
131
+ | DATA-3 | PII handling compliant with privacy policy | Review data collection/storage |
132
+ | DATA-4 | Logs don't contain sensitive data | Check logging statements |
133
+ | DATA-5 | Database queries don't expose unauthorized data | Review RLS policies, query filters |
134
+
135
+ ### Infrastructure (5 items)
136
+
137
+ | # | Check | How to Verify |
138
+ |---|-------|---------------|
139
+ | INFRA-1 | Environment variables properly protected | No hardcoded secrets in code |
140
+ | INFRA-2 | No hardcoded secrets | grep for API keys, passwords |
141
+ | INFRA-3 | Dependencies up to date | Check for known vulnerabilities |
142
+ | INFRA-4 | CSP headers configured | Review security headers |
143
+ | INFRA-5 | Security headers set (HSTS, X-Frame-Options, etc.) | Check Next.js config/middleware |
144
+
145
+ ## Threat Modeling
146
+
147
+ For each security review, perform basic threat modeling:
148
+
149
+ ### 1. Identify Threat Actors
150
+
151
+ | Actor Type | Description | Relevance |
152
+ |------------|-------------|-----------|
153
+ | Anonymous User | Unauthenticated visitor | Can they access protected resources? |
154
+ | Authenticated User | Logged in with basic role | Can they escalate privileges? |
155
+ | Admin User | Elevated privileges | Can they abuse their access? |
156
+ | Malicious Insider | Has valid credentials | Can they exfiltrate data? |
157
+ | External Attacker | No credentials, probing system | What attack surface is exposed? |
158
+
159
+ ### 2. Map Attack Surface
160
+
161
+ For the feature being reviewed, identify:
162
+ - **Inputs:** What data does the feature accept? (form fields, URL params, headers)
163
+ - **Outputs:** What data does the feature expose? (API responses, page content, logs)
164
+ - **State Changes:** What does the feature modify? (database, files, sessions)
165
+ - **External Dependencies:** What external systems does it interact with? (APIs, databases)
166
+
167
+ ### 3. Document Attack Vectors
168
+
169
+ For each identified risk, document:
170
+ - **Attack Vector:** How could this be exploited?
171
+ - **Impact:** What's the worst case scenario?
172
+ - **Likelihood:** How likely is this attack?
173
+ - **Mitigation:** What controls are in place?
174
+
175
+ ## Report Format
176
+
177
+ Generate a security review report in this format:
178
+
179
+ ```markdown
180
+ ## Security Review: [Feature Name]
181
+
182
+ **Issue:** #[number]
183
+ **Domain(s):** [Authentication | Authorization | API | Data | Infrastructure]
184
+ **Risk Level:** [Critical | High | Medium | Low]
185
+ **Files Reviewed:** [count]
186
+
187
+ ---
188
+
189
+ ### Threat Model Summary
190
+
191
+ **Attack Surface:**
192
+ - [List of inputs, outputs, state changes]
193
+
194
+ **Key Threat Actors:**
195
+ - [Relevant actors for this feature]
196
+
197
+ **Primary Attack Vectors:**
198
+ - [Top 3 attack vectors identified]
199
+
200
+ ---
201
+
202
+ ### Findings
203
+
204
+ #### Critical
205
+ _Issues requiring immediate attention before merge._
206
+
207
+ 1. **[Finding Title]** (`file:line`)
208
+ - **Issue:** [Description]
209
+ - **Impact:** [Potential damage]
210
+ - **Remediation:** [How to fix]
211
+
212
+ #### High
213
+ _Significant security concerns._
214
+
215
+ 1. **[Finding Title]** (`file:line`)
216
+ - **Issue:** [Description]
217
+ - **Remediation:** [How to fix]
218
+
219
+ #### Medium
220
+ _Issues that should be addressed._
221
+
222
+ 1. **[Finding Title]** (`file:line`)
223
+ - **Issue:** [Description]
224
+ - **Remediation:** [How to fix]
225
+
226
+ #### Low / Informational
227
+ _Best practice recommendations._
228
+
229
+ 1. **[Finding Title]**
230
+ - **Recommendation:** [Suggested improvement]
231
+
232
+ ---
233
+
234
+ ### Checklist Status
235
+
236
+ | Domain | Passed | Failed | Manual | Total |
237
+ |--------|--------|--------|--------|-------|
238
+ | Authentication | X | X | X | 8 |
239
+ | Authorization | X | X | X | 6 |
240
+ | API Security | X | X | X | 7 |
241
+ | Data Protection | X | X | X | 5 |
242
+ | Infrastructure | X | X | X | 5 |
243
+
244
+ ---
245
+
246
+ ### Verdict
247
+
248
+ **[SECURE | WARNINGS | ISSUES_FOUND]**
249
+
250
+ [Summary of overall security posture and recommended actions]
251
+ ```
252
+
253
+ ## Verdicts
254
+
255
+ | Verdict | Meaning | Action |
256
+ |---------|---------|--------|
257
+ | `SECURE` | No security issues found | Safe to proceed |
258
+ | `WARNINGS` | Minor issues or items needing manual review | Review warnings, may proceed |
259
+ | `ISSUES_FOUND` | Security issues requiring remediation | Fix before merge |
260
+
261
+ ## Integration with Workflow
262
+
263
+ ### Standalone Usage (Manual)
264
+
265
+ ```bash
266
+ /security-review 493
267
+ /security-review --domain auth
268
+ ```
269
+
270
+ ### As Part of Workflow
271
+
272
+ When working on security-sensitive issues:
273
+
274
+ ```
275
+ /spec 493 # Plan implementation
276
+ /exec 493 # Implement feature
277
+ /security-review 493 # Deep security analysis
278
+ /qa 493 # Final code review
279
+ ```
280
+
281
+ ### Logging to workflow_runs
282
+
283
+ After completing review, log results:
284
+ - **Phase:** `security`
285
+ - **Verdict:** Maps to existing verdict types:
286
+ - `SECURE` → `pass`
287
+ - `WARNINGS` → `pass_with_notes`
288
+ - `ISSUES_FOUND` → `fail`
289
+ - **Output Summary:** Findings count by severity
290
+
291
+ ## Post Review: GitHub Issue Update
292
+
293
+ After completing the security review, post results to the GitHub issue:
294
+
295
+ ```bash
296
+ gh issue comment <issue-number> --body "$(cat <<'EOF'
297
+ ## Security Review Complete
298
+
299
+ [Include full report from above]
300
+
301
+ ---
302
+ Generated with [Claude Code](https://claude.com/claude-code)
303
+ EOF
304
+ )"
305
+ ```
306
+
307
+ ## Examples
308
+
309
+ ### Example 1: Admin Feature Review
310
+
311
+ ```bash
312
+ /security-review 180
313
+ ```
314
+
315
+ **Detection:** Files in `app/admin/`, labels include "admin"
316
+ **Domains:** Authorization, API Security
317
+ **Focus:**
318
+ - AUTHZ-1: Check admin middleware enforces authentication
319
+ - AUTHZ-3: Check for IDOR in city configuration
320
+ - API-6: Verify error messages don't leak city data
321
+
322
+ ### Example 2: API Route Review
323
+
324
+ ```bash
325
+ /security-review --domain api
326
+ ```
327
+
328
+ **Focus:** API Security checklist (all 7 items)
329
+ **Additional:**
330
+ - Review request validation schemas
331
+ - Check response sanitization
332
+ - Verify rate limiting configuration
333
+
334
+ ### Example 3: Auth Flow Review
335
+
336
+ ```bash
337
+ /security-review --domain auth
338
+ ```
339
+
340
+ **Focus:** Authentication checklist (all 8 items)
341
+ **Additional:**
342
+ - Trace session lifecycle
343
+ - Review token handling
344
+ - Check for timing vulnerabilities