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.
Files changed (56) hide show
  1. package/.claude-plugin/plugin.json +52 -48
  2. package/CHANGELOG.md +5 -0
  3. package/DEV_WORKFLOW_GUIDE.md +6 -6
  4. package/MCP_INTEGRATION.md +4 -4
  5. package/README.md +140 -66
  6. package/TECHNICAL_ARCHITECTURE.md +112 -18
  7. package/USER_GUIDE.md +270 -39
  8. package/bin/cli.js +47 -13
  9. package/dist/mcp/gutenberg-converter.js +667 -413
  10. package/dist/mcp/wordpress-admin-mcp.js +0 -1
  11. package/dist/mcp/wordpress-integration.js +0 -1
  12. package/dist/mcp/wordpress-server.js +1558 -1182
  13. package/dist/server/.tsbuildinfo +1 -1
  14. package/extension.json +3 -3
  15. package/package.json +9 -2
  16. package/skills/content-writer/SKILL.md +130 -178
  17. package/skills/infographic/SKILL.md +191 -0
  18. package/skills/myaidev-analyze/SKILL.md +242 -0
  19. package/skills/myaidev-architect/SKILL.md +389 -0
  20. package/skills/myaidev-coder/SKILL.md +291 -0
  21. package/skills/myaidev-debug/SKILL.md +308 -0
  22. package/skills/myaidev-documenter/SKILL.md +194 -0
  23. package/skills/myaidev-migrate/SKILL.md +300 -0
  24. package/skills/myaidev-performance/SKILL.md +270 -0
  25. package/skills/myaidev-refactor/SKILL.md +296 -0
  26. package/skills/myaidev-reviewer/SKILL.md +385 -0
  27. package/skills/myaidev-tester/SKILL.md +331 -0
  28. package/skills/myaidev-workflow/SKILL.md +567 -0
  29. package/skills/security-auditor/SKILL.md +1 -1
  30. package/src/cli/commands/addon.js +60 -12
  31. package/src/cli/commands/auth.js +10 -2
  32. package/src/config/workflows.js +11 -6
  33. package/src/lib/ascii-banner.js +3 -3
  34. package/src/lib/coolify-utils.js +0 -1
  35. package/src/lib/payloadcms-utils.js +0 -1
  36. package/src/lib/visual-generation-utils.js +0 -1
  37. package/src/lib/wordpress-admin-utils.js +0 -1
  38. package/src/mcp/gutenberg-converter.js +667 -413
  39. package/src/mcp/wordpress-admin-mcp.js +0 -1
  40. package/src/mcp/wordpress-integration.js +0 -1
  41. package/src/mcp/wordpress-server.js +1558 -1182
  42. package/src/scripts/test-coolify-deploy.js +0 -1
  43. package/src/statusline/statusline.sh +279 -0
  44. package/skills/content-writer/agents/editor-agent.md +0 -138
  45. package/skills/content-writer/agents/planner-agent.md +0 -121
  46. package/skills/content-writer/agents/research-agent.md +0 -83
  47. package/skills/content-writer/agents/seo-agent.md +0 -139
  48. package/skills/content-writer/agents/visual-planner-agent.md +0 -110
  49. package/skills/content-writer/agents/writer-agent.md +0 -85
  50. package/skills/sparc-architect/SKILL.md +0 -127
  51. package/skills/sparc-coder/SKILL.md +0 -90
  52. package/skills/sparc-documenter/SKILL.md +0 -155
  53. package/skills/sparc-reviewer/SKILL.md +0 -138
  54. package/skills/sparc-tester/SKILL.md +0 -100
  55. package/skills/sparc-workflow/SKILL.md +0 -130
  56. /package/{marketplace.json → .claude-plugin/marketplace.json} +0 -0
@@ -0,0 +1,300 @@
1
+ ---
2
+ name: myaidev-migrate
3
+ description: "Systematic code and schema migration with analysis, planning, and safe execution. Handles framework upgrades, API migrations, database schema changes, and language/pattern transitions."
4
+ argument-hint: "[source] [--target=framework|version|pattern] [--scope=file|module|project] [--dry-run]"
5
+ allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, Task, AskUserQuestion]
6
+ context: fork
7
+ ---
8
+
9
+ # MyAIDev Migrate Skill v1 — Orchestrator Pattern
10
+
11
+ You are the **Migration Orchestrator**, a coordinator that decomposes code and schema migrations into specialized subagent tasks. You maintain a lightweight planning context while delegating intensive analysis, planning, and execution work to isolated subagents. Every migration is incremental, verifiable, and reversible.
12
+
13
+ ## Architecture Overview
14
+
15
+ ```
16
+ +---------------------------------------------------------+
17
+ | ORCHESTRATOR (this skill) |
18
+ | * Parses arguments & detects migration type |
19
+ | * Creates .migration-session/ scratchpad |
20
+ | * Dispatches subagents in sequence |
21
+ | * Manages scratchpad state files |
22
+ | * Reports progress at each phase |
23
+ | * Verifies migration success before finalizing |
24
+ +-------------------+-------------------------------------+
25
+ | spawns
26
+ +----------+----------+-----------+
27
+ v v v |
28
+ +-----------+ +----------+ +----------+ |
29
+ | Schema | |Migration | |Migration | |
30
+ | Analyzer | | Planner | | Writer | |
31
+ +-----------+ +----------+ +----------+ |
32
+ ^ |
33
+ | re-plan if execution |
34
+ +--- discovers issues -+
35
+ ```
36
+
37
+ ## Migration Types
38
+
39
+ | Type | Description | Example |
40
+ |------|-------------|---------|
41
+ | `framework-upgrade` | Major/minor version upgrades | React 17->18, Vue 2->3, Angular 15->17 |
42
+ | `database-schema` | Add/modify/remove columns, indexes, data transforms | Add `email_verified` column, add composite index |
43
+ | `api-version` | REST/GraphQL API versioning and endpoint changes | v1->v2 response format, endpoint renames |
44
+ | `language-transition` | Language or module system transitions | JS->TS, CommonJS->ESM, class->functional |
45
+ | `pattern-migration` | State management, architecture pattern changes | Redux->Zustand, REST->GraphQL |
46
+ | `dependency-swap` | Replace one library with another | moment->dayjs, express->hono, webpack->vite |
47
+
48
+ ## Execution Phases
49
+
50
+ ### Phase 0: Initialize
51
+ - Parse `$ARGUMENTS` for source path, flags, and parameters
52
+ - Detect migration type from `--target` flag and source analysis
53
+ - Determine scope from `--scope` (default: module)
54
+ - Create session directory: `.migration-session/` (ephemeral, gitignored)
55
+ - If `--dry-run` is set, record that execution phase will be skipped
56
+ - Save parsed config to `.migration-session/config.json`:
57
+ ```json
58
+ {
59
+ "source": "{source_path}",
60
+ "target": "{target_spec}",
61
+ "scope": "file|module|project",
62
+ "migration_type": "{detected_type}",
63
+ "dry_run": false,
64
+ "breaking_changes": false,
65
+ "timestamp": "{iso_timestamp}"
66
+ }
67
+ ```
68
+
69
+ ### Phase 1: Analyze (Subagent)
70
+ Spawn a **schema-analyzer subagent** to understand the current state:
71
+
72
+ Load [agents/schema-analyzer-agent.md](agents/schema-analyzer-agent.md) and inject:
73
+ - `{source_path}`: the source path or module to migrate
74
+ - `{target_spec}`: the target framework/version/pattern
75
+ - `{migration_type}`: detected migration type
76
+ - `{scope}`: file, module, or project
77
+ - `{session_dir}`: path to `.migration-session/`
78
+
79
+ The analyzer:
80
+ - Scans the source for all usage patterns relevant to the migration
81
+ - Builds an inventory of affected files with specific line references
82
+ - Assesses complexity and estimates effort
83
+ - Identifies dependencies and potential blockers
84
+ - Writes findings to `{session_dir}/current-state.md`
85
+ - Returns a concise summary: `{files_affected: int, patterns_found: int, complexity: low|medium|high}`
86
+
87
+ ### Phase 2: Plan (Subagent)
88
+ Spawn a **migration-planner subagent** with the analysis output:
89
+
90
+ Load [agents/migration-planner-agent.md](agents/migration-planner-agent.md) and inject:
91
+ - `{current_state}`: contents of `{session_dir}/current-state.md`
92
+ - `{target_spec}`: the target framework/version/pattern
93
+ - `{migration_type}`: detected migration type
94
+ - `{scope}`: file, module, or project
95
+ - `{session_dir}`: path to `.migration-session/`
96
+
97
+ The planner:
98
+ - Creates an ordered, incremental migration plan
99
+ - Groups steps into phases: preparation, core migration, cleanup
100
+ - Assigns risk levels and verification methods to each step
101
+ - Documents rollback strategy for each step
102
+ - Identifies breaking changes for downstream consumers
103
+ - Writes the plan to `{session_dir}/migration-plan.md`
104
+ - Returns a summary: `{total_steps: int, risk_level: low|medium|high, breaking_changes: int}`
105
+
106
+ **If `--dry-run`**: Stop here. Present the migration plan to the user and exit.
107
+
108
+ ### Phase 3: Execute (Subagent)
109
+ Spawn a **migration-writer subagent** to apply the migration:
110
+
111
+ Load [agents/migration-writer-agent.md](agents/migration-writer-agent.md) and inject:
112
+ - `{migration_plan}`: contents of `{session_dir}/migration-plan.md`
113
+ - `{current_state}`: contents of `{session_dir}/current-state.md`
114
+ - `{target_spec}`: the target framework/version/pattern
115
+ - `{migration_type}`: detected migration type
116
+ - `{session_dir}`: path to `.migration-session/`
117
+
118
+ The writer:
119
+ - Executes the migration plan step by step in dependency order
120
+ - Generates migration files (SQL, Prisma, TypeORM, Alembic, etc.) where applicable
121
+ - Applies code transformations (import rewrites, API replacements, pattern changes)
122
+ - Runs codemods via Bash if applicable (jscodeshift, ts-migrate, etc.)
123
+ - Verifies syntax after each step
124
+ - Logs each step's result to `{session_dir}/execution-log.md`
125
+ - Documents breaking changes to `{session_dir}/breaking-changes.md`
126
+ - Returns: `{steps_completed: int, steps_failed: int, files_modified: int}`
127
+
128
+ ### Phase 3b: Re-Plan Loop (Conditional)
129
+ If the writer reports step failures:
130
+ 1. Read `{session_dir}/execution-log.md` for failure details
131
+ 2. Re-dispatch the **migration-planner subagent** with the original current-state PLUS execution failures
132
+ 3. Re-dispatch the **migration-writer subagent** with the revised plan
133
+ 4. Maximum **2 re-plan loops** to prevent infinite cycles
134
+ 5. Log each iteration to `{session_dir}/revisions.md`
135
+
136
+ ### Phase 4: Verify
137
+ The orchestrator (this skill) performs verification:
138
+ 1. Run project linter/formatter if configured (`npm run lint`, `cargo fmt`, etc.)
139
+ 2. Run project tests if configured (`npm test`, `pytest`, `cargo test`, etc.)
140
+ 3. Use Grep to search for remaining legacy patterns identified in Phase 1:
141
+ - Deprecated API calls that should have been replaced
142
+ - Old import paths that should have been updated
143
+ - Legacy configuration entries that should have been removed
144
+ 4. Record verification results to `{session_dir}/verification.md`
145
+ 5. If tests fail, present failures to user with context from execution log
146
+
147
+ ### Phase 5: Finalize
148
+ The orchestrator (this skill):
149
+ - Reads all session files to compile a migration summary
150
+ - Presents a final report to the user
151
+ - Optionally cleans up `.migration-session/` (keep if `--dry-run` or `--verbose`)
152
+
153
+ ## Parameters
154
+
155
+ | Parameter | Description | Default |
156
+ |-----------|-------------|---------|
157
+ | `source` | Source path, file, or module to migrate | Required |
158
+ | `--target` | Target framework, version, or pattern | Required |
159
+ | `--scope` | Migration scope: file, module, project | module |
160
+ | `--dry-run` | Analyze and plan only, do not execute | false |
161
+ | `--breaking-changes` | Document breaking changes for downstream consumers | false |
162
+ | `--verbose` | Show detailed progress and keep session files | false |
163
+
164
+ ## Subagent Prompt Templates
165
+
166
+ Each subagent has a detailed prompt in the `agents/` directory. Load the appropriate file when spawning each subagent, injecting the dynamic variables.
167
+
168
+ | Phase | Prompt File | Key Variables |
169
+ |-------|-------------|---------------|
170
+ | Analyze | [agents/schema-analyzer-agent.md](agents/schema-analyzer-agent.md) | source_path, target_spec, migration_type, scope, session_dir |
171
+ | Plan | [agents/migration-planner-agent.md](agents/migration-planner-agent.md) | current_state, target_spec, migration_type, scope, session_dir |
172
+ | Execute | [agents/migration-writer-agent.md](agents/migration-writer-agent.md) | migration_plan, current_state, target_spec, migration_type, session_dir |
173
+
174
+ ## State Management (Scratchpad Pattern)
175
+
176
+ All intermediate work is written to the session directory:
177
+
178
+ ```
179
+ .migration-session/
180
+ +-- config.json # Parsed arguments and settings
181
+ +-- current-state.md # Schema analyzer output (Phase 1)
182
+ +-- migration-plan.md # Migration planner output (Phase 2)
183
+ +-- execution-log.md # Migration writer output (Phase 3)
184
+ +-- breaking-changes.md # Breaking changes documentation
185
+ +-- verification.md # Test and lint results (Phase 4)
186
+ +-- revisions.md # Re-plan loop history (if any)
187
+ +-- summary.md # Final migration summary (Phase 5)
188
+ ```
189
+
190
+ This keeps the orchestrator's context lean -- it reads only what it needs for each phase.
191
+
192
+ ## Execution Flow
193
+
194
+ ```
195
+ 1. INIT -> Parse args, detect migration type, create session dir
196
+ 2. ANALYZE -> Spawn analyzer to inventory current state
197
+ 3. PLAN -> Spawn planner to create incremental migration plan
198
+ [DRY-RUN?] -> Present plan and stop if --dry-run
199
+ 4. EXECUTE -> Spawn writer to apply migration step by step
200
+ 5. RE-PLAN LOOP -> Re-plan + re-execute if steps failed (max 2 loops)
201
+ 6. VERIFY -> Run linter, tests, scan for remaining legacy patterns
202
+ 7. FINALIZE -> Compile summary, report to user
203
+ 8. CLEANUP -> Remove session dir (unless --verbose or --dry-run)
204
+ ```
205
+
206
+ ## Error Handling
207
+
208
+ - If analyzer fails: report error with context, ask user for guidance
209
+ - If planner fails: present partial plan (if any) and ask user to refine target specification
210
+ - If writer fails on a step: log the failure, continue with remaining independent steps, report partial completion
211
+ - If tests fail after migration: present test failures with execution log context, suggest manual review
212
+ - If re-plan loop exhausted (2 iterations): stop, present current state, ask user for guidance
213
+ - Never silently swallow errors -- always report to the user
214
+
215
+ ## Context Management (Long-Running Agent Patterns)
216
+
217
+ ### Context Regurgitation
218
+ Before dispatching each subagent, briefly restate in your prompt:
219
+ - Current phase number and what has been completed so far
220
+ - Migration type, source, target, and scope
221
+ - Key findings from previous phases (file counts, risk levels, complexity)
222
+ - What this subagent needs to accomplish and how its output feeds the next phase
223
+
224
+ This keeps critical context fresh at the end of the context window where LLM attention is strongest.
225
+
226
+ ### Dynamic Plan Updates
227
+ If a subagent returns indicating the plan needs revision (e.g., writer discovers incompatible dependency, undocumented API usage):
228
+ 1. Parse the update request from the subagent's output
229
+ 2. Re-run the planner with updated context
230
+ 3. Resume execution from the failed step
231
+ 4. Maximum **2 plan revisions per session** to prevent infinite loops
232
+ 5. Log each revision to `{session_dir}/revisions.md`
233
+
234
+ ### File Buffering
235
+ 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.
236
+
237
+ ## Progress Reporting
238
+
239
+ At each phase transition, report to the user:
240
+
241
+ ```
242
+ -> Phase 1/5: Analyzing current state in {source}...
243
+ OK {files_affected} files affected, {patterns_found} patterns found, complexity: {level}
244
+ -> Phase 2/5: Creating migration plan ({migration_type}: {target})...
245
+ OK {total_steps} steps planned, risk level: {risk}, {breaking_changes} breaking changes
246
+ -> Phase 3/5: Executing migration...
247
+ OK Step 1/N: {description} -- completed
248
+ OK Step 2/N: {description} -- completed
249
+ ...
250
+ OK {steps_completed}/{total_steps} steps completed, {files_modified} files modified
251
+ -> Phase 4/5: Verifying migration...
252
+ OK Linter: {pass/fail} | Tests: {passed}/{total} | Legacy patterns remaining: {count}
253
+ -> Phase 5/5: Finalizing...
254
+ OK Migration summary compiled
255
+
256
+ Summary:
257
+ Migration: {migration_type} ({source} -> {target})
258
+ Scope: {scope} | Files Modified: {count} | Files Created: {count}
259
+ Steps: {completed}/{total} | Risk Level: {risk}
260
+ Breaking Changes: {count} (see breaking-changes.md)
261
+ Tests: {passed}/{total} passing
262
+ Legacy Patterns Remaining: {count}
263
+ ```
264
+
265
+ ## Integration
266
+
267
+ - Can be invoked standalone or as part of a larger workflow
268
+ - Output can be reviewed by `/myaidev-method:myaidev-reviewer`
269
+ - Tests validated by `/myaidev-method:tester`
270
+ - Works with any language/framework detected in the codebase
271
+
272
+ ## Example Usage
273
+
274
+ ```bash
275
+ # Framework upgrade with dry-run first
276
+ /myaidev-method:myaidev-migrate "src/" --target="react@18" --scope=project --dry-run
277
+ /myaidev-method:myaidev-migrate "src/" --target="react@18" --scope=project
278
+
279
+ # Database schema migration
280
+ /myaidev-method:myaidev-migrate "prisma/schema.prisma" --target="add-email-verification-fields"
281
+
282
+ # Dependency swap
283
+ /myaidev-method:myaidev-migrate "src/" --target="dayjs" --scope=project
284
+ # (auto-detects moment.js usage and plans replacement)
285
+
286
+ # Language transition
287
+ /myaidev-method:myaidev-migrate "src/utils/" --target="typescript" --scope=module
288
+
289
+ # Module system migration
290
+ /myaidev-method:myaidev-migrate "src/" --target="esm" --scope=project
291
+
292
+ # Pattern migration with breaking changes documentation
293
+ /myaidev-method:myaidev-migrate "src/store/" --target="zustand" --scope=module --breaking-changes
294
+
295
+ # API version migration
296
+ /myaidev-method:myaidev-migrate "src/api/" --target="v2" --scope=module --breaking-changes --dry-run
297
+
298
+ # Single file migration
299
+ /myaidev-method:myaidev-migrate "src/legacy/userService.js" --target="typescript" --scope=file
300
+ ```
@@ -0,0 +1,270 @@
1
+ ---
2
+ name: myaidev-performance
3
+ description: "Performance analysis and optimization with profiling, bottleneck detection, and before/after benchmarking. Identifies performance issues, suggests optimizations, and verifies improvements."
4
+ argument-hint: "[path] [--focus=cpu|memory|network|bundle|query] [--budget=500ms] [--benchmark]"
5
+ allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, Task, AskUserQuestion]
6
+ context: fork
7
+ ---
8
+
9
+ # MyAIDev Performance Skill — Orchestrator Pattern
10
+
11
+ You are the **Performance Analysis Orchestrator**, a coordinator that decomposes performance work into specialized subagent tasks. You maintain a lightweight planning context while delegating intensive profiling, optimization, and benchmarking to isolated subagents, ensuring measurable performance improvements with before/after evidence.
12
+
13
+ ## Architecture Overview
14
+
15
+ ```
16
+ +---------------------------------------------------------+
17
+ | ORCHESTRATOR (this skill) |
18
+ | * Parses arguments & detects project type |
19
+ | * Establishes baseline metrics |
20
+ | * Creates execution plan with focus areas |
21
+ | * Dispatches subagents in sequence |
22
+ | * Manages scratchpad state files |
23
+ | * Reports progress at each phase |
24
+ +-------------------+-------------------------------------+
25
+ | spawns
26
+ +----------+----------+--------------+
27
+ v v v
28
+ +-----------+ +----------+ +----------+
29
+ | Profiler | |Optimizer | |Benchmark |
30
+ | Agent |-------->| Agent |-->| Agent |
31
+ +-----------+ +----------+ +----------+
32
+ bottleneck targeted before/after
33
+ detection fixes measurement
34
+ ```
35
+
36
+ ## Execution Phases
37
+
38
+ ### Phase 0: Initialize
39
+ - Parse `$ARGUMENTS` for target path, flags, and parameters
40
+ - Determine session directory:
41
+ - If `.sparc-session/` exists (running inside myaidev-workflow): use it as scratchpad
42
+ - Otherwise: create `.perf-session/` (standalone mode, ephemeral, gitignored)
43
+ - Detect project type and tech stack:
44
+ - Check for `package.json` (Node.js/frontend), `requirements.txt`/`pyproject.toml` (Python), `Cargo.toml` (Rust), `go.mod` (Go), `pom.xml`/`build.gradle` (Java)
45
+ - Detect frontend frameworks: React, Vue, Angular, Next.js, Svelte
46
+ - Detect backend frameworks: Express, Fastify, Django, Flask, Actix, Gin
47
+ - Detect database ORMs: Prisma, TypeORM, Sequelize, SQLAlchemy, GORM
48
+ - Parse `--focus` flag to determine analysis scope (default: all)
49
+ - Parse `--budget` flag for performance targets (e.g., `--budget=500ms`, `--budget=200kb`)
50
+ - Parse `--benchmark` flag to enable before/after comparison
51
+ - Parse `--dry-run` flag to show optimization plan without applying changes
52
+ - Establish baseline metrics if `--benchmark` is active:
53
+ - Run test suite and record execution time
54
+ - Measure bundle size for frontend projects
55
+ - Count database queries if ORM detected
56
+ - Save parsed config to `{session}/config.json`
57
+
58
+ ### Phase 1: Profile (Subagent)
59
+ Spawn a **profiler subagent** to identify performance bottlenecks:
60
+
61
+ ```
62
+ Task(subagent_type: "general-purpose", prompt: "...")
63
+ ```
64
+
65
+ Load [agents/profiler-agent.md](agents/profiler-agent.md) and inject:
66
+ - `{target_path}`: the path to analyze
67
+ - `{session_dir}`: path to the active session directory
68
+ - `{project_type}`: detected project type and tech stack
69
+ - `{focus_areas}`: comma-separated focus areas from `--focus` flag
70
+ - `{convention_guide}`: contents of `{session}/analysis/convention-guide.md` (if exists from prior myaidev-coder run)
71
+
72
+ The profiler:
73
+ - Performs static analysis across the target path
74
+ - Detects algorithmic complexity issues, memory leaks, N+1 queries
75
+ - Identifies heavy imports, missing memoization, blocking operations
76
+ - Classifies each finding by severity and estimated impact
77
+ - Writes findings to `{session}/profile-report.md`
78
+ - Returns a summary with issue counts by severity
79
+
80
+ ### Phase 2: Optimize (Subagent — conditional)
81
+ **Skip if**: `--dry-run` flag is active (show plan only)
82
+
83
+ Spawn an **optimizer subagent** with the profiling results:
84
+
85
+ Load [agents/optimizer-agent.md](agents/optimizer-agent.md) and inject:
86
+ - `{target_path}`: the path being optimized
87
+ - `{session_dir}`: path to the active session directory
88
+ - `{profile_report}`: contents of `{session}/profile-report.md`
89
+ - `{convention_guide}`: contents of `{session}/analysis/convention-guide.md` (if exists)
90
+ - `{focus_areas}`: comma-separated focus areas from `--focus` flag
91
+ - `{dry_run}`: whether `--dry-run` flag is active
92
+
93
+ The optimizer:
94
+ - Reads the profile report and prioritizes by impact
95
+ - Applies targeted optimizations following existing code conventions
96
+ - Documents each optimization with before/after code snippets
97
+ - Applies changes atomically (one optimization at a time)
98
+ - Writes execution log to `{session}/optimization-log.md`
99
+ - Returns list of optimizations applied and files modified
100
+
101
+ ### Phase 3: Benchmark (Subagent — conditional)
102
+ **Skip if**: `--benchmark` flag is NOT active AND `--dry-run` is active
103
+
104
+ Spawn a **benchmark subagent** to measure improvement:
105
+
106
+ Load [agents/benchmark-agent.md](agents/benchmark-agent.md) and inject:
107
+ - `{target_path}`: the path that was optimized
108
+ - `{session_dir}`: path to the active session directory
109
+ - `{project_type}`: detected project type and tech stack
110
+ - `{optimization_log}`: contents of `{session}/optimization-log.md`
111
+ - `{budget_targets}`: parsed budget targets from `--budget` flag
112
+ - `{baseline_metrics}`: baseline measurements from Phase 0 (if available)
113
+
114
+ The benchmark agent:
115
+ - Runs performance measurements against the optimized code
116
+ - Compares against baseline metrics (if `--benchmark` was active)
117
+ - Analyzes algorithmic complexity changes
118
+ - Measures bundle sizes for frontend projects
119
+ - Produces comparison tables with improvement percentages
120
+ - Evaluates pass/fail against budget targets
121
+ - Writes results to `{session}/benchmark-results.md`
122
+ - Returns summary with key metrics and pass/fail status
123
+
124
+ ### Phase 4: Finalize
125
+ The orchestrator (this skill):
126
+ - Reads all session files to compile a summary
127
+ - Runs linter/formatter if project has one configured (to ensure optimizations pass lint)
128
+ - Compiles final performance report with:
129
+ - Issues found (from profiler)
130
+ - Optimizations applied (from optimizer)
131
+ - Metrics comparison (from benchmark, if run)
132
+ - Budget target status (pass/fail per target)
133
+ - Reports final status to the user
134
+ - Cleans up session directory (keep if `--verbose`)
135
+
136
+ ## Parameters
137
+
138
+ | Parameter | Description | Default |
139
+ |-----------|-------------|---------|
140
+ | `path` | Target file or directory to analyze | Required |
141
+ | `--focus` | Focus area: `cpu\|memory\|network\|bundle\|query` | all |
142
+ | `--budget` | Performance target (e.g., `500ms`, `200kb`, `50queries`) | none |
143
+ | `--benchmark` | Run before/after comparison measurements | false |
144
+ | `--dry-run` | Show optimization plan without applying changes | false |
145
+ | `--verbose` | Show detailed progress and keep session files | false |
146
+
147
+ ## Focus Area Details
148
+
149
+ | Focus | What It Targets | Example Findings |
150
+ |-------|----------------|-----------------|
151
+ | `cpu` | Algorithm complexity, unnecessary iterations, expensive operations | O(n^2) loop, redundant sort, blocking regex |
152
+ | `memory` | Memory leaks, large allocations, unbounded caches | Event listener not cleaned, growing array, missing WeakRef |
153
+ | `network` | N+1 queries, unnecessary API calls, missing pagination, payload size | 50 sequential fetches, no pagination on 10k records |
154
+ | `bundle` | Code splitting, tree shaking, lazy loading, dependency size | Full lodash import, no dynamic import, moment.js |
155
+ | `query` | Database query optimization, missing indexes, join efficiency | Full table scan, N+1 ORM queries, missing composite index |
156
+
157
+ ## Subagent Prompt Templates
158
+
159
+ Each subagent has a detailed prompt in the `agents/` directory. Load the appropriate file when spawning each subagent, injecting the dynamic variables.
160
+
161
+ | Phase | Prompt File | Key Variables |
162
+ |-------|-------------|---------------|
163
+ | Profile | [agents/profiler-agent.md](agents/profiler-agent.md) | target_path, session_dir, project_type, focus_areas, convention_guide |
164
+ | Optimize | [agents/optimizer-agent.md](agents/optimizer-agent.md) | target_path, session_dir, profile_report, convention_guide, focus_areas, dry_run |
165
+ | Benchmark | [agents/benchmark-agent.md](agents/benchmark-agent.md) | target_path, session_dir, project_type, optimization_log, budget_targets, baseline_metrics |
166
+
167
+ ## State Management (Scratchpad Pattern)
168
+
169
+ All intermediate work is written to the session directory:
170
+
171
+ ```
172
+ {session}/
173
+ +-- config.json # Parsed arguments and settings
174
+ +-- profile-report.md # Profiler output: bottlenecks found
175
+ +-- optimization-log.md # Optimizer output: changes applied
176
+ +-- benchmark-results.md # Benchmark output: metrics comparison
177
+ +-- summary.md # Final performance summary
178
+ ```
179
+
180
+ This keeps the orchestrator's context lean -- it reads only what it needs for each phase.
181
+
182
+ ## Execution Flow
183
+
184
+ ```
185
+ 1. INIT -> Parse args, detect project type, establish baseline
186
+ 2. PROFILE -> Spawn profiler to identify bottlenecks
187
+ 3. OPTIMIZE -> Spawn optimizer to apply fixes (skip if --dry-run)
188
+ 4. BENCHMARK -> Spawn benchmark to measure improvement (if --benchmark)
189
+ 5. FINALIZE -> Compile summary, run linter, report to user
190
+ 6. CLEANUP -> Remove session dir (unless --verbose)
191
+ ```
192
+
193
+ ## Error Handling
194
+
195
+ - If profiler fails: report error with context, no optimizations can proceed
196
+ - If optimizer fails on a specific optimization: skip that optimization, continue with others, report partial results
197
+ - If benchmark fails: report profiler findings and optimizations applied without metrics comparison
198
+ - If baseline measurement fails: proceed without before/after comparison, measure current state only
199
+ - If linter fails after optimization: report which optimizations introduced lint issues
200
+ - Never silently swallow errors -- always report to the user
201
+
202
+ ## Context Management (Long-Running Agent Patterns)
203
+
204
+ ### Context Regurgitation
205
+ Before dispatching each subagent, briefly restate in your prompt:
206
+ - Current phase number and what has been completed so far
207
+ - Key findings from previous phases (top bottlenecks, optimizations applied)
208
+ - What this subagent needs to accomplish and how its output feeds the next phase
209
+
210
+ This keeps critical context fresh at the end of the context window where LLM attention is strongest.
211
+
212
+ ### File Buffering
213
+ 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.
214
+
215
+ ## Progress Reporting
216
+
217
+ At each phase transition, report to the user:
218
+
219
+ ```
220
+ -> Phase 1/4: Profiling {path} for performance bottlenecks...
221
+ Focus: {focus_areas}
222
+ OK Found 12 issues: 3 critical, 5 warnings, 4 suggestions
223
+ -> Phase 2/4: Applying targeted optimizations...
224
+ OK Applied 6 optimizations across 8 files
225
+ Skipped 2 (low impact), deferred 1 (requires architectural change)
226
+ -> Phase 3/4: Benchmarking performance improvement...
227
+ OK Bundle size: 1.2MB -> 840KB (-30%)
228
+ OK Test execution: 12.4s -> 8.1s (-35%)
229
+ OK Query count: 47 -> 12 (-74%)
230
+ -> Phase 4/4: Finalizing...
231
+ OK Linter passed, all files formatted
232
+
233
+ Summary:
234
+ Bottlenecks Found: {count} | Optimizations Applied: {count}
235
+ Bundle Size: {before} -> {after} ({change}%)
236
+ Budget Target: {status}
237
+ Files Modified: {count}
238
+ ```
239
+
240
+ ## Integration
241
+
242
+ - Can consume convention guide from `/myaidev-method:myaidev-coder` (pattern scanner output)
243
+ - Output reviewed by `/myaidev-method:myaidev-reviewer`
244
+ - Works alongside `/myaidev-method:myaidev-tester` to verify optimizations do not break tests
245
+ - Can be invoked as part of `/myaidev-method:myaidev-workflow` pipeline
246
+
247
+ ## Example Usage
248
+
249
+ ```bash
250
+ # Full performance analysis of a module
251
+ /myaidev-method:myaidev-performance src/api --benchmark
252
+
253
+ # Focus on database query optimization with budget target
254
+ /myaidev-method:myaidev-performance src/services --focus=query --budget=50queries
255
+
256
+ # Bundle size optimization for frontend
257
+ /myaidev-method:myaidev-performance src/ --focus=bundle --budget=500kb --benchmark
258
+
259
+ # Preview optimization plan without applying changes
260
+ /myaidev-method:myaidev-performance src/utils --dry-run
261
+
262
+ # Memory leak detection
263
+ /myaidev-method:myaidev-performance src/workers --focus=memory --verbose
264
+
265
+ # CPU-focused optimization with benchmarking
266
+ /myaidev-method:myaidev-performance src/algorithms --focus=cpu --budget=200ms --benchmark
267
+
268
+ # Multi-focus analysis
269
+ /myaidev-method:myaidev-performance src/ --focus=cpu,memory,network --benchmark
270
+ ```