@haposoft/cafekit 0.3.1 → 0.3.5
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 +3 -3
- package/bin/install.js +1 -0
- package/package.json +1 -1
- package/src/antigravity/workflows/impact-analysis-output-example.md +313 -0
- package/src/antigravity/workflows/impact-analysis.md +735 -0
- package/src/claude/migration-manifest.json +2 -1
- package/src/common/skills/impact-analysis/SKILL.md +271 -0
- package/src/common/skills/impact-analysis/references/change-detection.md +270 -0
- package/src/common/skills/impact-analysis/references/dependency-scouting.md +337 -0
- package/src/common/skills/impact-analysis/references/edge-case-identification.md +439 -0
- package/src/common/skills/impact-analysis/references/industry-techniques.md +695 -0
- package/src/common/skills/impact-analysis/references/practical-techniques-guide.md +753 -0
- package/src/common/skills/impact-analysis/references/project-detection.md +704 -0
- package/src/common/skills/impact-analysis/references/react-native-customization.md +508 -0
- package/src/common/skills/impact-analysis/references/report-template.md +604 -0
- package/src/common/skills/impact-analysis/references/test-scenario-generation.md +459 -0
- package/src/common/skills/impact-analysis/scripts/README.md +476 -0
- package/src/common/skills/impact-analysis/scripts/ast-analyze.js +403 -0
- package/src/common/skills/impact-analysis/scripts/calculate-risk.js +475 -0
- package/src/common/skills/impact-analysis/scripts/find-dependencies.sh +202 -0
- package/src/common/skills/impact-analysis/scripts/run-analysis.sh +312 -0
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Phân tích tác động của code changes lên tính năng và hành động người dùng
|
|
3
|
+
allowed-tools: Read, Glob, Grep, Bash, WebSearch
|
|
4
|
+
argument-hint: <feature-name> [--from <branch>]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /impact-analysis - Phân Tích Tác Động Tính Năng
|
|
8
|
+
|
|
9
|
+
Sử dụng workflow này sau khi hoàn thành feature (sau `/code`) hoặc trước khi commit.
|
|
10
|
+
|
|
11
|
+
<background_information>
|
|
12
|
+
- **Mission**: Comprehensive impact analysis for completed features to prevent regression bugs
|
|
13
|
+
- **Success Criteria**:
|
|
14
|
+
- All affected features identified with user actions mapped
|
|
15
|
+
- Edge cases detected and documented
|
|
16
|
+
- Test scenarios generated for all critical paths
|
|
17
|
+
- Regression risks assessed with mitigation recommendations
|
|
18
|
+
- Cross-referenced with spec artifacts when available
|
|
19
|
+
- **Timing**: After implementing all tasks for a feature, before running `/test`
|
|
20
|
+
- **Helper Scripts**: Optionally use advanced analysis scripts from `.claude/skills/impact-analysis/scripts/` for automated dependency analysis, AST-based semantic analysis, and risk scoring
|
|
21
|
+
</background_information>
|
|
22
|
+
|
|
23
|
+
<instructions>
|
|
24
|
+
## Core Task
|
|
25
|
+
Analyze the impact of code changes for feature **$ARGUMENTS** to identify affected features, user actions, edge cases, and generate comprehensive test scenarios.
|
|
26
|
+
|
|
27
|
+
## Helper Scripts (Optional Enhancement)
|
|
28
|
+
|
|
29
|
+
If available in `.claude/skills/impact-analysis/scripts/`, these scripts provide advanced automated analysis:
|
|
30
|
+
|
|
31
|
+
**1. Dependency Analysis**:
|
|
32
|
+
```bash
|
|
33
|
+
.claude/skills/impact-analysis/scripts/find-dependencies.sh <file>
|
|
34
|
+
```
|
|
35
|
+
- Finds all files importing/using the changed file
|
|
36
|
+
- Identifies API consumers and component usage
|
|
37
|
+
- Provides impact recommendations
|
|
38
|
+
|
|
39
|
+
**2. AST-Based Analysis** (for TypeScript/JavaScript):
|
|
40
|
+
```bash
|
|
41
|
+
node .claude/skills/impact-analysis/scripts/ast-analyze.js <file>
|
|
42
|
+
```
|
|
43
|
+
- Detects function signature changes
|
|
44
|
+
- Identifies breaking changes
|
|
45
|
+
- Compares before/after versions
|
|
46
|
+
|
|
47
|
+
**3. Risk Calculation**:
|
|
48
|
+
```bash
|
|
49
|
+
node .claude/skills/impact-analysis/scripts/calculate-risk.js
|
|
50
|
+
```
|
|
51
|
+
- Calculates risk score (0-25)
|
|
52
|
+
- Determines risk level (CRITICAL/HIGH/MEDIUM/LOW)
|
|
53
|
+
- Provides actionable recommendations with time estimates
|
|
54
|
+
|
|
55
|
+
**4. Complete Analysis**:
|
|
56
|
+
```bash
|
|
57
|
+
.claude/skills/impact-analysis/scripts/run-analysis.sh
|
|
58
|
+
```
|
|
59
|
+
- Runs all techniques
|
|
60
|
+
- Generates comprehensive markdown report
|
|
61
|
+
|
|
62
|
+
**Usage Strategy**:
|
|
63
|
+
- Try to use helper scripts first for automated analysis
|
|
64
|
+
- Fall back to manual grep/analysis if scripts not available
|
|
65
|
+
- Combine automated results with manual insights for best coverage
|
|
66
|
+
|
|
67
|
+
## Execution Steps
|
|
68
|
+
|
|
69
|
+
### Step 0: Validate Context & Determine Scope
|
|
70
|
+
|
|
71
|
+
**Parse Arguments**:
|
|
72
|
+
- Extract feature name from `$ARGUMENTS` (first argument)
|
|
73
|
+
- Check for flags: `--from <branch>` for branch-based analysis
|
|
74
|
+
- If no arguments: Analyze uncommitted changes
|
|
75
|
+
|
|
76
|
+
**Load Spec Context (if feature name provided)**:
|
|
77
|
+
- Check if `.specs/$FEATURE_NAME/` exists
|
|
78
|
+
- If exists:
|
|
79
|
+
- Read `.specs/$FEATURE_NAME/spec.json` for metadata
|
|
80
|
+
- Read `.specs/$FEATURE_NAME/requirements.md` for requirements
|
|
81
|
+
- Read `.specs/$FEATURE_NAME/design.md` for design decisions
|
|
82
|
+
- Read `.specs/$FEATURE_NAME/tasks.md` for task list
|
|
83
|
+
- Note: This enables cross-referencing and coverage analysis
|
|
84
|
+
- If not exists: Continue with standalone analysis (no spec context)
|
|
85
|
+
|
|
86
|
+
**Determine Analysis Scope**:
|
|
87
|
+
- **Feature-based** (feature name provided): Analyze all changes since feature start
|
|
88
|
+
- Use git log to find first commit mentioning feature
|
|
89
|
+
- Or analyze all uncommitted + recent commits
|
|
90
|
+
- **Branch-based** (`--from` flag): Compare current branch with specified branch
|
|
91
|
+
- Example: `--from main` analyzes all changes since branching from main
|
|
92
|
+
- **Uncommitted** (no args): Analyze only uncommitted changes
|
|
93
|
+
- Use `git diff HEAD` for staged/unstaged changes
|
|
94
|
+
|
|
95
|
+
### Step 1: Detect & Classify Changes
|
|
96
|
+
|
|
97
|
+
**Execute Git Analysis**:
|
|
98
|
+
```bash
|
|
99
|
+
# Based on scope from Step 0:
|
|
100
|
+
# Feature-based: git diff <feature-start-commit>..HEAD
|
|
101
|
+
# Branch-based: git diff <branch>...HEAD
|
|
102
|
+
# Uncommitted: git diff HEAD
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Classify Changed Files**:
|
|
106
|
+
- **Backend**: Files in `src/api/`, `src/services/`, `src/lib/`, `src/utils/`
|
|
107
|
+
- **Frontend**: Files in `src/components/`, `src/pages/`, `src/app/`, `src/hooks/`
|
|
108
|
+
- **Database**: Files in `prisma/`, `migrations/`, `schema/`, `*.sql`
|
|
109
|
+
- **Config**: Files like `package.json`, `tsconfig.json`, `.env`, config files
|
|
110
|
+
- **Tests**: Files in `__tests__/`, `*.test.*`, `*.spec.*`
|
|
111
|
+
|
|
112
|
+
**Count & Summarize**:
|
|
113
|
+
- Total files changed
|
|
114
|
+
- Files per category
|
|
115
|
+
- Lines added/removed
|
|
116
|
+
- Commits involved (if applicable)
|
|
117
|
+
|
|
118
|
+
### Step 2: Map Features & User Actions
|
|
119
|
+
|
|
120
|
+
**Pattern-Based Feature Detection**:
|
|
121
|
+
|
|
122
|
+
Use file path patterns to identify affected features:
|
|
123
|
+
|
|
124
|
+
| File Pattern | Feature | User Actions |
|
|
125
|
+
|-------------|---------|--------------|
|
|
126
|
+
| `**/api/auth**`, `**/auth**` | Authentication & Login | Login, Logout, Sign Up, Password Reset, Session Management, 2FA |
|
|
127
|
+
| `**/api/users**`, `**/user**`, `**/profile**` | User Profile Management | View Profile, Edit Profile, Upload Avatar, Change Settings, Update Bio |
|
|
128
|
+
| `**/api/posts**`, `**/post**`, `**/article**` | Post Management | Create Post, Edit Post, Delete Post, View Posts, Like Post, Share Post |
|
|
129
|
+
| `**/api/comments**`, `**/comment**`, `**/reply**` | Comment System | Add Comment, Edit Comment, Delete Comment, View Comments, Reply |
|
|
130
|
+
| `**/api/payments**`, `**/payment**`, `**/checkout**` | Payment Processing | Make Payment, Process Refund, View History, Update Payment Method |
|
|
131
|
+
| `**/api/notifications**`, `**/notification**` | Notification System | Send Notification, View Notifications, Mark as Read, Settings |
|
|
132
|
+
| `**/components/auth**` | Login/Signup UI | Display Forms, Handle Validation, Show Errors |
|
|
133
|
+
| `**/hooks/useAuth**` | Authentication State | Check Login Status, Get User Info, Handle Logout |
|
|
134
|
+
| `**/prisma/schema**`, `**/migrations**` | Database Structure | All Database Operations, Queries, Mutations |
|
|
135
|
+
| `**/middleware/auth**` | Access Control | Check Permissions, Protect Routes, Validate Tokens |
|
|
136
|
+
|
|
137
|
+
**Content-Based Feature Detection**:
|
|
138
|
+
|
|
139
|
+
Scan file contents for keywords to detect additional features:
|
|
140
|
+
|
|
141
|
+
| Keywords | Feature | User Actions |
|
|
142
|
+
|----------|---------|--------------|
|
|
143
|
+
| `login`, `signin`, `authenticate` | Authentication & Login | Login, Logout, Session Management |
|
|
144
|
+
| `profile`, `avatar`, `bio` | User Profile Management | View Profile, Edit Profile, Upload Avatar |
|
|
145
|
+
| `post`, `article`, `content` | Post Management | Create, Edit, Delete, View Posts |
|
|
146
|
+
| `comment`, `reply` | Comment System | Add, Edit, Delete Comments |
|
|
147
|
+
| `payment`, `checkout`, `stripe`, `paypal` | Payment Processing | Make Payment, Process Refund |
|
|
148
|
+
| `search`, `filter`, `query` | Search & Filter | Search Content, Apply Filters, Sort Results |
|
|
149
|
+
| `upload`, `file`, `image` | File Upload | Upload File, Delete File, View Files |
|
|
150
|
+
| `email`, `send mail` | Email System | Send Email, Email Verification |
|
|
151
|
+
|
|
152
|
+
**Generate Feature Impact Map**:
|
|
153
|
+
- List all detected features
|
|
154
|
+
- Map user actions to each feature
|
|
155
|
+
- Create impact scenarios: "When user tries to [action], [potential impact]"
|
|
156
|
+
|
|
157
|
+
### Step 3: Find Dependencies & Affected Files
|
|
158
|
+
|
|
159
|
+
**Automated Dependency Analysis** (using helper script):
|
|
160
|
+
|
|
161
|
+
If helper script available, run comprehensive analysis:
|
|
162
|
+
```bash
|
|
163
|
+
# Run dependency analysis script for each changed file
|
|
164
|
+
.claude/skills/impact-analysis/scripts/find-dependencies.sh <file>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Manual Dependency Analysis** (fallback):
|
|
168
|
+
|
|
169
|
+
For each changed file, find:
|
|
170
|
+
1. **Direct imports**: Files that import the changed file
|
|
171
|
+
```bash
|
|
172
|
+
grep -r "from.*<filename>" src/
|
|
173
|
+
grep -r "import.*<filename>" src/
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
2. **Function/Class usage**: Files that call functions or use classes from changed file
|
|
177
|
+
```bash
|
|
178
|
+
grep -r "<function-name>\|<class-name>" src/
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
3. **API consumers**: If API changed, find frontend components calling it
|
|
182
|
+
```bash
|
|
183
|
+
grep -r "fetch.*<api-endpoint>" src/
|
|
184
|
+
grep -r "axios.*<api-endpoint>" src/
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
4. **Component usage**: If component changed, find parent components
|
|
188
|
+
```bash
|
|
189
|
+
grep -r "<ComponentName>" src/
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Count Affected Files**:
|
|
193
|
+
- Total affected files
|
|
194
|
+
- Breakdown by category (backend/frontend/tests)
|
|
195
|
+
- Highlight high-impact files (used in many places)
|
|
196
|
+
|
|
197
|
+
### Step 4: Identify Edge Cases
|
|
198
|
+
|
|
199
|
+
**Automated Edge Case Detection**:
|
|
200
|
+
|
|
201
|
+
**Option 1: Use Helper Scripts** (if available):
|
|
202
|
+
```bash
|
|
203
|
+
# Run AST analysis for TypeScript/JavaScript files
|
|
204
|
+
node .claude/skills/impact-analysis/scripts/ast-analyze.js <file>
|
|
205
|
+
|
|
206
|
+
# Run risk calculation
|
|
207
|
+
node .claude/skills/impact-analysis/scripts/calculate-risk.js
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Option 2: Manual Detection** (fallback):
|
|
211
|
+
|
|
212
|
+
Scan changed files for common issues:
|
|
213
|
+
|
|
214
|
+
1. **Null/Undefined Handling**:
|
|
215
|
+
```bash
|
|
216
|
+
# Find property access without optional chaining
|
|
217
|
+
grep -E "\.[a-zA-Z]+" <file> | grep -v "?\."
|
|
218
|
+
```
|
|
219
|
+
- Issue: Potential null pointer errors
|
|
220
|
+
- Action: Add null checks or optional chaining
|
|
221
|
+
|
|
222
|
+
2. **Error Handling**:
|
|
223
|
+
```bash
|
|
224
|
+
# Find async calls without try-catch
|
|
225
|
+
grep -E "await|fetch|axios" <file>
|
|
226
|
+
grep -E "try\s*\{" <file>
|
|
227
|
+
```
|
|
228
|
+
- Issue: Missing error handling
|
|
229
|
+
- Action: Add try-catch blocks
|
|
230
|
+
|
|
231
|
+
3. **Boundary Conditions**:
|
|
232
|
+
- Array access without length check
|
|
233
|
+
- Division without zero check
|
|
234
|
+
- String operations without empty check
|
|
235
|
+
|
|
236
|
+
4. **Race Conditions**:
|
|
237
|
+
- Multiple async operations without proper sequencing
|
|
238
|
+
- State updates without locks/mutexes
|
|
239
|
+
- Concurrent API calls
|
|
240
|
+
|
|
241
|
+
**Categorize by Severity**:
|
|
242
|
+
- **Critical**: Will cause crashes or data loss
|
|
243
|
+
- **Important**: Will cause incorrect behavior
|
|
244
|
+
- **Minor**: Edge cases that rarely occur
|
|
245
|
+
|
|
246
|
+
### Step 5: Cross-Reference with Spec (if available)
|
|
247
|
+
|
|
248
|
+
**If spec context loaded in Step 0**:
|
|
249
|
+
|
|
250
|
+
**Requirements Coverage**:
|
|
251
|
+
- Map changed files to requirement IDs
|
|
252
|
+
- Check if all requirements are implemented
|
|
253
|
+
- Identify partially implemented requirements
|
|
254
|
+
- Flag missing implementations
|
|
255
|
+
|
|
256
|
+
**Design Compliance**:
|
|
257
|
+
- Verify API endpoints match design
|
|
258
|
+
- Check database schema matches design
|
|
259
|
+
- Validate component structure follows design
|
|
260
|
+
- Note any deviations
|
|
261
|
+
|
|
262
|
+
**Task Completion**:
|
|
263
|
+
- Check task status in `tasks.md`
|
|
264
|
+
- Count completed vs pending tasks
|
|
265
|
+
- Identify blocked tasks
|
|
266
|
+
- Calculate completion percentage
|
|
267
|
+
|
|
268
|
+
**Output**:
|
|
269
|
+
```markdown
|
|
270
|
+
## Requirements Coverage
|
|
271
|
+
- FR-1: User Login ✅ Implemented
|
|
272
|
+
- FR-2: Password Reset ✅ Implemented
|
|
273
|
+
- FR-3: 2FA ⚠️ Partially implemented
|
|
274
|
+
|
|
275
|
+
## Design Compliance
|
|
276
|
+
- API endpoints: ✅ Match design
|
|
277
|
+
- Database schema: ✅ Match design
|
|
278
|
+
- Component structure: ⚠️ Deviation detected
|
|
279
|
+
|
|
280
|
+
## Task Status
|
|
281
|
+
- Completed: 8/10 tasks (80%)
|
|
282
|
+
- Pending: Task #9, Task #10
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Step 6: Generate Test Scenarios
|
|
286
|
+
|
|
287
|
+
**Scenario Generation Strategy**:
|
|
288
|
+
|
|
289
|
+
For each affected feature and user action, generate:
|
|
290
|
+
|
|
291
|
+
1. **Happy Path Scenarios**:
|
|
292
|
+
```markdown
|
|
293
|
+
Given: [precondition]
|
|
294
|
+
When: [user action]
|
|
295
|
+
Then: [expected result]
|
|
296
|
+
And: [additional verification]
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
2. **Error Handling Scenarios**:
|
|
300
|
+
```markdown
|
|
301
|
+
Given: [precondition]
|
|
302
|
+
When: [user action with invalid input]
|
|
303
|
+
Then: [error message shown]
|
|
304
|
+
And: [system remains stable]
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
3. **Edge Case Scenarios**:
|
|
308
|
+
```markdown
|
|
309
|
+
Given: [edge case condition]
|
|
310
|
+
When: [user action]
|
|
311
|
+
Then: [graceful handling]
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
4. **Regression Scenarios**:
|
|
315
|
+
```markdown
|
|
316
|
+
Given: [existing functionality]
|
|
317
|
+
When: [user performs old action]
|
|
318
|
+
Then: [still works as before]
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Prioritize Scenarios**:
|
|
322
|
+
- **Critical**: Must test before deployment
|
|
323
|
+
- **Important**: Should test before PR
|
|
324
|
+
- **Nice to have**: Test if time permits
|
|
325
|
+
|
|
326
|
+
### Step 7: Assess Regression Risks
|
|
327
|
+
|
|
328
|
+
**Automated Risk Assessment** (if helper script available):
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
# Run comprehensive risk calculation
|
|
332
|
+
node .claude/skills/impact-analysis/scripts/calculate-risk.js
|
|
333
|
+
|
|
334
|
+
# Output includes:
|
|
335
|
+
# - Risk score (0-25)
|
|
336
|
+
# - Risk level (CRITICAL/HIGH/MEDIUM/LOW)
|
|
337
|
+
# - Risk breakdown by factors
|
|
338
|
+
# - Actionable recommendations with time estimates
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**Manual Risk Assessment** (fallback):
|
|
342
|
+
|
|
343
|
+
Categorize changes by risk level:
|
|
344
|
+
|
|
345
|
+
**High Risk**:
|
|
346
|
+
- Database schema changes
|
|
347
|
+
- Authentication/authorization changes
|
|
348
|
+
- Payment processing changes
|
|
349
|
+
- API contract changes (breaking)
|
|
350
|
+
- Core business logic modifications
|
|
351
|
+
|
|
352
|
+
**Medium Risk**:
|
|
353
|
+
- UI component refactoring
|
|
354
|
+
- New features with existing integrations
|
|
355
|
+
- Configuration changes
|
|
356
|
+
- Dependency updates
|
|
357
|
+
|
|
358
|
+
**Low Risk**:
|
|
359
|
+
- Documentation updates
|
|
360
|
+
- Code formatting
|
|
361
|
+
- Minor UI tweaks
|
|
362
|
+
- Test additions
|
|
363
|
+
|
|
364
|
+
**For Each Risk Area**:
|
|
365
|
+
- Identify what could break
|
|
366
|
+
- List affected user workflows
|
|
367
|
+
- Suggest mitigation strategies
|
|
368
|
+
|
|
369
|
+
### Step 8: Create Comprehensive Report
|
|
370
|
+
|
|
371
|
+
**Generate Report Structure**:
|
|
372
|
+
|
|
373
|
+
```markdown
|
|
374
|
+
# Impact Analysis Report - {Feature Name}
|
|
375
|
+
|
|
376
|
+
**Generated**: {timestamp}
|
|
377
|
+
**Feature**: {feature-name}
|
|
378
|
+
**Branch**: {current-branch}
|
|
379
|
+
**Commits**: {commit-count}
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## 📋 Executive Summary
|
|
384
|
+
|
|
385
|
+
- **Files Changed**: {count}
|
|
386
|
+
- **Features Affected**: {count}
|
|
387
|
+
- **User Scenarios**: {count}
|
|
388
|
+
- **Edge Cases**: {count}
|
|
389
|
+
- **Risk Level**: {HIGH/MEDIUM/LOW}
|
|
390
|
+
- **Estimated Test Time**: {estimate}
|
|
391
|
+
|
|
392
|
+
{If spec available:}
|
|
393
|
+
- **Requirements Coverage**: {percentage}%
|
|
394
|
+
- **Tasks Completed**: {completed}/{total}
|
|
395
|
+
- **Design Compliance**: {status}
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## 🔍 Change Analysis
|
|
400
|
+
|
|
401
|
+
### Files Changed ({count})
|
|
402
|
+
|
|
403
|
+
**Backend** ({count} files):
|
|
404
|
+
- {list of backend files}
|
|
405
|
+
|
|
406
|
+
**Frontend** ({count} files):
|
|
407
|
+
- {list of frontend files}
|
|
408
|
+
|
|
409
|
+
**Database** ({count} files):
|
|
410
|
+
- {list of database files}
|
|
411
|
+
|
|
412
|
+
**Config** ({count} files):
|
|
413
|
+
- {list of config files}
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## 🎯 Feature Impact Map
|
|
418
|
+
|
|
419
|
+
### Feature 1: {Feature Name}
|
|
420
|
+
|
|
421
|
+
**User Actions Affected**:
|
|
422
|
+
- {action 1}
|
|
423
|
+
- {action 2}
|
|
424
|
+
- {action 3}
|
|
425
|
+
|
|
426
|
+
**Impact Level**: {HIGH/MEDIUM/LOW}
|
|
427
|
+
|
|
428
|
+
**Details**: {explanation of impact}
|
|
429
|
+
|
|
430
|
+
### Feature 2: {Feature Name}
|
|
431
|
+
...
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
## 🎬 Impact Scenarios
|
|
436
|
+
|
|
437
|
+
### Scenario 1: {Action Name}
|
|
438
|
+
- **When user tries to**: {action}
|
|
439
|
+
- **Potential impact**: {description}
|
|
440
|
+
- **Required action**: {test instruction}
|
|
441
|
+
- **Priority**: {CRITICAL/IMPORTANT/MINOR}
|
|
442
|
+
|
|
443
|
+
### Scenario 2: {Action Name}
|
|
444
|
+
...
|
|
445
|
+
|
|
446
|
+
---
|
|
447
|
+
|
|
448
|
+
## 🔗 Dependencies & Affected Files
|
|
449
|
+
|
|
450
|
+
### Direct Dependencies ({count})
|
|
451
|
+
- {file 1} → {affected by changes in file X}
|
|
452
|
+
- {file 2} → {affected by changes in file Y}
|
|
453
|
+
|
|
454
|
+
### Integration Points ({count})
|
|
455
|
+
- {component A} calls {API endpoint B}
|
|
456
|
+
- {page X} uses {component Y}
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## ⚠️ Edge Cases Detected
|
|
461
|
+
|
|
462
|
+
### Critical ({count})
|
|
463
|
+
1. **{Issue Title}**
|
|
464
|
+
- **Location**: {file:line}
|
|
465
|
+
- **Issue**: {description}
|
|
466
|
+
- **Impact**: {what could go wrong}
|
|
467
|
+
- **Action**: {how to fix}
|
|
468
|
+
|
|
469
|
+
### Important ({count})
|
|
470
|
+
...
|
|
471
|
+
|
|
472
|
+
### Minor ({count})
|
|
473
|
+
...
|
|
474
|
+
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
{If spec available:}
|
|
478
|
+
## 📊 Spec Cross-Reference
|
|
479
|
+
|
|
480
|
+
### Requirements Coverage
|
|
481
|
+
- FR-1: {requirement} ✅ Implemented
|
|
482
|
+
- FR-2: {requirement} ⚠️ Partially implemented
|
|
483
|
+
- FR-3: {requirement} ❌ Not implemented
|
|
484
|
+
|
|
485
|
+
### Design Compliance
|
|
486
|
+
- API Endpoints: {status}
|
|
487
|
+
- Database Schema: {status}
|
|
488
|
+
- Component Structure: {status}
|
|
489
|
+
|
|
490
|
+
### Task Completion
|
|
491
|
+
- Completed: {count}/{total} ({percentage}%)
|
|
492
|
+
- Pending: {list}
|
|
493
|
+
- Blocked: {list}
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
## 🧪 Test Scenarios
|
|
498
|
+
|
|
499
|
+
### Critical Scenarios (Must Test)
|
|
500
|
+
|
|
501
|
+
#### Scenario 1: {Name}
|
|
502
|
+
```gherkin
|
|
503
|
+
Given: {precondition}
|
|
504
|
+
When: {action}
|
|
505
|
+
Then: {expected result}
|
|
506
|
+
And: {verification}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
**Priority**: CRITICAL
|
|
510
|
+
**Estimated Time**: {minutes}
|
|
511
|
+
|
|
512
|
+
#### Scenario 2: {Name}
|
|
513
|
+
...
|
|
514
|
+
|
|
515
|
+
### Important Scenarios (Should Test)
|
|
516
|
+
...
|
|
517
|
+
|
|
518
|
+
### Regression Scenarios (Verify Old Functionality)
|
|
519
|
+
...
|
|
520
|
+
|
|
521
|
+
---
|
|
522
|
+
|
|
523
|
+
## 🎯 Regression Risk Assessment
|
|
524
|
+
|
|
525
|
+
### High Risk Areas
|
|
526
|
+
1. **{Area Name}**
|
|
527
|
+
- **Why**: {reason}
|
|
528
|
+
- **Impact**: {what could break}
|
|
529
|
+
- **Mitigation**: {how to prevent}
|
|
530
|
+
|
|
531
|
+
### Medium Risk Areas
|
|
532
|
+
...
|
|
533
|
+
|
|
534
|
+
### Low Risk Areas
|
|
535
|
+
...
|
|
536
|
+
|
|
537
|
+
---
|
|
538
|
+
|
|
539
|
+
## 💡 Recommendations
|
|
540
|
+
|
|
541
|
+
### Before Testing
|
|
542
|
+
- [ ] {recommendation 1}
|
|
543
|
+
- [ ] {recommendation 2}
|
|
544
|
+
- [ ] {recommendation 3}
|
|
545
|
+
|
|
546
|
+
### Testing Checklist
|
|
547
|
+
- [ ] Test all {count} critical scenarios
|
|
548
|
+
- [ ] Verify {count} edge cases fixed
|
|
549
|
+
- [ ] Run regression tests
|
|
550
|
+
- [ ] Test on multiple devices/browsers
|
|
551
|
+
- [ ] Performance testing (if applicable)
|
|
552
|
+
|
|
553
|
+
### Before Deployment
|
|
554
|
+
- [ ] Update documentation
|
|
555
|
+
- [ ] Notify stakeholders
|
|
556
|
+
- [ ] Prepare rollback plan
|
|
557
|
+
- [ ] Monitor metrics post-deployment
|
|
558
|
+
|
|
559
|
+
---
|
|
560
|
+
|
|
561
|
+
## 🚀 Next Steps
|
|
562
|
+
|
|
563
|
+
1. **Review this report** - Understand all impacts
|
|
564
|
+
2. **Fix critical edge cases** - Address {count} critical issues
|
|
565
|
+
3. **Run test scenarios** - Execute all critical tests
|
|
566
|
+
4. **Re-run analysis** - Verify fixes with `/impact-analysis {feature-name}`
|
|
567
|
+
5. **Proceed to testing** - Run `/test`
|
|
568
|
+
6. **Code review** - Run `/review`
|
|
569
|
+
7. **Commit & PR** - Create pull request with this report attached
|
|
570
|
+
|
|
571
|
+
---
|
|
572
|
+
|
|
573
|
+
**Report saved to**: `.specs/impact-reports/{feature-name}-{timestamp}.md`
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
**Save Report**:
|
|
577
|
+
- Create `.specs/impact-reports/` directory if not exists
|
|
578
|
+
- Save report as `{feature-name}-{timestamp}.md`
|
|
579
|
+
- Create symlink `latest.md` pointing to this report
|
|
580
|
+
|
|
581
|
+
</instructions>
|
|
582
|
+
|
|
583
|
+
## Tool Guidance
|
|
584
|
+
|
|
585
|
+
**Read Operations**:
|
|
586
|
+
- Load spec context first (if feature name provided)
|
|
587
|
+
- Read all relevant spec files (spec.json, requirements.md, design.md, tasks.md)
|
|
588
|
+
- Use Grep for dependency analysis and keyword detection
|
|
589
|
+
|
|
590
|
+
**Bash Operations**:
|
|
591
|
+
- Use git commands for change detection
|
|
592
|
+
- Use grep for pattern matching and content scanning
|
|
593
|
+
- Use find for file discovery
|
|
594
|
+
|
|
595
|
+
**Analysis Strategy**:
|
|
596
|
+
- Start broad (all changes) then narrow down (specific impacts)
|
|
597
|
+
- Cross-reference with spec when available
|
|
598
|
+
- Prioritize by risk and user impact
|
|
599
|
+
|
|
600
|
+
**Output**:
|
|
601
|
+
- Generate comprehensive markdown report
|
|
602
|
+
- Save to `.specs/impact-reports/`
|
|
603
|
+
- Display summary in terminal
|
|
604
|
+
|
|
605
|
+
## Output Description
|
|
606
|
+
|
|
607
|
+
**Terminal Output** (concise summary):
|
|
608
|
+
|
|
609
|
+
```markdown
|
|
610
|
+
✅ Impact Analysis Complete
|
|
611
|
+
|
|
612
|
+
**Feature**: {feature-name}
|
|
613
|
+
**Files Changed**: {count}
|
|
614
|
+
**Features Affected**: {count}
|
|
615
|
+
**User Scenarios**: {count}
|
|
616
|
+
**Edge Cases**: {count} ({critical} critical)
|
|
617
|
+
**Risk Level**: {HIGH/MEDIUM/LOW}
|
|
618
|
+
|
|
619
|
+
{If spec available:}
|
|
620
|
+
**Requirements Coverage**: {percentage}%
|
|
621
|
+
**Tasks Completed**: {completed}/{total}
|
|
622
|
+
|
|
623
|
+
📄 **Full Report**: `.specs/impact-reports/{feature-name}-{timestamp}.md`
|
|
624
|
+
|
|
625
|
+
🚀 **Next Steps**:
|
|
626
|
+
1. Review report and fix {count} critical edge cases
|
|
627
|
+
2. Run `/test` to execute test scenarios
|
|
628
|
+
3. Run `/review` for code quality check
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
**Report File**: Comprehensive markdown report saved to `.specs/impact-reports/`
|
|
632
|
+
|
|
633
|
+
## Safety & Fallback
|
|
634
|
+
|
|
635
|
+
### Error Scenarios
|
|
636
|
+
|
|
637
|
+
**No Changes Detected**:
|
|
638
|
+
- **Message**: "No changes detected. Check git status or specify files."
|
|
639
|
+
- **Suggested Action**: "Ensure you have uncommitted changes or specify feature name"
|
|
640
|
+
|
|
641
|
+
**Feature Not Found**:
|
|
642
|
+
- **Message**: "Feature '{name}' not found in .specs/"
|
|
643
|
+
- **Suggested Action**: "Continue with standalone analysis (no spec context)"
|
|
644
|
+
- **Proceed**: Analyze changes without spec cross-reference
|
|
645
|
+
|
|
646
|
+
**Git Not Available**:
|
|
647
|
+
- **Message**: "Git not available. Cannot detect changes."
|
|
648
|
+
- **Suggested Action**: "Ensure git is installed and repository is initialized"
|
|
649
|
+
- **Fallback**: Ask user to specify files manually
|
|
650
|
+
|
|
651
|
+
**No Spec Context**:
|
|
652
|
+
- **Warning**: "No spec context available. Analysis will be standalone."
|
|
653
|
+
- **Proceed**: Continue without requirements/design/tasks cross-reference
|
|
654
|
+
- **Note**: Report will not include spec-related sections
|
|
655
|
+
|
|
656
|
+
### Next Phase
|
|
657
|
+
|
|
658
|
+
**After Impact Analysis**:
|
|
659
|
+
1. **Review Report**: Read full report at `.specs/impact-reports/latest.md`
|
|
660
|
+
2. **Fix Critical Issues**: Address all critical edge cases
|
|
661
|
+
3. **Run Tests**: Execute `/test` with generated scenarios
|
|
662
|
+
4. **Code Review**: Run `/review` for quality check
|
|
663
|
+
5. **Re-analyze** (optional): Run `/impact-analysis` again to verify fixes
|
|
664
|
+
6. **Commit**: Create commit with report attached to PR
|
|
665
|
+
|
|
666
|
+
**Workflow Integration**:
|
|
667
|
+
```
|
|
668
|
+
/code {feature-name}
|
|
669
|
+
↓ (implement all tasks)
|
|
670
|
+
/impact-analysis {feature-name}
|
|
671
|
+
↓ (review report, fix issues)
|
|
672
|
+
/test
|
|
673
|
+
↓
|
|
674
|
+
/review
|
|
675
|
+
↓
|
|
676
|
+
Commit & PR
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
## Examples
|
|
680
|
+
|
|
681
|
+
### Example 1: Feature-Based Analysis
|
|
682
|
+
|
|
683
|
+
```bash
|
|
684
|
+
# After completing user-authentication feature
|
|
685
|
+
/impact-analysis user-authentication
|
|
686
|
+
|
|
687
|
+
# Output:
|
|
688
|
+
# - Analyzes all changes for the feature
|
|
689
|
+
# - Cross-references with spec
|
|
690
|
+
# - Maps to Authentication & Login feature
|
|
691
|
+
# - Lists 5 user actions affected
|
|
692
|
+
# - Identifies 3 critical edge cases
|
|
693
|
+
# - Generates 12 test scenarios
|
|
694
|
+
# - Report saved to .specs/impact-reports/user-authentication-20260320.md
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
### Example 2: Uncommitted Changes
|
|
698
|
+
|
|
699
|
+
```bash
|
|
700
|
+
# Quick analysis of current work
|
|
701
|
+
/impact-analysis
|
|
702
|
+
|
|
703
|
+
# Output:
|
|
704
|
+
# - Analyzes uncommitted changes only
|
|
705
|
+
# - No spec context (standalone)
|
|
706
|
+
# - Maps to affected features
|
|
707
|
+
# - Identifies edge cases
|
|
708
|
+
# - Generates test scenarios
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
### Example 3: Branch-Based Analysis
|
|
712
|
+
|
|
713
|
+
```bash
|
|
714
|
+
# Analyze all changes in feature branch
|
|
715
|
+
/impact-analysis --from main
|
|
716
|
+
|
|
717
|
+
# Output:
|
|
718
|
+
# - Compares current branch with main
|
|
719
|
+
# - Analyzes all differences
|
|
720
|
+
# - Comprehensive impact report
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
## Best Practices
|
|
724
|
+
|
|
725
|
+
1. **Run After Feature Completion**: Use after implementing all tasks, not after each small change
|
|
726
|
+
2. **Review Report Thoroughly**: Don't skip edge cases and test scenarios
|
|
727
|
+
3. **Fix Critical Issues First**: Address all critical edge cases before testing
|
|
728
|
+
4. **Attach to PR**: Include report in pull request description
|
|
729
|
+
5. **Re-run After Fixes**: Verify fixes by running analysis again
|
|
730
|
+
6. **Use with Spec**: Always provide feature name for spec cross-reference
|
|
731
|
+
7. **Test All Scenarios**: Execute all critical test scenarios before deployment
|
|
732
|
+
|
|
733
|
+
---
|
|
734
|
+
|
|
735
|
+
**Preferred workflow**: `/spec-init` → `/spec-requirements` → `/spec-design` → `/spec-validate` → `/spec-tasks` → `/code` → `/impact-analysis` → `/test` → `/review`
|