create-dev-agents 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/LICENSE +21 -0
- package/README.md +263 -0
- package/bin/cli.js +74 -0
- package/package.json +54 -0
- package/src/index.js +339 -0
- package/templates/CLAUDE.md +38 -0
- package/templates/agents/code-review/review.md +158 -0
- package/templates/agents/feature/develop.md +113 -0
- package/templates/agents/git/commit-pr.md +222 -0
- package/templates/agents/jira/ticket.md +148 -0
- package/templates/agents/project/scaffold.md +118 -0
- package/templates/commands/commit.md +130 -0
- package/templates/commands/feature.md +99 -0
- package/templates/commands/new-project.md +325 -0
- package/templates/commands/pr.md +175 -0
- package/templates/commands/review.md +200 -0
- package/templates/commands/ticket.md +135 -0
- package/templates/commit/examples.md +149 -0
- package/templates/jira/bug.md +49 -0
- package/templates/jira/story.md +36 -0
- package/templates/mcp-settings.json +32 -0
- package/templates/pr/bugfix.md +57 -0
- package/templates/pr/feature.md +48 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# /new-project - Create a New Project
|
|
2
|
+
|
|
3
|
+
Create a new project with interactive setup for all configurations.
|
|
4
|
+
|
|
5
|
+
## Instructions
|
|
6
|
+
|
|
7
|
+
When the user runs `/new-project`, guide them through these choices using the AskUserQuestion tool for each step.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
### Step 1: Project Type
|
|
12
|
+
|
|
13
|
+
Ask: **"What type of project do you want to create?"**
|
|
14
|
+
|
|
15
|
+
Options:
|
|
16
|
+
1. **Expo (React Native)** - Mobile app with Expo SDK (iOS, Android, Web)
|
|
17
|
+
2. **React Native CLI** - Mobile app without Expo managed workflow
|
|
18
|
+
3. **Next.js** - Full-stack React framework with App Router
|
|
19
|
+
4. **React (Vite)** - Fast single-page application
|
|
20
|
+
5. **React (CRA)** - Create React App (legacy)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
### Step 2: Project Name & Location
|
|
25
|
+
|
|
26
|
+
Ask:
|
|
27
|
+
- **"What's your project name?"** (lowercase, hyphens allowed)
|
|
28
|
+
- **"Where should I create it?"** (default: `./<project-name>`)
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### Step 3: Architecture Pattern
|
|
33
|
+
|
|
34
|
+
Based on project type, ask: **"Which architecture pattern?"**
|
|
35
|
+
|
|
36
|
+
**For Mobile (Expo/RN):**
|
|
37
|
+
1. **Feature-based (Recommended)** - Group by feature with colocation
|
|
38
|
+
```
|
|
39
|
+
src/features/auth/{components,hooks,services,types}
|
|
40
|
+
src/features/notes/{components,hooks,services,types}
|
|
41
|
+
```
|
|
42
|
+
2. **Layer-based** - Traditional separation by type
|
|
43
|
+
```
|
|
44
|
+
src/components/
|
|
45
|
+
src/hooks/
|
|
46
|
+
src/services/
|
|
47
|
+
```
|
|
48
|
+
3. **Domain-driven** - Organize by business domain
|
|
49
|
+
|
|
50
|
+
**For Next.js:**
|
|
51
|
+
1. **App Router + Feature modules (Recommended)**
|
|
52
|
+
2. **App Router + Colocation** - Keep related files together
|
|
53
|
+
3. **Pages Router** - Traditional Next.js structure
|
|
54
|
+
|
|
55
|
+
**For React (Vite):**
|
|
56
|
+
1. **Feature-based (Recommended)**
|
|
57
|
+
2. **Atomic Design** - atoms/molecules/organisms/templates/pages
|
|
58
|
+
3. **Component-driven** - Flat component structure
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### Step 4: TypeScript Configuration
|
|
63
|
+
|
|
64
|
+
Ask: **"TypeScript strictness level?"**
|
|
65
|
+
|
|
66
|
+
1. **Strict (Recommended)** - All strict checks enabled
|
|
67
|
+
2. **Standard** - Default TypeScript config
|
|
68
|
+
3. **Relaxed** - Minimal type checking
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### Step 5: Styling Solution
|
|
73
|
+
|
|
74
|
+
Ask: **"How do you want to handle styling?"**
|
|
75
|
+
|
|
76
|
+
**For Mobile:**
|
|
77
|
+
1. **StyleSheet (Recommended)** - React Native default
|
|
78
|
+
2. **NativeWind** - Tailwind CSS for React Native
|
|
79
|
+
3. **Styled Components** - CSS-in-JS
|
|
80
|
+
4. **Tamagui** - Universal design system
|
|
81
|
+
|
|
82
|
+
**For Web (Next.js/React):**
|
|
83
|
+
1. **Tailwind CSS (Recommended)** - Utility-first CSS
|
|
84
|
+
2. **CSS Modules** - Scoped CSS files
|
|
85
|
+
3. **Styled Components** - CSS-in-JS
|
|
86
|
+
4. **Vanilla CSS** - Plain CSS files
|
|
87
|
+
5. **Sass/SCSS** - CSS preprocessor
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### Step 6: State Management
|
|
92
|
+
|
|
93
|
+
Ask: **"Which state management solution?"**
|
|
94
|
+
|
|
95
|
+
1. **Zustand (Recommended)** - Simple, fast, minimal boilerplate
|
|
96
|
+
2. **TanStack Query** - Server state + caching (pair with Zustand for client state)
|
|
97
|
+
3. **Redux Toolkit** - Full-featured, good for complex apps
|
|
98
|
+
4. **Jotai** - Atomic state management
|
|
99
|
+
5. **Context API only** - Built-in React, good for simple apps
|
|
100
|
+
6. **None** - I'll add it later
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### Step 7: Data Fetching (for Web)
|
|
105
|
+
|
|
106
|
+
Ask: **"Data fetching approach?"** (Skip for mobile with local DB)
|
|
107
|
+
|
|
108
|
+
1. **TanStack Query (Recommended)** - Caching, refetching, mutations
|
|
109
|
+
2. **SWR** - Stale-while-revalidate
|
|
110
|
+
3. **Fetch/Axios only** - Manual implementation
|
|
111
|
+
4. **tRPC** - End-to-end typesafe APIs (Next.js)
|
|
112
|
+
5. **None** - No API calls needed
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### Step 8: Database (if applicable)
|
|
117
|
+
|
|
118
|
+
Ask: **"Do you need a database?"**
|
|
119
|
+
|
|
120
|
+
**For Mobile:**
|
|
121
|
+
1. **SQLite (expo-sqlite)** - Local relational database
|
|
122
|
+
2. **WatermelonDB** - High-performance local DB
|
|
123
|
+
3. **MMKV** - Fast key-value storage only
|
|
124
|
+
4. **None** - No local database
|
|
125
|
+
|
|
126
|
+
**For Next.js:**
|
|
127
|
+
1. **Prisma** - Type-safe ORM
|
|
128
|
+
2. **Drizzle** - Lightweight TypeScript ORM
|
|
129
|
+
3. **None** - No database / external API only
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
### Step 9: Authentication (optional)
|
|
134
|
+
|
|
135
|
+
Ask: **"Need authentication setup?"**
|
|
136
|
+
|
|
137
|
+
**For Mobile:**
|
|
138
|
+
1. **None** - I'll handle it myself
|
|
139
|
+
2. **Firebase Auth** - Google's auth service
|
|
140
|
+
3. **Supabase Auth** - Open source alternative
|
|
141
|
+
4. **Clerk** - Drop-in auth components
|
|
142
|
+
|
|
143
|
+
**For Next.js:**
|
|
144
|
+
1. **None** - I'll handle it myself
|
|
145
|
+
2. **NextAuth.js** - Flexible auth for Next.js
|
|
146
|
+
3. **Clerk** - Drop-in auth components
|
|
147
|
+
4. **Supabase Auth** - Open source BaaS
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### Step 10: Testing Setup
|
|
152
|
+
|
|
153
|
+
Ask: **"Which testing setup?"**
|
|
154
|
+
|
|
155
|
+
1. **Full (Recommended)** - Unit + Integration + E2E ready
|
|
156
|
+
- Jest + React Testing Library
|
|
157
|
+
- E2E framework configured (Playwright/Detox)
|
|
158
|
+
2. **Standard** - Unit + Integration tests
|
|
159
|
+
- Jest + React Testing Library
|
|
160
|
+
3. **Minimal** - Jest configured, no tests written
|
|
161
|
+
4. **Vitest** - Vite-native testing (for Vite projects)
|
|
162
|
+
5. **None** - No testing setup
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
### Step 11: Linting & Formatting
|
|
167
|
+
|
|
168
|
+
Ask: **"Code quality tools?"**
|
|
169
|
+
|
|
170
|
+
1. **Full (Recommended)** - ESLint + Prettier + Husky
|
|
171
|
+
- Pre-commit hooks
|
|
172
|
+
- Lint-staged
|
|
173
|
+
- Auto-fix on save
|
|
174
|
+
2. **Standard** - ESLint + Prettier (no hooks)
|
|
175
|
+
3. **ESLint only** - Linting without formatting
|
|
176
|
+
4. **Biome** - Fast all-in-one linter/formatter
|
|
177
|
+
5. **None** - No linting setup
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
### Step 12: Additional Features
|
|
182
|
+
|
|
183
|
+
Ask: **"Select additional features:"** (multi-select)
|
|
184
|
+
|
|
185
|
+
- [ ] **Path aliases** - `@/components`, `@/utils` imports
|
|
186
|
+
- [ ] **Environment variables** - `.env` setup with validation
|
|
187
|
+
- [ ] **CI/CD** - GitHub Actions workflow
|
|
188
|
+
- [ ] **Docker** - Dockerfile and docker-compose
|
|
189
|
+
- [ ] **Storybook** - Component documentation (web)
|
|
190
|
+
- [ ] **i18n** - Internationalization setup
|
|
191
|
+
- [ ] **PWA** - Progressive Web App (Next.js/React)
|
|
192
|
+
- [ ] **Analytics** - Basic analytics setup
|
|
193
|
+
- [ ] **Error tracking** - Sentry integration
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
### Step 13: Confirmation
|
|
198
|
+
|
|
199
|
+
Show summary of all selections:
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
📦 Project Summary
|
|
203
|
+
─────────────────────────────────
|
|
204
|
+
Name: my-awesome-app
|
|
205
|
+
Type: Expo (React Native)
|
|
206
|
+
Architecture: Feature-based
|
|
207
|
+
TypeScript: Strict
|
|
208
|
+
Styling: NativeWind
|
|
209
|
+
State: Zustand
|
|
210
|
+
Database: SQLite
|
|
211
|
+
Testing: Full (Jest + Detox)
|
|
212
|
+
Linting: Full (ESLint + Prettier + Husky)
|
|
213
|
+
Extras: Path aliases, CI/CD, Environment variables
|
|
214
|
+
─────────────────────────────────
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Ask: **"Create this project?"** (Yes / Modify / Cancel)
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
### Step 14: Generate Project
|
|
222
|
+
|
|
223
|
+
After confirmation:
|
|
224
|
+
|
|
225
|
+
1. **Create project directory**
|
|
226
|
+
2. **Initialize with template** (npx create-expo-app, etc.)
|
|
227
|
+
3. **Create folder structure** based on architecture
|
|
228
|
+
4. **Install dependencies** for selected options
|
|
229
|
+
5. **Configure TypeScript** with selected strictness
|
|
230
|
+
6. **Set up styling** solution
|
|
231
|
+
7. **Configure state management**
|
|
232
|
+
8. **Set up testing** framework
|
|
233
|
+
9. **Configure linting** and formatting
|
|
234
|
+
10. **Add selected extras**
|
|
235
|
+
11. **Create CLAUDE.md** with project context
|
|
236
|
+
12. **Initialize git** repository
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Output
|
|
241
|
+
|
|
242
|
+
After completion, show:
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
✅ Project created successfully!
|
|
246
|
+
|
|
247
|
+
📁 my-awesome-app/
|
|
248
|
+
├── src/
|
|
249
|
+
│ ├── features/
|
|
250
|
+
│ ├── components/
|
|
251
|
+
│ ├── hooks/
|
|
252
|
+
│ └── ...
|
|
253
|
+
├── package.json
|
|
254
|
+
├── tsconfig.json
|
|
255
|
+
├── .eslintrc.js
|
|
256
|
+
├── .prettierrc
|
|
257
|
+
└── CLAUDE.md
|
|
258
|
+
|
|
259
|
+
📋 Next steps:
|
|
260
|
+
cd my-awesome-app
|
|
261
|
+
npm install
|
|
262
|
+
npm start
|
|
263
|
+
|
|
264
|
+
🛠️ Available scripts:
|
|
265
|
+
npm start - Start development server
|
|
266
|
+
npm test - Run tests
|
|
267
|
+
npm run lint - Check code quality
|
|
268
|
+
npm run build - Build for production
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Configuration Files to Generate
|
|
274
|
+
|
|
275
|
+
### ESLint (.eslintrc.js)
|
|
276
|
+
```javascript
|
|
277
|
+
module.exports = {
|
|
278
|
+
extends: [
|
|
279
|
+
'eslint:recommended',
|
|
280
|
+
'plugin:@typescript-eslint/recommended',
|
|
281
|
+
'plugin:react/recommended',
|
|
282
|
+
'plugin:react-hooks/recommended',
|
|
283
|
+
'prettier'
|
|
284
|
+
],
|
|
285
|
+
// ... based on project type
|
|
286
|
+
};
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Prettier (.prettierrc)
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"semi": true,
|
|
293
|
+
"singleQuote": true,
|
|
294
|
+
"tabWidth": 2,
|
|
295
|
+
"trailingComma": "es5",
|
|
296
|
+
"printWidth": 100
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### TypeScript (tsconfig.json)
|
|
301
|
+
```json
|
|
302
|
+
{
|
|
303
|
+
"compilerOptions": {
|
|
304
|
+
"strict": true, // Based on selection
|
|
305
|
+
"baseUrl": ".",
|
|
306
|
+
"paths": {
|
|
307
|
+
"@/*": ["src/*"]
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Husky (pre-commit)
|
|
314
|
+
```bash
|
|
315
|
+
#!/bin/sh
|
|
316
|
+
npx lint-staged
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### lint-staged (.lintstagedrc)
|
|
320
|
+
```json
|
|
321
|
+
{
|
|
322
|
+
"*.{ts,tsx}": ["eslint --fix", "prettier --write"],
|
|
323
|
+
"*.{json,md}": ["prettier --write"]
|
|
324
|
+
}
|
|
325
|
+
```
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# /pr - Create a Pull Request
|
|
2
|
+
|
|
3
|
+
Create a comprehensive pull request with proper description and checklist.
|
|
4
|
+
|
|
5
|
+
## Instructions
|
|
6
|
+
|
|
7
|
+
When the user runs `/pr`:
|
|
8
|
+
|
|
9
|
+
### 1. Gather Context
|
|
10
|
+
Check current state:
|
|
11
|
+
- Current branch name
|
|
12
|
+
- Commits since branching from main
|
|
13
|
+
- Changed files
|
|
14
|
+
- Related issues (from commit messages)
|
|
15
|
+
|
|
16
|
+
### 2. Determine PR Type
|
|
17
|
+
Ask or infer:
|
|
18
|
+
- Feature (new functionality)
|
|
19
|
+
- Bug Fix (fixes an issue)
|
|
20
|
+
- Refactor (code improvement)
|
|
21
|
+
- Documentation
|
|
22
|
+
- Chore/Maintenance
|
|
23
|
+
|
|
24
|
+
### 3. Generate Title
|
|
25
|
+
Format: `<type>(<scope>): <description>`
|
|
26
|
+
|
|
27
|
+
Examples:
|
|
28
|
+
- `feat(auth): add social login with Google`
|
|
29
|
+
- `fix(notes): resolve crash on empty content`
|
|
30
|
+
- `refactor(api): migrate to axios interceptors`
|
|
31
|
+
|
|
32
|
+
### 4. Generate Description
|
|
33
|
+
Create comprehensive description:
|
|
34
|
+
|
|
35
|
+
```markdown
|
|
36
|
+
## Summary
|
|
37
|
+
[2-3 sentence overview of the changes]
|
|
38
|
+
|
|
39
|
+
## Type of Change
|
|
40
|
+
- [ ] Bug fix (non-breaking change fixing an issue)
|
|
41
|
+
- [ ] New feature (non-breaking change adding functionality)
|
|
42
|
+
- [ ] Breaking change (would cause existing functionality to change)
|
|
43
|
+
- [ ] Documentation update
|
|
44
|
+
- [ ] Refactoring (no functional changes)
|
|
45
|
+
|
|
46
|
+
## Related Issues
|
|
47
|
+
Closes #[issue_number]
|
|
48
|
+
|
|
49
|
+
## Changes Made
|
|
50
|
+
- [Bullet point for each significant change]
|
|
51
|
+
- [Include file/component names when helpful]
|
|
52
|
+
|
|
53
|
+
## Screenshots/Recordings
|
|
54
|
+
[If UI changes, add before/after screenshots]
|
|
55
|
+
|
|
56
|
+
| Before | After |
|
|
57
|
+
|--------|-------|
|
|
58
|
+
| [img] | [img] |
|
|
59
|
+
|
|
60
|
+
## Testing Done
|
|
61
|
+
- [ ] Unit tests added/updated
|
|
62
|
+
- [ ] Integration tests added/updated
|
|
63
|
+
- [ ] Manual testing completed
|
|
64
|
+
- [ ] Tested on iOS
|
|
65
|
+
- [ ] Tested on Android
|
|
66
|
+
|
|
67
|
+
## How to Test
|
|
68
|
+
1. [Step-by-step testing instructions]
|
|
69
|
+
2. [Include any setup needed]
|
|
70
|
+
3. [Expected outcomes]
|
|
71
|
+
|
|
72
|
+
## Checklist
|
|
73
|
+
- [ ] Code follows project conventions
|
|
74
|
+
- [ ] Self-review completed
|
|
75
|
+
- [ ] No new warnings
|
|
76
|
+
- [ ] Tests passing
|
|
77
|
+
- [ ] Documentation updated
|
|
78
|
+
- [ ] Accessibility considered
|
|
79
|
+
|
|
80
|
+
## Additional Notes
|
|
81
|
+
[Any context reviewers should know]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 5. Preview and Confirm
|
|
85
|
+
Show the generated PR:
|
|
86
|
+
- Title
|
|
87
|
+
- Description preview
|
|
88
|
+
- Base and head branches
|
|
89
|
+
- Reviewers to request
|
|
90
|
+
|
|
91
|
+
### 6. Create PR
|
|
92
|
+
If GitHub MCP configured:
|
|
93
|
+
- Create PR via API
|
|
94
|
+
- Add labels
|
|
95
|
+
- Request reviewers
|
|
96
|
+
- Return PR URL
|
|
97
|
+
|
|
98
|
+
If not:
|
|
99
|
+
- Output formatted content
|
|
100
|
+
- Provide GitHub CLI command
|
|
101
|
+
|
|
102
|
+
## Quick Templates
|
|
103
|
+
|
|
104
|
+
### Feature PR
|
|
105
|
+
```markdown
|
|
106
|
+
## Summary
|
|
107
|
+
Implements [feature] as specified in #[issue].
|
|
108
|
+
|
|
109
|
+
## Changes
|
|
110
|
+
- Added [component/hook/service]
|
|
111
|
+
- Updated [existing code]
|
|
112
|
+
- Created tests for [functionality]
|
|
113
|
+
|
|
114
|
+
## Demo
|
|
115
|
+
[Screenshot or video]
|
|
116
|
+
|
|
117
|
+
## Testing
|
|
118
|
+
Tested [scenarios] on [platforms].
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Bug Fix PR
|
|
122
|
+
```markdown
|
|
123
|
+
## Summary
|
|
124
|
+
Fixes [bug description] reported in #[issue].
|
|
125
|
+
|
|
126
|
+
## Root Cause
|
|
127
|
+
[Brief explanation of why bug occurred]
|
|
128
|
+
|
|
129
|
+
## Solution
|
|
130
|
+
[How the fix addresses it]
|
|
131
|
+
|
|
132
|
+
## Regression Test
|
|
133
|
+
Added test to prevent recurrence.
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Refactor PR
|
|
137
|
+
```markdown
|
|
138
|
+
## Summary
|
|
139
|
+
Refactors [area] to improve [goal].
|
|
140
|
+
|
|
141
|
+
## Motivation
|
|
142
|
+
[Why this refactor is needed]
|
|
143
|
+
|
|
144
|
+
## Changes
|
|
145
|
+
- Restructured [what]
|
|
146
|
+
- Extracted [components/utilities]
|
|
147
|
+
- Simplified [logic]
|
|
148
|
+
|
|
149
|
+
## Impact
|
|
150
|
+
No functional changes. [Any perf improvements]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Example Flow
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
User: /pr
|
|
157
|
+
|
|
158
|
+
Claude: I'll analyze your changes and create a PR.
|
|
159
|
+
|
|
160
|
+
Current branch: feature/user-profile
|
|
161
|
+
Commits: 3 (ahead of main)
|
|
162
|
+
Changed files:
|
|
163
|
+
- src/features/profile/UserProfile.tsx
|
|
164
|
+
- src/features/profile/useProfile.ts
|
|
165
|
+
- src/features/profile/profile.types.ts
|
|
166
|
+
- __tests__/profile/UserProfile.test.tsx
|
|
167
|
+
|
|
168
|
+
Generated PR:
|
|
169
|
+
|
|
170
|
+
Title: feat(profile): add user profile screen with avatar upload
|
|
171
|
+
|
|
172
|
+
[Full description...]
|
|
173
|
+
|
|
174
|
+
Create this PR? (y/n)
|
|
175
|
+
```
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# /review - Code Review
|
|
2
|
+
|
|
3
|
+
Perform a thorough code review with actionable feedback.
|
|
4
|
+
|
|
5
|
+
## Instructions
|
|
6
|
+
|
|
7
|
+
When the user runs `/review [file|PR]`:
|
|
8
|
+
|
|
9
|
+
### 1. Identify Target
|
|
10
|
+
- If file path: Review that specific file
|
|
11
|
+
- If PR number: Review PR changes via GitHub MCP
|
|
12
|
+
- If nothing: Review staged changes or recent commits
|
|
13
|
+
|
|
14
|
+
### 2. Analysis Categories
|
|
15
|
+
|
|
16
|
+
**Code Quality**
|
|
17
|
+
- Readability and clarity
|
|
18
|
+
- Function/component size
|
|
19
|
+
- Code duplication
|
|
20
|
+
- Naming conventions
|
|
21
|
+
- Comments (where needed)
|
|
22
|
+
|
|
23
|
+
**Type Safety**
|
|
24
|
+
- Proper TypeScript usage
|
|
25
|
+
- No unnecessary `any`
|
|
26
|
+
- Null/undefined handling
|
|
27
|
+
- Interface definitions
|
|
28
|
+
|
|
29
|
+
**React/RN Best Practices**
|
|
30
|
+
- Hook rules followed
|
|
31
|
+
- Proper dependencies in useEffect
|
|
32
|
+
- Memoization where needed
|
|
33
|
+
- Key props in lists
|
|
34
|
+
- Event handler patterns
|
|
35
|
+
|
|
36
|
+
**Performance**
|
|
37
|
+
- Unnecessary re-renders
|
|
38
|
+
- Missing memoization
|
|
39
|
+
- Large bundle imports
|
|
40
|
+
- Memory leak potential
|
|
41
|
+
|
|
42
|
+
**Security**
|
|
43
|
+
- Input validation
|
|
44
|
+
- Sensitive data handling
|
|
45
|
+
- SQL injection prevention
|
|
46
|
+
- XSS prevention
|
|
47
|
+
|
|
48
|
+
**Accessibility**
|
|
49
|
+
- ARIA labels
|
|
50
|
+
- Touch target sizes
|
|
51
|
+
- Color contrast
|
|
52
|
+
- Screen reader support
|
|
53
|
+
|
|
54
|
+
**Testing**
|
|
55
|
+
- Test coverage
|
|
56
|
+
- Edge cases
|
|
57
|
+
- Meaningful assertions
|
|
58
|
+
|
|
59
|
+
### 3. Output Format
|
|
60
|
+
|
|
61
|
+
```markdown
|
|
62
|
+
## Code Review: [File/PR]
|
|
63
|
+
|
|
64
|
+
### Summary
|
|
65
|
+
**Quality Score:** [A/B/C/D]
|
|
66
|
+
**Recommendation:** [Approve / Request Changes / Comment]
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### Critical Issues (Must Fix)
|
|
71
|
+
|
|
72
|
+
#### 1. [Issue Title]
|
|
73
|
+
**File:** `path/to/file.tsx`
|
|
74
|
+
**Line:** 42-48
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// Current code
|
|
78
|
+
const data = fetchData(); // Problem here
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Problem:** [Clear explanation]
|
|
82
|
+
**Impact:** [Why it matters]
|
|
83
|
+
**Fix:**
|
|
84
|
+
```typescript
|
|
85
|
+
// Suggested fix
|
|
86
|
+
const data = await fetchData();
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### Improvements (Should Fix)
|
|
92
|
+
|
|
93
|
+
#### 1. [Issue Title]
|
|
94
|
+
**File:** `path/to/file.tsx`
|
|
95
|
+
**Line:** 15
|
|
96
|
+
|
|
97
|
+
**Current:**
|
|
98
|
+
```typescript
|
|
99
|
+
// Less optimal
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Suggested:**
|
|
103
|
+
```typescript
|
|
104
|
+
// Better approach
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Reason:** [Why this is better]
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### Suggestions (Nice to Have)
|
|
112
|
+
|
|
113
|
+
- [ ] Consider extracting [X] into a custom hook
|
|
114
|
+
- [ ] Could use [pattern] for better readability
|
|
115
|
+
- [ ] Optional: Add JSDoc for public API
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### Positive Highlights
|
|
120
|
+
|
|
121
|
+
- Well-structured component architecture
|
|
122
|
+
- Good error handling in [area]
|
|
123
|
+
- Clean separation of concerns
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### Summary
|
|
128
|
+
|
|
129
|
+
[Overall assessment and specific action items]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Quick Review Mode
|
|
133
|
+
|
|
134
|
+
`/review --quick` or `/review -q`:
|
|
135
|
+
- Focus on critical issues only
|
|
136
|
+
- Shorter output
|
|
137
|
+
- Faster turnaround
|
|
138
|
+
|
|
139
|
+
## Review Checklist
|
|
140
|
+
|
|
141
|
+
Use as mental model:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
[ ] Types are correct and complete
|
|
145
|
+
[ ] No console.log left in code
|
|
146
|
+
[ ] Error states handled
|
|
147
|
+
[ ] Loading states handled
|
|
148
|
+
[ ] Edge cases considered
|
|
149
|
+
[ ] No memory leaks
|
|
150
|
+
[ ] Accessibility labels present
|
|
151
|
+
[ ] Tests cover happy path + errors
|
|
152
|
+
[ ] No hardcoded values
|
|
153
|
+
[ ] Imports are clean
|
|
154
|
+
[ ] File structure follows conventions
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Common Issues Database
|
|
158
|
+
|
|
159
|
+
### Hooks
|
|
160
|
+
```typescript
|
|
161
|
+
// Bad: Stale closure
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
const timer = setInterval(() => {
|
|
164
|
+
setCount(count + 1); // Stale!
|
|
165
|
+
}, 1000);
|
|
166
|
+
}, []);
|
|
167
|
+
|
|
168
|
+
// Good: Functional update
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
const timer = setInterval(() => {
|
|
171
|
+
setCount(c => c + 1);
|
|
172
|
+
}, 1000);
|
|
173
|
+
return () => clearInterval(timer);
|
|
174
|
+
}, []);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Async in useEffect
|
|
178
|
+
```typescript
|
|
179
|
+
// Bad: Async useEffect
|
|
180
|
+
useEffect(async () => {
|
|
181
|
+
const data = await fetch();
|
|
182
|
+
}, []);
|
|
183
|
+
|
|
184
|
+
// Good: Inner async function
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
const loadData = async () => {
|
|
187
|
+
const data = await fetch();
|
|
188
|
+
};
|
|
189
|
+
loadData();
|
|
190
|
+
}, []);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Optional Chaining
|
|
194
|
+
```typescript
|
|
195
|
+
// Bad: Unsafe access
|
|
196
|
+
const name = user.profile.name;
|
|
197
|
+
|
|
198
|
+
// Good: Safe access
|
|
199
|
+
const name = user?.profile?.name ?? 'Unknown';
|
|
200
|
+
```
|