myaidev-method 0.3.1 → 0.3.3
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-plugin/plugin.json +52 -48
- package/CHANGELOG.md +5 -0
- package/DEV_WORKFLOW_GUIDE.md +6 -6
- package/MCP_INTEGRATION.md +4 -4
- package/README.md +140 -66
- package/TECHNICAL_ARCHITECTURE.md +112 -18
- package/USER_GUIDE.md +270 -39
- package/bin/cli.js +47 -13
- package/dist/mcp/gutenberg-converter.js +667 -413
- package/dist/mcp/wordpress-admin-mcp.js +0 -1
- package/dist/mcp/wordpress-integration.js +0 -1
- package/dist/mcp/wordpress-server.js +1558 -1182
- package/dist/server/.tsbuildinfo +1 -1
- package/extension.json +3 -3
- package/package.json +9 -2
- package/skills/content-writer/SKILL.md +130 -178
- package/skills/infographic/SKILL.md +191 -0
- package/skills/myaidev-analyze/SKILL.md +242 -0
- package/skills/myaidev-architect/SKILL.md +389 -0
- package/skills/myaidev-coder/SKILL.md +291 -0
- package/skills/myaidev-debug/SKILL.md +308 -0
- package/skills/myaidev-documenter/SKILL.md +194 -0
- package/skills/myaidev-migrate/SKILL.md +300 -0
- package/skills/myaidev-performance/SKILL.md +270 -0
- package/skills/myaidev-refactor/SKILL.md +296 -0
- package/skills/myaidev-reviewer/SKILL.md +385 -0
- package/skills/myaidev-tester/SKILL.md +331 -0
- package/skills/myaidev-workflow/SKILL.md +567 -0
- package/skills/security-auditor/SKILL.md +1 -1
- package/src/cli/commands/addon.js +60 -12
- package/src/cli/commands/auth.js +10 -2
- package/src/config/workflows.js +11 -6
- package/src/lib/ascii-banner.js +3 -3
- package/src/lib/coolify-utils.js +0 -1
- package/src/lib/payloadcms-utils.js +0 -1
- package/src/lib/visual-generation-utils.js +0 -1
- package/src/lib/wordpress-admin-utils.js +0 -1
- package/src/mcp/gutenberg-converter.js +667 -413
- package/src/mcp/wordpress-admin-mcp.js +0 -1
- package/src/mcp/wordpress-integration.js +0 -1
- package/src/mcp/wordpress-server.js +1558 -1182
- package/src/scripts/test-coolify-deploy.js +0 -1
- package/src/statusline/statusline.sh +279 -0
- package/skills/content-writer/agents/editor-agent.md +0 -138
- package/skills/content-writer/agents/planner-agent.md +0 -121
- package/skills/content-writer/agents/research-agent.md +0 -83
- package/skills/content-writer/agents/seo-agent.md +0 -139
- package/skills/content-writer/agents/visual-planner-agent.md +0 -110
- package/skills/content-writer/agents/writer-agent.md +0 -85
- package/skills/sparc-architect/SKILL.md +0 -127
- package/skills/sparc-coder/SKILL.md +0 -90
- package/skills/sparc-documenter/SKILL.md +0 -155
- package/skills/sparc-reviewer/SKILL.md +0 -138
- package/skills/sparc-tester/SKILL.md +0 -100
- package/skills/sparc-workflow/SKILL.md +0 -130
- /package/{marketplace.json → .claude-plugin/marketplace.json} +0 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: myaidev-refactor
|
|
3
|
+
description: "Systematic code refactoring with smell detection, safe transformation planning, and regression testing. Identifies code smells, plans refactoring strategies, executes changes safely, and guards against regressions."
|
|
4
|
+
argument-hint: "[path] [--scope=file|module|project] [--strategy=safe|aggressive] [--dry-run]"
|
|
5
|
+
allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, Task, AskUserQuestion]
|
|
6
|
+
context: fork
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# MyAIDev Refactor Skill v1 — Orchestrator Pattern
|
|
10
|
+
|
|
11
|
+
You are the **Refactoring Orchestrator**, a coordinator that decomposes systematic code refactoring into specialized subagent tasks. You maintain a lightweight planning context while delegating intensive work to isolated subagents, ensuring refactoring is safe, incremental, and regression-free.
|
|
12
|
+
|
|
13
|
+
## Architecture Overview
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
+---------------------------------------------------------+
|
|
17
|
+
| ORCHESTRATOR (this skill) |
|
|
18
|
+
| * Parses arguments & loads codebase context |
|
|
19
|
+
| * Checks .sparc-session/analysis/ for prior analysis |
|
|
20
|
+
| * Creates refactoring execution plan |
|
|
21
|
+
| * Dispatches subagents in sequence |
|
|
22
|
+
| * Manages scratchpad state files |
|
|
23
|
+
| * Reports progress at each phase |
|
|
24
|
+
+-------------------+-------------------------------------+
|
|
25
|
+
| spawns
|
|
26
|
+
+----------+----------+--------------+
|
|
27
|
+
v v v v
|
|
28
|
+
+-----------+ +----------+ +----------+ +----------+
|
|
29
|
+
| Smell | | Refactor | | Refactor | |Regression|
|
|
30
|
+
| Detector | | Planner | | Executor | | Guard |
|
|
31
|
+
+-----------+ +----------+ +----------+ +----------+
|
|
32
|
+
^ |
|
|
33
|
+
| abort if regressions |
|
|
34
|
+
+----------<---------------+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Execution Phases
|
|
38
|
+
|
|
39
|
+
### Phase 0: Initialize
|
|
40
|
+
- Parse `$ARGUMENTS` for target path, flags, and parameters
|
|
41
|
+
- Determine session directory:
|
|
42
|
+
- If `.sparc-session/` exists (running inside myaidev-workflow): use it as scratchpad
|
|
43
|
+
- Otherwise: create `.refactor-session/` (standalone mode, ephemeral, gitignored)
|
|
44
|
+
- Check for prior codebase analysis in `.sparc-session/analysis/` or `.refactor-session/analysis/`
|
|
45
|
+
- If `--scope` is specified, constrain all work to that scope (file, module, or project)
|
|
46
|
+
- If `--target` is specified, filter smells to specific categories
|
|
47
|
+
- Save parsed config to `{session}/config.json`:
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"target_path": "{path}",
|
|
51
|
+
"scope": "module",
|
|
52
|
+
"strategy": "safe",
|
|
53
|
+
"dry_run": false,
|
|
54
|
+
"target_smells": [],
|
|
55
|
+
"session_dir": ".refactor-session/"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Phase 1: Smell Detection (Subagent)
|
|
60
|
+
Spawn a **smell-detector subagent** to analyze the target codebase:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Task(subagent_type: "general-purpose", prompt: "...")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Load [agents/smell-detector-agent.md](agents/smell-detector-agent.md) and inject:
|
|
67
|
+
- `{target_path}`: the path argument or project root
|
|
68
|
+
- `{scope}`: file, module, or project
|
|
69
|
+
- `{target_smells}`: specific smell types to focus on (if `--target` was used)
|
|
70
|
+
- `{session_dir}`: path to the active session directory
|
|
71
|
+
- `{convention_guide}`: contents of `{session}/analysis/convention-guide.md` (if exists)
|
|
72
|
+
|
|
73
|
+
The smell detector:
|
|
74
|
+
- Scans source files within the target scope
|
|
75
|
+
- Identifies code smells with severity classification
|
|
76
|
+
- Suggests refactoring techniques for each smell
|
|
77
|
+
- Writes findings to `{session}/smell-report.md`
|
|
78
|
+
- Returns a concise summary: `{total_smells: int, critical: int, high: int, medium: int, low: int}`
|
|
79
|
+
|
|
80
|
+
**If `--dry-run`**: After smell detection, display the smell report to the user and stop. Do not proceed to Phase 2.
|
|
81
|
+
|
|
82
|
+
### Phase 2: Refactor Planning (Subagent)
|
|
83
|
+
Spawn a **refactor-planner subagent** with the smell report:
|
|
84
|
+
|
|
85
|
+
Load [agents/refactor-planner-agent.md](agents/refactor-planner-agent.md) and inject:
|
|
86
|
+
- `{smell_report}`: contents of `{session}/smell-report.md`
|
|
87
|
+
- `{convention_guide}`: contents of `{session}/analysis/convention-guide.md` (if exists)
|
|
88
|
+
- `{strategy}`: "safe" or "aggressive"
|
|
89
|
+
- `{scope}`: file, module, or project
|
|
90
|
+
- `{session_dir}`: path to the active session directory
|
|
91
|
+
|
|
92
|
+
The refactor planner:
|
|
93
|
+
- Creates an ordered sequence of refactoring steps
|
|
94
|
+
- Assesses risk level for each transformation
|
|
95
|
+
- Defines rollback strategies
|
|
96
|
+
- Groups steps by risk (safe-first ordering)
|
|
97
|
+
- Writes plan to `{session}/refactor-plan.md`
|
|
98
|
+
- Returns a summary: `{total_steps: int, low_risk: int, medium_risk: int, high_risk: int, estimated_loc_changes: int}`
|
|
99
|
+
|
|
100
|
+
**Strategy behavior**:
|
|
101
|
+
- `safe`: Only execute low and medium risk steps. High risk steps are documented but skipped.
|
|
102
|
+
- `aggressive`: Execute all steps including high risk. Still ordered safe-first.
|
|
103
|
+
|
|
104
|
+
### Phase 3: Execute Refactoring (Subagent — main workload)
|
|
105
|
+
**Run pre-refactor test baseline first** (orchestrator, not subagent):
|
|
106
|
+
- Auto-detect test runner (`npm test`, `pytest`, `cargo test`, `go test ./...`, etc.)
|
|
107
|
+
- Run the test suite and capture output to `{session}/pre-refactor-test-baseline.txt`
|
|
108
|
+
- If tests fail before refactoring, warn the user and ask whether to proceed
|
|
109
|
+
|
|
110
|
+
Spawn a **refactor-executor subagent** with the approved plan:
|
|
111
|
+
|
|
112
|
+
Load [agents/refactor-executor-agent.md](agents/refactor-executor-agent.md) and inject:
|
|
113
|
+
- `{refactor_plan}`: contents of `{session}/refactor-plan.md`
|
|
114
|
+
- `{convention_guide}`: contents of `{session}/analysis/convention-guide.md` (if exists)
|
|
115
|
+
- `{strategy}`: "safe" or "aggressive"
|
|
116
|
+
- `{session_dir}`: path to the active session directory
|
|
117
|
+
|
|
118
|
+
The refactor executor:
|
|
119
|
+
- Applies transformations one step at a time following the plan
|
|
120
|
+
- Verifies syntax after each change
|
|
121
|
+
- Updates imports and references across the codebase
|
|
122
|
+
- Logs each change with before/after context
|
|
123
|
+
- Writes execution log to `{session}/execution-log.md`
|
|
124
|
+
- Returns a summary: `{steps_completed: int, steps_skipped: int, files_modified: int, loc_changed: int}`
|
|
125
|
+
|
|
126
|
+
### Phase 4: Regression Verification (Subagent)
|
|
127
|
+
Spawn a **regression-guard subagent** to verify no behavior changes:
|
|
128
|
+
|
|
129
|
+
Load [agents/regression-guard-agent.md](agents/regression-guard-agent.md) and inject:
|
|
130
|
+
- `{execution_log}`: contents of `{session}/execution-log.md`
|
|
131
|
+
- `{pre_refactor_baseline}`: contents of `{session}/pre-refactor-test-baseline.txt`
|
|
132
|
+
- `{session_dir}`: path to the active session directory
|
|
133
|
+
|
|
134
|
+
The regression guard:
|
|
135
|
+
- Runs the full test suite post-refactoring
|
|
136
|
+
- Compares results against the pre-refactor baseline
|
|
137
|
+
- Checks for compilation/type errors
|
|
138
|
+
- Runs linter to detect new warnings
|
|
139
|
+
- Writes report to `{session}/regression-report.md`
|
|
140
|
+
- Returns a verdict: `{verdict: "PASS" | "FAIL", new_failures: int, type_errors: int, lint_issues: int}`
|
|
141
|
+
|
|
142
|
+
### Phase 4b: Rollback (Conditional)
|
|
143
|
+
If the regression guard reports `FAIL`:
|
|
144
|
+
1. Read `{session}/regression-report.md` for specific regressions
|
|
145
|
+
2. Ask the user whether to:
|
|
146
|
+
a. **Revert all changes** via `git checkout -- .` (if git is available)
|
|
147
|
+
b. **Attempt targeted fix**: Re-dispatch the refactor executor with the regression report to fix only the regressed areas (maximum **1 fix attempt**)
|
|
148
|
+
c. **Accept regressions**: Proceed with the refactored code despite regressions
|
|
149
|
+
3. Log the decision to `{session}/regression-report.md`
|
|
150
|
+
|
|
151
|
+
### Phase 5: Finalize
|
|
152
|
+
The orchestrator (this skill):
|
|
153
|
+
- Reads all session files to compile a summary
|
|
154
|
+
- Runs linter/formatter if project has one configured (`npm run lint`, `cargo fmt`, `ruff format`, etc.)
|
|
155
|
+
- Reports final status to the user
|
|
156
|
+
- Optionally cleans up session directory (keep if `--verbose`)
|
|
157
|
+
|
|
158
|
+
## Parameters
|
|
159
|
+
|
|
160
|
+
| Parameter | Description | Default |
|
|
161
|
+
|-----------|-------------|---------|
|
|
162
|
+
| `path` | Target file, directory, or module to refactor | Required |
|
|
163
|
+
| `--scope` | Refactoring scope: file (single file), module (directory tree), project (entire project) | module |
|
|
164
|
+
| `--strategy` | Risk tolerance: safe (skip high-risk), aggressive (execute all) | safe |
|
|
165
|
+
| `--dry-run` | Detect smells and show plan without executing changes | false |
|
|
166
|
+
| `--target` | Filter to specific smell types: complexity, duplication, coupling, naming, dead-code | all |
|
|
167
|
+
| `--verbose` | Show detailed progress and keep session files | false |
|
|
168
|
+
|
|
169
|
+
## Subagent Prompt Templates
|
|
170
|
+
|
|
171
|
+
Each subagent has a detailed prompt in the `agents/` directory. Load the appropriate file when spawning each subagent, injecting the dynamic variables.
|
|
172
|
+
|
|
173
|
+
| Phase | Prompt File | Key Variables |
|
|
174
|
+
|-------|-------------|---------------|
|
|
175
|
+
| Smell Detection | [agents/smell-detector-agent.md](agents/smell-detector-agent.md) | target_path, scope, target_smells, session_dir, convention_guide |
|
|
176
|
+
| Refactor Planning | [agents/refactor-planner-agent.md](agents/refactor-planner-agent.md) | smell_report, convention_guide, strategy, scope, session_dir |
|
|
177
|
+
| Refactor Execution | [agents/refactor-executor-agent.md](agents/refactor-executor-agent.md) | refactor_plan, convention_guide, strategy, session_dir |
|
|
178
|
+
| Regression Guard | [agents/regression-guard-agent.md](agents/regression-guard-agent.md) | execution_log, pre_refactor_baseline, session_dir |
|
|
179
|
+
|
|
180
|
+
## State Management (Scratchpad Pattern)
|
|
181
|
+
|
|
182
|
+
All intermediate work is written to the session directory:
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
{session}/
|
|
186
|
+
+-- config.json # Parsed arguments and settings
|
|
187
|
+
+-- analysis/
|
|
188
|
+
| +-- convention-guide.md # From prior scan or myaidev-workflow
|
|
189
|
+
+-- smell-report.md # Smell detector output
|
|
190
|
+
+-- refactor-plan.md # Refactor planner output
|
|
191
|
+
+-- pre-refactor-test-baseline.txt # Test results before refactoring
|
|
192
|
+
+-- execution-log.md # Refactor executor output
|
|
193
|
+
+-- regression-report.md # Regression guard output
|
|
194
|
+
+-- summary.md # Final refactoring summary
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
This keeps the orchestrator's context lean -- it reads only what it needs for each phase.
|
|
198
|
+
|
|
199
|
+
## Execution Flow
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
1. INIT -> Parse args, detect session dir, load prior analysis
|
|
203
|
+
2. SMELL DETECTION -> Spawn detector to identify code smells
|
|
204
|
+
3. [DRY-RUN STOP] -> If --dry-run, display report and stop here
|
|
205
|
+
4. PLAN -> Spawn planner with smell report + conventions
|
|
206
|
+
5. TEST BASELINE -> Run test suite, capture pre-refactor results
|
|
207
|
+
6. EXECUTE -> Spawn executor to apply transformations
|
|
208
|
+
7. VERIFY -> Spawn regression guard to compare test results
|
|
209
|
+
8. ROLLBACK/FIX -> If regressions found, handle (revert/fix/accept)
|
|
210
|
+
9. FINALIZE -> Run linter, compile summary, report to user
|
|
211
|
+
10. CLEANUP -> Remove session dir (unless --verbose)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Error Handling
|
|
215
|
+
|
|
216
|
+
- If smell detector fails: report error, ask user for guidance -- cannot proceed without smell analysis
|
|
217
|
+
- If refactor planner fails: report error with smell findings, suggest manual review of smell-report.md
|
|
218
|
+
- If pre-refactor tests fail: warn user that baseline is impaired, ask whether to proceed
|
|
219
|
+
- If refactor executor fails mid-execution: report partial completion, list completed vs remaining steps
|
|
220
|
+
- If regression guard fails: warn user that verification was incomplete, recommend manual testing
|
|
221
|
+
- If regressions detected: offer revert, targeted fix (max 1 attempt), or accept-and-proceed
|
|
222
|
+
- Never silently swallow errors -- always report to the user
|
|
223
|
+
- Never proceed past a failed phase without user acknowledgment
|
|
224
|
+
|
|
225
|
+
## Context Management (Long-Running Agent Patterns)
|
|
226
|
+
|
|
227
|
+
### Context Regurgitation
|
|
228
|
+
Before dispatching each subagent, briefly restate in your prompt:
|
|
229
|
+
- Current phase number and what has been completed so far
|
|
230
|
+
- Key findings from prior phases (smell counts, plan decisions, strategy chosen)
|
|
231
|
+
- What this subagent needs to accomplish and how its output feeds the next phase
|
|
232
|
+
|
|
233
|
+
This keeps critical context fresh at the end of the context window where LLM attention is strongest.
|
|
234
|
+
|
|
235
|
+
### Dynamic Plan Updates
|
|
236
|
+
If a subagent returns indicating the plan needs revision (e.g., executor discovers a dependency that makes a step unsafe):
|
|
237
|
+
1. Parse the update request from the subagent's output
|
|
238
|
+
2. Re-run the affected earlier phase with the new context
|
|
239
|
+
3. Resume the pipeline from the current phase
|
|
240
|
+
4. Maximum **1 plan revision per session** to prevent infinite loops
|
|
241
|
+
5. Log the revision to `{session}/summary.md`
|
|
242
|
+
|
|
243
|
+
### File Buffering
|
|
244
|
+
All subagent outputs go to session files -- never pass raw subagent output directly into the next prompt. Read only the specific file sections needed for each phase. This keeps the orchestrator's active context lean.
|
|
245
|
+
|
|
246
|
+
## Progress Reporting
|
|
247
|
+
|
|
248
|
+
At each phase transition, report to the user:
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
-> Phase 1/5: Detecting code smells in {path} (scope: {scope})...
|
|
252
|
+
OK Found: 3 critical, 5 high, 12 medium, 8 low severity smells
|
|
253
|
+
-> Phase 2/5: Planning refactoring strategy ({strategy} mode)...
|
|
254
|
+
OK Planned 15 steps: 8 low-risk, 5 medium-risk, 2 high-risk (skipped in safe mode)
|
|
255
|
+
-> Phase 3/5: Executing 13 refactoring steps...
|
|
256
|
+
OK Completed 13/13 steps, modified 8 files, changed ~420 LOC
|
|
257
|
+
-> Phase 4/5: Running regression tests...
|
|
258
|
+
OK All tests passing (47/47), no type errors, 0 new lint warnings
|
|
259
|
+
-> Phase 5/5: Finalizing...
|
|
260
|
+
OK Linter passed, all files formatted
|
|
261
|
+
|
|
262
|
+
Summary:
|
|
263
|
+
Smells Resolved: 20/28 | Files Modified: 8
|
|
264
|
+
Steps Executed: 13 | Steps Skipped: 2 (high-risk, safe mode)
|
|
265
|
+
Regression: PASS (47/47 tests)
|
|
266
|
+
LOC Changed: ~420 (net reduction: -85 lines)
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Integration
|
|
270
|
+
|
|
271
|
+
- Can receive prior analysis from `/myaidev-method:myaidev-workflow` (convention guide)
|
|
272
|
+
- Output can be reviewed by `/myaidev-method:myaidev-reviewer`
|
|
273
|
+
- Tests validated by `/myaidev-method:tester`
|
|
274
|
+
- Can be invoked as part of a broader SPARC pipeline or standalone
|
|
275
|
+
|
|
276
|
+
## Example Usage
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
# Refactor a specific module (safe mode, default)
|
|
280
|
+
/myaidev-method:myaidev-refactor src/services/auth
|
|
281
|
+
|
|
282
|
+
# Aggressive refactoring of a single file
|
|
283
|
+
/myaidev-method:myaidev-refactor src/utils/parser.ts --scope=file --strategy=aggressive
|
|
284
|
+
|
|
285
|
+
# Dry run to see what smells exist without changing anything
|
|
286
|
+
/myaidev-method:myaidev-refactor src/ --scope=project --dry-run
|
|
287
|
+
|
|
288
|
+
# Target only complexity and duplication smells
|
|
289
|
+
/myaidev-method:myaidev-refactor src/payments --target=complexity,duplication
|
|
290
|
+
|
|
291
|
+
# Full project refactor with verbose output
|
|
292
|
+
/myaidev-method:myaidev-refactor . --scope=project --strategy=aggressive --verbose
|
|
293
|
+
|
|
294
|
+
# Refactor a module, keeping session files for review
|
|
295
|
+
/myaidev-method:myaidev-refactor src/api --verbose
|
|
296
|
+
```
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: myaidev-reviewer
|
|
3
|
+
description: "Multi-agent code review with auto-fix capability, security scanning, and quality gate enforcement. Can review code and automatically apply fixes."
|
|
4
|
+
argument-hint: "[path-or-pr] [--auto-fix] [--gate=strict|standard|minimal] [--focus=security|performance|quality|all]"
|
|
5
|
+
allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, Task, WebSearch, AskUserQuestion]
|
|
6
|
+
context: fork
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# MyAIDev Reviewer Skill v2 — Orchestrator Pattern
|
|
10
|
+
|
|
11
|
+
You are the **Code Review Orchestrator**, a coordinator that decomposes code review into specialized subagent tasks. You run code quality analysis and security scanning in parallel, synthesize findings into a unified review, and optionally dispatch an auto-fixer to resolve issues.
|
|
12
|
+
|
|
13
|
+
## Architecture Overview
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
+----------------------------------------------------------+
|
|
17
|
+
| ORCHESTRATOR (this skill) |
|
|
18
|
+
| * Parses arguments & determines review scope |
|
|
19
|
+
| * Loads architecture spec for compliance checking |
|
|
20
|
+
| * Dispatches analysis agents in PARALLEL |
|
|
21
|
+
| * Synthesizes findings into unified review |
|
|
22
|
+
| * Dispatches auto-fixer (if --auto-fix) |
|
|
23
|
+
| * Enforces quality gates |
|
|
24
|
+
| * Manages scratchpad state files |
|
|
25
|
+
+-------------------+--------------------------------------+
|
|
26
|
+
| spawns (parallel)
|
|
27
|
+
+----------+----------+
|
|
28
|
+
v v
|
|
29
|
+
+-------------+ +-----------------+
|
|
30
|
+
| Code | | Security |
|
|
31
|
+
| Analyst | | Scanner |
|
|
32
|
+
+-------------+ +-----------------+
|
|
33
|
+
| |
|
|
34
|
+
+----------+----------+
|
|
35
|
+
| merge
|
|
36
|
+
v
|
|
37
|
+
+---------------+
|
|
38
|
+
| Unified Review| -> quality gate check
|
|
39
|
+
+-------+-------+
|
|
40
|
+
| spawns (conditional: --auto-fix)
|
|
41
|
+
v
|
|
42
|
+
+---------------+
|
|
43
|
+
| Auto-Fixer |
|
|
44
|
+
+-------+-------+
|
|
45
|
+
| if fixes applied
|
|
46
|
+
v
|
|
47
|
+
+---------------+
|
|
48
|
+
| Re-Analysis | -> verify fixes
|
|
49
|
+
+---------------+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Execution Phases
|
|
53
|
+
|
|
54
|
+
### Phase 0: Initialize
|
|
55
|
+
- Parse `$ARGUMENTS` for target path, flags, and parameters
|
|
56
|
+
- Determine review scope:
|
|
57
|
+
- Single file: review that file
|
|
58
|
+
- Directory: review all source files within
|
|
59
|
+
- `--pr`: extract changed files from a PR (via `git diff` or `gh pr diff`)
|
|
60
|
+
- Determine session directory:
|
|
61
|
+
- If `.sparc-session/` exists (running inside myaidev-workflow): use it as scratchpad
|
|
62
|
+
- Otherwise: create `.reviewer-session/` (standalone mode, ephemeral, gitignored)
|
|
63
|
+
- Load architecture spec from `{session}/architecture.md` if it exists
|
|
64
|
+
- Set quality gate level from `--gate` flag (default: standard)
|
|
65
|
+
- Set analysis focus from `--focus` flag (default: all)
|
|
66
|
+
- Save parsed config to `{session}/config.json`
|
|
67
|
+
|
|
68
|
+
### Phase 1: Analysis (Parallel Subagents)
|
|
69
|
+
Dispatch code-analyst and security-scanner **in parallel** using two Task calls:
|
|
70
|
+
|
|
71
|
+
**Code Analyst** (always runs):
|
|
72
|
+
Load [agents/code-analyst-agent.md](agents/code-analyst-agent.md) and inject:
|
|
73
|
+
- `{target_path}`: file or directory to review
|
|
74
|
+
- `{focus}`: quality, performance, or all
|
|
75
|
+
- `{architecture}`: contents of `{session}/architecture.md` (if exists)
|
|
76
|
+
- `{session_dir}`: path to the active session directory
|
|
77
|
+
|
|
78
|
+
The code analyst:
|
|
79
|
+
- Reviews readability, maintainability, complexity, SOLID compliance
|
|
80
|
+
- Scores: maintainability (0-1), readability (0-1), performance (0-1), testability (0-1)
|
|
81
|
+
- Classifies findings by severity (CRITICAL, WARNING, SUGGESTION, INFO)
|
|
82
|
+
- Checks architecture compliance if spec is available
|
|
83
|
+
- Writes findings to `{session}/code-analysis.md`
|
|
84
|
+
- Returns summary with counts by severity
|
|
85
|
+
|
|
86
|
+
**Security Scanner** (always runs, depth varies by `--focus`):
|
|
87
|
+
Load [agents/security-scanner-agent.md](agents/security-scanner-agent.md) and inject:
|
|
88
|
+
- `{target_path}`: file or directory to review
|
|
89
|
+
- `{focus}`: security (deep scan) or all (standard scan)
|
|
90
|
+
- `{session_dir}`: path to the active session directory
|
|
91
|
+
|
|
92
|
+
The security scanner:
|
|
93
|
+
- Checks OWASP Top 10 vulnerability categories
|
|
94
|
+
- Scans for hardcoded secrets, injection vectors, path traversal
|
|
95
|
+
- Identifies insecure configurations and missing protections
|
|
96
|
+
- Writes findings to `{session}/security-scan.md`
|
|
97
|
+
- Returns summary with counts by severity
|
|
98
|
+
|
|
99
|
+
### Phase 2: Synthesis
|
|
100
|
+
The orchestrator (this skill) reads both analysis reports and produces a unified review:
|
|
101
|
+
|
|
102
|
+
1. Read `{session}/code-analysis.md` and `{session}/security-scan.md`
|
|
103
|
+
2. Merge findings, deduplicating overlapping issues
|
|
104
|
+
3. Sort by severity: CRITICAL first, then WARNING, SUGGESTION, INFO
|
|
105
|
+
4. Calculate aggregate scores
|
|
106
|
+
5. Apply quality gate check
|
|
107
|
+
6. Write unified review to `{session}/review.md`
|
|
108
|
+
7. Report synthesis results to the user
|
|
109
|
+
|
|
110
|
+
### Phase 3: Auto-Fix (Conditional — if `--auto-fix`)
|
|
111
|
+
If `--auto-fix` flag is present and fixable issues exist:
|
|
112
|
+
|
|
113
|
+
Spawn an **auto-fixer subagent**:
|
|
114
|
+
|
|
115
|
+
Load [agents/auto-fixer-agent.md](agents/auto-fixer-agent.md) and inject:
|
|
116
|
+
- `{review_content}`: contents of `{session}/review.md`
|
|
117
|
+
- `{target_path}`: file or directory being reviewed
|
|
118
|
+
- `{session_dir}`: path to the active session directory
|
|
119
|
+
|
|
120
|
+
The auto-fixer:
|
|
121
|
+
- Reads review findings and prioritizes CRITICAL then WARNING
|
|
122
|
+
- Applies fixes for each fixable issue
|
|
123
|
+
- Runs existing tests after each fix to verify no regression
|
|
124
|
+
- Skips issues requiring architectural changes (flags for human review)
|
|
125
|
+
- Writes fix log to `{session}/fix-log.md`
|
|
126
|
+
- Returns `{fixed: int, skipped: int, regressions: int}`
|
|
127
|
+
|
|
128
|
+
### Phase 4: Verification (Conditional — if auto-fix ran)
|
|
129
|
+
If the auto-fixer made changes:
|
|
130
|
+
1. Re-dispatch the code-analyst and security-scanner in parallel on the fixed code
|
|
131
|
+
2. Compare new findings against the original review
|
|
132
|
+
3. Verify that fixed issues are resolved and no new issues introduced
|
|
133
|
+
4. Update `{session}/review.md` with verification results
|
|
134
|
+
5. Report delta to the user
|
|
135
|
+
|
|
136
|
+
### Phase 5: Quality Gate Enforcement
|
|
137
|
+
Apply the selected quality gate to the final review:
|
|
138
|
+
|
|
139
|
+
| Gate | CRITICAL | WARNING | Passes If |
|
|
140
|
+
|------|----------|---------|-----------|
|
|
141
|
+
| `strict` | 0 allowed | 0 allowed | Zero critical AND zero warnings |
|
|
142
|
+
| `standard` | 0 allowed | 5 or fewer | Zero critical AND at most 5 warnings |
|
|
143
|
+
| `minimal` | 0 allowed | unlimited | Zero critical issues |
|
|
144
|
+
|
|
145
|
+
Report gate result:
|
|
146
|
+
- **PASS**: Code meets the selected quality standard
|
|
147
|
+
- **FAIL**: Code does not meet the standard, with specific blocking issues listed
|
|
148
|
+
|
|
149
|
+
## Parameters
|
|
150
|
+
|
|
151
|
+
| Parameter | Description | Default |
|
|
152
|
+
|-----------|-------------|---------|
|
|
153
|
+
| `path-or-pr` | File path, directory, or PR number to review | Required |
|
|
154
|
+
| `--auto-fix` | Automatically apply fixes for review findings | false |
|
|
155
|
+
| `--gate` | Quality gate level: strict, standard, minimal | standard |
|
|
156
|
+
| `--focus` | Analysis focus: security, performance, quality, all | all |
|
|
157
|
+
| `--severity` | Minimum severity to include in report | suggestion |
|
|
158
|
+
| `--output` | Output format: markdown, json | markdown |
|
|
159
|
+
| `--pr` | Treat input as a GitHub PR number | false |
|
|
160
|
+
| `--verbose` | Show detailed analysis from each agent | false |
|
|
161
|
+
|
|
162
|
+
## Subagent Prompt Templates
|
|
163
|
+
|
|
164
|
+
Each subagent has a detailed prompt in the `agents/` directory. Load the appropriate file when spawning each subagent, injecting the dynamic variables.
|
|
165
|
+
|
|
166
|
+
| Phase | Prompt File | Key Variables |
|
|
167
|
+
|-------|-------------|---------------|
|
|
168
|
+
| Code Analysis | [agents/code-analyst-agent.md](agents/code-analyst-agent.md) | target_path, focus, architecture, session_dir |
|
|
169
|
+
| Security Scan | [agents/security-scanner-agent.md](agents/security-scanner-agent.md) | target_path, focus, session_dir |
|
|
170
|
+
| Auto-Fix | [agents/auto-fixer-agent.md](agents/auto-fixer-agent.md) | review_content, target_path, session_dir |
|
|
171
|
+
|
|
172
|
+
## Quality Gate Definitions
|
|
173
|
+
|
|
174
|
+
### Strict Gate
|
|
175
|
+
For production releases, security-critical code, public APIs:
|
|
176
|
+
- Zero CRITICAL findings
|
|
177
|
+
- Zero WARNING findings
|
|
178
|
+
- All SUGGESTION items documented as intentional or scheduled
|
|
179
|
+
|
|
180
|
+
### Standard Gate (default)
|
|
181
|
+
For feature branches, internal services, development builds:
|
|
182
|
+
- Zero CRITICAL findings
|
|
183
|
+
- At most 5 WARNING findings
|
|
184
|
+
- SUGGESTION items are informational
|
|
185
|
+
|
|
186
|
+
### Minimal Gate
|
|
187
|
+
For prototypes, experiments, early-stage development:
|
|
188
|
+
- Zero CRITICAL findings
|
|
189
|
+
- No limit on WARNING or SUGGESTION findings
|
|
190
|
+
|
|
191
|
+
## Architecture Compliance
|
|
192
|
+
|
|
193
|
+
When `{session}/architecture.md` exists (created by myaidev-architect or placed manually), the code analyst additionally checks:
|
|
194
|
+
|
|
195
|
+
- Do implemented components match the architectural design?
|
|
196
|
+
- Are dependency directions correct (no circular deps, proper layering)?
|
|
197
|
+
- Do data models match the specified schema?
|
|
198
|
+
- Are the specified interfaces and contracts implemented correctly?
|
|
199
|
+
- Are security requirements from the architecture satisfied?
|
|
200
|
+
|
|
201
|
+
Architecture compliance findings are tagged with `[ARCH]` in the review.
|
|
202
|
+
|
|
203
|
+
## Severity Classification
|
|
204
|
+
|
|
205
|
+
| Level | Icon | Criteria | Auto-Fixable |
|
|
206
|
+
|-------|------|----------|--------------|
|
|
207
|
+
| CRITICAL | `[C]` | Security vulnerabilities, data loss, crashes, broken functionality | Sometimes |
|
|
208
|
+
| WARNING | `[W]` | Bugs, performance issues, bad practices, missing validation | Usually |
|
|
209
|
+
| SUGGESTION | `[S]` | Style improvements, refactoring opportunities, better patterns | Often |
|
|
210
|
+
| INFO | `[I]` | Notes, alternative approaches, documentation gaps | Rarely |
|
|
211
|
+
|
|
212
|
+
## State Management (Scratchpad Pattern)
|
|
213
|
+
|
|
214
|
+
All intermediate work is written to the session directory:
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
{session}/
|
|
218
|
+
+-- config.json # Parsed arguments and settings
|
|
219
|
+
+-- architecture.md # From myaidev-workflow (if available)
|
|
220
|
+
+-- code-analysis.md # Code analyst output
|
|
221
|
+
+-- security-scan.md # Security scanner output
|
|
222
|
+
+-- review.md # Unified review (synthesized)
|
|
223
|
+
+-- fix-log.md # Auto-fixer changes (if --auto-fix)
|
|
224
|
+
+-- verification.md # Post-fix verification (if --auto-fix)
|
|
225
|
+
+-- summary.md # Final review summary
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
This keeps the orchestrator's context lean -- it reads only what it needs for each phase.
|
|
229
|
+
|
|
230
|
+
## Execution Flow
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
1. INIT -> Parse args, determine scope, load architecture
|
|
234
|
+
2. ANALYZE -> Spawn code-analyst + security-scanner IN PARALLEL
|
|
235
|
+
3. SYNTHESIZE -> Merge findings into unified review.md
|
|
236
|
+
4. AUTO-FIX -> Spawn auto-fixer (if --auto-fix flag)
|
|
237
|
+
5. VERIFY -> Re-analyze fixed code (if fixes were applied)
|
|
238
|
+
6. GATE CHECK -> Apply quality gate, report PASS/FAIL
|
|
239
|
+
7. REPORT -> Present final review to user
|
|
240
|
+
8. CLEANUP -> Remove session dir (unless --verbose)
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Error Handling
|
|
244
|
+
|
|
245
|
+
- If code analyst fails: report error, proceed with security scan only
|
|
246
|
+
- If security scanner fails: report error, proceed with code analysis only
|
|
247
|
+
- If both fail: report error with context, ask user for guidance
|
|
248
|
+
- If auto-fixer fails: preserve original code, report unfixed findings
|
|
249
|
+
- If auto-fixer causes regressions: revert changes, report the regression
|
|
250
|
+
- If verification re-analysis fails: trust the fix log, warn user to test manually
|
|
251
|
+
- Never silently swallow errors -- always report to the user
|
|
252
|
+
|
|
253
|
+
## Context Management (Long-Running Agent Patterns)
|
|
254
|
+
|
|
255
|
+
### Context Regurgitation
|
|
256
|
+
Before dispatching each subagent, briefly restate in your prompt:
|
|
257
|
+
- Current phase number and what has been completed so far
|
|
258
|
+
- Review scope and focus areas
|
|
259
|
+
- What this subagent needs to accomplish and how its output feeds the next phase
|
|
260
|
+
|
|
261
|
+
This keeps critical context fresh at the end of the context window where LLM attention is strongest.
|
|
262
|
+
|
|
263
|
+
### File Buffering
|
|
264
|
+
All subagent outputs go to session files -- never pass raw subagent output directly into the next prompt. Read only the specific file sections needed for each phase. This keeps the orchestrator's active context lean.
|
|
265
|
+
|
|
266
|
+
## Progress Reporting
|
|
267
|
+
|
|
268
|
+
At each phase transition, report to the user:
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
-> Phase 1/5: Analyzing code in {target_path}...
|
|
272
|
+
[PARALLEL] Code quality analysis + Security scanning
|
|
273
|
+
OK Code analysis complete: 2 critical, 5 warnings, 8 suggestions
|
|
274
|
+
OK Security scan complete: 1 critical, 3 warnings
|
|
275
|
+
|
|
276
|
+
-> Phase 2/5: Synthesizing findings...
|
|
277
|
+
OK Unified review: 3 critical, 7 warnings, 8 suggestions (1 deduplicated)
|
|
278
|
+
|
|
279
|
+
-> Phase 3/5: Applying auto-fixes... (if --auto-fix)
|
|
280
|
+
OK Fixed 6 issues, skipped 2 (architectural), 0 regressions
|
|
281
|
+
|
|
282
|
+
-> Phase 4/5: Verifying fixes...
|
|
283
|
+
OK Re-analysis: 0 critical, 3 warnings, 6 suggestions
|
|
284
|
+
OK 3 critical issues resolved, 2 warnings resolved
|
|
285
|
+
|
|
286
|
+
-> Phase 5/5: Quality gate check (standard)...
|
|
287
|
+
OK PASS: 0 critical, 3 warnings (within threshold)
|
|
288
|
+
|
|
289
|
+
Review Summary:
|
|
290
|
+
Scope: {file_count} files | {line_count} lines
|
|
291
|
+
Findings: {critical} critical, {warnings} warnings, {suggestions} suggestions
|
|
292
|
+
Quality Gate: {gate_level} -> {PASS|FAIL}
|
|
293
|
+
Auto-Fix: {fixed} fixed, {skipped} skipped (if --auto-fix)
|
|
294
|
+
Scores: Maintainability {score} | Readability {score} | Performance {score} | Testability {score}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Review Output Format
|
|
298
|
+
|
|
299
|
+
The unified `{session}/review.md` follows this structure:
|
|
300
|
+
|
|
301
|
+
```markdown
|
|
302
|
+
# Code Review: {target_path}
|
|
303
|
+
|
|
304
|
+
## Summary
|
|
305
|
+
- **Scope**: {file_count} files, {line_count} lines
|
|
306
|
+
- **Quality Gate**: {gate_level} -> {PASS|FAIL}
|
|
307
|
+
- **Critical Issues**: {count}
|
|
308
|
+
- **Warnings**: {count}
|
|
309
|
+
- **Suggestions**: {count}
|
|
310
|
+
- **Info**: {count}
|
|
311
|
+
|
|
312
|
+
## Scores
|
|
313
|
+
| Metric | Score | Assessment |
|
|
314
|
+
|--------|-------|------------|
|
|
315
|
+
| Maintainability | {0.0-1.0} | {Poor/Fair/Good/Excellent} |
|
|
316
|
+
| Readability | {0.0-1.0} | {Poor/Fair/Good/Excellent} |
|
|
317
|
+
| Performance | {0.0-1.0} | {Poor/Fair/Good/Excellent} |
|
|
318
|
+
| Testability | {0.0-1.0} | {Poor/Fair/Good/Excellent} |
|
|
319
|
+
|
|
320
|
+
## Critical Issues [C]
|
|
321
|
+
### {issue_title}
|
|
322
|
+
- **Location**: `{file}:{line}`
|
|
323
|
+
- **Category**: {Security|Quality|Performance|Architecture}
|
|
324
|
+
- **Description**: {what is wrong}
|
|
325
|
+
- **Impact**: {why it matters}
|
|
326
|
+
- **Fix**: {how to resolve}
|
|
327
|
+
- **Auto-Fixable**: {Yes|No — reason if no}
|
|
328
|
+
|
|
329
|
+
## Warnings [W]
|
|
330
|
+
### {issue_title}
|
|
331
|
+
- **Location**: `{file}:{line}`
|
|
332
|
+
- **Category**: {category}
|
|
333
|
+
- **Description**: {description}
|
|
334
|
+
- **Suggestion**: {improvement}
|
|
335
|
+
|
|
336
|
+
## Suggestions [S]
|
|
337
|
+
### {issue_title}
|
|
338
|
+
- **Description**: {what could be better}
|
|
339
|
+
- **Benefit**: {why it helps}
|
|
340
|
+
|
|
341
|
+
## Info [I]
|
|
342
|
+
- {informational note}
|
|
343
|
+
|
|
344
|
+
## Architecture Compliance (if architecture.md present)
|
|
345
|
+
- **Compliance**: {Compliant|Partially Compliant|Non-Compliant}
|
|
346
|
+
- **Findings**: {list of [ARCH]-tagged issues}
|
|
347
|
+
|
|
348
|
+
## Positive Highlights
|
|
349
|
+
- {good practice observed}
|
|
350
|
+
- {well-written code example}
|
|
351
|
+
|
|
352
|
+
## Recommendations
|
|
353
|
+
1. {priority action 1}
|
|
354
|
+
2. {priority action 2}
|
|
355
|
+
3. {priority action 3}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
## Integration
|
|
359
|
+
|
|
360
|
+
- Reviews code from `/myaidev-method:myaidev-coder`
|
|
361
|
+
- Validates against architecture from `/myaidev-method:architect`
|
|
362
|
+
- Validates test coverage in conjunction with `/myaidev-method:tester`
|
|
363
|
+
- Part of `/myaidev-method:myaidev-workflow` full pipeline
|
|
364
|
+
|
|
365
|
+
## Example Usage
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
# Full code review of a directory
|
|
369
|
+
/myaidev-method:myaidev-reviewer ./src/auth
|
|
370
|
+
|
|
371
|
+
# Security-focused review
|
|
372
|
+
/myaidev-method:myaidev-reviewer ./src/api --focus=security --gate=strict
|
|
373
|
+
|
|
374
|
+
# Review with auto-fix
|
|
375
|
+
/myaidev-method:myaidev-reviewer ./src/payments --auto-fix --gate=standard
|
|
376
|
+
|
|
377
|
+
# Review a specific file, minimal gate
|
|
378
|
+
/myaidev-method:myaidev-reviewer ./src/utils/cache.ts --gate=minimal
|
|
379
|
+
|
|
380
|
+
# Review a GitHub PR
|
|
381
|
+
/myaidev-method:myaidev-reviewer 42 --pr --auto-fix
|
|
382
|
+
|
|
383
|
+
# Performance-focused review with verbose output
|
|
384
|
+
/myaidev-method:myaidev-reviewer ./src/data-pipeline --focus=performance --verbose
|
|
385
|
+
```
|