claude-dev-kit 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/angelic-workshop-energy-clearing.md +113 -0
- package/.claude/agents/angelic-workshop-intake.md +84 -0
- package/.claude/agents/angelic-workshop-integration.md +140 -0
- package/.claude/agents/angelic-workshop-invocation.md +92 -0
- package/.claude/agents/angelic-workshop-lead.md +225 -0
- package/.claude/agents/angelic-workshop-transmission.md +108 -0
- package/.claude/agents/deep-think-partner.md +41 -0
- package/.claude/agents/dev-backend.md +74 -0
- package/.claude/agents/dev-e2e.md +101 -0
- package/.claude/agents/dev-frontend.md +82 -0
- package/.claude/agents/dev-lead.md +144 -0
- package/.claude/agents/dev-reviewer.md +122 -0
- package/.claude/agents/dev-test.md +88 -0
- package/.claude/agents/documentation-manager.md +73 -0
- package/.claude/agents/haiku-executor.md +8 -0
- package/.claude/agents/pm-groomer.md +98 -0
- package/.claude/agents/pm-prp-writer.md +144 -0
- package/.claude/agents/pm-sizer.md +84 -0
- package/.claude/agents/project-manager.md +91 -0
- package/.claude/agents/system-architect.md +98 -0
- package/.claude/agents/validation-gates.md +121 -0
- package/.claude/agents/workflow-builder.md +416 -0
- package/.claude/commands/ai/detect.md +117 -0
- package/.claude/commands/ai/route.md +128 -0
- package/.claude/commands/ai/switch.md +121 -0
- package/.claude/commands/bs/brainstorm_full.md +149 -0
- package/.claude/commands/bs/claude.md +37 -0
- package/.claude/commands/bs/codex.md +37 -0
- package/.claude/commands/bs/gemini.md +37 -0
- package/.claude/commands/bs/glm.md +37 -0
- package/.claude/commands/bs/grok.md +37 -0
- package/.claude/commands/bs/kimi.md +37 -0
- package/.claude/commands/bs/minimax.md +37 -0
- package/.claude/commands/bs/ollama.md +71 -0
- package/.claude/commands/code/build-and-fix.md +80 -0
- package/.claude/commands/code/simplify.md +77 -0
- package/.claude/commands/dev/backend.md +47 -0
- package/.claude/commands/dev/e2e.md +49 -0
- package/.claude/commands/dev/frontend.md +45 -0
- package/.claude/commands/dev/review.md +48 -0
- package/.claude/commands/dev/test.md +54 -0
- package/.claude/commands/dev-epic.md +121 -0
- package/.claude/commands/dev-issue.md +79 -0
- package/.claude/commands/dev.md +134 -0
- package/.claude/commands/execute-prp.md +113 -0
- package/.claude/commands/fix-github-issue.md +14 -0
- package/.claude/commands/generate-prp.md +73 -0
- package/.claude/commands/git/status.md +14 -0
- package/.claude/commands/haiku.md +13 -0
- package/.claude/commands/improve.md +178 -0
- package/.claude/commands/init.md +311 -0
- package/.claude/commands/pm/groom.md +58 -0
- package/.claude/commands/pm/plan-epic.md +74 -0
- package/.claude/commands/pm/size.md +46 -0
- package/.claude/commands/pm.md +47 -0
- package/.claude/commands/primer.md +16 -0
- package/.claude/commands/self-improve.md +243 -0
- package/.claude/commands/think.md +68 -0
- package/.claude/commands/workflow/angelic-workshop.md +89 -0
- package/.claude/commands/workflow/build.md +91 -0
- package/.claude/hooks/pre-tool-use/block-dangerous-commands.js +196 -0
- package/.claude/hooks/skill-activation-prompt/package-lock.json +560 -0
- package/.claude/hooks/skill-activation-prompt/package.json +16 -0
- package/.claude/hooks/skill-activation-prompt/skill-activation-prompt.ts +135 -0
- package/.claude/hooks/skill-activation-prompt/skill-rules.json +50 -0
- package/.claude/hooks/stop/context_monitor.py +155 -0
- package/.claude/hooks/stop/learning_logger.py +218 -0
- package/.claude/skills/ai-router/SKILL.md +119 -0
- package/.claude/skills/build-and-fix/SKILL.md +271 -0
- package/.claude/skills/build-and-fix/examples/javascript-lint-fix.md +37 -0
- package/.claude/skills/build-and-fix/language-configs/javascript.yaml +139 -0
- package/.claude/skills/build-and-fix/references/config-schema.md +120 -0
- package/.claude/skills/build-and-fix/references/error-patterns.md +273 -0
- package/.claude/skills/code-investigator/SKILL.md +299 -0
- package/.claude/skills/code-investigator/references/investigation-workflows.md +542 -0
- package/.claude/skills/code-investigator/references/language-specific.md +761 -0
- package/.claude/skills/code-investigator/references/search-patterns.md +258 -0
- package/.claude/skills/code-investigator/references/serena-patterns.md +328 -0
- package/.claude/skills/stack-detector/SKILL.md +153 -0
- package/.claude/skills/verification-before-completion/SKILL.md +143 -0
- package/.claude/templates/claude-md-template.md +56 -0
- package/.claude/templates/stacks/express-node.md +134 -0
- package/.claude/templates/stacks/fastapi.md +152 -0
- package/.claude/templates/stacks/generic.md +101 -0
- package/.claude/templates/stacks/nextjs-prisma.md +235 -0
- package/README.md +499 -0
- package/bin/claude-dev-kit.js +11 -0
- package/package.json +31 -0
- package/scripts/install.sh +448 -0
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
# Investigation Workflows
|
|
2
|
+
|
|
3
|
+
Detailed workflows for common code investigation scenarios.
|
|
4
|
+
|
|
5
|
+
**Note:** These workflows now prefer Serena MCP tools over LSP/Grep for better context and efficiency.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Workflow 1: Debug an Error
|
|
10
|
+
|
|
11
|
+
**Goal:** Find the root cause of an error message or exception.
|
|
12
|
+
|
|
13
|
+
### Step 1: Search for the Error Message (Serena-First)
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
# Preferred: Serena search with code-only filter
|
|
17
|
+
mcp__serena__search_for_pattern:
|
|
18
|
+
substring_pattern: "exact error message"
|
|
19
|
+
restrict_search_to_code_files: true
|
|
20
|
+
context_lines_before: 3
|
|
21
|
+
context_lines_after: 5
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Fallback to Grep:
|
|
25
|
+
```
|
|
26
|
+
Grep pattern="exact error message" output_mode="files_with_matches"
|
|
27
|
+
Grep pattern="key words from error" -i=true output_mode="content" -A 5 -B 5
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Step 2: Trace the Error Origin (Serena-First)
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
# Find the throwing function with context
|
|
34
|
+
mcp__serena__find_symbol:
|
|
35
|
+
name_path_pattern: "function_throwing_error"
|
|
36
|
+
include_body: true
|
|
37
|
+
include_info: true
|
|
38
|
+
|
|
39
|
+
# Find all callers with code snippets
|
|
40
|
+
mcp__serena__find_referencing_symbols:
|
|
41
|
+
name_path: "function_throwing_error"
|
|
42
|
+
relative_path: "path/to/file.ts"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Fallback to LSP:
|
|
46
|
+
- `goToDefinition` on the throwing function
|
|
47
|
+
- `findReferences` to trace callers
|
|
48
|
+
|
|
49
|
+
Fallback to Grep:
|
|
50
|
+
```
|
|
51
|
+
Grep pattern="function_throwing_error\s*\(" output_mode="content" -B 5 -A 15
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Step 3: Check Recent Changes
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
git log --oneline -20 --all -- <file_with_error>
|
|
58
|
+
git log -S "error message" --oneline
|
|
59
|
+
git blame <file> -L <start>,<end>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Step 4: Find Related Error Handling
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
Grep pattern="(try|catch|except|Result|Error)" path="<file_with_error>" -A 3 output_mode="content"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Step 5: Read Targeted Code
|
|
69
|
+
|
|
70
|
+
Convert Grep line numbers to Read ranges:
|
|
71
|
+
```
|
|
72
|
+
Read file="path/to/file" offset=<line-10> limit=25
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Anti-Patterns to Avoid
|
|
76
|
+
|
|
77
|
+
- Reading entire files "for context" before searching
|
|
78
|
+
- Searching broadly before understanding the error message
|
|
79
|
+
- Skipping git history for recently introduced bugs
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Workflow 2: Trace a Code Path
|
|
84
|
+
|
|
85
|
+
**Goal:** Understand how data flows from point A to point B.
|
|
86
|
+
|
|
87
|
+
### Preferred: Serena Symbol Tracing (Best Context)
|
|
88
|
+
|
|
89
|
+
Serena provides richer context than LSP - code snippets at each call site:
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
Step 1: Find the function with its body
|
|
93
|
+
mcp__serena__find_symbol:
|
|
94
|
+
name_path_pattern: "target_function"
|
|
95
|
+
include_body: true
|
|
96
|
+
include_info: true
|
|
97
|
+
|
|
98
|
+
Step 2: Trace BACKWARDS (who calls this?) - with snippets
|
|
99
|
+
mcp__serena__find_referencing_symbols:
|
|
100
|
+
name_path: "ClassName/target_function"
|
|
101
|
+
relative_path: "path/to/file.ts"
|
|
102
|
+
# Returns code snippets around each call site!
|
|
103
|
+
|
|
104
|
+
Step 3: For each caller, trace further back
|
|
105
|
+
mcp__serena__find_referencing_symbols:
|
|
106
|
+
name_path: "caller_function"
|
|
107
|
+
relative_path: "path/to/caller.ts"
|
|
108
|
+
|
|
109
|
+
Step 4: Check investigation quality
|
|
110
|
+
mcp__serena__think_about_collected_information
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Advantage over LSP:** Returns actual code at call sites, not just locations.
|
|
114
|
+
|
|
115
|
+
### Alternative: LSP Call Hierarchy
|
|
116
|
+
|
|
117
|
+
If cursor position is known, LSP provides fast tracing:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
Step 1: LSP prepareCallHierarchy filePath="/path/to/file" line=42 character=10
|
|
121
|
+
Step 2: LSP incomingCalls (trace backwards)
|
|
122
|
+
Step 3: LSP outgoingCalls (trace forwards)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Fallback: Grep-Based Tracing
|
|
126
|
+
|
|
127
|
+
If both Serena and LSP are unavailable:
|
|
128
|
+
|
|
129
|
+
### Step 1: Identify Entry Point
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
# Try Serena first
|
|
133
|
+
mcp__serena__search_for_pattern:
|
|
134
|
+
substring_pattern: "entry_function_name"
|
|
135
|
+
restrict_search_to_code_files: true
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Fallback:
|
|
139
|
+
```
|
|
140
|
+
Grep pattern="entry_function_name" output_mode="files_with_matches"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Step 2: Follow Function Calls
|
|
144
|
+
|
|
145
|
+
```yaml
|
|
146
|
+
# Get function body to see what it calls
|
|
147
|
+
mcp__serena__find_symbol:
|
|
148
|
+
name_path_pattern: "called_function"
|
|
149
|
+
include_body: true
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Fallback:
|
|
153
|
+
```
|
|
154
|
+
Grep pattern="^\s*(export\s+)?(async\s+)?function\s+called_function" output_mode="content" -A 10
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Step 3: Find All References (Reverse Trace)
|
|
158
|
+
|
|
159
|
+
```yaml
|
|
160
|
+
mcp__serena__find_referencing_symbols:
|
|
161
|
+
name_path: "target_function"
|
|
162
|
+
relative_path: "path/to/file.ts"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Fallback:
|
|
166
|
+
```
|
|
167
|
+
Grep pattern="target_function\s*\(" output_mode="content" -B 2 -A 5
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Step 4: Visualize the Call Chain
|
|
171
|
+
|
|
172
|
+
Document as you trace:
|
|
173
|
+
```
|
|
174
|
+
entry_point()
|
|
175
|
+
→ function_a() [src/module/file.ts:42]
|
|
176
|
+
→ function_b() [src/utils/helper.ts:18]
|
|
177
|
+
→ target_function() [src/core/processor.ts:156]
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Step 5: Store Complex Findings
|
|
181
|
+
|
|
182
|
+
For complex call chains, persist to memory:
|
|
183
|
+
```yaml
|
|
184
|
+
mcp__serena__write_memory:
|
|
185
|
+
memory_file_name: "payment-call-chain"
|
|
186
|
+
content: |
|
|
187
|
+
# Payment Processing Call Chain
|
|
188
|
+
entry_point() → ...
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Workflow 3: Learn a Library/API
|
|
194
|
+
|
|
195
|
+
**Goal:** Understand how to use an external library.
|
|
196
|
+
|
|
197
|
+
### Step 1: Check Context7 First
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
mcp__context7__resolve-library-id libraryName="library-name" query="what I want to do"
|
|
201
|
+
mcp__context7__query-docs libraryId="/org/library" query="specific topic"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Step 2: Find Usage Examples in Codebase
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
Grep pattern="import.*library-name" output_mode="files_with_matches"
|
|
208
|
+
Grep pattern="from library-name import" output_mode="files_with_matches"
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Step 3: Study Existing Implementations
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
Grep pattern="libraryFunction\(" output_mode="content" -A 5 -B 2
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Step 4: Check Configuration
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
Grep pattern="library" glob="*.{json,yaml,yml,toml,ini,env}" output_mode="content"
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Step 5: Read Targeted Examples
|
|
224
|
+
|
|
225
|
+
Select the most relevant file from Step 2 and read specific usage:
|
|
226
|
+
```
|
|
227
|
+
Read file="path/to/example" offset=<import_line> limit=50
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Workflow 4: Understand a Feature
|
|
233
|
+
|
|
234
|
+
**Goal:** Comprehensively understand how a feature works.
|
|
235
|
+
|
|
236
|
+
### Step 1: Explore Feature Directory (Serena-First)
|
|
237
|
+
|
|
238
|
+
```yaml
|
|
239
|
+
# Get directory structure
|
|
240
|
+
mcp__serena__list_dir:
|
|
241
|
+
relative_path: "src/features/feature_name"
|
|
242
|
+
recursive: true
|
|
243
|
+
skip_ignored_files: true
|
|
244
|
+
|
|
245
|
+
# For each key file, get symbol overview
|
|
246
|
+
mcp__serena__get_symbols_overview:
|
|
247
|
+
relative_path: "src/features/feature_name/index.ts"
|
|
248
|
+
depth: 1
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Fallback:
|
|
252
|
+
```
|
|
253
|
+
Grep pattern="feature_name" output_mode="files_with_matches"
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Step 2: Find Entry Points (Serena-First)
|
|
257
|
+
|
|
258
|
+
```yaml
|
|
259
|
+
# Search for exports/handlers
|
|
260
|
+
mcp__serena__find_symbol:
|
|
261
|
+
name_path_pattern: "feature"
|
|
262
|
+
substring_matching: true
|
|
263
|
+
relative_path: "src/features/"
|
|
264
|
+
|
|
265
|
+
# Or search patterns
|
|
266
|
+
mcp__serena__search_for_pattern:
|
|
267
|
+
substring_pattern: "(route|endpoint|handler).*feature"
|
|
268
|
+
restrict_search_to_code_files: true
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Step 3: Map the Architecture
|
|
272
|
+
|
|
273
|
+
Create a mental model:
|
|
274
|
+
```
|
|
275
|
+
Feature: [name]
|
|
276
|
+
├── UI Layer: [files]
|
|
277
|
+
├── API Layer: [files]
|
|
278
|
+
├── Business Logic: [files]
|
|
279
|
+
├── Data Layer: [files]
|
|
280
|
+
└── Tests: [files]
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Step 4: Trace Key Flows
|
|
284
|
+
|
|
285
|
+
Pick 2-3 critical operations and use Workflow 2 (Serena tracing) to follow them.
|
|
286
|
+
|
|
287
|
+
### Step 5: Check Tests for Behavior Specification
|
|
288
|
+
|
|
289
|
+
```yaml
|
|
290
|
+
mcp__serena__search_for_pattern:
|
|
291
|
+
substring_pattern: "describe.*feature|test.*feature"
|
|
292
|
+
paths_include_glob: "**/*.test.*"
|
|
293
|
+
context_lines_after: 20
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Step 6: Quality Check and Persist
|
|
297
|
+
|
|
298
|
+
```yaml
|
|
299
|
+
# Check if investigation is complete
|
|
300
|
+
mcp__serena__think_about_collected_information
|
|
301
|
+
|
|
302
|
+
# Store findings for future reference
|
|
303
|
+
mcp__serena__write_memory:
|
|
304
|
+
memory_file_name: "feature-name-architecture"
|
|
305
|
+
content: |
|
|
306
|
+
# Feature Architecture
|
|
307
|
+
## Entry Points
|
|
308
|
+
- ...
|
|
309
|
+
## Key Components
|
|
310
|
+
- ...
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Workflow 5: Investigate Performance Issues
|
|
316
|
+
|
|
317
|
+
**Goal:** Find performance bottlenecks.
|
|
318
|
+
|
|
319
|
+
### Step 1: Search for Known Slow Patterns
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
# N+1 queries
|
|
323
|
+
Grep pattern="for.*\{" -A 10 output_mode="content" then look for (query|find|select|fetch)
|
|
324
|
+
|
|
325
|
+
# Synchronous operations in async code
|
|
326
|
+
Grep pattern="(sync|blocking|sleep)" type="rust" output_mode="content"
|
|
327
|
+
|
|
328
|
+
# Missing indexes (comments/TODOs)
|
|
329
|
+
Grep pattern="(slow|performance|optimize|TODO.*index)" -i=true output_mode="content"
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Step 2: Find Heavy Operations
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
# Large data operations
|
|
336
|
+
Grep pattern="(map|filter|reduce|forEach)\s*\(" -A 3 output_mode="content"
|
|
337
|
+
|
|
338
|
+
# File I/O
|
|
339
|
+
Grep pattern="(readFile|writeFile|open\(|File::)" output_mode="content"
|
|
340
|
+
|
|
341
|
+
# Network calls
|
|
342
|
+
Grep pattern="(fetch|axios|http\.|request\()" output_mode="content"
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Step 3: Check Caching
|
|
346
|
+
|
|
347
|
+
```
|
|
348
|
+
Grep pattern="(cache|memo|lazy|preload)" -i=true output_mode="files_with_matches"
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Step 4: Review Database Queries
|
|
352
|
+
|
|
353
|
+
```
|
|
354
|
+
Grep pattern="(SELECT|INSERT|UPDATE|DELETE|\.query|\.execute)" -A 2 output_mode="content"
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Step 5: Examine Loops and Iterations
|
|
358
|
+
|
|
359
|
+
```
|
|
360
|
+
Grep pattern="(for\s*\(|while\s*\(|\.forEach|\.map\()" -A 5 output_mode="content" glob="!*test*"
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## Workflow 6: Security Audit
|
|
366
|
+
|
|
367
|
+
**Goal:** Find potential security vulnerabilities.
|
|
368
|
+
|
|
369
|
+
### Step 1: Search for Common Vulnerabilities
|
|
370
|
+
|
|
371
|
+
```
|
|
372
|
+
# SQL Injection
|
|
373
|
+
Grep pattern="(\+.*query|query.*\+|f\".*SELECT|\.format.*SELECT)" output_mode="content"
|
|
374
|
+
|
|
375
|
+
# Command Injection
|
|
376
|
+
Grep pattern="(exec\(|spawn\(|system\(|subprocess|child_process)" output_mode="content"
|
|
377
|
+
|
|
378
|
+
# XSS
|
|
379
|
+
Grep pattern="(innerHTML|dangerouslySetInnerHTML|v-html)" output_mode="content"
|
|
380
|
+
|
|
381
|
+
# Hardcoded secrets
|
|
382
|
+
Grep pattern="(password|secret|api_key|token)\s*=\s*['\"]" -i=true output_mode="content"
|
|
383
|
+
|
|
384
|
+
# Insecure randomness
|
|
385
|
+
Grep pattern="(Math\.random|random\(\))" output_mode="content"
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Step 2: Check Input Validation
|
|
389
|
+
|
|
390
|
+
```
|
|
391
|
+
Grep pattern="(validate|sanitize|escape|encode)" output_mode="files_with_matches"
|
|
392
|
+
Grep pattern="(req\.body|req\.params|req\.query)" -A 3 output_mode="content"
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Step 3: Review Authentication/Authorization
|
|
396
|
+
|
|
397
|
+
```
|
|
398
|
+
Grep pattern="(auth|login|session|jwt|token)" -i=true output_mode="files_with_matches"
|
|
399
|
+
Grep pattern="(middleware|guard|interceptor)" -A 5 output_mode="content"
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Step 4: Check Dependencies
|
|
403
|
+
|
|
404
|
+
```
|
|
405
|
+
# Look for known vulnerable patterns in package files
|
|
406
|
+
Glob pattern="**/package.json"
|
|
407
|
+
Glob pattern="**/Cargo.toml"
|
|
408
|
+
Glob pattern="**/requirements.txt"
|
|
409
|
+
Glob pattern="**/go.mod"
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## Workflow 7: Prepare for Refactoring
|
|
415
|
+
|
|
416
|
+
**Goal:** Understand impact before making changes.
|
|
417
|
+
|
|
418
|
+
### Step 1: Find All References (Serena-First)
|
|
419
|
+
|
|
420
|
+
```yaml
|
|
421
|
+
# Get all usages with code context
|
|
422
|
+
mcp__serena__find_referencing_symbols:
|
|
423
|
+
name_path: "symbol_to_refactor"
|
|
424
|
+
relative_path: "path/to/symbol/file.ts"
|
|
425
|
+
include_info: true
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Fallback to LSP `findReferences`, then Grep:
|
|
429
|
+
```
|
|
430
|
+
Grep pattern="symbol_to_refactor" output_mode="files_with_matches"
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Step 2: Check for Dynamic Usage
|
|
434
|
+
|
|
435
|
+
```yaml
|
|
436
|
+
mcp__serena__search_for_pattern:
|
|
437
|
+
substring_pattern: "\\[.*symbol_to_refactor.*\\]|eval\\(|new Function"
|
|
438
|
+
restrict_search_to_code_files: true
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### Step 3: Review Tests
|
|
442
|
+
|
|
443
|
+
```yaml
|
|
444
|
+
mcp__serena__search_for_pattern:
|
|
445
|
+
substring_pattern: "symbol_to_refactor"
|
|
446
|
+
paths_include_glob: "**/*test*"
|
|
447
|
+
context_lines_before: 2
|
|
448
|
+
context_lines_after: 5
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### Step 4: Check for External Exposure
|
|
452
|
+
|
|
453
|
+
```yaml
|
|
454
|
+
# Public API exposure
|
|
455
|
+
mcp__serena__search_for_pattern:
|
|
456
|
+
substring_pattern: "export.*symbol_to_refactor|(public|pub)\\s+.*symbol_to_refactor"
|
|
457
|
+
restrict_search_to_code_files: true
|
|
458
|
+
|
|
459
|
+
# Configuration references
|
|
460
|
+
mcp__serena__search_for_pattern:
|
|
461
|
+
substring_pattern: "symbol_to_refactor"
|
|
462
|
+
paths_include_glob: "**/*.{json,yaml,yml,toml}"
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### Step 5: Quality Check Before Proceeding
|
|
466
|
+
|
|
467
|
+
```yaml
|
|
468
|
+
# Verify we have complete impact assessment
|
|
469
|
+
mcp__serena__think_about_task_adherence
|
|
470
|
+
|
|
471
|
+
# Ensure we haven't missed anything
|
|
472
|
+
mcp__serena__think_about_collected_information
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### Step 6: Document Impact
|
|
476
|
+
|
|
477
|
+
```yaml
|
|
478
|
+
mcp__serena__write_memory:
|
|
479
|
+
memory_file_name: "refactor-symbol-impact"
|
|
480
|
+
content: |
|
|
481
|
+
# Refactoring Impact: symbol_to_refactor
|
|
482
|
+
|
|
483
|
+
## Files Affected
|
|
484
|
+
- file1.ts (5 usages)
|
|
485
|
+
- file2.ts (2 usages)
|
|
486
|
+
|
|
487
|
+
## Test Coverage
|
|
488
|
+
- Tests exist in test_file.ts
|
|
489
|
+
|
|
490
|
+
## External Exposure
|
|
491
|
+
- Exported from public API: yes/no
|
|
492
|
+
|
|
493
|
+
## Risk Level
|
|
494
|
+
- Low/Medium/High
|
|
495
|
+
|
|
496
|
+
## Recommended Approach
|
|
497
|
+
- ...
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
### Step 7: Execute Refactoring (if approved)
|
|
501
|
+
|
|
502
|
+
```yaml
|
|
503
|
+
# Serena can rename across codebase
|
|
504
|
+
mcp__serena__rename_symbol:
|
|
505
|
+
name_path: "symbol_to_refactor"
|
|
506
|
+
relative_path: "path/to/file.ts"
|
|
507
|
+
new_name: "new_symbol_name"
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
## Git Investigation Patterns
|
|
513
|
+
|
|
514
|
+
### Find When Something Was Introduced
|
|
515
|
+
|
|
516
|
+
```bash
|
|
517
|
+
git log -S "pattern" --oneline
|
|
518
|
+
git log -G "regex" --oneline
|
|
519
|
+
git log --all --oneline -- path/to/file
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Find Who Wrote Code
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
git blame file.ts -L 100,120
|
|
526
|
+
git log --follow -p -- path/to/file
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
### Find Related Changes
|
|
530
|
+
|
|
531
|
+
```bash
|
|
532
|
+
git log --oneline --since="2 weeks ago" -- path/
|
|
533
|
+
git diff HEAD~10..HEAD -- path/to/file
|
|
534
|
+
git log --grep="feature" --oneline
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### Compare Branches
|
|
538
|
+
|
|
539
|
+
```bash
|
|
540
|
+
git diff main..feature-branch -- path/
|
|
541
|
+
git log main..feature-branch --oneline
|
|
542
|
+
```
|