@codeharbor/agent-playbook 0.1.0 → 0.1.2
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/README.md +4 -2
- package/package.json +5 -2
- package/skills/api-designer/README.md +36 -0
- package/skills/api-designer/SKILL.md +232 -0
- package/skills/api-designer/references/graphql-patterns.md +12 -0
- package/skills/api-designer/references/rest-patterns.md +17 -0
- package/skills/api-designer/scripts/generate_api.py +87 -0
- package/skills/api-designer/scripts/validate_api.py +48 -0
- package/skills/api-documenter/README.md +41 -0
- package/skills/api-documenter/SKILL.md +209 -0
- package/skills/api-documenter/references/examples/README.md +3 -0
- package/skills/api-documenter/references/examples/openapi-example.yaml +10 -0
- package/skills/api-documenter/references/openapi-template.yaml +5 -0
- package/skills/api-documenter/scripts/generate_openapi.py +84 -0
- package/skills/api-documenter/scripts/validate_openapi.py +45 -0
- package/skills/architecting-solutions/README.md +22 -0
- package/skills/architecting-solutions/SKILL.md +459 -0
- package/skills/auto-trigger/README.md +23 -0
- package/skills/auto-trigger/SKILL.md +183 -0
- package/skills/code-reviewer/README.md +59 -0
- package/skills/code-reviewer/SKILL.md +220 -0
- package/skills/code-reviewer/references/checklist.md +80 -0
- package/skills/code-reviewer/references/patterns.md +226 -0
- package/skills/code-reviewer/references/security.md +88 -0
- package/skills/code-reviewer/scripts/review_checklist.py +191 -0
- package/skills/commit-helper/README.md +58 -0
- package/skills/commit-helper/SKILL.md +159 -0
- package/skills/commit-helper/references/conventional-commits.md +68 -0
- package/skills/commit-helper/references/examples.md +125 -0
- package/skills/commit-helper/references/scopes.md +49 -0
- package/skills/commit-helper/scripts/validate_commit.py +70 -0
- package/skills/create-pr/README.md +182 -0
- package/skills/create-pr/SKILL.md +340 -0
- package/skills/debugger/README.md +53 -0
- package/skills/debugger/SKILL.md +239 -0
- package/skills/debugger/references/checklist.md +7 -0
- package/skills/debugger/references/errors.md +6 -0
- package/skills/debugger/references/patterns.md +5 -0
- package/skills/debugger/scripts/debug_report.py +77 -0
- package/skills/deployment-engineer/README.md +40 -0
- package/skills/deployment-engineer/SKILL.md +242 -0
- package/skills/deployment-engineer/references/kubernetes.md +23 -0
- package/skills/deployment-engineer/references/monitoring.md +14 -0
- package/skills/deployment-engineer/references/pipelines.md +12 -0
- package/skills/deployment-engineer/scripts/generate_deploy.py +72 -0
- package/skills/deployment-engineer/scripts/validate_deploy.py +46 -0
- package/skills/documentation-engineer/README.md +41 -0
- package/skills/documentation-engineer/SKILL.md +164 -0
- package/skills/documentation-engineer/references/api-template.md +22 -0
- package/skills/documentation-engineer/references/readme-template.md +25 -0
- package/skills/documentation-engineer/references/style-guide.md +13 -0
- package/skills/documentation-engineer/scripts/generate_docs.py +68 -0
- package/skills/documentation-engineer/scripts/validate_docs.py +46 -0
- package/skills/figma-designer/README.md +222 -0
- package/skills/figma-designer/SKILL.md +407 -0
- package/skills/figma-designer/references/example-output.md +86 -0
- package/skills/performance-engineer/README.md +42 -0
- package/skills/performance-engineer/SKILL.md +236 -0
- package/skills/performance-engineer/references/checklist.md +6 -0
- package/skills/performance-engineer/references/monitoring.md +5 -0
- package/skills/performance-engineer/references/optimization.md +7 -0
- package/skills/performance-engineer/scripts/perf_report.py +64 -0
- package/skills/performance-engineer/scripts/profile.py +63 -0
- package/skills/planning-with-files/README.md +27 -0
- package/skills/planning-with-files/SKILL.md +103 -0
- package/skills/prd-implementation-precheck/README.md +97 -0
- package/skills/prd-implementation-precheck/SKILL.md +112 -0
- package/skills/prd-planner/README.md +102 -0
- package/skills/prd-planner/SKILL.md +449 -0
- package/skills/prd-planner/references/edge-case-analysis.md +111 -0
- package/skills/qa-expert/README.md +37 -0
- package/skills/qa-expert/SKILL.md +225 -0
- package/skills/qa-expert/references/gates.md +11 -0
- package/skills/qa-expert/references/metrics.md +6 -0
- package/skills/qa-expert/references/strategy.md +11 -0
- package/skills/qa-expert/scripts/coverage_analysis.py +61 -0
- package/skills/qa-expert/scripts/generate_test_plan.py +68 -0
- package/skills/refactoring-specialist/README.md +37 -0
- package/skills/refactoring-specialist/SKILL.md +283 -0
- package/skills/refactoring-specialist/references/checklist.md +6 -0
- package/skills/refactoring-specialist/references/smells.md +6 -0
- package/skills/refactoring-specialist/references/techniques.md +6 -0
- package/skills/security-auditor/README.md +48 -0
- package/skills/security-auditor/SKILL.md +256 -0
- package/skills/security-auditor/references/checklist.md +7 -0
- package/skills/security-auditor/references/owasp.md +12 -0
- package/skills/security-auditor/references/remediation.md +7 -0
- package/skills/security-auditor/scripts/find_secrets.py +58 -0
- package/skills/security-auditor/scripts/security_audit.py +64 -0
- package/skills/self-improving-agent/README.md +136 -0
- package/skills/self-improving-agent/SKILL.md +407 -0
- package/skills/self-improving-agent/hooks/post-bash.sh +10 -0
- package/skills/self-improving-agent/hooks/pre-tool.sh +10 -0
- package/skills/self-improving-agent/hooks/session-end.sh +4 -0
- package/skills/self-improving-agent/memory/semantic-patterns.json +288 -0
- package/skills/self-improving-agent/references/appendix.md +131 -0
- package/skills/self-improving-agent/templates/correction-template.md +11 -0
- package/skills/self-improving-agent/templates/pattern-template.md +15 -0
- package/skills/self-improving-agent/templates/validation-template.md +14 -0
- package/skills/session-logger/README.md +50 -0
- package/skills/session-logger/SKILL.md +156 -0
- package/skills/skill-router/README.md +155 -0
- package/skills/skill-router/SKILL.md +215 -0
- package/skills/test-automator/README.md +41 -0
- package/skills/test-automator/SKILL.md +202 -0
- package/skills/test-automator/references/best-practices.md +6 -0
- package/skills/test-automator/references/examples/README.md +3 -0
- package/skills/test-automator/references/examples/unit-test-example.md +8 -0
- package/skills/test-automator/references/mocking.md +5 -0
- package/skills/test-automator/scripts/coverage_report.py +59 -0
- package/skills/test-automator/scripts/generate_test.py +66 -0
- package/skills/workflow-orchestrator/README.md +20 -0
- package/skills/workflow-orchestrator/SKILL.md +342 -0
- package/src/cli.js +107 -20
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Code Reviewer
|
|
2
|
+
|
|
3
|
+
> A Claude Code skill for comprehensive code review of pull requests and code changes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
This skill is part of the [agent-playbook](https://github.com/Charon-Fan/agent-playbook) collection.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
When reviewing code, simply ask:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
You: Review this PR
|
|
15
|
+
You: Check my changes
|
|
16
|
+
You: Review the code in src/auth/
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The skill will:
|
|
20
|
+
1. Analyze the changes
|
|
21
|
+
2. Check against security best practices
|
|
22
|
+
3. Evaluate code quality
|
|
23
|
+
4. Review test coverage
|
|
24
|
+
5. Provide structured feedback
|
|
25
|
+
|
|
26
|
+
## Review Categories
|
|
27
|
+
|
|
28
|
+
| Category | Description |
|
|
29
|
+
|----------|-------------|
|
|
30
|
+
| **Correctness** | Logic, edge cases, error handling |
|
|
31
|
+
| **Security** | OWASP Top 10, secrets, injection prevention |
|
|
32
|
+
| **Performance** | N+1 queries, caching, algorithms |
|
|
33
|
+
| **Code Quality** | DRY, KISS, naming, abstractions |
|
|
34
|
+
| **Testing** | Coverage, edge cases, meaningful assertions |
|
|
35
|
+
| **Documentation** | Comments, API docs, README |
|
|
36
|
+
| **Maintainability** | Modularity, separation of concerns |
|
|
37
|
+
|
|
38
|
+
## Output Format
|
|
39
|
+
|
|
40
|
+
Reviews are structured with severity levels:
|
|
41
|
+
|
|
42
|
+
- **Critical**: Must fix before merge
|
|
43
|
+
- **High**: Should fix before merge
|
|
44
|
+
- **Medium**: Consider fixing
|
|
45
|
+
- **Low**: Nice to have improvements
|
|
46
|
+
|
|
47
|
+
## Scripts
|
|
48
|
+
|
|
49
|
+
Generate a review checklist:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
python scripts/review_checklist.py
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## References
|
|
56
|
+
|
|
57
|
+
- [OWASP Top 10](https://owasp.org/www-project-top-ten/)
|
|
58
|
+
- [Google Engineering Practices](https://google.github.io/eng-practices/review/)
|
|
59
|
+
- [Clean Code](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882)
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-reviewer
|
|
3
|
+
description: Reviews pull requests and code changes for quality, security, and best practices. Use when user asks for code review, PR review, or mentions reviewing changes.
|
|
4
|
+
allowed-tools: Read, Grep, Glob, Bash, WebFetch, WebSearch
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Code Reviewer
|
|
8
|
+
|
|
9
|
+
A comprehensive code review skill that analyzes pull requests and code changes for quality, security, maintainability, and best practices.
|
|
10
|
+
|
|
11
|
+
## When This Skill Activates
|
|
12
|
+
|
|
13
|
+
This skill activates when you:
|
|
14
|
+
- Ask for a code review
|
|
15
|
+
- Request a PR review
|
|
16
|
+
- Mention reviewing changes
|
|
17
|
+
- Say "review this" or "check this code"
|
|
18
|
+
|
|
19
|
+
## Review Process
|
|
20
|
+
|
|
21
|
+
### Phase 1: Context Gathering
|
|
22
|
+
|
|
23
|
+
1. **Get changed files**
|
|
24
|
+
```bash
|
|
25
|
+
git diff main...HEAD --name-only
|
|
26
|
+
git log main...HEAD --oneline
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2. **Get the diff**
|
|
30
|
+
```bash
|
|
31
|
+
git diff main...HEAD
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
3. **Understand project context**
|
|
35
|
+
- Read relevant documentation
|
|
36
|
+
- Check existing patterns in similar files
|
|
37
|
+
- Identify project-specific conventions
|
|
38
|
+
|
|
39
|
+
### Phase 2: Analysis Categories
|
|
40
|
+
|
|
41
|
+
#### 1. Correctness
|
|
42
|
+
- [ ] Logic is sound and matches requirements
|
|
43
|
+
- [ ] Edge cases are handled
|
|
44
|
+
- [ ] Error handling is appropriate
|
|
45
|
+
- [ ] No obvious bugs or typos
|
|
46
|
+
|
|
47
|
+
#### 2. Security
|
|
48
|
+
- [ ] No hardcoded secrets or credentials
|
|
49
|
+
- [ ] Input validation and sanitization
|
|
50
|
+
- [ ] SQL injection prevention
|
|
51
|
+
- [ ] XSS prevention (for frontend)
|
|
52
|
+
- [ ] Authentication/authorization checks
|
|
53
|
+
- [ ] Safe handling of user data
|
|
54
|
+
|
|
55
|
+
#### 3. Performance
|
|
56
|
+
- [ ] No N+1 queries
|
|
57
|
+
- [ ] Appropriate caching
|
|
58
|
+
- [ ] Efficient algorithms
|
|
59
|
+
- [ ] No unnecessary computations
|
|
60
|
+
- [ ] Memory efficiency
|
|
61
|
+
|
|
62
|
+
#### 4. Code Quality
|
|
63
|
+
- [ ] Follows DRY principle
|
|
64
|
+
- [ ] Follows KISS principle
|
|
65
|
+
- [ ] Appropriate abstractions
|
|
66
|
+
- [ ] Clear naming conventions
|
|
67
|
+
- [ ] Proper typing (if TypeScript)
|
|
68
|
+
- [ ] No commented-out code
|
|
69
|
+
|
|
70
|
+
#### 5. Testing
|
|
71
|
+
- [ ] Tests cover new functionality
|
|
72
|
+
- [ ] Tests cover edge cases
|
|
73
|
+
- [ ] Test assertions are meaningful
|
|
74
|
+
- [ ] No brittle tests
|
|
75
|
+
|
|
76
|
+
#### 6. Documentation
|
|
77
|
+
- [ ] Complex logic is explained
|
|
78
|
+
- [ ] Public APIs have documentation
|
|
79
|
+
- [ ] JSDoc/TSDoc for functions
|
|
80
|
+
- [ ] README updated if needed
|
|
81
|
+
|
|
82
|
+
#### 7. Maintainability
|
|
83
|
+
- [ ] Code is readable
|
|
84
|
+
- [ ] Consistent style
|
|
85
|
+
- [ ] Modular design
|
|
86
|
+
- [ ] Separation of concerns
|
|
87
|
+
|
|
88
|
+
### Phase 3: Output Format
|
|
89
|
+
|
|
90
|
+
Use this structured format for review feedback:
|
|
91
|
+
|
|
92
|
+
```markdown
|
|
93
|
+
# Code Review
|
|
94
|
+
|
|
95
|
+
## Summary
|
|
96
|
+
Brief overview of the changes (2-3 sentences).
|
|
97
|
+
|
|
98
|
+
## Issues by Severity
|
|
99
|
+
|
|
100
|
+
### Critical
|
|
101
|
+
Must fix before merge.
|
|
102
|
+
|
|
103
|
+
- [ ] **Issue Title**: Description with file:line reference
|
|
104
|
+
|
|
105
|
+
### High
|
|
106
|
+
Should fix before merge unless there's a good reason.
|
|
107
|
+
|
|
108
|
+
- [ ] **Issue Title**: Description with file:line reference
|
|
109
|
+
|
|
110
|
+
### Medium
|
|
111
|
+
Consider fixing, can be done in follow-up.
|
|
112
|
+
|
|
113
|
+
- [ ] **Issue Title**: Description with file:line reference
|
|
114
|
+
|
|
115
|
+
### Low
|
|
116
|
+
Nice to have improvements.
|
|
117
|
+
|
|
118
|
+
- [ ] **Issue Title**: Description with file:line reference
|
|
119
|
+
|
|
120
|
+
## Positive Highlights
|
|
121
|
+
What was done well in this PR.
|
|
122
|
+
|
|
123
|
+
## Suggestions
|
|
124
|
+
Optional improvements that don't require immediate action.
|
|
125
|
+
|
|
126
|
+
## Approval Status
|
|
127
|
+
- [ ] Approved
|
|
128
|
+
- [ ] Approved with suggestions
|
|
129
|
+
- [ ] Request changes
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Common Issues to Check
|
|
133
|
+
|
|
134
|
+
### Security Issues
|
|
135
|
+
|
|
136
|
+
| Issue | Pattern | Recommendation |
|
|
137
|
+
|-------|----------|----------------|
|
|
138
|
+
| Hardcoded secrets | `const API_KEY = "sk-"` | Use environment variables |
|
|
139
|
+
| SQL injection | `\"SELECT * FROM...\" + user_input` | Use parameterized queries |
|
|
140
|
+
| XSS vulnerability | `innerHTML = user_input` | Sanitize or use textContent |
|
|
141
|
+
| Missing auth check | New endpoint without `@RequireAuth` | Add authentication middleware |
|
|
142
|
+
|
|
143
|
+
### Performance Issues
|
|
144
|
+
|
|
145
|
+
| Issue | Pattern | Recommendation |
|
|
146
|
+
|-------|----------|----------------|
|
|
147
|
+
| N+1 query | Loop with database call | Use eager loading or batch queries |
|
|
148
|
+
| Unnecessary re-render | Missing dependencies in `useEffect` | Fix dependency array |
|
|
149
|
+
| Memory leak | Event listener not removed | Add cleanup in useEffect return |
|
|
150
|
+
| Inefficient loop | Nested loops O(n²) | Consider hash map or different algorithm |
|
|
151
|
+
|
|
152
|
+
### Code Quality Issues
|
|
153
|
+
|
|
154
|
+
| Issue | Pattern | Recommendation |
|
|
155
|
+
|-------|----------|----------------|
|
|
156
|
+
| Duplicate code | Similar blocks repeated | Extract to function |
|
|
157
|
+
| Magic number | `if (status === 5)` | Use named constant |
|
|
158
|
+
| Long function | Function >50 lines | Split into smaller functions |
|
|
159
|
+
| Complex condition | `a && b || c && d` | Extract to variable with descriptive name |
|
|
160
|
+
|
|
161
|
+
### Testing Issues
|
|
162
|
+
|
|
163
|
+
| Issue | Pattern | Recommendation |
|
|
164
|
+
|-------|----------|----------------|
|
|
165
|
+
| No tests | New feature without test file | Add unit tests |
|
|
166
|
+
| Untested edge case | Test only covers happy path | Add edge case tests |
|
|
167
|
+
| Brittle test | Test relies on implementation details | Test behavior, not implementation |
|
|
168
|
+
| Missing assertion | Test doesn't assert anything | Add proper assertions |
|
|
169
|
+
|
|
170
|
+
## Language-Specific Guidelines
|
|
171
|
+
|
|
172
|
+
### TypeScript
|
|
173
|
+
- Use `unknown` instead of `any` for untyped values
|
|
174
|
+
- Prefer `interface` for public APIs, `type` for unions
|
|
175
|
+
- Use strict mode settings
|
|
176
|
+
- Avoid `as` assertions when possible
|
|
177
|
+
|
|
178
|
+
### React
|
|
179
|
+
- Follow Hooks rules
|
|
180
|
+
- Use `useCallback`/`useMemo` appropriately (not prematurely)
|
|
181
|
+
- Prefer function components
|
|
182
|
+
- Use proper key props in lists
|
|
183
|
+
- Avoid prop drilling with Context
|
|
184
|
+
|
|
185
|
+
### Python
|
|
186
|
+
- Follow PEP 8 style guide
|
|
187
|
+
- Use type hints
|
|
188
|
+
- Use f-strings for formatting
|
|
189
|
+
- Prefer list comprehensions over map/filter
|
|
190
|
+
- Use context managers for resources
|
|
191
|
+
|
|
192
|
+
### Go
|
|
193
|
+
- Handle errors explicitly
|
|
194
|
+
- Use named returns for clarity
|
|
195
|
+
- Keep goroutines simple
|
|
196
|
+
- Use channels for communication
|
|
197
|
+
- Avoid package-level state
|
|
198
|
+
|
|
199
|
+
## Before Approving
|
|
200
|
+
|
|
201
|
+
Confirm the following:
|
|
202
|
+
- [ ] All critical issues are addressed
|
|
203
|
+
- [ ] Tests pass locally
|
|
204
|
+
- [ ] No merge conflicts
|
|
205
|
+
- [ ] Commit messages are clear
|
|
206
|
+
- [ ] Documentation is updated
|
|
207
|
+
- [ ] Breaking changes are documented
|
|
208
|
+
|
|
209
|
+
## Scripts
|
|
210
|
+
|
|
211
|
+
Run the review checklist script:
|
|
212
|
+
```bash
|
|
213
|
+
python scripts/review_checklist.py <pr-number>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## References
|
|
217
|
+
|
|
218
|
+
- `references/checklist.md` - Complete review checklist
|
|
219
|
+
- `references/security.md` - Security review guidelines
|
|
220
|
+
- `references/patterns.md` - Common patterns and anti-patterns
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Code Review Checklist
|
|
2
|
+
|
|
3
|
+
Use this checklist for systematic code reviews.
|
|
4
|
+
|
|
5
|
+
## Pre-Review
|
|
6
|
+
|
|
7
|
+
- [ ] I understand what this PR is trying to achieve
|
|
8
|
+
- [ ] I have read the linked issues/tickets
|
|
9
|
+
- [ ] I have checked the base branch is correct
|
|
10
|
+
- [ ] I have verified the PR is not a draft
|
|
11
|
+
|
|
12
|
+
## Code Review
|
|
13
|
+
|
|
14
|
+
### Correctness
|
|
15
|
+
- [ ] Code implements the stated requirements
|
|
16
|
+
- [ ] Edge cases are handled
|
|
17
|
+
- [ ] Error handling is appropriate
|
|
18
|
+
- [ ] No obvious bugs
|
|
19
|
+
- [ ] Input validation is present
|
|
20
|
+
|
|
21
|
+
### Security
|
|
22
|
+
- [ ] No hardcoded secrets/credentials
|
|
23
|
+
- [ ] User input is validated/sanitized
|
|
24
|
+
- [ ] SQL/NoSQL injection prevention
|
|
25
|
+
- [ ] XSS prevention (for web)
|
|
26
|
+
- [ ] CSRF protection (for state-changing operations)
|
|
27
|
+
- [ ] Authentication/authorization is correct
|
|
28
|
+
- [ ] Sensitive data is handled securely
|
|
29
|
+
|
|
30
|
+
### Performance
|
|
31
|
+
- [ ] No N+1 queries
|
|
32
|
+
- [ ] Appropriate caching (if applicable)
|
|
33
|
+
- [ ] Efficient algorithm/data structure choice
|
|
34
|
+
- [ ] No unnecessary database/network calls
|
|
35
|
+
- [ ] Pagination for large datasets
|
|
36
|
+
- [ ] Indexes used where appropriate
|
|
37
|
+
|
|
38
|
+
### Code Quality
|
|
39
|
+
- [ ] Code is readable and understandable
|
|
40
|
+
- [ ] Naming is clear and consistent
|
|
41
|
+
- [ ] No dead/commented-out code
|
|
42
|
+
- [ ] No duplicate code
|
|
43
|
+
- [ ] Appropriate abstractions
|
|
44
|
+
- [ ] Follows DRY, KISS, YAGNI
|
|
45
|
+
- [ ] Type definitions are accurate (if typed)
|
|
46
|
+
|
|
47
|
+
### Testing
|
|
48
|
+
- [ ] Tests cover new functionality
|
|
49
|
+
- [ ] Tests cover edge cases
|
|
50
|
+
- [ ] Tests are meaningful (not tautologies)
|
|
51
|
+
- [ ] No hardcoded test data that makes tests brittle
|
|
52
|
+
- [ ] All tests pass
|
|
53
|
+
- [ ] Test coverage not decreased
|
|
54
|
+
|
|
55
|
+
### Documentation
|
|
56
|
+
- [ ] Complex logic has comments
|
|
57
|
+
- [ ] Public APIs are documented
|
|
58
|
+
- [ ] Breaking changes are noted
|
|
59
|
+
- [ ] README/API docs updated if needed
|
|
60
|
+
- [ ] Migration guide provided for breaking changes
|
|
61
|
+
|
|
62
|
+
### Maintainability
|
|
63
|
+
- [ ] Code is modular
|
|
64
|
+
- [ ] Separation of concerns
|
|
65
|
+
- [ ] Easy to modify
|
|
66
|
+
- [ ] Easy to test
|
|
67
|
+
- [ ] Follows project conventions
|
|
68
|
+
|
|
69
|
+
### Style
|
|
70
|
+
- [ ] Consistent formatting
|
|
71
|
+
- [ ] Follows project style guide
|
|
72
|
+
- [ ] No lint errors
|
|
73
|
+
- [ ] No console.log/debugger left in
|
|
74
|
+
|
|
75
|
+
## Post-Review
|
|
76
|
+
|
|
77
|
+
- [ ] Provided clear, actionable feedback
|
|
78
|
+
- [ ] Explained reasoning for suggestions
|
|
79
|
+
- [ ] Flagged blocking issues separately from nice-to-haves
|
|
80
|
+
- [ ] Recognized good work in the PR
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# Common Patterns and Anti-Patterns
|
|
2
|
+
|
|
3
|
+
## Patterns to Encourage
|
|
4
|
+
|
|
5
|
+
### Error Handling
|
|
6
|
+
|
|
7
|
+
**Good:**
|
|
8
|
+
```typescript
|
|
9
|
+
async function getUser(id: string) {
|
|
10
|
+
const user = await db.users.findById(id);
|
|
11
|
+
if (!user) {
|
|
12
|
+
throw new NotFoundError(`User ${id} not found`);
|
|
13
|
+
}
|
|
14
|
+
return user;
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**Bad:**
|
|
19
|
+
```typescript
|
|
20
|
+
async function getUser(id: string) {
|
|
21
|
+
return await db.users.findById(id); // Returns null, not handled
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Async/Await
|
|
26
|
+
|
|
27
|
+
**Good:**
|
|
28
|
+
```typescript
|
|
29
|
+
const result = await fetch(url);
|
|
30
|
+
const data = await result.json();
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Bad:**
|
|
34
|
+
```typescript
|
|
35
|
+
fetch(url).then(r => r.json()).then(data => {
|
|
36
|
+
// Nested callbacks
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Early Returns
|
|
41
|
+
|
|
42
|
+
**Good:**
|
|
43
|
+
```typescript
|
|
44
|
+
function process(user) {
|
|
45
|
+
if (!user) return null;
|
|
46
|
+
if (!user.active) return null;
|
|
47
|
+
return user.data;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Bad:**
|
|
52
|
+
```typescript
|
|
53
|
+
function process(user) {
|
|
54
|
+
if (user) {
|
|
55
|
+
if (user.active) {
|
|
56
|
+
return user.data;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Destructuring
|
|
64
|
+
|
|
65
|
+
**Good:**
|
|
66
|
+
```typescript
|
|
67
|
+
const { name, email } = user;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Bad:**
|
|
71
|
+
```typescript
|
|
72
|
+
const name = user.name;
|
|
73
|
+
const email = user.email;
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Anti-Patterns to Catch
|
|
77
|
+
|
|
78
|
+
### Magic Numbers
|
|
79
|
+
|
|
80
|
+
**Bad:**
|
|
81
|
+
```typescript
|
|
82
|
+
if (user.role === 5) { ... }
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Good:**
|
|
86
|
+
```typescript
|
|
87
|
+
const Role = { ADMIN: 5, USER: 1 };
|
|
88
|
+
if (user.role === Role.ADMIN) { ... }
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Neglected Promise Rejection
|
|
92
|
+
|
|
93
|
+
**Bad:**
|
|
94
|
+
```typescript
|
|
95
|
+
fetch(url).then(data => processData(data));
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Good:**
|
|
99
|
+
```typescript
|
|
100
|
+
fetch(url)
|
|
101
|
+
.then(data => processData(data))
|
|
102
|
+
.catch(error => logError(error));
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Any Type
|
|
106
|
+
|
|
107
|
+
**Bad:**
|
|
108
|
+
```typescript
|
|
109
|
+
function parse(data: any) { ... }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Good:**
|
|
113
|
+
```typescript
|
|
114
|
+
function parse(data: unknown): Result { ... }
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Deep Nesting
|
|
118
|
+
|
|
119
|
+
**Bad:**
|
|
120
|
+
```typescript
|
|
121
|
+
if (a) {
|
|
122
|
+
if (b) {
|
|
123
|
+
if (c) {
|
|
124
|
+
doSomething();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Good:**
|
|
131
|
+
```typescript
|
|
132
|
+
if (!a) return;
|
|
133
|
+
if (!b) return;
|
|
134
|
+
if (!c) return;
|
|
135
|
+
doSomething();
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Large Functions
|
|
139
|
+
|
|
140
|
+
**Bad:** Functions > 50 lines
|
|
141
|
+
|
|
142
|
+
**Good:** Split into smaller, focused functions
|
|
143
|
+
|
|
144
|
+
### God Objects
|
|
145
|
+
|
|
146
|
+
**Bad:** Classes/methods that do everything
|
|
147
|
+
|
|
148
|
+
**Good:** Single Responsibility Principle
|
|
149
|
+
|
|
150
|
+
### Shotgun Surgery
|
|
151
|
+
|
|
152
|
+
**Bad:** Adding a feature requires changing many files
|
|
153
|
+
|
|
154
|
+
**Good:** Good separation of concerns
|
|
155
|
+
|
|
156
|
+
## React Specific
|
|
157
|
+
|
|
158
|
+
### Hooks Dependencies
|
|
159
|
+
|
|
160
|
+
**Bad:**
|
|
161
|
+
```typescript
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
fetchData(userId);
|
|
164
|
+
}, []); // Missing userId dependency
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Good:**
|
|
168
|
+
```typescript
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
fetchData(userId);
|
|
171
|
+
}, [userId]);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### State Updates
|
|
175
|
+
|
|
176
|
+
**Bad:**
|
|
177
|
+
```typescript
|
|
178
|
+
setCount(count + 1);
|
|
179
|
+
setCount(count + 1);
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Good:**
|
|
183
|
+
```typescript
|
|
184
|
+
setCount(c => c + 2);
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Key Props
|
|
188
|
+
|
|
189
|
+
**Bad:**
|
|
190
|
+
```typescript
|
|
191
|
+
items.map((item, i) => <Item key={i} />)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Good:**
|
|
195
|
+
```typescript
|
|
196
|
+
items.map(item => <Item key={item.id} />)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Backend Specific
|
|
200
|
+
|
|
201
|
+
### N+1 Query
|
|
202
|
+
|
|
203
|
+
**Bad:**
|
|
204
|
+
```python
|
|
205
|
+
for user in users:
|
|
206
|
+
posts = db.query("SELECT * FROM posts WHERE user_id = ?", user.id)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Good:**
|
|
210
|
+
```python
|
|
211
|
+
user_ids = [u.id for u in users]
|
|
212
|
+
posts = db.query("SELECT * FROM posts WHERE user_id IN ?", user_ids)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Transaction Handling
|
|
216
|
+
|
|
217
|
+
**Bad:**
|
|
218
|
+
```python
|
|
219
|
+
db.transfer(a, b, amount) # No transaction
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Good:**
|
|
223
|
+
```python
|
|
224
|
+
with db.transaction():
|
|
225
|
+
db.transfer(a, b, amount)
|
|
226
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Security Review Guidelines
|
|
2
|
+
|
|
3
|
+
## OWASP Top 10 Coverage
|
|
4
|
+
|
|
5
|
+
### A01:2021 – Broken Access Control
|
|
6
|
+
- [ ] Users can only access their own data
|
|
7
|
+
- [ ] API endpoints have proper authentication
|
|
8
|
+
- [ ] Admin actions require admin role
|
|
9
|
+
- [ ] No IDOR (Insecure Direct Object References)
|
|
10
|
+
- [ ] Proper authorization checks on all endpoints
|
|
11
|
+
|
|
12
|
+
### A02:2021 – Cryptographic Failures
|
|
13
|
+
- [ ] Passwords are hashed (bcrypt/argon2)
|
|
14
|
+
- [ ] HTTPS is enforced
|
|
15
|
+
- [ ] Sensitive data is encrypted at rest
|
|
16
|
+
- [ ] No weak cipher suites
|
|
17
|
+
- [ ] Proper key management
|
|
18
|
+
|
|
19
|
+
### A03:2021 – Injection
|
|
20
|
+
- [ ] Parameterized queries for SQL
|
|
21
|
+
- [ ] Input validation and sanitization
|
|
22
|
+
- [ ] ORM used safely
|
|
23
|
+
- [ ] No command injection from user input
|
|
24
|
+
- [ ] No LDAP injection
|
|
25
|
+
|
|
26
|
+
### A04:2021 – Insecure Design
|
|
27
|
+
- [ ] Rate limiting on auth endpoints
|
|
28
|
+
- [ ] Proper logout functionality
|
|
29
|
+
- [ ] Session timeout is reasonable
|
|
30
|
+
- [ ] No security through obscurity
|
|
31
|
+
|
|
32
|
+
### A05:2021 – Security Misconfiguration
|
|
33
|
+
- [ ] Debug mode off in production
|
|
34
|
+
- [ ] Error messages don't leak information
|
|
35
|
+
- [ ] Default credentials changed
|
|
36
|
+
- [ ] Security headers configured
|
|
37
|
+
- [ ] CORS configured correctly
|
|
38
|
+
|
|
39
|
+
### A06:2021 – Vulnerable Components
|
|
40
|
+
- [ ] Dependencies up to date
|
|
41
|
+
- [ ] No known vulnerabilities in deps
|
|
42
|
+
- [ ] Unused dependencies removed
|
|
43
|
+
|
|
44
|
+
### A07:2021 – Auth Failures
|
|
45
|
+
- [ ] Strong password policy
|
|
46
|
+
- [ ] No brute force protection needed (rate limiting)
|
|
47
|
+
- [ ] MFA implemented for sensitive operations
|
|
48
|
+
- [ ] Session IDs are random
|
|
49
|
+
|
|
50
|
+
### A08:2021 – Software/Data Integrity
|
|
51
|
+
- [ ] Dependencies from trusted sources
|
|
52
|
+
- [ ] CI/CD has integrity checks
|
|
53
|
+
- [ ] Verify data integrity
|
|
54
|
+
|
|
55
|
+
### A09:2021 – Logging Failures
|
|
56
|
+
- [ ] Security events logged
|
|
57
|
+
- [ ] Logs don't contain sensitive data
|
|
58
|
+
- [ ] Log tampering protection
|
|
59
|
+
- [ ] Audit trail for critical operations
|
|
60
|
+
|
|
61
|
+
### A10:2021 – SSRF
|
|
62
|
+
- [ ] No arbitrary URL fetching from user input
|
|
63
|
+
- [ ] Allowlist for external calls
|
|
64
|
+
- [ ] Network segmentation
|
|
65
|
+
|
|
66
|
+
## Frontend Security
|
|
67
|
+
|
|
68
|
+
- [ ] XSS prevention
|
|
69
|
+
- [ ] CSRF tokens
|
|
70
|
+
- [ ] Content Security Policy
|
|
71
|
+
- [ ] Subresource Integrity
|
|
72
|
+
- [ ] No `dangerouslySetInnerHTML` with user content
|
|
73
|
+
|
|
74
|
+
## Backend Security
|
|
75
|
+
|
|
76
|
+
- [ ] Input validation on all endpoints
|
|
77
|
+
- [ ] Output encoding
|
|
78
|
+
- [ ] Prepared statements
|
|
79
|
+
- [ ] Principle of least privilege
|
|
80
|
+
- [ ] Secure file upload handling
|
|
81
|
+
|
|
82
|
+
## Infrastructure Security
|
|
83
|
+
|
|
84
|
+
- [ ] Secrets in environment variables
|
|
85
|
+
- [ ] No secrets in code
|
|
86
|
+
- [ ] Proper RBAC
|
|
87
|
+
- [ ] Network security rules
|
|
88
|
+
- [ ] Regular security updates
|