Communitygithub.com

提示詞優化器

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

提示詞優化器 是什麼?

提示詞優化器是一項用於分析與優化提示詞的 AI 技能,專為 Claude Code、Cursor 與 Codex 等 AI 代理平台設計。它會執行一個六階段的管道:專案偵測(偵測技術棧與慣例)、意圖分類(新功能、錯誤修復、重構等)、範圍評估(瑣碎、低、中、高、史詩),以及 ECC 元件匹配(對應指令、技能與代理)。此技能會產生結構化的診斷報告,包括一份「優化提示詞 — 完整版」(可供複製貼上的 Markdown 區塊)與一份「優化提示詞 — 快速版」(適用於有經驗的使用者)。它適用於提示詞草稿模糊、缺少關鍵背景,或使用者明確請求提示詞改善(例如「優化這個提示詞」、「幫我寫個更好的提示詞」)的情境。當使用者要求直接執行任務時,不應使用此技能。

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

在你喜歡的 AI 中提問

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

說明文件

提示詞優化器 是做什麼的?

分析草稿提示詞、進行評析、匹配 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、架構性變更使用藍圖技能規劃多階段工作階段

階段 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 偵測到,或需要使用者指定?
  • 目標範圍 — 是否提及檔案、目錄或模組?
  • 驗收標準 — 如何確認任務完成?
  • 錯誤處理 — 是否處理邊界情況與失敗模式?
  • 安全需求 — 驗證、輸入驗證、機密?
  • 測試期望 — 單元測試、整合測試、端對端測試?
  • 效能限制 — 負載、延遲、資源限制?
  • UI/UX 需求 — 設計規格、響應式設計、無障礙(若為前端)?
  • 資料庫變更 — Schema、遷移、索引(若涉及資料層)?
  • 既有模式 — 需遵循的參考檔案或慣例?
  • 範圍邊界 — 不應做的事?

如果遺失 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 偵測到: 含有 Next.js 15、TypeScript、Tailwind CSS 的 package.json

優化提示詞(完整版):

使用專案現有技術棧(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 1.22、Chi 路由器的 go.mod

優化提示詞(完整版):

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/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

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.

相關技能