bros-harness 0.1.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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +183 -0
- package/SECURITY.md +16 -0
- package/assets/agents.manifest.json +55 -0
- package/assets/commands.manifest.json +35 -0
- package/assets/docs.manifest.json +20 -0
- package/assets/import-report.md +25 -0
- package/assets/manifest.json +799 -0
- package/assets/opencode/agents/README.md +3 -0
- package/assets/opencode/agents/bro-build.md +256 -0
- package/assets/opencode/agents/bro-design.md +77 -0
- package/assets/opencode/agents/bro-docs.md +72 -0
- package/assets/opencode/agents/bro-explore.md +143 -0
- package/assets/opencode/agents/bro-ops.md +195 -0
- package/assets/opencode/agents/bro-shield.md +77 -0
- package/assets/opencode/agents/bro-test.md +204 -0
- package/assets/opencode/agents/bro-ui.md +135 -0
- package/assets/opencode/agents/mighty-bro.md +252 -0
- package/assets/opencode/commands/README.md +3 -0
- package/assets/opencode/commands/bros-assemble.md +32 -0
- package/assets/opencode/commands/bros-build.md +58 -0
- package/assets/opencode/commands/bros-plan.md +83 -0
- package/assets/opencode/commands/bros-review.md +38 -0
- package/assets/opencode/commands/bros-status.md +26 -0
- package/assets/opencode/docs/README.md +3 -0
- package/assets/opencode/docs/bros-builtin-skills.md +63 -0
- package/assets/opencode/docs/bros-harness.md +194 -0
- package/assets/opencode/skills/README.md +3 -0
- package/assets/opencode/skills/agent-architecture-audit/SKILL.md +256 -0
- package/assets/opencode/skills/agent-harness-construction/.openskills.json +7 -0
- package/assets/opencode/skills/agent-harness-construction/SKILL.md +73 -0
- package/assets/opencode/skills/agent-introspection-debugging/.openskills.json +7 -0
- package/assets/opencode/skills/agent-introspection-debugging/SKILL.md +153 -0
- package/assets/opencode/skills/api-design/.openskills.json +7 -0
- package/assets/opencode/skills/api-design/agents/openai.yaml +7 -0
- package/assets/opencode/skills/architecture-decision-records/.openskills.json +7 -0
- package/assets/opencode/skills/architecture-decision-records/SKILL.md +179 -0
- package/assets/opencode/skills/article-writing/.openskills.json +7 -0
- package/assets/opencode/skills/article-writing/SKILL.md +79 -0
- package/assets/opencode/skills/article-writing/agents/openai.yaml +7 -0
- package/assets/opencode/skills/automation-audit-ops/.openskills.json +7 -0
- package/assets/opencode/skills/automation-audit-ops/SKILL.md +142 -0
- package/assets/opencode/skills/backend-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/backend-patterns/SKILL.md +561 -0
- package/assets/opencode/skills/backend-patterns/agents/openai.yaml +7 -0
- package/assets/opencode/skills/benchmark/.openskills.json +7 -0
- package/assets/opencode/skills/benchmark/SKILL.md +93 -0
- package/assets/opencode/skills/bros-orchestrate/SKILL.md +455 -0
- package/assets/opencode/skills/browser-qa/.openskills.json +7 -0
- package/assets/opencode/skills/browser-qa/SKILL.md +87 -0
- package/assets/opencode/skills/canary-watch/.openskills.json +7 -0
- package/assets/opencode/skills/canary-watch/SKILL.md +107 -0
- package/assets/opencode/skills/code-review-expert/SKILL.md +155 -0
- package/assets/opencode/skills/code-review-expert/agents/agent.yaml +7 -0
- package/assets/opencode/skills/code-review-expert/references/code-quality-checklist.md +130 -0
- package/assets/opencode/skills/code-review-expert/references/removal-plan.md +52 -0
- package/assets/opencode/skills/code-review-expert/references/security-checklist.md +118 -0
- package/assets/opencode/skills/code-review-expert/references/solid-checklist.md +65 -0
- package/assets/opencode/skills/code-tour/.openskills.json +7 -0
- package/assets/opencode/skills/code-tour/SKILL.md +236 -0
- package/assets/opencode/skills/coding-standards/.openskills.json +7 -0
- package/assets/opencode/skills/coding-standards/SKILL.md +549 -0
- package/assets/opencode/skills/coding-standards/agents/openai.yaml +7 -0
- package/assets/opencode/skills/context-budget/.openskills.json +7 -0
- package/assets/opencode/skills/context-budget/SKILL.md +135 -0
- package/assets/opencode/skills/database-migrations/.openskills.json +7 -0
- package/assets/opencode/skills/database-migrations/SKILL.md +429 -0
- package/assets/opencode/skills/deployment-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/deployment-patterns/SKILL.md +427 -0
- package/assets/opencode/skills/design-system/.openskills.json +7 -0
- package/assets/opencode/skills/design-system/SKILL.md +82 -0
- package/assets/opencode/skills/docker-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/docker-patterns/SKILL.md +364 -0
- package/assets/opencode/skills/documentation-lookup/.openskills.json +7 -0
- package/assets/opencode/skills/documentation-lookup/SKILL.md +90 -0
- package/assets/opencode/skills/documentation-lookup/agents/openai.yaml +7 -0
- package/assets/opencode/skills/e2e-testing/.openskills.json +7 -0
- package/assets/opencode/skills/e2e-testing/SKILL.md +326 -0
- package/assets/opencode/skills/e2e-testing/agents/openai.yaml +7 -0
- package/assets/opencode/skills/error-handling/SKILL.md +376 -0
- package/assets/opencode/skills/frontend-design/.openskills.json +7 -0
- package/assets/opencode/skills/frontend-design/SKILL.md +145 -0
- package/assets/opencode/skills/frontend-design-direction/SKILL.md +92 -0
- package/assets/opencode/skills/frontend-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/frontend-patterns/SKILL.md +642 -0
- package/assets/opencode/skills/frontend-patterns/agents/openai.yaml +7 -0
- package/assets/opencode/skills/gateguard/.openskills.json +7 -0
- package/assets/opencode/skills/gateguard/SKILL.md +125 -0
- package/assets/opencode/skills/git-master/SKILL.md +60 -0
- package/assets/opencode/skills/golang-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/golang-patterns/SKILL.md +674 -0
- package/assets/opencode/skills/golang-testing/.openskills.json +7 -0
- package/assets/opencode/skills/golang-testing/SKILL.md +720 -0
- package/assets/opencode/skills/grafana-dashboard-design/SKILL.md +65 -0
- package/assets/opencode/skills/hexagonal-architecture/.openskills.json +7 -0
- package/assets/opencode/skills/hexagonal-architecture/SKILL.md +276 -0
- package/assets/opencode/skills/java-coding-standards/.openskills.json +7 -0
- package/assets/opencode/skills/java-coding-standards/SKILL.md +383 -0
- package/assets/opencode/skills/jpa-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/jpa-patterns/SKILL.md +151 -0
- package/assets/opencode/skills/knowledge-ops/.openskills.json +7 -0
- package/assets/opencode/skills/knowledge-ops/SKILL.md +154 -0
- package/assets/opencode/skills/make-interfaces-feel-better/SKILL.md +151 -0
- package/assets/opencode/skills/mysql-patterns/SKILL.md +412 -0
- package/assets/opencode/skills/nestjs-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/nestjs-patterns/SKILL.md +230 -0
- package/assets/opencode/skills/nextjs-turbopack/.openskills.json +7 -0
- package/assets/opencode/skills/nextjs-turbopack/SKILL.md +57 -0
- package/assets/opencode/skills/nextjs-turbopack/agents/openai.yaml +7 -0
- package/assets/opencode/skills/parallel-execution-optimizer/SKILL.md +72 -0
- package/assets/opencode/skills/postgres-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/postgres-patterns/SKILL.md +147 -0
- package/assets/opencode/skills/prisma-patterns/SKILL.md +371 -0
- package/assets/opencode/skills/product-capability/.openskills.json +7 -0
- package/assets/opencode/skills/product-capability/SKILL.md +141 -0
- package/assets/opencode/skills/product-lens/.openskills.json +7 -0
- package/assets/opencode/skills/product-lens/SKILL.md +92 -0
- package/assets/opencode/skills/production-audit/SKILL.md +206 -0
- package/assets/opencode/skills/python-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/python-patterns/SKILL.md +750 -0
- package/assets/opencode/skills/python-testing/.openskills.json +7 -0
- package/assets/opencode/skills/python-testing/SKILL.md +816 -0
- package/assets/opencode/skills/redis-patterns/SKILL.md +403 -0
- package/assets/opencode/skills/requirements-clarity/README.md +260 -0
- package/assets/opencode/skills/requirements-clarity/SKILL.md +324 -0
- package/assets/opencode/skills/rust-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/rust-patterns/SKILL.md +499 -0
- package/assets/opencode/skills/rust-testing/.openskills.json +7 -0
- package/assets/opencode/skills/rust-testing/SKILL.md +500 -0
- package/assets/opencode/skills/safety-guard/.openskills.json +7 -0
- package/assets/opencode/skills/safety-guard/SKILL.md +75 -0
- package/assets/opencode/skills/search-first/.openskills.json +7 -0
- package/assets/opencode/skills/search-first/SKILL.md +181 -0
- package/assets/opencode/skills/security-review/.openskills.json +7 -0
- package/assets/opencode/skills/security-review/agents/openai.yaml +7 -0
- package/assets/opencode/skills/security-review/cloud-infrastructure-security.md +361 -0
- package/assets/opencode/skills/security-scan/.openskills.json +7 -0
- package/assets/opencode/skills/security-scan/SKILL.md +165 -0
- package/assets/opencode/skills/springboot-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/springboot-patterns/SKILL.md +314 -0
- package/assets/opencode/skills/springboot-tdd/.openskills.json +7 -0
- package/assets/opencode/skills/springboot-tdd/SKILL.md +158 -0
- package/assets/opencode/skills/springboot-verification/.openskills.json +7 -0
- package/assets/opencode/skills/springboot-verification/SKILL.md +231 -0
- package/assets/opencode/skills/strategic-compact/.openskills.json +7 -0
- package/assets/opencode/skills/strategic-compact/SKILL.md +131 -0
- package/assets/opencode/skills/strategic-compact/agents/openai.yaml +7 -0
- package/assets/opencode/skills/strategic-compact/suggest-compact.sh +54 -0
- package/assets/opencode/skills/tdd-workflow/.openskills.json +7 -0
- package/assets/opencode/skills/tdd-workflow/SKILL.md +463 -0
- package/assets/opencode/skills/tdd-workflow/agents/openai.yaml +7 -0
- package/assets/opencode/skills/verification-loop/.openskills.json +7 -0
- package/assets/opencode/skills/verification-loop/SKILL.md +126 -0
- package/assets/opencode/skills/verification-loop/agents/openai.yaml +7 -0
- package/assets/opencode/skills/vite-patterns/SKILL.md +449 -0
- package/assets/opencode/skills/web-doc-search/SKILL.md +51 -0
- package/assets/opencode/templates/README.md +3 -0
- package/assets/opencode/templates/bros/adr.md +39 -0
- package/assets/opencode/templates/bros/delivery-report.md +71 -0
- package/assets/opencode/templates/bros/explorer-evidence-packet.md +51 -0
- package/assets/opencode/templates/bros/prd.md +72 -0
- package/assets/opencode/templates/bros/security-review.md +48 -0
- package/assets/opencode/templates/bros/status-board.md +33 -0
- package/assets/opencode/templates/bros/task-packet.md +94 -0
- package/assets/opencode/templates/bros/test-strategy.md +57 -0
- package/assets/opencode/templates/bros/ui-implementation-packet.md +64 -0
- package/assets/skills.manifest.json +650 -0
- package/assets/templates.manifest.json +55 -0
- package/bin/bros.mjs +122 -0
- package/docs/compatibility.md +9 -0
- package/docs/installation.md +66 -0
- package/docs/integrations/claude.md +5 -0
- package/docs/integrations/codex.md +5 -0
- package/docs/integrations/opencode.md +39 -0
- package/docs/migration/from-local-opencode-config.md +10 -0
- package/docs/release-process.md +11 -0
- package/docs/repository-structure.md +15 -0
- package/docs/roadmap.md +20 -0
- package/docs/security.md +18 -0
- package/docs/testing.md +9 -0
- package/examples/opencode/README.md +11 -0
- package/examples/opencode/opencode.example.jsonc +4 -0
- package/package.json +43 -0
- package/scripts/validate-assets.mjs +22 -0
- package/scripts/verify-no-secrets.mjs +38 -0
- package/src/plugin.mjs +98 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-review-expert
|
|
3
|
+
description: "Expert code review of current git changes with a senior engineer lens. Detects SOLID violations, security risks, and proposes actionable improvements."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Review Expert
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Perform a structured review of the current git changes with focus on SOLID, architecture, removal candidates, and security risks. Default to review-only output unless the user asks to implement changes.
|
|
11
|
+
|
|
12
|
+
## Severity Levels
|
|
13
|
+
|
|
14
|
+
| Level | Name | Description | Action |
|
|
15
|
+
|-------|------|-------------|--------|
|
|
16
|
+
| **P0** | Critical | Security vulnerability, data loss risk, correctness bug | Must block merge |
|
|
17
|
+
| **P1** | High | Logic error, significant SOLID violation, performance regression | Should fix before merge |
|
|
18
|
+
| **P2** | Medium | Code smell, maintainability concern, minor SOLID violation | Fix in this PR or create follow-up |
|
|
19
|
+
| **P3** | Low | Style, naming, minor suggestion | Optional improvement |
|
|
20
|
+
|
|
21
|
+
## Workflow
|
|
22
|
+
|
|
23
|
+
### 1) Preflight context
|
|
24
|
+
|
|
25
|
+
- Use `git status -sb`, `git diff --stat`, and `git diff` to scope changes.
|
|
26
|
+
- If needed, use `rg` or `grep` to find related modules, usages, and contracts.
|
|
27
|
+
- Identify entry points, ownership boundaries, and critical paths (auth, payments, data writes, network).
|
|
28
|
+
|
|
29
|
+
**Edge cases:**
|
|
30
|
+
- **No changes**: If `git diff` is empty, inform user and ask if they want to review staged changes or a specific commit range.
|
|
31
|
+
- **Large diff (>500 lines)**: Summarize by file first, then review in batches by module/feature area.
|
|
32
|
+
- **Mixed concerns**: Group findings by logical feature, not just file order.
|
|
33
|
+
|
|
34
|
+
### 2) SOLID + architecture smells
|
|
35
|
+
|
|
36
|
+
- Load `references/solid-checklist.md` for specific prompts.
|
|
37
|
+
- Look for:
|
|
38
|
+
- **SRP**: Overloaded modules with unrelated responsibilities.
|
|
39
|
+
- **OCP**: Frequent edits to add behavior instead of extension points.
|
|
40
|
+
- **LSP**: Subclasses that break expectations or require type checks.
|
|
41
|
+
- **ISP**: Wide interfaces with unused methods.
|
|
42
|
+
- **DIP**: High-level logic tied to low-level implementations.
|
|
43
|
+
- When you propose a refactor, explain *why* it improves cohesion/coupling and outline a minimal, safe split.
|
|
44
|
+
- If refactor is non-trivial, propose an incremental plan instead of a large rewrite.
|
|
45
|
+
|
|
46
|
+
### 3) Removal candidates + iteration plan
|
|
47
|
+
|
|
48
|
+
- Load `references/removal-plan.md` for template.
|
|
49
|
+
- Identify code that is unused, redundant, or feature-flagged off.
|
|
50
|
+
- Distinguish **safe delete now** vs **defer with plan**.
|
|
51
|
+
- Provide a follow-up plan with concrete steps and checkpoints (tests/metrics).
|
|
52
|
+
|
|
53
|
+
### 4) Security and reliability scan
|
|
54
|
+
|
|
55
|
+
- Load `references/security-checklist.md` for coverage.
|
|
56
|
+
- Check for:
|
|
57
|
+
- XSS, injection (SQL/NoSQL/command), SSRF, path traversal
|
|
58
|
+
- AuthZ/AuthN gaps, missing tenancy checks
|
|
59
|
+
- Secret leakage or API keys in logs/env/files
|
|
60
|
+
- Rate limits, unbounded loops, CPU/memory hotspots
|
|
61
|
+
- Unsafe deserialization, weak crypto, insecure defaults
|
|
62
|
+
- **Race conditions**: concurrent access, check-then-act, TOCTOU, missing locks
|
|
63
|
+
- Call out both **exploitability** and **impact**.
|
|
64
|
+
|
|
65
|
+
### 5) Code quality scan
|
|
66
|
+
|
|
67
|
+
- Load `references/code-quality-checklist.md` for coverage.
|
|
68
|
+
- Check for:
|
|
69
|
+
- **Error handling**: swallowed exceptions, overly broad catch, missing error handling, async errors
|
|
70
|
+
- **Performance**: N+1 queries, CPU-intensive ops in hot paths, missing cache, unbounded memory
|
|
71
|
+
- **Boundary conditions**: null/undefined handling, empty collections, numeric boundaries, off-by-one
|
|
72
|
+
- Flag issues that may cause silent failures or production incidents.
|
|
73
|
+
|
|
74
|
+
### 6) Output format
|
|
75
|
+
|
|
76
|
+
Structure your review as follows:
|
|
77
|
+
|
|
78
|
+
```markdown
|
|
79
|
+
## Code Review Summary
|
|
80
|
+
|
|
81
|
+
**Files reviewed**: X files, Y lines changed
|
|
82
|
+
**Overall assessment**: [APPROVE / REQUEST_CHANGES / COMMENT]
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Findings
|
|
87
|
+
|
|
88
|
+
### P0 - Critical
|
|
89
|
+
(none or list)
|
|
90
|
+
|
|
91
|
+
### P1 - High
|
|
92
|
+
- **[file:line]** Brief title
|
|
93
|
+
- Description of issue
|
|
94
|
+
- Suggested fix
|
|
95
|
+
|
|
96
|
+
### P2 - Medium
|
|
97
|
+
...
|
|
98
|
+
|
|
99
|
+
### P3 - Low
|
|
100
|
+
...
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Removal/Iteration Plan
|
|
105
|
+
(if applicable)
|
|
106
|
+
|
|
107
|
+
## Additional Suggestions
|
|
108
|
+
(optional improvements, not blocking)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Inline comments**: Use this format for file-specific findings:
|
|
112
|
+
```
|
|
113
|
+
::code-comment{file="path/to/file.ts" line="42" severity="P1"}
|
|
114
|
+
Description of the issue and suggested fix.
|
|
115
|
+
::
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Clean review**: If no issues found, explicitly state:
|
|
119
|
+
- What was checked
|
|
120
|
+
- Any areas not covered (e.g., "Did not verify database migrations")
|
|
121
|
+
- Residual risks or recommended follow-up tests
|
|
122
|
+
|
|
123
|
+
### 7) Next steps confirmation
|
|
124
|
+
|
|
125
|
+
After presenting findings, ask user how to proceed:
|
|
126
|
+
|
|
127
|
+
```markdown
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Next Steps
|
|
131
|
+
|
|
132
|
+
I found X issues (P0: _, P1: _, P2: _, P3: _).
|
|
133
|
+
|
|
134
|
+
**How would you like to proceed?**
|
|
135
|
+
|
|
136
|
+
1. **Fix all** - I'll implement all suggested fixes
|
|
137
|
+
2. **Fix P0/P1 only** - Address critical and high priority issues
|
|
138
|
+
3. **Fix specific items** - Tell me which issues to fix
|
|
139
|
+
4. **No changes** - Review complete, no implementation needed
|
|
140
|
+
|
|
141
|
+
Please choose an option or provide specific instructions.
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Important**: Do NOT implement any changes until user explicitly confirms. This is a review-first workflow.
|
|
145
|
+
|
|
146
|
+
## Resources
|
|
147
|
+
|
|
148
|
+
### references/
|
|
149
|
+
|
|
150
|
+
| File | Purpose |
|
|
151
|
+
|------|---------|
|
|
152
|
+
| `solid-checklist.md` | SOLID smell prompts and refactor heuristics |
|
|
153
|
+
| `security-checklist.md` | Web/app security and runtime risk checklist |
|
|
154
|
+
| `code-quality-checklist.md` | Error handling, performance, boundary conditions |
|
|
155
|
+
| `removal-plan.md` | Template for deletion candidates and follow-up plan |
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Code Review Expert"
|
|
3
|
+
short_description: "Senior engineer code review: SOLID, security, performance, error handling"
|
|
4
|
+
default_prompt: "Review current git changes for SOLID violations, security risks, race conditions, error handling issues, performance problems, and boundary condition bugs."
|
|
5
|
+
|
|
6
|
+
# Agent-agnostic skill - works with any LLM provider.
|
|
7
|
+
# No provider-specific configuration required.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Code Quality Checklist
|
|
2
|
+
|
|
3
|
+
## Error Handling
|
|
4
|
+
|
|
5
|
+
### Anti-patterns to Flag
|
|
6
|
+
|
|
7
|
+
- **Swallowed exceptions**: Empty catch blocks or catch with only logging
|
|
8
|
+
```javascript
|
|
9
|
+
try { ... } catch (e) { } // Silent failure
|
|
10
|
+
try { ... } catch (e) { console.log(e) } // Log and forget
|
|
11
|
+
```
|
|
12
|
+
- **Overly broad catch**: Catching `Exception`/`Error` base class instead of specific types
|
|
13
|
+
- **Error information leakage**: Stack traces or internal details exposed to users
|
|
14
|
+
- **Missing error handling**: No try-catch around fallible operations (I/O, network, parsing)
|
|
15
|
+
- **Async error handling**: Unhandled promise rejections, missing `.catch()`, no error boundary
|
|
16
|
+
|
|
17
|
+
### Best Practices to Check
|
|
18
|
+
|
|
19
|
+
- [ ] Errors are caught at appropriate boundaries
|
|
20
|
+
- [ ] Error messages are user-friendly (no internal details exposed)
|
|
21
|
+
- [ ] Errors are logged with sufficient context for debugging
|
|
22
|
+
- [ ] Async errors are properly propagated or handled
|
|
23
|
+
- [ ] Fallback behavior is defined for recoverable errors
|
|
24
|
+
- [ ] Critical errors trigger alerts/monitoring
|
|
25
|
+
|
|
26
|
+
### Questions to Ask
|
|
27
|
+
- "What happens when this operation fails?"
|
|
28
|
+
- "Will the caller know something went wrong?"
|
|
29
|
+
- "Is there enough context to debug this error?"
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Performance & Caching
|
|
34
|
+
|
|
35
|
+
### CPU-Intensive Operations
|
|
36
|
+
|
|
37
|
+
- **Expensive operations in hot paths**: Regex compilation, JSON parsing, crypto in loops
|
|
38
|
+
- **Blocking main thread**: Sync I/O, heavy computation without worker/async
|
|
39
|
+
- **Unnecessary recomputation**: Same calculation done multiple times
|
|
40
|
+
- **Missing memoization**: Pure functions called repeatedly with same inputs
|
|
41
|
+
|
|
42
|
+
### Database & I/O
|
|
43
|
+
|
|
44
|
+
- **N+1 queries**: Loop that makes a query per item instead of batch
|
|
45
|
+
```javascript
|
|
46
|
+
// Bad: N+1
|
|
47
|
+
for (const id of ids) {
|
|
48
|
+
const user = await db.query(`SELECT * FROM users WHERE id = ?`, id)
|
|
49
|
+
}
|
|
50
|
+
// Good: Batch
|
|
51
|
+
const users = await db.query(`SELECT * FROM users WHERE id IN (?)`, ids)
|
|
52
|
+
```
|
|
53
|
+
- **Missing indexes**: Queries on unindexed columns
|
|
54
|
+
- **Over-fetching**: SELECT * when only few columns needed
|
|
55
|
+
- **No pagination**: Loading entire dataset into memory
|
|
56
|
+
|
|
57
|
+
### Caching Issues
|
|
58
|
+
|
|
59
|
+
- **Missing cache for expensive operations**: Repeated API calls, DB queries, computations
|
|
60
|
+
- **Cache without TTL**: Stale data served indefinitely
|
|
61
|
+
- **Cache without invalidation strategy**: Data updated but cache not cleared
|
|
62
|
+
- **Cache key collisions**: Insufficient key uniqueness
|
|
63
|
+
- **Caching user-specific data globally**: Security/privacy issue
|
|
64
|
+
|
|
65
|
+
### Memory
|
|
66
|
+
|
|
67
|
+
- **Unbounded collections**: Arrays/maps that grow without limit
|
|
68
|
+
- **Large object retention**: Holding references preventing GC
|
|
69
|
+
- **String concatenation in loops**: Use StringBuilder/join instead
|
|
70
|
+
- **Loading large files entirely**: Use streaming instead
|
|
71
|
+
|
|
72
|
+
### Questions to Ask
|
|
73
|
+
- "What's the time complexity of this operation?"
|
|
74
|
+
- "How does this behave with 10x/100x data?"
|
|
75
|
+
- "Is this result cacheable? Should it be?"
|
|
76
|
+
- "Can this be batched instead of one-by-one?"
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Boundary Conditions
|
|
81
|
+
|
|
82
|
+
### Null/Undefined Handling
|
|
83
|
+
|
|
84
|
+
- **Missing null checks**: Accessing properties on potentially null objects
|
|
85
|
+
- **Truthy/falsy confusion**: `if (value)` when `0` or `""` are valid
|
|
86
|
+
- **Optional chaining overuse**: `a?.b?.c?.d` hiding structural issues
|
|
87
|
+
- **Null vs undefined inconsistency**: Mixed usage without clear convention
|
|
88
|
+
|
|
89
|
+
### Empty Collections
|
|
90
|
+
|
|
91
|
+
- **Empty array not handled**: Code assumes array has items
|
|
92
|
+
- **Empty object edge case**: `for...in` or `Object.keys` on empty object
|
|
93
|
+
- **First/last element access**: `arr[0]` or `arr[arr.length-1]` without length check
|
|
94
|
+
|
|
95
|
+
### Numeric Boundaries
|
|
96
|
+
|
|
97
|
+
- **Division by zero**: Missing check before division
|
|
98
|
+
- **Integer overflow**: Large numbers exceeding safe integer range
|
|
99
|
+
- **Floating point comparison**: Using `===` instead of epsilon comparison
|
|
100
|
+
- **Negative values**: Index or count that shouldn't be negative
|
|
101
|
+
- **Off-by-one errors**: Loop bounds, array slicing, pagination
|
|
102
|
+
|
|
103
|
+
### String Boundaries
|
|
104
|
+
|
|
105
|
+
- **Empty string**: Not handled as edge case
|
|
106
|
+
- **Whitespace-only string**: Passes truthy check but is effectively empty
|
|
107
|
+
- **Very long strings**: No length limits causing memory/display issues
|
|
108
|
+
- **Unicode edge cases**: Emoji, RTL text, combining characters
|
|
109
|
+
|
|
110
|
+
### Common Patterns to Flag
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
// Dangerous: no null check
|
|
114
|
+
const name = user.profile.name
|
|
115
|
+
|
|
116
|
+
// Dangerous: array access without check
|
|
117
|
+
const first = items[0]
|
|
118
|
+
|
|
119
|
+
// Dangerous: division without check
|
|
120
|
+
const avg = total / count
|
|
121
|
+
|
|
122
|
+
// Dangerous: truthy check excludes valid values
|
|
123
|
+
if (value) { ... } // fails for 0, "", false
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Questions to Ask
|
|
127
|
+
- "What if this is null/undefined?"
|
|
128
|
+
- "What if this collection is empty?"
|
|
129
|
+
- "What's the valid range for this number?"
|
|
130
|
+
- "What happens at the boundaries (0, -1, MAX_INT)?"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Removal and Iteration Plan Template
|
|
2
|
+
|
|
3
|
+
## Priority Levels
|
|
4
|
+
|
|
5
|
+
- [ ] **P0**: Immediate removal needed (security risk, significant cost, blocking other work)
|
|
6
|
+
- [ ] **P1**: Remove in current sprint
|
|
7
|
+
- [ ] **P2**: Backlog / next iteration
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Safe to Remove Now
|
|
12
|
+
|
|
13
|
+
### Item: [Name/Description]
|
|
14
|
+
|
|
15
|
+
| Field | Details |
|
|
16
|
+
|-------|---------|
|
|
17
|
+
| **Location** | `path/to/file.ts:line` |
|
|
18
|
+
| **Rationale** | Why this should be removed |
|
|
19
|
+
| **Evidence** | Unused (no references), dead feature flag, deprecated API |
|
|
20
|
+
| **Impact** | None / Low - no active consumers |
|
|
21
|
+
| **Deletion steps** | 1. Remove code 2. Remove tests 3. Remove config |
|
|
22
|
+
| **Verification** | Run tests, check no runtime errors, monitor logs |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Defer Removal (Plan Required)
|
|
27
|
+
|
|
28
|
+
### Item: [Name/Description]
|
|
29
|
+
|
|
30
|
+
| Field | Details |
|
|
31
|
+
|-------|---------|
|
|
32
|
+
| **Location** | `path/to/file.ts:line` |
|
|
33
|
+
| **Why defer** | Active consumers, needs migration, stakeholder sign-off |
|
|
34
|
+
| **Preconditions** | Feature flag off for 2 weeks, telemetry shows 0 usage |
|
|
35
|
+
| **Breaking changes** | List any API/contract changes |
|
|
36
|
+
| **Migration plan** | Steps for consumers to migrate |
|
|
37
|
+
| **Timeline** | Target date or sprint |
|
|
38
|
+
| **Owner** | Person/team responsible |
|
|
39
|
+
| **Validation** | Metrics to confirm safe removal (error rates, usage counts) |
|
|
40
|
+
| **Rollback plan** | How to restore if issues found |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Checklist Before Removal
|
|
45
|
+
|
|
46
|
+
- [ ] Searched codebase for all references (`rg`, `grep`)
|
|
47
|
+
- [ ] Checked for dynamic/reflection-based usage
|
|
48
|
+
- [ ] Verified no external consumers (APIs, SDKs, docs)
|
|
49
|
+
- [ ] Feature flag telemetry reviewed (if applicable)
|
|
50
|
+
- [ ] Tests updated/removed
|
|
51
|
+
- [ ] Documentation updated
|
|
52
|
+
- [ ] Team notified (if shared code)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Security and Reliability Checklist
|
|
2
|
+
|
|
3
|
+
## Input/Output Safety
|
|
4
|
+
|
|
5
|
+
- **XSS**: Unsafe HTML injection, `dangerouslySetInnerHTML`, unescaped templates, innerHTML assignments
|
|
6
|
+
- **Injection**: SQL/NoSQL/command/GraphQL injection via string concatenation or template literals
|
|
7
|
+
- **SSRF**: User-controlled URLs reaching internal services without allowlist validation
|
|
8
|
+
- **Path traversal**: User input in file paths without sanitization (`../` attacks)
|
|
9
|
+
- **Prototype pollution**: Unsafe object merging in JavaScript (`Object.assign`, spread with user input)
|
|
10
|
+
|
|
11
|
+
## AuthN/AuthZ
|
|
12
|
+
|
|
13
|
+
- Missing tenant or ownership checks for read/write operations
|
|
14
|
+
- New endpoints without auth guards or RBAC enforcement
|
|
15
|
+
- Trusting client-provided roles/flags/IDs
|
|
16
|
+
- Broken access control (IDOR - Insecure Direct Object Reference)
|
|
17
|
+
- Session fixation or weak session management
|
|
18
|
+
|
|
19
|
+
## JWT & Token Security
|
|
20
|
+
|
|
21
|
+
- Algorithm confusion attacks (accepting `none` or `HS256` when expecting `RS256`)
|
|
22
|
+
- Weak or hardcoded secrets
|
|
23
|
+
- Missing expiration (`exp`) or not validating it
|
|
24
|
+
- Sensitive data in JWT payload (tokens are base64, not encrypted)
|
|
25
|
+
- Not validating `iss` (issuer) or `aud` (audience)
|
|
26
|
+
|
|
27
|
+
## Secrets and PII
|
|
28
|
+
|
|
29
|
+
- API keys, tokens, or credentials in code/config/logs
|
|
30
|
+
- Secrets in git history or environment variables exposed to client
|
|
31
|
+
- Excessive logging of PII or sensitive payloads
|
|
32
|
+
- Missing data masking in error messages
|
|
33
|
+
|
|
34
|
+
## Supply Chain & Dependencies
|
|
35
|
+
|
|
36
|
+
- Unpinned dependencies allowing malicious updates
|
|
37
|
+
- Dependency confusion (private package name collision)
|
|
38
|
+
- Importing from untrusted sources or CDNs without integrity checks
|
|
39
|
+
- Outdated dependencies with known CVEs
|
|
40
|
+
|
|
41
|
+
## CORS & Headers
|
|
42
|
+
|
|
43
|
+
- Overly permissive CORS (`Access-Control-Allow-Origin: *` with credentials)
|
|
44
|
+
- Missing security headers (CSP, X-Frame-Options, X-Content-Type-Options)
|
|
45
|
+
- Exposed internal headers or stack traces
|
|
46
|
+
|
|
47
|
+
## Runtime Risks
|
|
48
|
+
|
|
49
|
+
- Unbounded loops, recursive calls, or large in-memory buffers
|
|
50
|
+
- Missing timeouts, retries, or rate limiting on external calls
|
|
51
|
+
- Blocking operations on request path (sync I/O in async context)
|
|
52
|
+
- Resource exhaustion (file handles, connections, memory)
|
|
53
|
+
- ReDoS (Regular Expression Denial of Service)
|
|
54
|
+
|
|
55
|
+
## Cryptography
|
|
56
|
+
|
|
57
|
+
- Weak algorithms (MD5, SHA1 for security purposes)
|
|
58
|
+
- Hardcoded IVs or salts
|
|
59
|
+
- Using encryption without authentication (ECB mode, no HMAC)
|
|
60
|
+
- Insufficient key length
|
|
61
|
+
|
|
62
|
+
## Race Conditions
|
|
63
|
+
|
|
64
|
+
Race conditions are subtle bugs that cause intermittent failures and security vulnerabilities. Pay special attention to:
|
|
65
|
+
|
|
66
|
+
### Shared State Access
|
|
67
|
+
- Multiple threads/goroutines/async tasks accessing shared variables without synchronization
|
|
68
|
+
- Global state or singletons modified concurrently
|
|
69
|
+
- Lazy initialization without proper locking (double-checked locking issues)
|
|
70
|
+
- Non-thread-safe collections used in concurrent context
|
|
71
|
+
|
|
72
|
+
### Check-Then-Act (TOCTOU)
|
|
73
|
+
- `if (exists) then use` patterns without atomic operations
|
|
74
|
+
- `if (authorized) then perform` where authorization can change
|
|
75
|
+
- File existence check followed by file operation
|
|
76
|
+
- Balance check followed by deduction (financial operations)
|
|
77
|
+
- Inventory check followed by order placement
|
|
78
|
+
|
|
79
|
+
### Database Concurrency
|
|
80
|
+
- Missing optimistic locking (`version` column, `updated_at` checks)
|
|
81
|
+
- Missing pessimistic locking (`SELECT FOR UPDATE`)
|
|
82
|
+
- Read-modify-write without transaction isolation
|
|
83
|
+
- Counter increments without atomic operations (`UPDATE SET count = count + 1`)
|
|
84
|
+
- Unique constraint violations in concurrent inserts
|
|
85
|
+
|
|
86
|
+
### Distributed Systems
|
|
87
|
+
- Missing distributed locks for shared resources
|
|
88
|
+
- Leader election race conditions
|
|
89
|
+
- Cache invalidation races (stale reads after writes)
|
|
90
|
+
- Event ordering dependencies without proper sequencing
|
|
91
|
+
- Split-brain scenarios in cluster operations
|
|
92
|
+
|
|
93
|
+
### Common Patterns to Flag
|
|
94
|
+
```
|
|
95
|
+
# Dangerous patterns:
|
|
96
|
+
if not exists(key): # TOCTOU
|
|
97
|
+
create(key)
|
|
98
|
+
|
|
99
|
+
value = get(key) # Read-modify-write
|
|
100
|
+
value += 1
|
|
101
|
+
set(key, value)
|
|
102
|
+
|
|
103
|
+
if user.balance >= amount: # Check-then-act
|
|
104
|
+
user.balance -= amount
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Questions to Ask
|
|
108
|
+
- "What happens if two requests hit this code simultaneously?"
|
|
109
|
+
- "Is this operation atomic or can it be interrupted?"
|
|
110
|
+
- "What shared state does this code access?"
|
|
111
|
+
- "How does this behave under high concurrency?"
|
|
112
|
+
|
|
113
|
+
## Data Integrity
|
|
114
|
+
|
|
115
|
+
- Missing transactions, partial writes, or inconsistent state updates
|
|
116
|
+
- Weak validation before persistence (type coercion issues)
|
|
117
|
+
- Missing idempotency for retryable operations
|
|
118
|
+
- Lost updates due to concurrent modifications
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# SOLID Smell Prompts
|
|
2
|
+
|
|
3
|
+
## SRP (Single Responsibility)
|
|
4
|
+
|
|
5
|
+
- File owns unrelated concerns (e.g., HTTP + DB + domain rules in one file)
|
|
6
|
+
- Large class/module with low cohesion or multiple reasons to change
|
|
7
|
+
- Functions that orchestrate many unrelated steps
|
|
8
|
+
- God objects that know too much about the system
|
|
9
|
+
- **Ask**: "What is the single reason this module would change?"
|
|
10
|
+
|
|
11
|
+
## OCP (Open/Closed)
|
|
12
|
+
|
|
13
|
+
- Adding a new behavior requires editing many switch/if blocks
|
|
14
|
+
- Feature growth requires modifying core logic rather than extending
|
|
15
|
+
- No plugin/strategy/hook points for variation
|
|
16
|
+
- **Ask**: "Can I add a new variant without touching existing code?"
|
|
17
|
+
|
|
18
|
+
## LSP (Liskov Substitution)
|
|
19
|
+
|
|
20
|
+
- Subclass checks for concrete type or throws for base method
|
|
21
|
+
- Overridden methods weaken preconditions or strengthen postconditions
|
|
22
|
+
- Subclass ignores or no-ops parent behavior
|
|
23
|
+
- **Ask**: "Can I substitute any subclass without the caller knowing?"
|
|
24
|
+
|
|
25
|
+
## ISP (Interface Segregation)
|
|
26
|
+
|
|
27
|
+
- Interfaces with many methods, most unused by implementers
|
|
28
|
+
- Callers depend on broad interfaces for narrow needs
|
|
29
|
+
- Empty/stub implementations of interface methods
|
|
30
|
+
- **Ask**: "Do all implementers use all methods?"
|
|
31
|
+
|
|
32
|
+
## DIP (Dependency Inversion)
|
|
33
|
+
|
|
34
|
+
- High-level logic depends on concrete IO, storage, or network types
|
|
35
|
+
- Hard-coded implementations instead of abstractions or injection
|
|
36
|
+
- Import chains that couple business logic to infrastructure
|
|
37
|
+
- **Ask**: "Can I swap the implementation without changing business logic?"
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Common Code Smells (Beyond SOLID)
|
|
42
|
+
|
|
43
|
+
| Smell | Signs |
|
|
44
|
+
|-------|-------|
|
|
45
|
+
| **Long method** | Function > 30 lines, multiple levels of nesting |
|
|
46
|
+
| **Feature envy** | Method uses more data from another class than its own |
|
|
47
|
+
| **Data clumps** | Same group of parameters passed together repeatedly |
|
|
48
|
+
| **Primitive obsession** | Using strings/numbers instead of domain types |
|
|
49
|
+
| **Shotgun surgery** | One change requires edits across many files |
|
|
50
|
+
| **Divergent change** | One file changes for many unrelated reasons |
|
|
51
|
+
| **Dead code** | Unreachable or never-called code |
|
|
52
|
+
| **Speculative generality** | Abstractions for hypothetical future needs |
|
|
53
|
+
| **Magic numbers/strings** | Hardcoded values without named constants |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Refactor Heuristics
|
|
58
|
+
|
|
59
|
+
1. **Split by responsibility, not by size** - A small file can still violate SRP
|
|
60
|
+
2. **Introduce abstraction only when needed** - Wait for the second use case
|
|
61
|
+
3. **Keep refactors incremental** - Isolate behavior before moving
|
|
62
|
+
4. **Preserve behavior first** - Add tests before restructuring
|
|
63
|
+
5. **Name things by intent** - If naming is hard, the abstraction might be wrong
|
|
64
|
+
6. **Prefer composition over inheritance** - Inheritance creates tight coupling
|
|
65
|
+
7. **Make illegal states unrepresentable** - Use types to enforce invariants
|