claudecode-omc 5.6.3 → 5.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,793 @@
1
+ ---
2
+ name: prompt-optimizer
3
+ description: >-
4
+ Analyze raw prompts, identify intent and gaps, match ECC components
5
+ (skills/commands/agents/hooks), and output a ready-to-paste optimized
6
+ prompt. Advisory role only — never executes the task itself.
7
+ TRIGGER when: user says "optimize prompt", "improve my prompt",
8
+ "how to write a prompt for", "help me prompt", "rewrite this prompt",
9
+ or explicitly asks to enhance prompt quality. Also triggers on Chinese
10
+ equivalents: "优化prompt", "改进prompt", "怎么写prompt", "帮我优化这个指令".
11
+ Specially handles short Chinese bug reports (the dominant real-world use
12
+ case): runs Bug Report Triage to extract repro/expected/actual/environment,
13
+ asks up to 3 clarifying questions if ≤ 2 fields are present, and inserts
14
+ systematic-debugging as a hard prerequisite before any code change.
15
+ DO NOT TRIGGER when: user wants the task executed directly, or says
16
+ "just do it" / "直接做". DO NOT TRIGGER when user says "优化代码",
17
+ "优化性能", "optimize performance", "optimize this code" — those are
18
+ refactoring/performance tasks, not prompt optimization (unless the user
19
+ explicitly invokes /prompt-optimize, in which case treat them as
20
+ Bug Fix + Refactor combined).
21
+ origin: community
22
+ metadata:
23
+ author: YannJY02
24
+ version: "1.2.0"
25
+ changelog: |
26
+ 1.2.0 — Skill Existence & Alias Resolution (Phase 0.5) so we stop
27
+ recommending phantom skills (`tdd-workflow`, `search-first`,
28
+ `blueprint`, `tdd-guide` agent, etc. that don't exist on most
29
+ installs). Multi-Intent Detection in Phase 1 with structured
30
+ patterns and scope-bump rule. Conductor scope-gating column
31
+ in Phase 2 (TRIVIAL/LOW skip, MEDIUM optional, HIGH default,
32
+ EPIC required) — prevents over-ceremonialized small tasks.
33
+ Best-Practices Skill Chains subsection in Phase 3 documenting
34
+ the superpowers pipeline per intent (New Feature, Bug Fix,
35
+ Performance, Research-then-Build, Multi-Intent, Refactor).
36
+ 1.1.0 — Added Bug Report Triage (Phase 1.5), Compact Mode (Phase 6),
37
+ Tauri/Electron tech stacks, Research-then-Build intent,
38
+ Performance intent, conductor/systematic-debugging/trace/analyze
39
+ in component matching, real-data Chinese bug example.
40
+ Driven by 8 real /prompt-optimize invocations: 7/8 were Chinese
41
+ bug reports, 1/8 was research-then-build.
42
+ 1.0.0 — Initial release.
43
+ ---
44
+
45
+ # Prompt Optimizer
46
+
47
+ Analyze a draft prompt, critique it, match it to ECC ecosystem components,
48
+ and output a complete optimized prompt the user can paste and run.
49
+
50
+ ## When to Use
51
+
52
+ - User says "optimize this prompt", "improve my prompt", "rewrite this prompt"
53
+ - User says "help me write a better prompt for..."
54
+ - User says "what's the best way to ask Claude Code to..."
55
+ - User says "优化prompt", "改进prompt", "怎么写prompt", "帮我优化这个指令"
56
+ - User pastes a draft prompt and asks for feedback or enhancement
57
+ - User says "I don't know how to prompt for this"
58
+ - User says "how should I use ECC for..."
59
+ - User explicitly invokes `/prompt-optimize`
60
+
61
+ ### Do Not Use When
62
+
63
+ - User wants the task done directly (just execute it)
64
+ - User says "优化代码", "优化性能", "optimize this code", "optimize performance" — these are refactoring tasks, not prompt optimization
65
+ - User is asking about ECC configuration (use `configure-ecc` instead)
66
+ - User wants a skill inventory (use `skill-stocktake` instead)
67
+ - User says "just do it" or "直接做"
68
+
69
+ ## How It Works
70
+
71
+ **Advisory only — do not execute the user's task.**
72
+
73
+ Do NOT write code, create files, run commands, or take any implementation
74
+ action. Your ONLY output is an analysis plus an optimized prompt.
75
+
76
+ If the user says "just do it", "直接做", or "don't optimize, just execute",
77
+ do not switch into implementation mode inside this skill. Tell the user this
78
+ skill only produces optimized prompts, and instruct them to make a normal
79
+ task request if they want execution instead.
80
+
81
+ Run this 6-phase pipeline sequentially. Present results using the Output Format below.
82
+
83
+ ### Analysis Pipeline
84
+
85
+ ### Phase 0: Project Detection
86
+
87
+ Before analyzing the prompt, detect the current project context:
88
+
89
+ 1. Check if a `CLAUDE.md` exists in the working directory — read it for project conventions
90
+ 2. Detect tech stack from project files:
91
+ - `package.json` → Node.js / TypeScript / React / Next.js
92
+ - `go.mod` → Go
93
+ - `pyproject.toml` / `requirements.txt` → Python
94
+ - `Cargo.toml` → Rust
95
+ - `src-tauri/` + `Cargo.toml` + `package.json` → **Tauri** (Rust core + Web frontend)
96
+ - `electron.json` / `electron-builder.json` / `electron` in `package.json` deps → **Electron**
97
+ - `expo.json` / `app.json` with Expo SDK → React Native (Expo)
98
+ - `build.gradle` / `pom.xml` → Java / Kotlin / Spring Boot
99
+ - `Package.swift` → Swift
100
+ - `Gemfile` → Ruby
101
+ - `composer.json` → PHP
102
+ - `*.csproj` / `*.sln` → .NET
103
+ - `Makefile` / `CMakeLists.txt` → C / C++
104
+ - `cpanfile` / `Makefile.PL` → Perl
105
+ 3. **Git context auto-pull** — if the user's prompt mentions `当前分支` / `current branch` / `this PR` / `本次改动`, run these read-only commands and inject results into Phase 4 context:
106
+ - `git status --short` (uncommitted changes)
107
+ - `git log -5 --oneline` (recent commits)
108
+ - `git diff --stat HEAD~1` (latest commit's surface area)
109
+ This converts vague references into concrete file lists.
110
+ 4. Note detected tech stack for use in Phase 3 and Phase 4
111
+
112
+ If no project files are found (e.g., the prompt is abstract or for a new project),
113
+ skip detection and flag "tech stack unknown" in Phase 4.
114
+
115
+ ### Phase 0.5: Skill Existence & Alias Resolution
116
+
117
+ The component tables below were authored against a generic ECC distribution.
118
+ Many users run OMC, superpowers, or their own custom installs where the same
119
+ capability lives under a **different skill name**. Recommending a phantom skill
120
+ wastes the user's time.
121
+
122
+ **Preferred check (live index):** before listing a skill in Section 2 / Section 3,
123
+ read the auto-generated catalog:
124
+
125
+ ```
126
+ cat ~/.claude/skills/_index.md
127
+ ```
128
+
129
+ This file is regenerated by `omc-manage setup` (or manually via
130
+ `omc-manage skill index`) and contains one row per installed skill with its
131
+ `name | description`. Grep it for keywords from the user's intent:
132
+
133
+ ```
134
+ grep -i "test\|tdd\|verification" ~/.claude/skills/_index.md
135
+ ```
136
+
137
+ If a recommended skill does **not** appear in `_index.md`, replace it with a
138
+ matching installed skill or fall back to the alias table below.
139
+
140
+ **Fallback rule (when index is missing or empty):** mentally check
141
+ *"Is this skill likely installed locally?"* If unsure, follow the alias table
142
+ or add a verification note.
143
+
144
+ **Common alias map (generic ECC name → likely real names):**
145
+
146
+ | Generic ECC name | superpowers / OMC actual | Verification |
147
+ |---|---|---|
148
+ | `tdd-workflow` (skill) | `test-driven-development` (superpowers) OR `tdd-generator` (OMC) | `ls ~/.claude/skills/test-driven-development` |
149
+ | `verification-loop` (skill) | `verification-before-completion` (superpowers) OR `verification-loop` (OMC) | both common |
150
+ | `search-first` (skill) | `external-context` OR `iterative-retrieval` | check both |
151
+ | `blueprint` (skill) | **`conductor`** (preferred multi-session driver) | `ls ~/.claude/skills/conductor` |
152
+ | `e2e-testing` (skill) | `e2e` | — |
153
+ | `tdd-guide` (agent) | `test-engineer` (OMC) | — |
154
+ | `build-error-resolver` (agent) | `debugger` (OMC) | — |
155
+ | `refactor-cleaner` (agent) | `code-simplifier` (OMC) | — |
156
+ | `doc-updater` (agent) | `writer` (OMC) | — |
157
+ | `python-reviewer` / `go-reviewer` / etc. | usually just `code-reviewer` | — |
158
+
159
+ **Tech-stack-specific patterns** (`django-patterns`, `springboot-patterns`,
160
+ `frontend-patterns`, etc., listed in the By Tech Stack table) are **aspirational
161
+ on most installs** — assume absent unless the user confirms otherwise. When
162
+ referencing them in Section 3, write:
163
+
164
+ > If you don't have `<skill-name>` installed, recommend the universal `coding-standards` skill instead, or use the conventions in the project's `CLAUDE.md`.
165
+
166
+ **Discovery shortcut for the user:** if `_index.md` is missing entirely, suggest
167
+ they run `omc-manage skill index --scope user` (or just `omc-manage setup`,
168
+ which regenerates it as a side effect). For a quality audit, use
169
+ `/oh-my-claudecode:skill-stocktake`.
170
+
171
+ ### Phase 1: Intent Detection
172
+
173
+ Classify the user's task into one or more categories:
174
+
175
+ | Category | Signal Words | Example |
176
+ |----------|-------------|---------|
177
+ | New Feature | build, create, add, implement, 创建, 实现, 添加, 增加 | "Build a login page" |
178
+ | Bug Fix | fix, broken, not working, error, 修复, 报错, 偶现, 不工作, 失效, 卡顿, 我发现一个问题, 你先看看 | "Fix the auth flow" / "我发现头像不显示" |
179
+ | Refactor | refactor, clean up, restructure, 重构, 整理 | "Refactor the API layer" |
180
+ | Research | how to, what is, explore, investigate, 怎么, 如何 | "How to add SSO" |
181
+ | **Research-then-Build** | "先调研 X 再实现", "参考 X 怎么做", "look at how X does it then build" | "先调研 Gemini CLI 自动补全再实现" |
182
+ | Testing | test, coverage, verify, 测试, 覆盖率 | "Add tests for the cart" |
183
+ | Review | review, audit, check, 审查, 检查 | "Review my PR" |
184
+ | Documentation | document, update docs, 文档 | "Update the API docs" |
185
+ | Infrastructure | deploy, CI, docker, database, 部署, 数据库 | "Set up CI/CD pipeline" |
186
+ | Design | design, architecture, plan, 设计, 架构 | "Design the data model" |
187
+ | Performance | "优化性能", "卡顿", "slow", "latency", "做性能优化" | "Windows 上卡顿" |
188
+
189
+ **Multi-intent prompts** (detect at this phase, plan in Phase 2):
190
+
191
+ Many real prompts pack ≥ 2 intents into one sentence. Detect by counting
192
+ distinct verbs/categories. Common patterns:
193
+
194
+ | Pattern | Example | Intents |
195
+ |---|---|---|
196
+ | "先 X 再 Y" | "先做性能优化,再做 UX 优化" | Performance → Refactor |
197
+ | "X 同时 Y" | "修复 bug 同时加一个新页面" | Bug Fix + New Feature |
198
+ | "顺便/也" | "改这个 bug,顺便补测试" | Bug Fix + Testing |
199
+ | "调研 X 然后实现" | "调研 Gemini CLI 自动补全再实现" | Research-then-Build |
200
+ | "重构 X 顺便加 Y" | "重构 API 顺便补文档" | Refactor + Documentation |
201
+
202
+ **When ≥ 2 distinct intents detected:**
203
+
204
+ 1. **Do not collapse into a single prompt.** That produces ambiguous task
205
+ ordering and loses scope discipline.
206
+ 2. **Bump scope assessment by one level** (e.g., MEDIUM → HIGH). Multi-intent
207
+ work has higher coordination cost than single-intent.
208
+ 3. **Recommend the conductor skill** if combined scope is HIGH or above —
209
+ each intent becomes a track:
210
+ ```
211
+ .omc/conductor/<feature-name>/
212
+ ├── tracks/
213
+ │ ├── perf-optimization/ # spec → plan → review
214
+ │ └── ux-improvement/ # spec → plan → review
215
+ ```
216
+ 4. **Order matters**: explicit "先 X 再 Y" is sequential; "X + Y" with no
217
+ ordering signal — recommend a default order based on dependency
218
+ (e.g., investigation before fix, fix before refactor, refactor before docs).
219
+ 5. **Stop conditions per intent**: each track gets its own /verify gate; do
220
+ NOT proceed to track 2 until track 1's verify passes.
221
+
222
+ **Note on Performance intent**: The skill's "Do Not Use When" rule blocks `优化性能` *as a trigger* — but if the user explicitly invoked `/prompt-optimize` with a performance task, treat it like Bug Fix + Refactor combined: investigate first (`analyze`/`trace`), then refactor with measurement gates.
223
+
224
+ ### Phase 1.5: Bug Report Triage (only if Intent = Bug Fix or Performance)
225
+
226
+ Bug reports are the highest-volume use case for this skill, and they fail in
227
+ predictable ways: vague repro, missing environment, no expected/actual.
228
+ For Bug Fix and Performance intents, you MUST score the prompt against this
229
+ checklist before generating the optimized prompt.
230
+
231
+ | Field | What to extract | Default if missing |
232
+ |---|---|---|
233
+ | **Repro steps** | Concrete numbered steps to trigger the bug | Mark `TODO: 用户补充复现步骤` |
234
+ | **Expected behavior** | What should happen | Infer from prompt or mark TODO |
235
+ | **Actual behavior** | What does happen (error message, screenshot, log) | Mark TODO |
236
+ | **Environment** | OS (macOS/Windows/Linux), version, browser, device | Ask if absent and prompt mentions cross-platform symptoms |
237
+ | **Reproducibility** | 100% / 偶现 (intermittent) / "first time" | Default 100% if not stated |
238
+ | **Recent changes** | Branch name, recent commits, suspected commit | Auto-fill via `git log -5` (Phase 0) |
239
+ | **Logs / stack trace** | Error text, console output, network response | Mark `TODO: 粘贴完整错误日志/截图` |
240
+
241
+ **Scoring rule:**
242
+ - ≥ 5 fields present → proceed to Phase 2 directly
243
+ - 3–4 fields present → fill TODO markers in optimized prompt; do NOT block
244
+ - ≤ 2 fields present → ask the user up to 3 clarifying questions BEFORE generating prompt. Prioritize: (1) repro, (2) environment if "偶现"/"intermittent"/cross-platform mentioned, (3) actual error/log
245
+
246
+ **Special signals:**
247
+ - "偶现" / "intermittent" / "flaky" / "sometimes" / "occasionally" → MUST ask: trigger pattern, frequency, environment differences
248
+ - "X 平台正常 Y 平台不正常" / "works on mac, broken on windows" → cross-platform Bug; recommend `electron-driver` skill if Electron, recommend platform-conditional repro
249
+ - "重启后/restart" → state-persistence bug; recommend reading any storage layer (localStorage, electron-store, Tauri store, sqlite) before fixing
250
+ - "性能/slow/卡顿" → Performance intent; recommend `analyze` skill + measurement-first workflow (record baseline, then optimize)
251
+
252
+ **Bug Fix optimized-prompt template** (used in Section 3 when intent = Bug Fix):
253
+
254
+ ```
255
+ ## 问题描述
256
+ [symptom in 1-2 sentences]
257
+
258
+ ## 复现步骤
259
+ 1. ...
260
+ 2. ...
261
+ 3. ...
262
+
263
+ ## 期望 vs 实际
264
+ - 期望:...
265
+ - 实际:...
266
+
267
+ ## 环境
268
+ - OS / 版本:[macOS 14 / Windows 11 / ...]
269
+ - 复现率:[100% / 偶现 N 次/M 次]
270
+ - 当前分支:[auto-filled via git]
271
+ - 相关日志:[paste here / TODO]
272
+
273
+ ## 工作流
274
+ 1. **不要直接改代码**。先用 systematic-debugging skill 定位根因
275
+ - 列出至少 3 个候选假设
276
+ - 对每个假设设计最小验证(添加日志 / 阅读相关代码)
277
+ 2. /tdd 写一个 failing 测试复现 bug(如果是 UI bug,写 e2e 用例)
278
+ 3. 修复到 green
279
+ 4. /verify 跨平台验证(如适用,跑 macOS + Windows)
280
+ 5. /code-review
281
+
282
+ ## 不要做
283
+ - 不要重构相邻无关代码
284
+ - 不要修改无关文件
285
+ - 不要在没有定位根因前提交"试试看"的修复
286
+ ```
287
+
288
+ ### Phase 2: Scope Assessment
289
+
290
+ If Phase 0 detected a project, use codebase size as a signal. Otherwise, estimate
291
+ from the prompt description alone and mark the estimate as uncertain.
292
+
293
+ | Scope | Heuristic | Orchestration | **Conductor recommendation** |
294
+ |-------|-----------|---------------|------------------------------|
295
+ | TRIVIAL | Single file, < 50 lines | Direct execution | **Skip** — overkill |
296
+ | LOW | Single component or module | Single command or skill | **Skip** — single skill is enough |
297
+ | MEDIUM | Multiple components, same domain | Command chain + /verify | **Optional** — offer it but don't force; user choice |
298
+ | HIGH | Cross-domain, 5+ files | /plan first, then phased execution | **Default ON** — `conductor` track keeps phases coherent across reviews |
299
+ | EPIC | Multi-session, multi-PR, architectural shift | conductor (or blueprint) for multi-session plan | **Required** — single-session execution will lose context |
300
+
301
+ **Why the gating matters:** Recommending conductor for a TRIVIAL task ("rename
302
+ this variable") creates `.omc/conductor/<track>/spec.md` etc. — pure ceremony
303
+ overhead. Conductor's value (durable spec/plan/review across sessions) only
304
+ pays off when the task itself is durable (HIGH+).
305
+
306
+ **Multi-intent override**: per Phase 1, multi-intent prompts bump scope by
307
+ one level. So a MEDIUM task with 2 intents → HIGH → conductor defaults ON.
308
+
309
+ ### Phase 3: ECC Component Matching
310
+
311
+ Map intent + scope + tech stack (from Phase 0) to specific ECC components.
312
+
313
+ #### By Intent Type
314
+
315
+ | Intent | Commands | Skills | Agents |
316
+ |--------|----------|--------|--------|
317
+ | New Feature | /plan, /tdd, /code-review, /verify | tdd-workflow, verification-loop | planner, tdd-guide, code-reviewer |
318
+ | **Bug Fix** | /tdd, /verify | **systematic-debugging (REQUIRED first)**, trace, analyze, debug, verification-loop | **debugger**, tdd-guide, code-reviewer |
319
+ | **Bug Fix (intermittent / 偶现)** | /verify | systematic-debugging, trace, **e2e (for flaky reproduction harness)** | debugger, tracer |
320
+ | **Bug Fix (cross-platform)** | /verify | systematic-debugging, **electron-driver** (if Electron) | debugger, code-reviewer |
321
+ | **Performance** | /verify | analyze, trace, verification-loop | architect, code-reviewer |
322
+ | Refactor | /refactor-clean, /code-review, /verify | verification-loop | refactor-cleaner, code-reviewer |
323
+ | Research | /plan | search-first, iterative-retrieval, external-context | — |
324
+ | **Research-then-Build** | /plan | external-context (research) → **conductor** (track delivery) → /tdd per phase | planner → executor |
325
+ | Testing | /tdd, /e2e, /test-coverage | tdd-workflow, e2e-testing | tdd-guide, e2e-runner |
326
+ | Review | /code-review | security-review | code-reviewer, security-reviewer |
327
+ | Documentation | /update-docs, /update-codemaps | — | doc-updater, writer |
328
+ | Infrastructure | /plan, /verify | docker-patterns, deployment-patterns, database-migrations | architect |
329
+ | Design (MEDIUM-HIGH) | /plan | — | planner, architect |
330
+ | Design (EPIC) | — | **conductor** (multi-session track) OR blueprint | planner, architect |
331
+
332
+ #### By Tech Stack
333
+
334
+ | Tech Stack | Skills to Add | Agent |
335
+ |------------|--------------|-------|
336
+ | Python / Django | django-patterns, django-tdd, django-security, django-verification, python-patterns, python-testing | python-reviewer |
337
+ | Go | golang-patterns, golang-testing | go-reviewer, go-build-resolver |
338
+ | Spring Boot / Java | springboot-patterns, springboot-tdd, springboot-security, springboot-verification, java-coding-standards, jpa-patterns | code-reviewer |
339
+ | Kotlin / Android | kotlin-coroutines-flows, compose-multiplatform-patterns, android-clean-architecture | kotlin-reviewer |
340
+ | TypeScript / React | frontend-patterns, backend-patterns, coding-standards | code-reviewer |
341
+ | Swift / iOS | swiftui-patterns, swift-concurrency-6-2, swift-actor-persistence, swift-protocol-di-testing | code-reviewer |
342
+ | **Tauri (Rust + Web)** | rust-patterns, frontend-patterns, coding-standards (note IPC bridge between Rust core and Web) | code-reviewer |
343
+ | **Electron** | **electron-driver (E2E)**, frontend-patterns, coding-standards (note main vs renderer process) | code-reviewer |
344
+ | **React Native / Expo** | frontend-patterns, coding-standards | code-reviewer |
345
+ | **Cross-platform desktop bug** | electron-driver (if Electron) + systematic-debugging + platform-conditional repro | debugger |
346
+ | PostgreSQL | postgres-patterns, database-migrations | database-reviewer |
347
+ | Perl | perl-patterns, perl-testing, perl-security | code-reviewer |
348
+ | C++ | cpp-coding-standards, cpp-testing | code-reviewer |
349
+ | Other / Unlisted | coding-standards (universal) | code-reviewer |
350
+
351
+ #### Best-Practices Skill Chains
352
+
353
+ The two tables above pick **single skills**; this subsection wires them into
354
+ **ordered chains** that match documented community best practices (primarily
355
+ the superpowers pipeline). Use these chains in Section 3 — don't just dump a
356
+ flat list of skills.
357
+
358
+ **Chain notation:** `A → B → C` means run A first, then B, then C, with each
359
+ step gated by its own success criterion. `[X]` = optional, include only if
360
+ scope/risk warrants it.
361
+
362
+ ##### Chain: New Feature (HIGH+ scope)
363
+
364
+ ```
365
+ brainstorming (clarify intent + requirements)
366
+ → using-git-worktrees (isolate work)
367
+ → conductor (init track) (create spec.md / plan.md skeleton)
368
+ → writing-plans (fill plan.md with concrete steps)
369
+ → [research] external-context (only if novel domain)
370
+ → test-driven-development (red → green per step)
371
+ → verification-before-completion (evidence-based check)
372
+ → requesting-code-review (independent review pass)
373
+ → finishing-a-development-branch (merge / PR / cleanup)
374
+ ```
375
+
376
+ ##### Chain: New Feature (LOW–MEDIUM scope, no conductor)
377
+
378
+ ```
379
+ brainstorming
380
+ → writing-plans (lightweight inline plan)
381
+ → test-driven-development
382
+ → verification-before-completion
383
+ → [requesting-code-review] (skip for trivial)
384
+ ```
385
+
386
+ ##### Chain: Bug Fix (any scope)
387
+
388
+ ```
389
+ systematic-debugging (REQUIRED: hypotheses → evidence)
390
+ → [trace] (only if intermittent / 偶现)
391
+ → test-driven-development (failing test reproduces bug)
392
+ → verification-before-completion (test passes + no regressions)
393
+ → [requesting-code-review] (for non-trivial fixes)
394
+ → finishing-a-development-branch
395
+ ```
396
+
397
+ ##### Chain: Performance Optimization
398
+
399
+ ```
400
+ analyze (baseline measurement: profile / timing)
401
+ → trace (locate hotspot with evidence)
402
+ → writing-plans (which optimizations, in what order)
403
+ → test-driven-development (regression test for behavior)
404
+ → [implement] (one optimization at a time)
405
+ → verification-before-completion (re-measure: did it actually improve?)
406
+ → finishing-a-development-branch
407
+ ```
408
+
409
+ ##### Chain: Research-then-Build
410
+
411
+ ```
412
+ external-context (study reference implementation)
413
+ → produce comparison report (what to copy, what to skip, what to adapt)
414
+ → brainstorming (apply learnings to our context)
415
+ → conductor (init multi-phase track)
416
+ → phase-1: minimal viable port
417
+ → phase-2: project-specific adaptations
418
+ → phase-3: integration + tests
419
+ → finishing-a-development-branch
420
+ ```
421
+
422
+ ##### Chain: Multi-Intent Prompt
423
+
424
+ ```
425
+ brainstorming (decompose into intents, prioritize)
426
+ → conductor (multi-track init) (one track per intent)
427
+ → for each track in dependency order:
428
+ → use the appropriate single-intent chain above
429
+ → /verify gate before next track starts
430
+ → finishing-a-development-branch (one PR or split per track, user's call)
431
+ ```
432
+
433
+ ##### Chain: Refactor (no behavior change)
434
+
435
+ ```
436
+ [code-review of current state] (understand existing intent)
437
+ → writing-plans (refactor steps, each behavior-preserving)
438
+ → test-driven-development (characterization tests if absent)
439
+ → ai-slop-cleaner (only if cleaning AI-generated bloat)
440
+ → verification-before-completion (behavior unchanged: tests still pass)
441
+ → finishing-a-development-branch
442
+ ```
443
+
444
+ **When to deviate from these chains:**
445
+ - User explicitly says "skip TDD" → drop test-driven-development
446
+ - Project's `CLAUDE.md` mandates a different workflow → follow it (CLAUDE.md > skill chains, per superpowers `using-superpowers` priority rule)
447
+ - Time-boxed prototype / spike → can drop verification-before-completion + requesting-code-review (mark explicitly: "this is a spike, not production")
448
+
449
+ ### Phase 4: Missing Context Detection
450
+
451
+ Scan the prompt for missing critical information. Check each item and mark
452
+ whether Phase 0 auto-detected it or the user must supply it:
453
+
454
+ - [ ] **Tech stack** — Detected in Phase 0, or must user specify?
455
+ - [ ] **Target scope** — Files, directories, or modules mentioned?
456
+ - [ ] **Acceptance criteria** — How to know the task is done?
457
+ - [ ] **Error handling** — Edge cases and failure modes addressed?
458
+ - [ ] **Security requirements** — Auth, input validation, secrets?
459
+ - [ ] **Testing expectations** — Unit, integration, E2E?
460
+ - [ ] **Performance constraints** — Load, latency, resource limits?
461
+ - [ ] **UI/UX requirements** — Design specs, responsive, a11y? (if frontend)
462
+ - [ ] **Database changes** — Schema, migrations, indexes? (if data layer)
463
+ - [ ] **Existing patterns** — Reference files or conventions to follow?
464
+ - [ ] **Scope boundaries** — What NOT to do?
465
+
466
+ **If 3+ critical items are missing**, ask the user up to 3 clarification
467
+ questions before generating the optimized prompt. Then incorporate the
468
+ answers into the optimized prompt.
469
+
470
+ ### Phase 5: Workflow & Model Recommendation
471
+
472
+ Determine where this prompt sits in the development lifecycle:
473
+
474
+ ```
475
+ Research → Plan → Implement (TDD) → Review → Verify → Commit
476
+ ```
477
+
478
+ For MEDIUM+ tasks, always start with /plan. For EPIC tasks, use blueprint skill.
479
+
480
+ **Model recommendation** (include in output):
481
+
482
+ | Scope | Recommended Model | Rationale |
483
+ |-------|------------------|-----------|
484
+ | TRIVIAL-LOW | Sonnet 4.6 | Fast, cost-efficient for simple tasks |
485
+ | MEDIUM | Sonnet 4.6 | Best coding model for standard work |
486
+ | HIGH | Sonnet 4.6 (main) + Opus 4.6 (planning) | Opus for architecture, Sonnet for implementation |
487
+ | EPIC | Opus 4.6 (blueprint) + Sonnet 4.6 (execution) | Deep reasoning for multi-session planning |
488
+
489
+ **Multi-prompt splitting** (for HIGH/EPIC scope):
490
+
491
+ For tasks that exceed a single session, split into sequential prompts:
492
+ - Prompt 1: Research + Plan (use search-first skill, then /plan)
493
+ - Prompt 2-N: Implement one phase per prompt (each ends with /verify)
494
+ - Final Prompt: Integration test + /code-review across all phases
495
+ - Use /save-session and /resume-session to preserve context between sessions
496
+ - For multi-session structured delivery, prefer the **conductor** skill (creates `.omc/conductor/` tracks with Context → Spec → Plan → Implement artifacts that survive across sessions)
497
+
498
+ ### Phase 6: Compact Mode (output short-circuit)
499
+
500
+ When ALL of these are true, skip Section 1 (Diagnosis) and Section 5 (Rationale)
501
+ in the output — just deliver Section 2 (Components) + Section 3 (Full prompt) +
502
+ Section 4 (Quick) + Footer:
503
+
504
+ - Original prompt is < 300 characters AND
505
+ - Single, well-defined issue (no multi-part request) AND
506
+ - Tech stack auto-detected in Phase 0 AND
507
+ - Bug Triage scored ≥ 5/7 OR intent ≠ Bug Fix
508
+
509
+ **Why:** Real telemetry shows the majority of `/prompt-optimize` invocations
510
+ are short Chinese bug reports. Forcing them through full diagnosis adds reading
511
+ overhead with no signal. Diagnosis tables matter when prompts are ambiguous —
512
+ not when they're already concrete.
513
+
514
+ If Compact Mode triggers, prefix Section 2 with: `> Compact mode (short single-issue prompt). Full diagnosis skipped — ask if you want it.`
515
+
516
+ ---
517
+
518
+ ## Output Format
519
+
520
+ Present your analysis in this exact structure. Respond in the same language
521
+ as the user's input.
522
+
523
+ ### Section 1: Prompt Diagnosis
524
+
525
+ **Strengths:** List what the original prompt does well.
526
+
527
+ **Issues:**
528
+
529
+ | Issue | Impact | Suggested Fix |
530
+ |-------|--------|---------------|
531
+ | (problem) | (consequence) | (how to fix) |
532
+
533
+ **Needs Clarification:** Numbered list of questions the user should answer.
534
+ If Phase 0 auto-detected the answer, state it instead of asking.
535
+
536
+ ### Section 2: Recommended ECC Components
537
+
538
+ | Type | Component | Purpose |
539
+ |------|-----------|---------|
540
+ | Command | /plan | Plan architecture before coding |
541
+ | Skill | tdd-workflow | TDD methodology guidance |
542
+ | Agent | code-reviewer | Post-implementation review |
543
+ | Model | Sonnet 4.6 | Recommended for this scope |
544
+
545
+ ### Section 3: Optimized Prompt — Full Version
546
+
547
+ Present the complete optimized prompt inside a single fenced code block.
548
+ The prompt must be self-contained and ready to copy-paste. Include:
549
+ - Clear task description with context
550
+ - Tech stack (detected or specified)
551
+ - /command invocations at the right workflow stages
552
+ - Acceptance criteria
553
+ - Verification steps
554
+ - Scope boundaries (what NOT to do)
555
+
556
+ For items that reference blueprint, write: "Use the blueprint skill to..."
557
+ (not `/blueprint`, since blueprint is a skill, not a command).
558
+
559
+ ### Section 4: Optimized Prompt — Quick Version
560
+
561
+ A compact version for experienced ECC users. Vary by intent type:
562
+
563
+ | Intent | Quick Pattern |
564
+ |--------|--------------|
565
+ | New Feature | `/plan [feature]. /tdd to implement. /code-review. /verify.` |
566
+ | Bug Fix | `Use systematic-debugging for [bug] — list 3 hypotheses, verify each. Then /tdd: write failing test, fix to green. /verify.` |
567
+ | Bug Fix (intermittent) | `Use trace skill for [intermittent bug] — competing hypotheses with evidence. Build flaky-repro harness in /e2e. Fix only after 100% repro. /verify.` |
568
+ | Bug Fix (cross-platform) | `Use systematic-debugging for [bug]. Repro on both [platform A] and [platform B]. Fix. /verify on both platforms.` |
569
+ | Performance | `Use analyze for [slow path] — measure baseline first (timing/profile). Identify top 3 hotspots. Fix one at a time, re-measure after each. /verify regression.` |
570
+ | Refactor | `/refactor-clean [scope]. /code-review. /verify.` |
571
+ | Research | `Use external-context skill for [topic]. /plan based on findings.` |
572
+ | Research-then-Build | `Use external-context to study [reference X]. Produce comparison report. Then use conductor skill to track delivery: spec → plan → /tdd per phase.` |
573
+ | Testing | `/tdd [module]. /e2e for critical flows. /test-coverage.` |
574
+ | Review | `/code-review. Then use security-reviewer agent.` |
575
+ | Docs | `/update-docs. /update-codemaps.` |
576
+ | EPIC | `Use conductor skill (or blueprint) for "[objective]". Execute phases with /verify gates.` |
577
+
578
+ ### Section 5: Enhancement Rationale
579
+
580
+ | Enhancement | Reason |
581
+ |-------------|--------|
582
+ | (what was added) | (why it matters) |
583
+
584
+ ### Footer
585
+
586
+ > Not what you need? Tell me what to adjust, or make a normal task request
587
+ > if you want execution instead of prompt optimization.
588
+ >
589
+ > **For bug reports:** before pasting the optimized prompt into a new session,
590
+ > attach any error logs, stack traces, or screenshots — they make the
591
+ > investigation 10× faster than text descriptions alone.
592
+
593
+ ---
594
+
595
+ ## Examples
596
+
597
+ ### Trigger Examples
598
+
599
+ - "Optimize this prompt for ECC"
600
+ - "Rewrite this prompt so Claude Code uses the right commands"
601
+ - "帮我优化这个指令"
602
+ - "How should I prompt ECC for this task?"
603
+
604
+ ### Example 1: Vague Chinese Prompt (Project Detected)
605
+
606
+ **User input:**
607
+ ```
608
+ 帮我写一个用户登录页面
609
+ ```
610
+
611
+ **Phase 0 detects:** `package.json` with Next.js 15, TypeScript, Tailwind CSS
612
+
613
+ **Optimized Prompt (Full):**
614
+ ```
615
+ 使用项目现有技术栈(Next.js 15 + TypeScript + Tailwind CSS)实现用户登录页面。
616
+
617
+ 技术要求:
618
+ - 沿用项目现有的组件结构和路由约定
619
+ - 表单验证使用项目中已有的验证方案(检查是否已用 Zod/Yup/其他)
620
+ - 认证方式:沿用项目现有认证方案(如无,默认 JWT)
621
+ - 包含:邮箱/密码登录表单、表单验证、错误提示、加载状态、响应式布局
622
+
623
+ 工作流:
624
+ 1. /plan 先规划组件结构和认证流程,参考现有页面的模式
625
+ 2. /tdd 测试先行:编写登录表单的单元测试和认证流程的集成测试
626
+ 3. 实现登录页面和认证逻辑
627
+ 4. /code-review 审查实现
628
+ 5. /verify 验证所有测试通过且页面正常渲染
629
+
630
+ 安全要求:
631
+ - 密码不明文传输
632
+ - 防止暴力破解(rate limiting)
633
+ - XSS 防护
634
+ - CSRF token
635
+
636
+ 验收标准:
637
+ - 所有测试通过,覆盖率 80%+
638
+ - 页面在移动端和桌面端正常渲染
639
+ - 登录成功跳转到 dashboard,失败显示错误信息
640
+
641
+ 不要做:
642
+ - 不要实现注册页面
643
+ - 不要实现忘记密码功能
644
+ - 不要修改现有的路由结构
645
+ ```
646
+
647
+ ### Example 2: Moderate English Prompt
648
+
649
+ **User input:**
650
+ ```
651
+ Add a REST API endpoint for user profile updates with validation
652
+ ```
653
+
654
+ **Phase 0 detects:** `go.mod` with Go 1.22, Chi router
655
+
656
+ **Optimized Prompt (Full):**
657
+ ```
658
+ Add a REST API endpoint for user profile updates (PATCH /api/users/:id).
659
+
660
+ Tech stack: Go 1.22 + Chi router (detected from project)
661
+
662
+ Requirements:
663
+ - PATCH /api/users/:id — partial update of user profile
664
+ - Input validation for fields: name, email, avatar_url, bio
665
+ - Auth: require valid token, users can only update own profile
666
+ - Return 200 with updated user on success
667
+ - Return 400 with validation errors on invalid input
668
+ - Return 401/403 for auth failures
669
+ - Follow existing API patterns in the codebase
670
+
671
+ Workflow:
672
+ 1. /plan the endpoint structure, middleware chain, and validation logic
673
+ 2. /tdd — write table-driven tests for success, validation failure, auth failure, not-found
674
+ 3. Implement following existing handler patterns
675
+ 4. /go-review
676
+ 5. /verify — run full test suite, confirm no regressions
677
+
678
+ Do not:
679
+ - Modify existing endpoints
680
+ - Change the database schema (use existing user table)
681
+ - Add new dependencies without checking existing ones first (use search-first skill)
682
+ ```
683
+
684
+ ### Example 3: Chinese Bug Report (real-data pattern)
685
+
686
+ **User input:**
687
+ ```
688
+ 当前分支的分享 html 项目或者 md 文档的功能,存在一个问题,就是如果用户修改已经分享的文件,无法再次分享,这样链接始终不会发生改变
689
+ ```
690
+
691
+ **Phase 0 detects:** Tauri (Rust + Web) project. Git context: 3 uncommitted files in `src/share/`, branch `feat/share-html`.
692
+
693
+ **Phase 1.5 Triage:** repro 1/7 (only symptom), expected/actual implicit, environment unspecified, reproducibility 100% inferred. **Score 3/7 → fill TODO markers, do not block.**
694
+
695
+ **Optimized Prompt (Full):**
696
+ ```
697
+ ## 问题描述
698
+ 分享 HTML 项目 / MD 文档功能:用户修改已分享文件后,无法再次生成新链接,
699
+ 链接始终不更新。
700
+
701
+ ## 复现步骤
702
+ 1. 在当前分支(feat/share-html)打开任意 HTML 项目或 MD 文档
703
+ 2. 点击分享,记录生成的链接 A
704
+ 3. 修改文件内容并保存
705
+ 4. 再次点击分享
706
+ 5. 观察生成的链接是否变化
707
+
708
+ ## 期望 vs 实际
709
+ - 期望:再次分享时生成新链接(或同链接但内容已更新)
710
+ - 实际:分享按钮无响应 / 链接不变 / 旧内容(请确认是哪种)
711
+
712
+ ## 环境
713
+ - OS / 版本:[macOS / Windows,请补充]
714
+ - 复现率:100%(推测,请确认)
715
+ - 当前分支:feat/share-html
716
+ - 相关文件:src/share/*(git status 显示 3 个未提交改动 — 是否相关?)
717
+
718
+ ## 工作流
719
+ 1. **不要直接改代码**。先用 systematic-debugging skill 定位根因,候选假设:
720
+ - H1: 分享缓存(按文件路径 key)未失效
721
+ - H2: 文件 hash 计算逻辑用了 mtime 而非内容 hash
722
+ - H3: 分享接口幂等性设计阻止了重复请求
723
+ - H4: 前端短路 — 检测到"已分享"就不再触发请求
724
+ 对每个假设:阅读 src/share/ 相关代码 + 添加临时日志验证
725
+ 2. /tdd 写 e2e 测试用例:分享 → 修改 → 再分享,断言链接或内容变化
726
+ 3. 修复到 green
727
+ 4. /verify:跑 e2e 测试 + macOS + Windows 各手测一次(Tauri 项目跨平台)
728
+ 5. /code-review
729
+
730
+ ## 不要做
731
+ - 不要改其他分享类型(仅 HTML / MD 文档)
732
+ - 不要重构 share 模块的整体架构
733
+ - 不要在没定位根因前做"清缓存"之类的猜测性修复
734
+ ```
735
+
736
+ **Optimized Prompt (Quick):**
737
+ ```
738
+ Use systematic-debugging for "分享 HTML/MD 后修改文件链接不更新" — list 3 hypotheses
739
+ (cache key, hash strategy, idempotent API), verify each. /tdd write failing e2e.
740
+ Fix to green. /verify on macOS + Windows.
741
+ ```
742
+
743
+ ### Example 4: EPIC Project
744
+
745
+ **User input:**
746
+ ```
747
+ Migrate our monolith to microservices
748
+ ```
749
+
750
+ **Optimized Prompt (Full):**
751
+ ```
752
+ Use the blueprint skill to plan: "Migrate monolith to microservices architecture"
753
+
754
+ Before executing, answer these questions in the blueprint:
755
+ 1. Which domain boundaries exist in the current monolith?
756
+ 2. Which service should be extracted first (lowest coupling)?
757
+ 3. Communication pattern: REST APIs, gRPC, or event-driven (Kafka/RabbitMQ)?
758
+ 4. Database strategy: shared DB initially or database-per-service from start?
759
+ 5. Deployment target: Kubernetes, Docker Compose, or serverless?
760
+
761
+ The blueprint should produce phases like:
762
+ - Phase 1: Identify service boundaries and create domain map
763
+ - Phase 2: Set up infrastructure (API gateway, service mesh, CI/CD per service)
764
+ - Phase 3: Extract first service (strangler fig pattern)
765
+ - Phase 4: Verify with integration tests, then extract next service
766
+ - Phase N: Decommission monolith
767
+
768
+ Each phase = 1 PR, with /verify gates between phases.
769
+ Use /save-session between phases. Use /resume-session to continue.
770
+ Use git worktrees for parallel service extraction when dependencies allow.
771
+
772
+ Recommended: Opus 4.6 for blueprint planning, Sonnet 4.6 for phase execution.
773
+ ```
774
+
775
+ ---
776
+
777
+ ## Related Components
778
+
779
+ | Component | When to Reference |
780
+ |-----------|------------------|
781
+ | `configure-ecc` | User hasn't set up ECC yet |
782
+ | `skill-stocktake` | Audit which components are installed (use instead of hardcoded catalog) |
783
+ | `search-first` | Research phase in optimized prompts |
784
+ | `external-context` | Research external docs/products (e.g., "调研 Gemini CLI 怎么做的") |
785
+ | `systematic-debugging` | **Always** referenced for Bug Fix intent — root-cause before code |
786
+ | `trace` | Bug Fix with competing hypotheses, intermittent / 偶现 bugs |
787
+ | `analyze` | Performance intent or unknown-cause investigation |
788
+ | `debug` | OMC session/repo state diagnosis |
789
+ | `conductor` | Multi-session structured delivery (replaces blueprint for most cases) |
790
+ | `blueprint` | EPIC-scope when conductor is unavailable (legacy) |
791
+ | `electron-driver` | Electron cross-platform bugs requiring E2E repro |
792
+ | `strategic-compact` | Long session context management |
793
+ | `cost-aware-llm-pipeline` | Token optimization recommendations |