@qball-inc/the-bulwark 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.
- package/.claude-plugin/plugin.json +43 -0
- package/agents/bulwark-fix-validator.md +633 -0
- package/agents/bulwark-implementer.md +391 -0
- package/agents/bulwark-issue-analyzer.md +308 -0
- package/agents/bulwark-standards-reviewer.md +221 -0
- package/agents/plan-creation-architect.md +323 -0
- package/agents/plan-creation-eng-lead.md +352 -0
- package/agents/plan-creation-po.md +300 -0
- package/agents/plan-creation-qa-critic.md +334 -0
- package/agents/product-ideation-competitive-analyzer.md +298 -0
- package/agents/product-ideation-idea-validator.md +268 -0
- package/agents/product-ideation-market-researcher.md +292 -0
- package/agents/product-ideation-pattern-documenter.md +308 -0
- package/agents/product-ideation-segment-analyzer.md +303 -0
- package/agents/product-ideation-strategist.md +259 -0
- package/agents/statusline-setup.md +97 -0
- package/hooks/hooks.json +59 -0
- package/package.json +45 -0
- package/scripts/hooks/cleanup-stale.sh +13 -0
- package/scripts/hooks/enforce-quality.sh +166 -0
- package/scripts/hooks/implementer-quality.sh +256 -0
- package/scripts/hooks/inject-protocol.sh +52 -0
- package/scripts/hooks/suggest-pipeline.sh +175 -0
- package/scripts/hooks/track-pipeline-start.sh +37 -0
- package/scripts/hooks/track-pipeline-stop.sh +52 -0
- package/scripts/init-rules.sh +35 -0
- package/scripts/init.sh +151 -0
- package/skills/anthropic-validator/SKILL.md +607 -0
- package/skills/anthropic-validator/references/agents-checklist.md +131 -0
- package/skills/anthropic-validator/references/commands-checklist.md +102 -0
- package/skills/anthropic-validator/references/hooks-checklist.md +151 -0
- package/skills/anthropic-validator/references/mcp-checklist.md +136 -0
- package/skills/anthropic-validator/references/plugins-checklist.md +148 -0
- package/skills/anthropic-validator/references/skills-checklist.md +85 -0
- package/skills/assertion-patterns/SKILL.md +296 -0
- package/skills/bug-magnet-data/SKILL.md +284 -0
- package/skills/bug-magnet-data/context/cli-args.md +91 -0
- package/skills/bug-magnet-data/context/db-query.md +104 -0
- package/skills/bug-magnet-data/context/file-contents.md +103 -0
- package/skills/bug-magnet-data/context/http-body.md +91 -0
- package/skills/bug-magnet-data/context/process-spawn.md +123 -0
- package/skills/bug-magnet-data/data/booleans/boundaries.yaml +143 -0
- package/skills/bug-magnet-data/data/collections/arrays.yaml +114 -0
- package/skills/bug-magnet-data/data/collections/objects.yaml +123 -0
- package/skills/bug-magnet-data/data/concurrency/race-conditions.yaml +118 -0
- package/skills/bug-magnet-data/data/concurrency/state-machines.yaml +115 -0
- package/skills/bug-magnet-data/data/dates/boundaries.yaml +137 -0
- package/skills/bug-magnet-data/data/dates/invalid.yaml +132 -0
- package/skills/bug-magnet-data/data/dates/timezone.yaml +118 -0
- package/skills/bug-magnet-data/data/encoding/charset.yaml +79 -0
- package/skills/bug-magnet-data/data/encoding/normalization.yaml +105 -0
- package/skills/bug-magnet-data/data/formats/email.yaml +154 -0
- package/skills/bug-magnet-data/data/formats/json.yaml +187 -0
- package/skills/bug-magnet-data/data/formats/url.yaml +165 -0
- package/skills/bug-magnet-data/data/language-specific/javascript.yaml +182 -0
- package/skills/bug-magnet-data/data/language-specific/python.yaml +174 -0
- package/skills/bug-magnet-data/data/language-specific/rust.yaml +148 -0
- package/skills/bug-magnet-data/data/numbers/boundaries.yaml +161 -0
- package/skills/bug-magnet-data/data/numbers/precision.yaml +89 -0
- package/skills/bug-magnet-data/data/numbers/special.yaml +69 -0
- package/skills/bug-magnet-data/data/strings/boundaries.yaml +109 -0
- package/skills/bug-magnet-data/data/strings/injection.yaml +208 -0
- package/skills/bug-magnet-data/data/strings/special-chars.yaml +190 -0
- package/skills/bug-magnet-data/data/strings/unicode.yaml +139 -0
- package/skills/bug-magnet-data/references/external-lists.md +115 -0
- package/skills/bulwark-brainstorm/SKILL.md +563 -0
- package/skills/bulwark-brainstorm/references/at-teammate-prompts.md +60 -0
- package/skills/bulwark-brainstorm/references/role-critical-analyst.md +78 -0
- package/skills/bulwark-brainstorm/references/role-development-lead.md +66 -0
- package/skills/bulwark-brainstorm/references/role-product-delivery-lead.md +79 -0
- package/skills/bulwark-brainstorm/references/role-product-manager.md +62 -0
- package/skills/bulwark-brainstorm/references/role-project-sme.md +59 -0
- package/skills/bulwark-brainstorm/references/role-technical-architect.md +66 -0
- package/skills/bulwark-research/SKILL.md +298 -0
- package/skills/bulwark-research/references/viewpoint-contrarian.md +63 -0
- package/skills/bulwark-research/references/viewpoint-direct-investigation.md +62 -0
- package/skills/bulwark-research/references/viewpoint-first-principles.md +65 -0
- package/skills/bulwark-research/references/viewpoint-practitioner.md +62 -0
- package/skills/bulwark-research/references/viewpoint-prior-art.md +66 -0
- package/skills/bulwark-scaffold/SKILL.md +330 -0
- package/skills/bulwark-statusline/SKILL.md +161 -0
- package/skills/bulwark-statusline/scripts/statusline.sh +144 -0
- package/skills/bulwark-verify/SKILL.md +519 -0
- package/skills/code-review/SKILL.md +428 -0
- package/skills/code-review/examples/anti-patterns/linting.ts +181 -0
- package/skills/code-review/examples/anti-patterns/security.ts +91 -0
- package/skills/code-review/examples/anti-patterns/standards.ts +195 -0
- package/skills/code-review/examples/anti-patterns/type-safety.ts +108 -0
- package/skills/code-review/examples/recommended/linting.ts +195 -0
- package/skills/code-review/examples/recommended/security.ts +154 -0
- package/skills/code-review/examples/recommended/standards.ts +231 -0
- package/skills/code-review/examples/recommended/type-safety.ts +181 -0
- package/skills/code-review/frameworks/angular.md +218 -0
- package/skills/code-review/frameworks/django.md +235 -0
- package/skills/code-review/frameworks/express.md +207 -0
- package/skills/code-review/frameworks/flask.md +298 -0
- package/skills/code-review/frameworks/generic.md +146 -0
- package/skills/code-review/frameworks/react.md +152 -0
- package/skills/code-review/frameworks/vue.md +244 -0
- package/skills/code-review/references/linting-patterns.md +221 -0
- package/skills/code-review/references/security-patterns.md +125 -0
- package/skills/code-review/references/standards-patterns.md +246 -0
- package/skills/code-review/references/type-safety-patterns.md +130 -0
- package/skills/component-patterns/SKILL.md +131 -0
- package/skills/component-patterns/references/pattern-cli-command.md +118 -0
- package/skills/component-patterns/references/pattern-database.md +166 -0
- package/skills/component-patterns/references/pattern-external-api.md +139 -0
- package/skills/component-patterns/references/pattern-file-parser.md +168 -0
- package/skills/component-patterns/references/pattern-http-server.md +162 -0
- package/skills/component-patterns/references/pattern-process-spawner.md +133 -0
- package/skills/continuous-feedback/SKILL.md +327 -0
- package/skills/continuous-feedback/references/collect-instructions.md +81 -0
- package/skills/continuous-feedback/references/specialize-code-review.md +82 -0
- package/skills/continuous-feedback/references/specialize-general.md +98 -0
- package/skills/continuous-feedback/references/specialize-test-audit.md +81 -0
- package/skills/create-skill/SKILL.md +359 -0
- package/skills/create-skill/references/agent-conventions.md +194 -0
- package/skills/create-skill/references/agent-template.md +195 -0
- package/skills/create-skill/references/content-guidance.md +291 -0
- package/skills/create-skill/references/decision-framework.md +124 -0
- package/skills/create-skill/references/template-pipeline.md +217 -0
- package/skills/create-skill/references/template-reference-heavy.md +111 -0
- package/skills/create-skill/references/template-research.md +210 -0
- package/skills/create-skill/references/template-script-driven.md +172 -0
- package/skills/create-skill/references/template-simple.md +80 -0
- package/skills/create-subagent/SKILL.md +353 -0
- package/skills/create-subagent/references/agent-conventions.md +268 -0
- package/skills/create-subagent/references/content-guidance.md +232 -0
- package/skills/create-subagent/references/decision-framework.md +134 -0
- package/skills/create-subagent/references/template-single-agent.md +192 -0
- package/skills/fix-bug/SKILL.md +241 -0
- package/skills/governance-protocol/SKILL.md +116 -0
- package/skills/init/SKILL.md +341 -0
- package/skills/issue-debugging/SKILL.md +385 -0
- package/skills/issue-debugging/references/anti-patterns.md +245 -0
- package/skills/issue-debugging/references/debug-report-schema.md +227 -0
- package/skills/mock-detection/SKILL.md +511 -0
- package/skills/mock-detection/references/false-positive-prevention.md +402 -0
- package/skills/mock-detection/references/stub-patterns.md +236 -0
- package/skills/pipeline-templates/SKILL.md +215 -0
- package/skills/pipeline-templates/references/code-change-workflow.md +277 -0
- package/skills/pipeline-templates/references/code-review.md +336 -0
- package/skills/pipeline-templates/references/fix-validation.md +421 -0
- package/skills/pipeline-templates/references/new-feature.md +335 -0
- package/skills/pipeline-templates/references/research-brainstorm.md +161 -0
- package/skills/pipeline-templates/references/research-planning.md +257 -0
- package/skills/pipeline-templates/references/test-audit.md +389 -0
- package/skills/pipeline-templates/references/test-execution-fix.md +238 -0
- package/skills/plan-creation/SKILL.md +497 -0
- package/skills/product-ideation/SKILL.md +372 -0
- package/skills/product-ideation/references/analysis-frameworks.md +161 -0
- package/skills/session-handoff/SKILL.md +139 -0
- package/skills/session-handoff/references/examples.md +223 -0
- package/skills/setup-lsp/SKILL.md +312 -0
- package/skills/setup-lsp/references/server-registry.md +85 -0
- package/skills/setup-lsp/references/troubleshooting.md +135 -0
- package/skills/subagent-output-templating/SKILL.md +415 -0
- package/skills/subagent-output-templating/references/examples.md +440 -0
- package/skills/subagent-prompting/SKILL.md +364 -0
- package/skills/subagent-prompting/references/examples.md +342 -0
- package/skills/test-audit/SKILL.md +531 -0
- package/skills/test-audit/references/known-limitations.md +41 -0
- package/skills/test-audit/references/priority-classification.md +30 -0
- package/skills/test-audit/references/prompts/deep-mode-detection.md +83 -0
- package/skills/test-audit/references/prompts/synthesis.md +57 -0
- package/skills/test-audit/references/rewrite-instructions.md +46 -0
- package/skills/test-audit/references/schemas/audit-output.yaml +100 -0
- package/skills/test-audit/references/schemas/diagnostic-output.yaml +49 -0
- package/skills/test-audit/scripts/data-flow-analyzer.ts +509 -0
- package/skills/test-audit/scripts/integration-mock-detector.ts +462 -0
- package/skills/test-audit/scripts/package.json +20 -0
- package/skills/test-audit/scripts/skip-detector.ts +211 -0
- package/skills/test-audit/scripts/verification-counter.ts +295 -0
- package/skills/test-classification/SKILL.md +310 -0
- package/skills/test-fixture-creation/SKILL.md +295 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-review
|
|
3
|
+
description: Comprehensive code review with distinct aspect based sections. Use when reviewing code, checking for security issues, finding type safety problems, auditing code quality, or when user asks to review code, PRs or changes. Three-phase workflow runs static tools, LLM judgment, and writes diagnostic log.
|
|
4
|
+
user-invocable: true
|
|
5
|
+
agent: sonnet
|
|
6
|
+
skills:
|
|
7
|
+
- subagent-prompting
|
|
8
|
+
- subagent-output-templating
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Code Review
|
|
12
|
+
|
|
13
|
+
Comprehensive code review with four independently-referenceable sections. Runs static tools first (fail fast), then applies LLM judgment for patterns tools cannot catch.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## When to Use This Skill
|
|
18
|
+
|
|
19
|
+
**Load this skill when the user request matches ANY of these patterns:**
|
|
20
|
+
|
|
21
|
+
| Trigger Pattern | Example User Request |
|
|
22
|
+
|-----------------|---------------------|
|
|
23
|
+
| Code review | "Review this code", "Check my changes", "Code review for PR" |
|
|
24
|
+
| Security review | "Check for security issues", "Find vulnerabilities", "OWASP audit" |
|
|
25
|
+
| Type safety check | "Find any usage", "Check type safety", "Null handling issues?" |
|
|
26
|
+
| Quality check | "Is this code clean?", "Check code quality", "Standards compliance" |
|
|
27
|
+
|
|
28
|
+
**DO NOT use for:**
|
|
29
|
+
- Running tests (use `just test`)
|
|
30
|
+
- Auditing test quality (use `test-audit` skill)
|
|
31
|
+
- Debugging issues (use `issue-debugging` skill)
|
|
32
|
+
- Performance profiling (requires runtime analysis)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Dependencies
|
|
37
|
+
|
|
38
|
+
This skill references supporting files. Understanding what's required vs optional ensures consistent execution.
|
|
39
|
+
|
|
40
|
+
| Category | Files | Requirement | When to Load |
|
|
41
|
+
|----------|-------|-------------|--------------|
|
|
42
|
+
| **Pattern references** | `references/{section}-patterns.md` | **REQUIRED** | Always load for each enabled section |
|
|
43
|
+
| **Framework patterns** | `frameworks/{detected}.md` | **CONDITIONALLY REQUIRED** | If framework detected → MUST load; if not detected → skip |
|
|
44
|
+
| **Examples** | `examples/anti-patterns/*.ts`, `examples/recommended/*.ts` | OPTIONAL | For calibration on ambiguous cases; kept for model portability |
|
|
45
|
+
|
|
46
|
+
**Fallback behavior:**
|
|
47
|
+
- If framework detected → Loading `frameworks/{name}.md` is REQUIRED
|
|
48
|
+
- If no framework detected → Skip framework patterns entirely (do not load `generic.md`)
|
|
49
|
+
- If a referenced file is missing → Note in diagnostic log, continue with available patterns
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
/code-review [path] [flags]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Arguments:**
|
|
60
|
+
- `path` - File or directory to review (default: files in recent context)
|
|
61
|
+
|
|
62
|
+
**Flags:**
|
|
63
|
+
- `--quick` - Tiered review by change size (Security-only for <50 lines)
|
|
64
|
+
- `--framework=<name>` - Override auto-detected framework (react|express|django|generic)
|
|
65
|
+
- `--include-git-context` - Include git history for complexity findings
|
|
66
|
+
- `--section=<name>` - Run single section only (security|type-safety|linting|standards)
|
|
67
|
+
|
|
68
|
+
**Examples:**
|
|
69
|
+
- `/code-review src/auth/` - Full review of auth directory
|
|
70
|
+
- `/code-review src/api.ts --quick` - Quick review (tiered by lines)
|
|
71
|
+
- `/code-review src/ --section=security` - Security section only
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Three-Phase Workflow
|
|
76
|
+
|
|
77
|
+
**CRITICAL**: All three phases are REQUIRED. Do not skip any phase.
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
Phase 1: Static Analysis (Deterministic)
|
|
81
|
+
├── Run: just typecheck → capture output
|
|
82
|
+
├── Run: just lint → capture output
|
|
83
|
+
└── If failures: STOP, return to user (fail fast)
|
|
84
|
+
|
|
85
|
+
Phase 2: LLM Review (Judgment-Based)
|
|
86
|
+
├── Load references/{section}-patterns.md for each enabled section (REQUIRED)
|
|
87
|
+
├── If framework detected: Load frameworks/{detected}.md (REQUIRED)
|
|
88
|
+
├── If no framework detected: Skip framework patterns
|
|
89
|
+
├── Apply each enabled section using loaded patterns
|
|
90
|
+
└── Output findings to user
|
|
91
|
+
|
|
92
|
+
Phase 3: Write Diagnostic Log (REQUIRED)
|
|
93
|
+
├── Write to: logs/diagnostics/code-review-{timestamp}.yaml
|
|
94
|
+
├── Include: invocation details, static analysis results, findings summary
|
|
95
|
+
└── This phase is MANDATORY - do not return to user without completing it
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Why Phase 1 First:**
|
|
99
|
+
- Saves tokens (don't analyze code that won't compile)
|
|
100
|
+
- Eliminates false positives (LLM doesn't rediscover tool findings)
|
|
101
|
+
- Fail fast on obvious issues
|
|
102
|
+
|
|
103
|
+
**Why Phase 3 is Required:**
|
|
104
|
+
- Enables pipeline orchestration to collect sub-agent outputs
|
|
105
|
+
- Provides observability for multi-agent workflows
|
|
106
|
+
- Creates audit trail for code review decisions
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Sections
|
|
111
|
+
|
|
112
|
+
Each section is independently referenceable by pipeline agents via `--section=<name>`.
|
|
113
|
+
|
|
114
|
+
### Quick Reference
|
|
115
|
+
|
|
116
|
+
| Section | Boundary | Key Patterns | Severity Range |
|
|
117
|
+
|---------|----------|--------------|----------------|
|
|
118
|
+
| Security | Threats & exploits | OWASP Top 10, injection, auth | Critical-Important |
|
|
119
|
+
| Type Safety | Type system holes | `any`, null, unsafe assertions | Critical-Important |
|
|
120
|
+
| Linting | Style requiring judgment | Complexity, naming, structure | Important-Suggestion |
|
|
121
|
+
| Coding Standards | Conventions & architecture | Patterns, documentation | Important-Suggestion |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Security
|
|
126
|
+
|
|
127
|
+
### Purpose
|
|
128
|
+
Identify security vulnerabilities that static analysis cannot catch.
|
|
129
|
+
|
|
130
|
+
### Boundary
|
|
131
|
+
Threats and exploits: authentication/authorization logic, injection patterns, secrets exposure, CSRF, CORS misconfigurations.
|
|
132
|
+
|
|
133
|
+
**Does NOT cover:** Type errors (→ Type Safety), code style (→ Linting).
|
|
134
|
+
|
|
135
|
+
### Prerequisites
|
|
136
|
+
- `just typecheck` passed
|
|
137
|
+
- `just lint` passed
|
|
138
|
+
|
|
139
|
+
### Patterns (REQUIRED)
|
|
140
|
+
Load `references/security-patterns.md` for:
|
|
141
|
+
- OWASP Top 10 checklist with detection criteria
|
|
142
|
+
- Framework-specific patterns (from `frameworks/{detected}.md` if framework detected)
|
|
143
|
+
|
|
144
|
+
### Examples (OPTIONAL - for calibration)
|
|
145
|
+
Reference when encountering ambiguous cases:
|
|
146
|
+
- Anti-patterns: `examples/anti-patterns/security.ts`
|
|
147
|
+
- Recommended: `examples/recommended/security.ts`
|
|
148
|
+
|
|
149
|
+
### What to Skip (Common False Positives)
|
|
150
|
+
- Parameterized queries flagged due to nearby string concatenation
|
|
151
|
+
- Test fixtures with intentional "vulnerable" code
|
|
152
|
+
- Comments containing SQL/code examples
|
|
153
|
+
- Sanitization already applied upstream
|
|
154
|
+
|
|
155
|
+
### Output Requirements
|
|
156
|
+
- confidence: verified | suspected
|
|
157
|
+
- evidence: Data flow trace or pattern match
|
|
158
|
+
- owasp: Category reference (e.g., A03:2021-Injection)
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Type Safety
|
|
163
|
+
|
|
164
|
+
### Purpose
|
|
165
|
+
Identify type system holes that bypass compile-time safety.
|
|
166
|
+
|
|
167
|
+
### Boundary
|
|
168
|
+
Type system integrity: explicit `any`, implicit any from missing types, unsafe type assertions, null/undefined handling gaps.
|
|
169
|
+
|
|
170
|
+
**Does NOT cover:** Runtime errors from logic bugs (→ tests), security issues (→ Security).
|
|
171
|
+
|
|
172
|
+
### Prerequisites
|
|
173
|
+
- `just typecheck` passed (confirms type-correct, looking for holes)
|
|
174
|
+
|
|
175
|
+
### Patterns (REQUIRED)
|
|
176
|
+
Load `references/type-safety-patterns.md` for:
|
|
177
|
+
- `any` usage patterns (explicit, implicit, from libraries)
|
|
178
|
+
- Null handling patterns (optional chaining gaps, assertion misuse)
|
|
179
|
+
- Unsafe assertion patterns (as unknown as T, non-null assertion operator)
|
|
180
|
+
|
|
181
|
+
### Examples (OPTIONAL - for calibration)
|
|
182
|
+
Reference when encountering ambiguous cases:
|
|
183
|
+
- Anti-patterns: `examples/anti-patterns/type-safety.ts`
|
|
184
|
+
- Recommended: `examples/recommended/type-safety.ts`
|
|
185
|
+
|
|
186
|
+
### What to Skip (Common False Positives)
|
|
187
|
+
- `any` in test fixtures for flexibility
|
|
188
|
+
- `any` in JSON parsing with immediate validation
|
|
189
|
+
- Third-party library types that require `any`
|
|
190
|
+
- Intentional `as const` assertions
|
|
191
|
+
|
|
192
|
+
### Output Requirements
|
|
193
|
+
- pattern: any_explicit | any_implicit | null_gap | unsafe_assertion
|
|
194
|
+
- location: Precise line and column
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Linting
|
|
199
|
+
|
|
200
|
+
### Purpose
|
|
201
|
+
Identify code quality issues requiring human judgment beyond what automated linters catch.
|
|
202
|
+
|
|
203
|
+
### Boundary
|
|
204
|
+
Style and structure requiring judgment: cyclomatic complexity, semantic naming, deep nesting, code duplication, unclear control flow.
|
|
205
|
+
|
|
206
|
+
**Does NOT cover:** Formatting (automated), syntax (compiler), security (→ Security).
|
|
207
|
+
|
|
208
|
+
### Prerequisites
|
|
209
|
+
- `just lint` passed (catches automatable issues)
|
|
210
|
+
|
|
211
|
+
### Patterns (REQUIRED)
|
|
212
|
+
Load `references/linting-patterns.md` for:
|
|
213
|
+
- Complexity thresholds (cyclomatic, nesting depth, function length)
|
|
214
|
+
- Naming anti-patterns (single letters, generic names, misleading names)
|
|
215
|
+
- Structure anti-patterns (god functions, mixed concerns)
|
|
216
|
+
|
|
217
|
+
### Examples (OPTIONAL - for calibration)
|
|
218
|
+
Reference when encountering ambiguous cases:
|
|
219
|
+
- Anti-patterns: `examples/anti-patterns/linting.ts`
|
|
220
|
+
- Recommended: `examples/recommended/linting.ts`
|
|
221
|
+
|
|
222
|
+
### What to Skip (Common False Positives)
|
|
223
|
+
- Intentionally complex algorithms with comments
|
|
224
|
+
- Generated code with unusual patterns
|
|
225
|
+
- Legacy code explicitly marked for future refactoring
|
|
226
|
+
- Single-letter variables in tight loops (`i`, `j`, `k`)
|
|
227
|
+
|
|
228
|
+
### Git Context (Optional)
|
|
229
|
+
When `--include-git-context` is enabled, include for complexity findings:
|
|
230
|
+
```yaml
|
|
231
|
+
git_context:
|
|
232
|
+
last_modified: "2025-08-15 by @alice"
|
|
233
|
+
commit_message: "Workaround for #1234"
|
|
234
|
+
note: "Complexity may be intentional - verify before refactoring"
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Output Requirements
|
|
238
|
+
- pattern: deep_nesting | long_function | generic_naming | god_function
|
|
239
|
+
- metrics: Quantitative values where applicable (nesting level, line count)
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Coding Standards
|
|
244
|
+
|
|
245
|
+
### Purpose
|
|
246
|
+
Verify adherence to project conventions and architectural patterns.
|
|
247
|
+
|
|
248
|
+
### Boundary
|
|
249
|
+
Conventions and architecture: atomic principles (single responsibility, explicit I/O), documentation quality, pattern adherence, consistency with codebase.
|
|
250
|
+
|
|
251
|
+
**Does NOT cover:** Style formatting (→ linters), security patterns (→ Security).
|
|
252
|
+
|
|
253
|
+
### Prerequisites
|
|
254
|
+
- Code compiles and passes lint
|
|
255
|
+
|
|
256
|
+
### Patterns (REQUIRED)
|
|
257
|
+
Load `references/standards-patterns.md` for:
|
|
258
|
+
- Atomic principles checklist (CS1-CS4 from Rules.md)
|
|
259
|
+
- Documentation requirements (when to document, JSDoc format)
|
|
260
|
+
- Pattern consistency checks
|
|
261
|
+
|
|
262
|
+
### Examples (OPTIONAL - for calibration)
|
|
263
|
+
Reference when encountering ambiguous cases:
|
|
264
|
+
- Anti-patterns: `examples/anti-patterns/standards.ts`
|
|
265
|
+
- Recommended: `examples/recommended/standards.ts`
|
|
266
|
+
|
|
267
|
+
### What to Skip (Common False Positives)
|
|
268
|
+
- Prototype/experimental code explicitly marked
|
|
269
|
+
- Third-party integration code matching external patterns
|
|
270
|
+
- Auto-generated code (migrations, schemas)
|
|
271
|
+
|
|
272
|
+
### Output Requirements
|
|
273
|
+
- principle: cs1_single_responsibility | cs2_no_magic | cs3_fail_fast | cs4_clean_code
|
|
274
|
+
- reference: Link to documentation or pattern definition
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Framework Detection
|
|
279
|
+
|
|
280
|
+
Auto-detect framework from project files. **If detected, loading framework patterns is REQUIRED.**
|
|
281
|
+
|
|
282
|
+
### Detection Logic
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
package.json dependencies → Framework
|
|
286
|
+
─────────────────────────────────────
|
|
287
|
+
react, next, gatsby → react
|
|
288
|
+
express, fastify, koa → express
|
|
289
|
+
@angular/core → angular
|
|
290
|
+
vue, nuxt → vue
|
|
291
|
+
|
|
292
|
+
requirements.txt / pyproject.toml:
|
|
293
|
+
django → django
|
|
294
|
+
flask → flask
|
|
295
|
+
fastapi → fastapi
|
|
296
|
+
|
|
297
|
+
(none of above) → (no framework)
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Override
|
|
301
|
+
Use `--framework=<name>` to override detection.
|
|
302
|
+
|
|
303
|
+
### Fallback Behavior
|
|
304
|
+
If no framework is detected:
|
|
305
|
+
- **Do NOT load `generic.md`** - skip framework patterns entirely
|
|
306
|
+
- Continue with core patterns from `references/*.md` files (which are REQUIRED)
|
|
307
|
+
- Note in diagnostic log that framework-specific checks were skipped
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Quick Mode
|
|
312
|
+
|
|
313
|
+
When `--quick` flag is specified, sections are tiered by lines changed:
|
|
314
|
+
|
|
315
|
+
| Lines Changed | Sections Run |
|
|
316
|
+
|---------------|--------------|
|
|
317
|
+
| <50 lines | Security only |
|
|
318
|
+
| 50-500 lines | Security + Type Safety |
|
|
319
|
+
| >500 lines | All sections |
|
|
320
|
+
|
|
321
|
+
**Default (no flag):** All sections (comprehensive review).
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Severity Tiers
|
|
326
|
+
|
|
327
|
+
| Tier | Label | Criteria | Action |
|
|
328
|
+
|------|-------|----------|--------|
|
|
329
|
+
| **CRITICAL** | Must fix before merge | Security vulnerabilities, type safety holes causing runtime errors | Block merge |
|
|
330
|
+
| **IMPORTANT** | Should fix | Anti-patterns, missing tests, significant quality issues | Address before or after merge |
|
|
331
|
+
| **SUGGESTION** | Optional | Style improvements, naming clarity, minor refactoring | Consider for future |
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Confidence Levels
|
|
336
|
+
|
|
337
|
+
| Level | Label | Criteria |
|
|
338
|
+
|-------|-------|----------|
|
|
339
|
+
| **Verified** | Data flow traced, exploit path confirmed | "User input from req.query.id flows to db.query at line 45 without sanitization" |
|
|
340
|
+
| **Suspected** | Pattern matches but context unclear | "String concatenation in SQL-like context - verify if this is actually a query" |
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## Output Format
|
|
345
|
+
|
|
346
|
+
Output templates follow the `subagent-output-templating` skill (P0.2) structure with skill-specific extensions for code review findings.
|
|
347
|
+
|
|
348
|
+
### Direct Invocation
|
|
349
|
+
Use template from `templates/output-direct.yaml`:
|
|
350
|
+
- Summary with counts by severity
|
|
351
|
+
- Findings grouped by severity
|
|
352
|
+
- Each finding has: file, line, section, pattern, confidence, evidence, description, why, fix
|
|
353
|
+
|
|
354
|
+
### Pipeline Stage
|
|
355
|
+
Use template from `templates/output-pipeline.yaml`:
|
|
356
|
+
- Scoped to single section
|
|
357
|
+
- Findings list with severity
|
|
358
|
+
- Summary statement
|
|
359
|
+
- Gate pass/fail for pipeline orchestration
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
## Pipeline Integration
|
|
364
|
+
|
|
365
|
+
### As Full Auditor (bulwark-code-auditor)
|
|
366
|
+
```fsharp
|
|
367
|
+
bulwark-code-auditor
|
|
368
|
+
├── context: fork (isolated review)
|
|
369
|
+
├── skills: code-review
|
|
370
|
+
└── Runs all 4 sections, never fixes
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### As Pipeline Stage (role-based)
|
|
374
|
+
```fsharp
|
|
375
|
+
SecurityReviewer (--section=security)
|
|
376
|
+
|> TypeSafetyReviewer (--section=type-safety)
|
|
377
|
+
|> LintReviewer (--section=linting)
|
|
378
|
+
|> StandardsReviewer (--section=standards)
|
|
379
|
+
|> ReviewSynthesizer (consolidate)
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
## Diagnostic Output (REQUIRED)
|
|
385
|
+
|
|
386
|
+
**MANDATORY**: You MUST write diagnostic output after every review. This is Phase 3 of the workflow and cannot be skipped.
|
|
387
|
+
|
|
388
|
+
**Standard**: Follows `subagent-output-templating` (P0.2) diagnostic format.
|
|
389
|
+
|
|
390
|
+
Write diagnostic output to:
|
|
391
|
+
```
|
|
392
|
+
logs/diagnostics/code-review-{timestamp}.yaml
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
Format:
|
|
396
|
+
```yaml
|
|
397
|
+
diagnostic:
|
|
398
|
+
skill: code-review
|
|
399
|
+
timestamp: 2026-01-31T12:00:00Z
|
|
400
|
+
invocation:
|
|
401
|
+
mode: comprehensive | quick
|
|
402
|
+
sections_run: [security, type_safety, linting, standards]
|
|
403
|
+
framework_detected: react
|
|
404
|
+
framework_override: null
|
|
405
|
+
files_count: 5
|
|
406
|
+
lines_total: 450
|
|
407
|
+
static_analysis:
|
|
408
|
+
typecheck: passed | failed | skipped
|
|
409
|
+
lint: passed | failed | skipped
|
|
410
|
+
findings_summary:
|
|
411
|
+
critical: 1
|
|
412
|
+
important: 3
|
|
413
|
+
suggestion: 5
|
|
414
|
+
duration_ms: 1200
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## Completion Checklist
|
|
420
|
+
|
|
421
|
+
**IMPORTANT**: Before returning to the user, verify ALL items are complete:
|
|
422
|
+
|
|
423
|
+
- [ ] Phase 1: Static analysis ran (`just typecheck`, `just lint`)
|
|
424
|
+
- [ ] Phase 2: LLM review completed for all enabled sections
|
|
425
|
+
- [ ] Phase 2: Findings delivered to user (console output)
|
|
426
|
+
- [ ] Phase 3: Diagnostic log written to `logs/diagnostics/code-review-{timestamp}.yaml`
|
|
427
|
+
|
|
428
|
+
**Do NOT return to user until all checkboxes can be marked complete.**
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linting Anti-Patterns
|
|
3
|
+
*
|
|
4
|
+
* DO NOT use these patterns in production code.
|
|
5
|
+
* Each example demonstrates code quality issues.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Deep nesting - hard to read and maintain
|
|
9
|
+
function processOrderUnsafe(order: Order) {
|
|
10
|
+
if (order) {
|
|
11
|
+
if (order.items) {
|
|
12
|
+
if (order.items.length > 0) {
|
|
13
|
+
for (const item of order.items) {
|
|
14
|
+
if (item.quantity > 0) {
|
|
15
|
+
if (item.price > 0) {
|
|
16
|
+
// Finally doing something
|
|
17
|
+
console.log(item);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Long function - doing too many things
|
|
27
|
+
async function handleCheckoutUnsafe(cart: Cart, user: User) {
|
|
28
|
+
// Validate cart
|
|
29
|
+
if (!cart.items.length) throw new Error('Empty cart');
|
|
30
|
+
for (const item of cart.items) {
|
|
31
|
+
if (!item.available) throw new Error('Item unavailable');
|
|
32
|
+
if (item.quantity > item.stock) throw new Error('Insufficient stock');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Calculate totals
|
|
36
|
+
let subtotal = 0;
|
|
37
|
+
for (const item of cart.items) {
|
|
38
|
+
subtotal += item.price * item.quantity;
|
|
39
|
+
}
|
|
40
|
+
const discount = user.isPremium ? subtotal * 0.1 : 0;
|
|
41
|
+
const tax = (subtotal - discount) * 0.08;
|
|
42
|
+
const shipping = subtotal > 100 ? 0 : 10;
|
|
43
|
+
const total = subtotal - discount + tax + shipping;
|
|
44
|
+
|
|
45
|
+
// Create order
|
|
46
|
+
const order = {
|
|
47
|
+
id: generateId(),
|
|
48
|
+
userId: user.id,
|
|
49
|
+
items: cart.items,
|
|
50
|
+
subtotal,
|
|
51
|
+
discount,
|
|
52
|
+
tax,
|
|
53
|
+
shipping,
|
|
54
|
+
total,
|
|
55
|
+
status: 'pending',
|
|
56
|
+
createdAt: new Date(),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Save to database
|
|
60
|
+
await db.orders.insert(order);
|
|
61
|
+
await db.carts.delete(cart.id);
|
|
62
|
+
for (const item of cart.items) {
|
|
63
|
+
await db.inventory.decrement(item.productId, item.quantity);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Send notifications
|
|
67
|
+
await email.send(user.email, 'orderConfirmation', { order });
|
|
68
|
+
await slack.notify('#sales', `New order: ${order.id} - $${total}`);
|
|
69
|
+
await analytics.track('checkout_complete', { orderId: order.id, total });
|
|
70
|
+
|
|
71
|
+
// Update user stats
|
|
72
|
+
user.totalOrders += 1;
|
|
73
|
+
user.totalSpent += total;
|
|
74
|
+
if (user.totalSpent > 1000 && !user.isPremium) {
|
|
75
|
+
user.isPremium = true;
|
|
76
|
+
await email.send(user.email, 'premiumUpgrade', {});
|
|
77
|
+
}
|
|
78
|
+
await db.users.update(user);
|
|
79
|
+
|
|
80
|
+
return order;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Generic naming - unclear purpose
|
|
84
|
+
function process(data: any) {
|
|
85
|
+
const result = data.map((item: any) => {
|
|
86
|
+
const temp = item.value * 2;
|
|
87
|
+
return { ...item, temp };
|
|
88
|
+
});
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Single letter variables outside loops
|
|
93
|
+
function calculate(a: number, b: number, c: number, d: number) {
|
|
94
|
+
const x = a + b;
|
|
95
|
+
const y = c - d;
|
|
96
|
+
const z = x * y;
|
|
97
|
+
return z;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Misleading names
|
|
101
|
+
const userList = getUser(); // Returns single user, not list
|
|
102
|
+
const isValid = validateAndSave(data); // Does more than validate
|
|
103
|
+
const tempFix = calculatePermanentDiscount(); // Not temporary
|
|
104
|
+
|
|
105
|
+
// God function - mixed responsibilities
|
|
106
|
+
function doEverything(input: string) {
|
|
107
|
+
// Parse
|
|
108
|
+
const parsed = JSON.parse(input);
|
|
109
|
+
|
|
110
|
+
// Validate
|
|
111
|
+
if (!parsed.name) throw new Error('Missing name');
|
|
112
|
+
|
|
113
|
+
// Transform
|
|
114
|
+
const transformed = { ...parsed, name: parsed.name.toUpperCase() };
|
|
115
|
+
|
|
116
|
+
// Log
|
|
117
|
+
console.log('Processing:', transformed);
|
|
118
|
+
|
|
119
|
+
// Save
|
|
120
|
+
localStorage.setItem('data', JSON.stringify(transformed));
|
|
121
|
+
|
|
122
|
+
// Notify
|
|
123
|
+
dispatchEvent(new CustomEvent('dataUpdated', { detail: transformed }));
|
|
124
|
+
|
|
125
|
+
// Return
|
|
126
|
+
return transformed;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Complex conditionals
|
|
130
|
+
function canAccessResource(user: User, resource: Resource): boolean {
|
|
131
|
+
return (
|
|
132
|
+
user.role === 'admin' ||
|
|
133
|
+
(user.role === 'manager' && user.department === resource.department) ||
|
|
134
|
+
(user.role === 'employee' &&
|
|
135
|
+
user.department === resource.department &&
|
|
136
|
+
resource.accessLevel === 'public') ||
|
|
137
|
+
user.permissions.includes(resource.id) ||
|
|
138
|
+
(resource.sharedWith.includes(user.id) && !resource.revoked)
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Duplicate code
|
|
143
|
+
function createUser(data: UserData) {
|
|
144
|
+
if (!data.email) throw new Error('Email required');
|
|
145
|
+
if (!data.email.includes('@')) throw new Error('Invalid email');
|
|
146
|
+
if (data.email.length > 255) throw new Error('Email too long');
|
|
147
|
+
// ...create user
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function updateUser(id: string, data: UserData) {
|
|
151
|
+
if (!data.email) throw new Error('Email required');
|
|
152
|
+
if (!data.email.includes('@')) throw new Error('Invalid email');
|
|
153
|
+
if (data.email.length > 255) throw new Error('Email too long');
|
|
154
|
+
// ...update user
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Inconsistent style
|
|
158
|
+
async function fetchDataInconsistent() {
|
|
159
|
+
return fetch('/api/data')
|
|
160
|
+
.then((response) => response.json())
|
|
161
|
+
.then((data) => {
|
|
162
|
+
return processData(data);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function fetchDataInconsistent2() {
|
|
167
|
+
const response = await fetch('/api/other');
|
|
168
|
+
const data = await response.json();
|
|
169
|
+
return processData(data);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Magic numbers
|
|
173
|
+
function calculateShipping(weight: number, distance: number): number {
|
|
174
|
+
if (weight < 5) {
|
|
175
|
+
return distance * 0.5 + 3.99;
|
|
176
|
+
} else if (weight < 20) {
|
|
177
|
+
return distance * 0.75 + 7.99;
|
|
178
|
+
} else {
|
|
179
|
+
return distance * 1.25 + 14.99;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Anti-Patterns
|
|
3
|
+
*
|
|
4
|
+
* DO NOT use these patterns in production code.
|
|
5
|
+
* Each example demonstrates a security vulnerability.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// A03:2021 - SQL Injection
|
|
9
|
+
// BAD: String concatenation in SQL query
|
|
10
|
+
async function getUserByIdUnsafe(userId: string) {
|
|
11
|
+
const query = `SELECT * FROM users WHERE id = '${userId}'`;
|
|
12
|
+
return db.query(query);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// A03:2021 - Command Injection
|
|
16
|
+
// BAD: User input in shell command
|
|
17
|
+
function processFileUnsafe(filename: string) {
|
|
18
|
+
const { execSync } = require('child_process');
|
|
19
|
+
execSync(`cat ${filename} | grep pattern`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// A03:2021 - XSS (Cross-Site Scripting)
|
|
23
|
+
// BAD: Rendering user input without escaping
|
|
24
|
+
function renderCommentUnsafe(comment: string) {
|
|
25
|
+
document.getElementById('comments').innerHTML = comment;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// A02:2021 - Hardcoded Secrets
|
|
29
|
+
// BAD: API key in source code
|
|
30
|
+
const API_KEY = 'sk-1234567890abcdef';
|
|
31
|
+
const DB_PASSWORD = 'production_password_123';
|
|
32
|
+
|
|
33
|
+
// A02:2021 - Weak Cryptography
|
|
34
|
+
// BAD: MD5 for password hashing
|
|
35
|
+
import * as crypto from 'crypto';
|
|
36
|
+
function hashPasswordUnsafe(password: string) {
|
|
37
|
+
return crypto.createHash('md5').update(password).digest('hex');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// A02:2021 - Insecure Random
|
|
41
|
+
// BAD: Math.random for security-sensitive operations
|
|
42
|
+
function generateTokenUnsafe() {
|
|
43
|
+
return Math.random().toString(36).substring(2);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// A01:2021 - Missing Authorization
|
|
47
|
+
// BAD: No ownership check
|
|
48
|
+
async function getDocumentUnsafe(documentId: string) {
|
|
49
|
+
// Missing: Check if current user owns this document
|
|
50
|
+
return db.documents.findById(documentId);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// A01:2021 - Path Traversal
|
|
54
|
+
// BAD: User input in file path without sanitization
|
|
55
|
+
function readFileUnsafe(userPath: string) {
|
|
56
|
+
const fs = require('fs');
|
|
57
|
+
return fs.readFileSync(`./uploads/${userPath}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// A07:2021 - Session Fixation
|
|
61
|
+
// BAD: Not regenerating session after login
|
|
62
|
+
async function loginUnsafe(req: Request, res: Response) {
|
|
63
|
+
const user = await authenticate(req.body);
|
|
64
|
+
// Missing: req.session.regenerate()
|
|
65
|
+
req.session.userId = user.id;
|
|
66
|
+
res.json({ success: true });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// A09:2021 - Sensitive Data in Logs
|
|
70
|
+
// BAD: Logging passwords
|
|
71
|
+
function authenticateUnsafe(username: string, password: string) {
|
|
72
|
+
console.log(`Login attempt: ${username} with password ${password}`);
|
|
73
|
+
// ...
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// A10:2021 - SSRF (Server-Side Request Forgery)
|
|
77
|
+
// BAD: User-controlled URL without validation
|
|
78
|
+
async function fetchUrlUnsafe(url: string) {
|
|
79
|
+
const response = await fetch(url);
|
|
80
|
+
return response.text();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// A05:2021 - Debug Mode in Production
|
|
84
|
+
// BAD: Verbose error messages
|
|
85
|
+
function handleErrorUnsafe(error: Error, res: Response) {
|
|
86
|
+
res.status(500).json({
|
|
87
|
+
error: error.message,
|
|
88
|
+
stack: error.stack,
|
|
89
|
+
internalDetails: error.cause,
|
|
90
|
+
});
|
|
91
|
+
}
|