plan-flow-skill 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/commands/create-contract.md +468 -0
- package/.claude/commands/create-plan.md +512 -0
- package/.claude/commands/discovery-plan.md +561 -0
- package/.claude/commands/execute-plan.md +682 -0
- package/.claude/commands/review-code.md +459 -0
- package/.claude/commands/review-pr.md +651 -0
- package/.claude/commands/setup.md +1609 -0
- package/.claude/commands/write-tests.md +543 -0
- package/.claude/rules/core/allowed-patterns.md +175 -0
- package/.claude/rules/core/complexity-scoring.md +225 -0
- package/.claude/rules/core/forbidden-patterns.md +253 -0
- package/.claude/rules/languages/python-patterns.md +6 -0
- package/.claude/rules/languages/typescript-patterns.md +7 -0
- package/.claude/rules/patterns/contract-patterns.md +332 -0
- package/.claude/rules/patterns/discovery-patterns.md +342 -0
- package/.claude/rules/patterns/discovery-templates.md +319 -0
- package/.claude/rules/patterns/jest-patterns.md +482 -0
- package/.claude/rules/patterns/plans-patterns.md +225 -0
- package/.claude/rules/patterns/plans-templates.md +227 -0
- package/.claude/rules/patterns/pytest-patterns.md +457 -0
- package/.claude/rules/patterns/review-code-templates.md +305 -0
- package/.claude/rules/patterns/review-pr-patterns.md +360 -0
- package/.claude/rules/tools/auth-pr-tool.md +30 -0
- package/.claude/rules/tools/interactive-questions-tool.md +235 -0
- package/.claude/rules/tools/jest-testing-tool.md +73 -0
- package/.claude/rules/tools/plan-mode-tool.md +164 -0
- package/.claude/rules/tools/pytest-testing-tool.md +121 -0
- package/.claude/rules/tools/reference-expansion-tool.md +326 -0
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/dist/cli/commands/init.d.ts +6 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +139 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/handlers/claude.d.ts +9 -0
- package/dist/cli/handlers/claude.d.ts.map +1 -0
- package/dist/cli/handlers/claude.js +119 -0
- package/dist/cli/handlers/claude.js.map +1 -0
- package/dist/cli/handlers/codex.d.ts +9 -0
- package/dist/cli/handlers/codex.d.ts.map +1 -0
- package/dist/cli/handlers/codex.js +100 -0
- package/dist/cli/handlers/codex.js.map +1 -0
- package/dist/cli/handlers/cursor.d.ts +8 -0
- package/dist/cli/handlers/cursor.d.ts.map +1 -0
- package/dist/cli/handlers/cursor.js +34 -0
- package/dist/cli/handlers/cursor.js.map +1 -0
- package/dist/cli/handlers/openclaw.d.ts +8 -0
- package/dist/cli/handlers/openclaw.d.ts.map +1 -0
- package/dist/cli/handlers/openclaw.js +34 -0
- package/dist/cli/handlers/openclaw.js.map +1 -0
- package/dist/cli/handlers/shared.d.ts +9 -0
- package/dist/cli/handlers/shared.d.ts.map +1 -0
- package/dist/cli/handlers/shared.js +44 -0
- package/dist/cli/handlers/shared.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +43 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/types.d.ts +26 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +5 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/utils/files.d.ts +37 -0
- package/dist/cli/utils/files.d.ts.map +1 -0
- package/dist/cli/utils/files.js +122 -0
- package/dist/cli/utils/files.js.map +1 -0
- package/dist/cli/utils/logger.d.ts +11 -0
- package/dist/cli/utils/logger.d.ts.map +1 -0
- package/dist/cli/utils/logger.js +34 -0
- package/dist/cli/utils/logger.js.map +1 -0
- package/dist/cli/utils/prompts.d.ts +10 -0
- package/dist/cli/utils/prompts.d.ts.map +1 -0
- package/dist/cli/utils/prompts.js +65 -0
- package/dist/cli/utils/prompts.js.map +1 -0
- package/dist/test/setup.d.ts +5 -0
- package/dist/test/setup.d.ts.map +1 -0
- package/dist/test/setup.js +7 -0
- package/dist/test/setup.js.map +1 -0
- package/package.json +63 -0
- package/rules/core/_index.mdc +89 -0
- package/rules/core/allowed-patterns.mdc +185 -0
- package/rules/core/complexity-scoring.mdc +235 -0
- package/rules/core/forbidden-patterns.mdc +263 -0
- package/rules/languages/_index.mdc +80 -0
- package/rules/languages/python-patterns.mdc +188 -0
- package/rules/languages/typescript-patterns.mdc +128 -0
- package/rules/patterns/_index.mdc +185 -0
- package/rules/patterns/contract-patterns.mdc +344 -0
- package/rules/patterns/discovery-patterns.mdc +354 -0
- package/rules/patterns/discovery-templates.mdc +329 -0
- package/rules/patterns/jest-patterns.mdc +492 -0
- package/rules/patterns/plans-patterns.mdc +237 -0
- package/rules/patterns/plans-templates.mdc +237 -0
- package/rules/patterns/pytest-patterns.mdc +467 -0
- package/rules/patterns/review-code-templates.mdc +315 -0
- package/rules/patterns/review-pr-patterns.mdc +370 -0
- package/rules/skills/_index.mdc +174 -0
- package/rules/skills/create-contract-skill.mdc +239 -0
- package/rules/skills/create-plan-skill.mdc +271 -0
- package/rules/skills/discovery-skill.mdc +295 -0
- package/rules/skills/execute-plan-skill.mdc +388 -0
- package/rules/skills/review-code-skill.mdc +308 -0
- package/rules/skills/review-pr-skill.mdc +496 -0
- package/rules/skills/setup-skill.mdc +923 -0
- package/rules/skills/write-tests-skill.mdc +294 -0
- package/rules/templates/index-template.mdc +126 -0
- package/rules/tools/_index.mdc +114 -0
- package/rules/tools/auth-pr-tool.mdc +362 -0
- package/rules/tools/interactive-questions-tool.mdc +337 -0
- package/rules/tools/jest-testing-tool.mdc +96 -0
- package/rules/tools/plan-mode-tool.mdc +229 -0
- package/rules/tools/pytest-testing-tool.mdc +144 -0
- package/rules/tools/reference-expansion-tool.mdc +338 -0
- package/skills/plan-flow/SKILL.md +109 -0
- package/skills/plan-flow/create-contract/SKILL.md +139 -0
- package/skills/plan-flow/create-plan/SKILL.md +93 -0
- package/skills/plan-flow/discovery/SKILL.md +85 -0
- package/skills/plan-flow/execute-plan/SKILL.md +89 -0
- package/skills/plan-flow/review-code/SKILL.md +100 -0
- package/skills/plan-flow/review-pr/SKILL.md +122 -0
- package/skills/plan-flow/setup/SKILL.md +73 -0
- package/skills/plan-flow/write-tests/SKILL.md +115 -0
- package/templates/shared/AGENTS.md.template +60 -0
- package/templates/shared/CLAUDE.md.template +62 -0
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: This command reviews local uncommitted changes by invoking the `review-code` skill. The command vali
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Review Code Command
|
|
6
|
+
|
|
7
|
+
## Command Description
|
|
8
|
+
|
|
9
|
+
This command reviews local uncommitted changes by invoking the `review-code` skill. The command validates inputs and orchestrates the review process.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Help
|
|
15
|
+
|
|
16
|
+
**If the user invokes this command with `-help`, display only this section and stop:**
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
/review-code - Review Local Code Changes
|
|
20
|
+
|
|
21
|
+
DESCRIPTION:
|
|
22
|
+
Reviews local uncommitted changes against project patterns and best
|
|
23
|
+
practices. Generates a detailed review document.
|
|
24
|
+
|
|
25
|
+
USAGE:
|
|
26
|
+
/review-code [file_path] [--scope <staged|unstaged>]
|
|
27
|
+
/review-code -help
|
|
28
|
+
|
|
29
|
+
ARGUMENTS:
|
|
30
|
+
file_path Optional. Specific file to review (reviews all if not provided)
|
|
31
|
+
--scope Optional. "staged" or "unstaged" (reviews both if not provided)
|
|
32
|
+
|
|
33
|
+
EXAMPLES:
|
|
34
|
+
/review-code # Review all changes
|
|
35
|
+
/review-code --scope staged # Review only staged changes
|
|
36
|
+
/review-code src/services/userService.ts # Review specific file
|
|
37
|
+
/review-code src/api --scope unstaged # Review unstaged in directory
|
|
38
|
+
|
|
39
|
+
OUTPUT:
|
|
40
|
+
Creates: flow/reviewed-code/<filename>.md
|
|
41
|
+
|
|
42
|
+
WORKFLOW:
|
|
43
|
+
1. Identifies changed files via git diff
|
|
44
|
+
2. Loads review patterns from project rules
|
|
45
|
+
3. Finds similar implementations in codebase
|
|
46
|
+
4. Compares against existing patterns
|
|
47
|
+
5. Generates review document with findings
|
|
48
|
+
|
|
49
|
+
REVIEW CATEGORIES:
|
|
50
|
+
- Pattern compliance
|
|
51
|
+
- Code quality issues
|
|
52
|
+
- Potential bugs
|
|
53
|
+
- Performance concerns
|
|
54
|
+
- Security considerations
|
|
55
|
+
|
|
56
|
+
RECOMMENDED MODEL:
|
|
57
|
+
Claude Opus 4.5 or Sonnet 4.5 for best results
|
|
58
|
+
|
|
59
|
+
RELATED COMMANDS:
|
|
60
|
+
/review-pr Review a Pull Request instead
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Critical Rules
|
|
66
|
+
|
|
67
|
+
| Rule | Description |
|
|
68
|
+
| ------------------------ | -------------------------------------------------------- |
|
|
69
|
+
| **Read-Only Analysis** | This command ONLY produces a review document |
|
|
70
|
+
| **Complete and Stop** | After presenting results, STOP and wait for user |
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Instructions
|
|
75
|
+
|
|
76
|
+
### Step 1: Validate Inputs
|
|
77
|
+
|
|
78
|
+
| Input | Required | Description |
|
|
79
|
+
|-------|----------|-------------|
|
|
80
|
+
| `file_path` | No | Specific file to review (if not provided, reviews all changes) |
|
|
81
|
+
| `scope` | No | `staged` or `unstaged` (if not provided, reviews both) |
|
|
82
|
+
| `language` | No | Primary language (auto-detected if not provided) |
|
|
83
|
+
|
|
84
|
+
### Step 2: Check for Changes
|
|
85
|
+
|
|
86
|
+
Verify there are changes to review using `git diff`.
|
|
87
|
+
|
|
88
|
+
### Step 3: Invoke Review Code Skill
|
|
89
|
+
|
|
90
|
+
The skill will:
|
|
91
|
+
1. Identify changed files
|
|
92
|
+
2. Load review patterns
|
|
93
|
+
3. Find similar implementations in codebase
|
|
94
|
+
4. Compare patterns against existing code
|
|
95
|
+
5. Generate review document
|
|
96
|
+
|
|
97
|
+
### Step 4: Present Results
|
|
98
|
+
|
|
99
|
+
**Review document created**: `flow/reviewed-code/{filename}.md`
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Example Usage
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Review all changes
|
|
107
|
+
review-code
|
|
108
|
+
|
|
109
|
+
# Review only staged changes
|
|
110
|
+
review-code --scope staged
|
|
111
|
+
|
|
112
|
+
# Review a specific file
|
|
113
|
+
review-code src/services/userService.ts
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Context Optimization
|
|
119
|
+
|
|
120
|
+
This command uses hierarchical context loading to reduce context consumption. Instead of loading full files, load indexes first and expand specific sections on-demand.
|
|
121
|
+
|
|
122
|
+
### Recommended Loading Order
|
|
123
|
+
|
|
124
|
+
1. **Always load first**: This command file (`commands/review-code.md`)
|
|
125
|
+
2. **Load indexes**: Load `_index.md` files for relevant folders
|
|
126
|
+
3. **Expand on-demand**: Use reference codes to load specific sections when needed
|
|
127
|
+
|
|
128
|
+
### Index Files for Code Review
|
|
129
|
+
|
|
130
|
+
| Index | When to Load |
|
|
131
|
+
|-------|--------------|
|
|
132
|
+
| `rules/skills/_index.md` | To understand review workflow |
|
|
133
|
+
| `rules/patterns/_index.md` | For review patterns and templates |
|
|
134
|
+
| `rules/core/_index.md` | For allowed/forbidden patterns reference |
|
|
135
|
+
|
|
136
|
+
### Reference Codes for Code Review
|
|
137
|
+
|
|
138
|
+
| Code | Description | When to Expand |
|
|
139
|
+
|------|-------------|----------------|
|
|
140
|
+
| SKL-REV-1 | Review code skill workflow | Understanding full process |
|
|
141
|
+
| PTN-REV-1 | Review document structure | Creating review output |
|
|
142
|
+
| COR-AP-1 | Allowed patterns overview | Checking pattern compliance |
|
|
143
|
+
| COR-FP-1 | Forbidden patterns overview | Identifying anti-patterns |
|
|
144
|
+
|
|
145
|
+
### Expansion Instructions
|
|
146
|
+
|
|
147
|
+
When executing this command:
|
|
148
|
+
|
|
149
|
+
1. **Start with indexes**: Read `rules/skills/_index.md` and `rules/patterns/_index.md`
|
|
150
|
+
2. **Identify needed codes**: Based on detected language/framework, expand relevant patterns
|
|
151
|
+
3. **Expand as needed**: Use the Read tool with specific line ranges from the index
|
|
152
|
+
4. **Don't expand everything**: Only load patterns relevant to the files being reviewed
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Related Resources
|
|
157
|
+
|
|
158
|
+
| Resource | Purpose |
|
|
159
|
+
| ------------------------------ | -------------------------------------- |
|
|
160
|
+
| `rules/skills/_index.md` | Index of skills with reference codes |
|
|
161
|
+
| `rules/patterns/_index.md` | Index of patterns with reference codes |
|
|
162
|
+
| `rules/core/_index.md` | Index of core rules with reference codes |
|
|
163
|
+
| `review-code-skill.md` | Skill that executes the review |
|
|
164
|
+
| `review-pr-patterns.md` | Review patterns and guidelines |
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
# Implementation Details
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
## Restrictions - READ ONLY
|
|
172
|
+
|
|
173
|
+
This skill is **strictly read-only analysis**. The review process:
|
|
174
|
+
|
|
175
|
+
1. **Reads** the local diff (staged and unstaged changes)
|
|
176
|
+
2. **Searches** the codebase for similar implementations as reference
|
|
177
|
+
3. **Analyzes** changes against patterns and guidelines
|
|
178
|
+
4. **Generates** a markdown file with findings and recommendations
|
|
179
|
+
|
|
180
|
+
**No code modification, no commits, no builds.**
|
|
181
|
+
|
|
182
|
+
### NEVER Do These Actions
|
|
183
|
+
|
|
184
|
+
| Forbidden Action | Reason |
|
|
185
|
+
| ------------------------------------- | ------------------------------------------ |
|
|
186
|
+
| Edit/modify any source code | No code changes - review produces findings |
|
|
187
|
+
| `git commit` | No commits |
|
|
188
|
+
| `git add` | No staging changes |
|
|
189
|
+
| `git checkout` | No discarding changes |
|
|
190
|
+
| `git reset` | No resetting changes |
|
|
191
|
+
| `npm run build` | No build commands |
|
|
192
|
+
| `npm run test` | No test commands |
|
|
193
|
+
| Create/edit files outside `flow/` | Only write to `flow/reviewed-code/` |
|
|
194
|
+
|
|
195
|
+
### Allowed Actions
|
|
196
|
+
|
|
197
|
+
| Allowed Action | Purpose |
|
|
198
|
+
| -------------------------------------- | ------------------------------- |
|
|
199
|
+
| `git status` | List changed files |
|
|
200
|
+
| `git diff` | View uncommitted changes |
|
|
201
|
+
| `git diff --cached` | View staged changes |
|
|
202
|
+
| `git diff --name-only` | List changed file names |
|
|
203
|
+
| `git log` (read only) | View commit history for context |
|
|
204
|
+
| Read any project file | Find similar implementations |
|
|
205
|
+
| Search codebase (grep, glob, semantic) | Find reference patterns |
|
|
206
|
+
| Write to `flow/reviewed-code/` | Save review notes locally |
|
|
207
|
+
| Read project rule files | Load patterns for analysis |
|
|
208
|
+
|
|
209
|
+
> **Important**: The ONLY writable location is `flow/reviewed-code/`. No source code, configuration files, or any other project files should be modified.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Inputs
|
|
214
|
+
|
|
215
|
+
| Input | Required | Description |
|
|
216
|
+
| ----------- | -------- | ---------------------------------------------------- |
|
|
217
|
+
| `file_path` | Optional | Specific file(s) to review (defaults to all changed) |
|
|
218
|
+
| `language` | Optional | Primary language (auto-detected if not provided) |
|
|
219
|
+
| `scope` | Optional | `all` (default), `staged`, or `unstaged` changes |
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Workflow
|
|
224
|
+
|
|
225
|
+
### Step 1: Identify Changed Files
|
|
226
|
+
|
|
227
|
+
1. Run `git status` to identify all changed files
|
|
228
|
+
2. Run `git diff --name-only` to get list of unstaged changes
|
|
229
|
+
3. Run `git diff --cached --name-only` to get list of staged changes
|
|
230
|
+
4. If `file_path` is provided, filter to only those files
|
|
231
|
+
5. If `scope` is provided, filter to staged or unstaged only
|
|
232
|
+
|
|
233
|
+
### Step 2: Load Review Patterns
|
|
234
|
+
|
|
235
|
+
1. Read `.claude/rules/patterns/review-pr-patterns.md` for general review guidelines
|
|
236
|
+
2. Based on the detected language(s), load the appropriate pattern file:
|
|
237
|
+
- **TypeScript/JavaScript**: Load `.claude/rules/languages/typescript-patterns.md`
|
|
238
|
+
- **Python**: Load `.claude/rules/languages/python-patterns.md`
|
|
239
|
+
3. Cross-reference with `.claude/rules/core/forbidden-patterns.md` for anti-patterns to flag
|
|
240
|
+
4. Cross-reference with `.claude/rules/core/allowed-patterns.md` for best practices to encourage
|
|
241
|
+
5. Use the [`complexity-scoring` pattern](../core/complexity-scoring.md) for fix complexity scoring
|
|
242
|
+
|
|
243
|
+
### Step 3: Find Similar Implementations in Codebase
|
|
244
|
+
|
|
245
|
+
**This is a critical step that differentiates this from PR review.**
|
|
246
|
+
|
|
247
|
+
For each changed file:
|
|
248
|
+
|
|
249
|
+
1. **Identify the type of code being written**:
|
|
250
|
+
|
|
251
|
+
- Component? Search for similar components
|
|
252
|
+
- Utility function? Search for similar utilities
|
|
253
|
+
- API route? Search for similar routes
|
|
254
|
+
- Hook? Search for similar hooks
|
|
255
|
+
- Type/interface? Search for similar type definitions
|
|
256
|
+
|
|
257
|
+
2. **Search for existing patterns in the codebase**:
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# Example searches to find similar code
|
|
261
|
+
# For components:
|
|
262
|
+
grep -r "export const" --include="*.tsx" src/components/
|
|
263
|
+
|
|
264
|
+
# For hooks:
|
|
265
|
+
grep -r "export function use" --include="*.ts" src/hooks/
|
|
266
|
+
|
|
267
|
+
# For API routes:
|
|
268
|
+
grep -r "export async function" --include="route.ts" src/app/api/
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
3. **Document the reference implementations found**:
|
|
272
|
+
|
|
273
|
+
- File path of similar code
|
|
274
|
+
- Key patterns used in that code
|
|
275
|
+
- How the new code differs (if at all)
|
|
276
|
+
|
|
277
|
+
4. **Flag pattern inconsistencies**:
|
|
278
|
+
- New code uses a different pattern than existing code
|
|
279
|
+
- New code introduces a pattern not documented in rules
|
|
280
|
+
- New code conflicts with established patterns
|
|
281
|
+
|
|
282
|
+
### Step 4: Analyze Code Changes
|
|
283
|
+
|
|
284
|
+
For each changed file:
|
|
285
|
+
|
|
286
|
+
1. Review the diff/changes using `git diff {file_path}`
|
|
287
|
+
2. Check for violations of forbidden patterns
|
|
288
|
+
3. Verify adherence to allowed patterns
|
|
289
|
+
4. Apply language-specific checks
|
|
290
|
+
5. **Compare against similar implementations found in Step 3**
|
|
291
|
+
6. Identify security, performance, and maintainability concerns
|
|
292
|
+
7. **Flag any pattern conflicts with existing codebase**
|
|
293
|
+
|
|
294
|
+
### Step 5: Identify Pattern Conflicts
|
|
295
|
+
|
|
296
|
+
**This is unique to local code review.**
|
|
297
|
+
|
|
298
|
+
When a pattern conflict is found:
|
|
299
|
+
|
|
300
|
+
1. **Document the conflict**:
|
|
301
|
+
|
|
302
|
+
- What pattern the new code uses
|
|
303
|
+
- What pattern exists in similar code
|
|
304
|
+
- Which file(s) contain the reference pattern
|
|
305
|
+
|
|
306
|
+
2. **Determine the correct resolution**:
|
|
307
|
+
|
|
308
|
+
- If existing pattern is better → recommend changing new code
|
|
309
|
+
- If new pattern is better → recommend updating rules AND existing code
|
|
310
|
+
- If unclear → flag for team discussion
|
|
311
|
+
|
|
312
|
+
3. **Generate rule update recommendations**:
|
|
313
|
+
- Suggest additions to `.claude/rules/core/allowed-patterns.md`
|
|
314
|
+
- Suggest additions to `.claude/rules/core/forbidden-patterns.md`
|
|
315
|
+
|
|
316
|
+
### Step 6: Generate Review Document
|
|
317
|
+
|
|
318
|
+
Create a markdown file in `flow/reviewed-code/` with the naming convention:
|
|
319
|
+
|
|
320
|
+
```
|
|
321
|
+
code-review-{date}-{sanitized-description}.md
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Example**: For changes related to user authentication:
|
|
325
|
+
|
|
326
|
+
```
|
|
327
|
+
flow/reviewed-code/code-review-2026-01-14-user-authentication.md
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
**Output Format**: Use the templates from `.claude/rules/patterns/review-code-templates.md`
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Severity Levels
|
|
335
|
+
|
|
336
|
+
| Level | Description |
|
|
337
|
+
| ---------- | -------------------------------------------------------- |
|
|
338
|
+
| Critical | Security vulnerabilities, data loss risks, blocking bugs |
|
|
339
|
+
| Major | Significant issues affecting functionality or quality |
|
|
340
|
+
| Minor | Code style, minor improvements, non-critical concerns |
|
|
341
|
+
| Suggestion | Nice-to-have improvements, optional enhancements |
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## Pattern Conflict Resolution
|
|
346
|
+
|
|
347
|
+
When a conflict is found between new code and existing patterns:
|
|
348
|
+
|
|
349
|
+
### Option 1: Update New Code (Recommended for established patterns)
|
|
350
|
+
|
|
351
|
+
If the existing pattern is:
|
|
352
|
+
|
|
353
|
+
- Documented in rules files
|
|
354
|
+
- Used consistently across the codebase
|
|
355
|
+
- Has clear benefits
|
|
356
|
+
|
|
357
|
+
**Action**: Update the new code to match the existing pattern.
|
|
358
|
+
|
|
359
|
+
### Option 2: Update Rules (For better new patterns)
|
|
360
|
+
|
|
361
|
+
If the new pattern is:
|
|
362
|
+
|
|
363
|
+
- Demonstrably better than existing
|
|
364
|
+
- More maintainable or readable
|
|
365
|
+
- Follows best practices that existing code doesn't
|
|
366
|
+
|
|
367
|
+
**Action**:
|
|
368
|
+
|
|
369
|
+
1. Document the new pattern in `allowed-patterns.md`
|
|
370
|
+
2. Add the old pattern to `forbidden-patterns.md`
|
|
371
|
+
3. Create a task to refactor existing code (optional)
|
|
372
|
+
|
|
373
|
+
### Option 3: Team Discussion (For unclear cases)
|
|
374
|
+
|
|
375
|
+
If:
|
|
376
|
+
|
|
377
|
+
- Both patterns have valid trade-offs
|
|
378
|
+
- Team preference is unclear
|
|
379
|
+
- Architectural decision is required
|
|
380
|
+
|
|
381
|
+
**Action**: Flag for team discussion before committing.
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## Finding Similar Implementations
|
|
386
|
+
|
|
387
|
+
### Search Strategies by Code Type
|
|
388
|
+
|
|
389
|
+
| Code Type | Search Strategy |
|
|
390
|
+
| --------------- | -------------------------------------------------------- |
|
|
391
|
+
| React Component | Search `src/components/` for similar component structure |
|
|
392
|
+
| Custom Hook | Search `src/hooks/` for similar hook patterns |
|
|
393
|
+
| Utility | Search `src/utils/` for similar utility functions |
|
|
394
|
+
| API Route | Search `src/app/api/` for similar route handlers |
|
|
395
|
+
| Type Definition | Search `src/types/` for similar type structures |
|
|
396
|
+
| Store/State | Search `src/stores/` for similar state management |
|
|
397
|
+
| Test File | Search `__tests__/` for similar test patterns |
|
|
398
|
+
|
|
399
|
+
### Key Aspects to Compare
|
|
400
|
+
|
|
401
|
+
When comparing new code with reference implementations:
|
|
402
|
+
|
|
403
|
+
1. **Naming Conventions**: Do variable/function names follow the same pattern?
|
|
404
|
+
2. **Error Handling**: Is error handling consistent?
|
|
405
|
+
3. **Type Definitions**: Are types structured similarly?
|
|
406
|
+
4. **Code Organization**: Is the file structure consistent?
|
|
407
|
+
5. **Comments/Documentation**: Does documentation follow the same style?
|
|
408
|
+
6. **Import Structure**: Are imports organized the same way?
|
|
409
|
+
7. **Export Patterns**: Default vs named exports consistency?
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
## Quick Reference Commands
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
# Review all uncommitted changes
|
|
417
|
+
review-code
|
|
418
|
+
|
|
419
|
+
# Review specific file
|
|
420
|
+
review-code src/services/userService.ts
|
|
421
|
+
|
|
422
|
+
# Review only staged changes
|
|
423
|
+
review-code --scope staged
|
|
424
|
+
|
|
425
|
+
# Review only unstaged changes
|
|
426
|
+
review-code --scope unstaged
|
|
427
|
+
|
|
428
|
+
# Review with explicit language
|
|
429
|
+
review-code --language typescript
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## Related Files
|
|
435
|
+
|
|
436
|
+
| File | Purpose |
|
|
437
|
+
| -------------------------------------------------- | ------------------------------------ |
|
|
438
|
+
| `.claude/rules/patterns/review-pr-patterns.md` | Main review checklist and guidelines |
|
|
439
|
+
| `.claude/rules/patterns/review-code-templates.md` | Output templates for review docs |
|
|
440
|
+
| `.claude/rules/core/forbidden-patterns.md` | Anti-patterns to flag |
|
|
441
|
+
| `.claude/rules/core/allowed-patterns.md` | Best practices to encourage |
|
|
442
|
+
| `.claude/rules/languages/typescript-patterns.md` | TypeScript-specific checks |
|
|
443
|
+
| `.claude/rules/languages/python-patterns.md` | Python-specific checks |
|
|
444
|
+
| `.claude/rules/core/complexity-scoring.md` | Fix complexity scoring system |
|
|
445
|
+
| `flow/reviewed-code/` | Output folder for review documents |
|
|
446
|
+
|
|
447
|
+
---
|
|
448
|
+
|
|
449
|
+
## Workflow Integration
|
|
450
|
+
|
|
451
|
+
After running this command:
|
|
452
|
+
|
|
453
|
+
1. **Review the generated document** in `flow/reviewed-code/`
|
|
454
|
+
2. **Address Critical and Major findings** before committing
|
|
455
|
+
3. **Resolve pattern conflicts** by choosing the appropriate resolution
|
|
456
|
+
4. **Update rule files** if recommended (add to allowed/forbidden patterns)
|
|
457
|
+
5. **Commit changes** once review concerns are addressed
|
|
458
|
+
|
|
459
|
+
> The goal is not just to review current changes, but to **improve the codebase patterns over time** by documenting good patterns and preventing anti-patterns from spreading.
|