Communitygithub.com

Prompt 優化器

分析草稿提示詞,提供改進建議,並產出完整優化後的提示詞,可直接複製貼上使用。

Prompt 優化器 是什麼?

Prompt 優化器 是一項專為開發者與 AI 代理(如 Claude Code、Cursor)設計的技能,用於分析和優化提示詞,使其更符合 ECC 生態系統的運作方式。它能自動檢測專案脈絡(技術棧、專案慣例),並將使用者的意圖分類為新功能、錯誤修復、重構等類型,同時評估任務範圍(從簡單到史詩級)。對於中等以上範圍的任務,它會建議適當的工作流程、ECC 元件(命令、技能、代理)與模型選擇。輸出結果包含完整的診斷、優化提示詞(完整版與快速版)以及強化理由,幫助使用者以最佳方式向 AI 代理下達指令。支援中文與英文輸入,適用於 Claude Code、Codex 等平台,特別適合需要結構化開發指引的專案。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/prompt-optimizer

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Prompt 優化器 是做什麼的?

分析草稿提示詞,提供評論,匹配 ECC 生態系統元件, 並產出一個完整的優化提示詞,使用者可以直接複製貼上執行。

使用時機

  • 使用者說「優化這個提示詞」、「改進我的提示詞」、「改寫這個提示詞」
  • 使用者說「幫我寫一個更好的提示詞來...」
  • 使用者說「讓 Claude Code 做... 的最佳方法是?」
  • 使用者說「優化 prompt」、「改進 prompt」、「怎麼寫 prompt」、「幫我優化這個指令」
  • 使用者貼上草稿提示詞並要求回饋或增強
  • 使用者說「我不知道怎麼為這個寫提示詞」
  • 使用者說「我該怎麼用 ECC 做...」
  • 使用者明確呼叫 /prompt-optimize

不應使用的情況

  • 使用者希望直接完成任務(只需執行)
  • 使用者說「優化程式碼」、「優化效能」、「optimize this code」、「optimize performance」——這些是重構任務,不是提示詞優化
  • 使用者詢問 ECC 設定(應改用 configure-ecc)
  • 使用者想要技能清單(應改用 skill-stocktake)
  • 使用者說「直接做」或「直接做」

運作方式

僅提供建議 — 請勿執行使用者的任務。

不要寫程式碼、建立檔案、執行命令或採取任何實作行動。 您的唯一輸出是分析加上優化後的提示詞。

如果使用者說「直接做」、「直接做」或「不用優化,直接執行」, 請勿在此技能內切換為實作模式。告訴使用者此技能只產生優化提示詞, 並指示他們如果需要執行,請提出一般的任務要求。

依次執行此 6 階段流程。使用下方「輸出格式」呈現結果。

分析流程

階段 0:專案偵測

在分析提示詞之前,先偵測當前專案脈絡:

  1. 檢查工作目錄中是否存在 CLAUDE.md — 讀取其專案慣例
  2. 從專案檔案偵測技術棧:
    • package.json → Node.js / TypeScript / React / Next.js
    • go.mod → Go
    • pyproject.toml / requirements.txt → Python
    • Cargo.toml → Rust
    • build.gradle / pom.xml → Java / Kotlin(然後檢查建構檔中是否有 quarkus → Quarkus,或 spring-boot → Spring Boot)
    • Package.swift → Swift
    • Gemfile → Ruby
    • composer.json → PHP
    • *.csproj / *.sln → .NET
    • Makefile / CMakeLists.txt → C / C++
    • cpanfile / Makefile.PL → Perl
  3. 記錄偵測到的技術棧,以供階段 3 與階段 4 使用

如果找不到專案檔案(例如提示詞是抽象概念或用於新專案), 則跳過偵測,並在階段 4 中標記「技術棧未知」。

階段 1:意圖偵測

將使用者的任務分類為一個或多個類別:

類別信號詞範例
新功能build, create, add, implement, 建立, 實作, 新增「建立一個登入頁面」
錯誤修復fix, broken, not working, error, 修復, 報錯「修復認證流程」
重構refactor, clean up, restructure, 重構, 整理「重構 API 層」
研究how to, what is, explore, investigate, 怎麼, 如何「如何加入 SSO」
測試test, coverage, verify, 測試, 覆蓋率「為購物車新增測試」
審查review, audit, check, 審查, 檢查「審查我的 PR」
文件document, update docs, 文件「更新 API 文件」
基礎設施deploy, CI, docker, database, 部署, 資料庫「設定 CI/CD 流程」
設計design, architecture, plan, 設計, 架構「設計資料模型」

階段 2:範圍評估

如果階段 0 偵測到專案,則以程式碼庫大小作為信號。否則, 僅根據提示詞描述進行估計,並將估計標記為不確定。

範圍啟發式編排方式
簡單單一檔案,少於 50 行直接執行
低單一元件或模組單一命令或技能
中多個元件,同一領域命令鏈 + /verify
高跨領域,5 個以上檔案先 /plan,然後分階段執行
史詩級多工作階段、多 PR、架構轉變使用 bluePrint 技能進行多階段規劃

階段 3:ECC 元件匹配

將意圖 + 範圍 + 技術棧(來自階段 0)映射到特定的 ECC 元件。

依意圖類型

意圖命令技能代理
新功能/plan, /tdd, /code-review, /verifytdd-workflow, verification-loopplanner, tdd-guide, code-reviewer
錯誤修復/tdd, /build-fix, /verifytdd-workflowtdd-guide, build-error-resolver
重構/refactor-clean, /code-review, /verifyverification-looprefactor-cleaner, code-reviewer
研究/plansearch-first, iterative-retrieval—
測試/tdd, /e2e, /test-coveragetdd-workflow, e2e-testingtdd-guide, e2e-runner
審查/code-reviewsecurity-reviewcode-reviewer, security-reviewer
文件/update-docs, /update-codemaps—doc-updater
基礎設施/plan, /verifydocker-patterns, deployment-patterns, database-migrationsarchitect
設計(中-高)/plan—planner, architect
設計(史詩級)—blueprint(以技能方式呼叫)planner, architect

依技術棧

技術棧需新增的技能代理
Python / Djangodjango-patterns, django-tdd, django-security, django-verification, python-patterns, python-testingpython-reviewer
Gogolang-patterns, golang-testinggo-reviewer, go-build-resolver
Spring Boot / Javaspringboot-patterns, springboot-tdd, springboot-security, springboot-verification, java-coding-standards, jpa-patternsjava-reviewer
Quarkus / Javaquarkus-patterns, quarkus-tdd, quarkus-security, quarkus-verification, java-coding-standards, jpa-patternsjava-reviewer
Kotlin / Androidkotlin-coroutines-flows, compose-multiplatform-patterns, android-clean-architecturekotlin-reviewer
TypeScript / Reactfrontend-patterns, backend-patterns, coding-standardscode-reviewer
Swift / iOSswiftui-patterns, swift-concurrency-6-2, swift-actor-persistence, swift-protocol-di-testingcode-reviewer
PostgreSQLpostgres-patterns, database-migrationsdatabase-reviewer
Perlperl-patterns, perl-testing, perl-securitycode-reviewer
C++cpp-coding-standards, cpp-testingcode-reviewer
其他 / 未列出coding-standards(通用)code-reviewer

階段 4:遺漏脈絡偵測

掃描提示詞中遺漏的關鍵資訊。檢查每個項目,並標記階段 0 是否已自動偵測到,或者使用者必須提供:

  • 技術棧 — 已在階段 0 偵測到,或需使用者指定?
  • 目標範圍 — 有提到檔案、目錄或模組嗎?
  • 驗收標準 — 如何知道任務完成?
  • 錯誤處理 — 是否涵蓋邊緣情況與失敗模式?
  • 安全需求 — 認證、輸入驗證、機密?
  • 測試期望 — 單元測試、整合測試、E2E?
  • 效能限制 — 負載、延遲、資源限制?
  • UI/UX 需求 — 設計規範、響應式設計、無障礙?(如果是前端)
  • 資料庫變更 — 綱要、遷移、索引?(如果是資料層)
  • 現有模式 — 需遵循的參考檔案或慣例?
  • 範圍邊界 — 什麼不該做?

如果遺漏 3 個以上關鍵項目,在產生優化提示詞前,先向使用者提出最多 3 個澄清問題。然後將答案納入優化提示詞中。

階段 5:工作流程與模型建議

確定此提示詞在開發生命週期中的位置:

研究 → 規劃 → 實作 (TDD) → 審查 → 驗證 → 提交

對於「中」以上任務,一律先使用 /plan。對於「史詩級」任務,使用 bluePrint 技能。

模型建議(包含在輸出中):

範圍建議模型理由
簡單-低Sonnet 5快速、經濟實惠,適用於簡單任務
中Sonnet 5標準工作的最佳編碼模型
高Sonnet 5(主要)+ Opus 5(規劃)Opus 負責架構,Sonnet 負責實作
史詩級Opus 5(規劃)+ Sonnet 5(執行)多階段規劃需深度推理

多重提示詞拆分(適用於高/史詩級範圍):

對於超出單一工作階段的任務,拆分成連續的提示詞:

  • 提示詞 1:研究 + 規劃(先使用 search-first 技能,然後 /plan)
  • 提示詞 2-N:每個提示詞實作一個階段(每個以 /verify 結尾)
  • 最後提示詞:整合測試 + 跨所有階段的 /code-review
  • 使用 /save-session 與 /resume-session 在工作階段之間保留脈絡

輸出格式

以以下結構呈現您的分析。請以與使用者輸入相同的語言回應。

區段 1:提示詞診斷

優點: 列出原始提示詞做得好的地方。

問題:

問題影響建議修正
(問題)(後果)(如何修正)

需要釐清: 使用者應回答的問題編號清單。 如果階段 0 已自動偵測到答案,請直接說明,而非提問。

區段 2:建議的 ECC 元件

類型元件用途
命令/plan在編碼前規劃架構
技能tdd-workflowTDD 方法論指引
代理code-reviewer實作後審查
模型Sonnet 5建議用於此範圍

區段 3:優化提示詞 — 完整版

將完整的優化提示詞放在一個獨立的程式碼區塊內。 提示詞必須自含且可隨時複製貼上。包含:

  • 清楚的任務描述與脈絡
  • 技術棧(偵測到或指定)
  • 在正確工作流程階段中使用的 /command 呼叫
  • 驗收標準
  • 驗證步驟
  • 範圍邊界(什麼不該做)

對於參照 blueprint 的項目,請寫:「使用 blueprint 技能來...」 (而不是 /blueprint,因為 blueprint 是技能,不是命令)。

區段 4:優化提示詞 — 快速版

適合有經驗的 ECC 使用者的精簡版本。依意圖類型而異:

意圖快速模式
新功能/plan [功能]. /tdd 來實作. /code-review. /verify.
錯誤修復/tdd — 為 [錯誤] 撰寫失敗測試. 修復至通過. /verify.
重構/refactor-clean [範圍]. /code-review. /verify.
研究為 [主題] 使用 search-first 技能. 根據發現結果 /plan.
測試/tdd [模組]. 為關鍵流程執行 /e2e. /test-coverage.
審查/code-review. 然後使用 security-reviewer 代理.
文件/update-docs. /update-codemaps.
史詩級為「[目標]」使用 bluePrint 技能. 使用 /verify 閘門執行各階段.

區段 5:增強理由

增強理由
(新增了什麼)(為什麼重要)

頁尾

不是您需要的?告訴我要調整什麼,或者如果您需要執行而非提示詞優化,請提出一般的任務要求。


範例

觸發範例

  • 「為 ECC 優化此提示詞」
  • 「改寫此提示詞,讓 Claude Code 使用正確的命令」
  • 「幫我優化這個指令」
  • 「我該怎麼為此任務向 ECC 下提示詞?」

範例 1:模糊的中文提示詞(已偵測到專案)

使用者輸入:

幫我寫一個使用者登入頁面

階段 0 偵測到: package.json 中有 Next.js 15、TypeScript、Tailwind CSS

優化提示詞(完整版):

使用專案現有技術棧(Next.js 15 + TypeScript + Tailwind CSS)實作使用者登入頁面。

技術要求:
- 沿用專案現有的元件結構和路由慣例
- 表單驗證使用專案中已有的驗證方案(檢查是否已用 Zod/Yup/其他)
- 認證方式:沿用專案現有認證方案(如無,預設 JWT)
- 包含:電子郵件/密碼登入表單、表單驗證、錯誤提示、載入狀態、響應式佈局

工作流程:
1. /plan 先規劃元件結構和認證流程,參考現有頁面的模式
2. /tdd 測試先行:撰寫登入表單的單元測試和認證流程的整合測試
3. 實作登入頁面和認證邏輯
4. /code-review 審查實作
5. /verify 驗證所有測試通過且頁面正常渲染

安全要求:
- 密碼不以明文傳輸
- 防止暴力破解(rate limiting)
- XSS 防護
- CSRF token

驗收標準:
- 所有測試通過,覆蓋率 80%+
- 頁面在行動裝置和桌面上正常渲染
- 登入成功跳轉到 dashboard,失敗顯示錯誤訊息

不要做:
- 不要實作註冊頁面
- 不要實作忘記密碼功能
- 不要修改現有的路由結構

範例 2:中等英文提示詞

使用者輸入:

Add a REST API endpoint for user profile updates with validation

階段 0 偵測到: go.mod 中有 Go 1.22、Chi router

優化提示詞(完整版):

Add a REST API endpoint for user profile updates (PATCH /api/users/:id).

Tech stack: Go 1.22 + Chi router (detected from project)

Requirements:
- PATCH /api/users/:id — partial update of user profile
- Input validation for fields: name, email, avatar_url, bio
- Auth: require valid token, users can only update own profile
- Return 200 with updated user on success
- Return 400 with validation errors on invalid input
- Return 401/403 for auth failures
- Follow existing API patterns in the codebase

Workflow:
1. /plan the endpoint structure, middleware chain, and validation logic
2. /tdd — write table-driven tests for success, validation failure, auth failure, not-found
3. Implement following existing handler patterns
4. /go-review
5. /verify — run full test suite, confirm no regressions

Do not:
- Modify existing endpoints
- Change the database schema (use existing user table)
- Add new dependencies without checking existing ones first (use search-first skill)

範例 3:史詩級專案

使用者輸入:

Migrate our monolith to microservices

優化提示詞(完整版):

Use the blueprint skill to plan: "Migrate monolith to microservices architecture"

Before executing, answer these questions in the blueprint:
1. Which domain boundaries exist in the current monolith?
2. Which service should be extracted first (lowest coupling)?
3. Communication pattern: REST APIs, gRPC, or event-driven (Kafka/RabbitMQ)?
4. Database strategy: shared DB initially or database-per-service from start?
5. Deployment target: Kubernetes, Docker Compose, or serverless?

The blueprint should produce phases like:
- Phase 1: Identify service boundaries and create domain map
- Phase 2: Set up infrastructure (API gateway, service mesh, CI/CD per service)
- Phase 3: Extract first service (strangler fig pattern)
- Phase 4: Verify with integration tests, then extract next service
- Phase N: Decommission monolith

Each phase = 1 PR, with /verify gates between phases.
Use /save-session between phases

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相關技能