prompt-optimizer 按需觸發提問優化 Skill

在 AI 動手前判斷提問是否值得改寫:對情緒發洩、確認指令與清晰單步修改靜默放行,僅將含糊請求在保留 100% 意圖的前提下翻譯為準確領域術語與可驗證標準,待確認後執行。

Tink1.0.02026年11月23日MIT原始碼儲存庫
取得 Skill

使用需求

  • 支援 Skill 的 AI 程式開發助手(Claude Code、Codex、Antigravity、Cursor、Pi 或 Grok)
  • 如需安裝可選的自動觸發 Hook / 擴充套件,需 Node.js 18 及以上版本

快速開始

1. 安裝 Skill

git clone https://github.com/TinkCarlos/prompt-optimizer.git
cd prompt-optimizer
for d in ~/.claude/skills ~/.codex/skills ~/.cursor/skills ~/.grok/skills \
         ~/.gemini/config/skills ~/.agents/skills; do
  [ -d "$d" ] && mkdir -p "$d/prompt-optimizer" && cp SKILL.md "$d/prompt-optimizer/"
done

安裝後即可手動觸發:/prompt-optimizer 幫我做個PPT介紹新產品(Pi 中為 /skill:prompt-optimizer ...)。

2. 可選自動觸發 Hook(需 Node.js 18+)

壓縮檔內 hooks/ 目錄自帶 Antigravity(prompt-optimizer-agy.js)、Claude Code 與 Codex(prompt-optimizer-hook.js)以及 Pi(pi install git:github.com/TinkCarlos/prompt-optimizer)的自動分流腳本,本機直接過濾 繼續、同意 等確認短語,零額外 Token 消耗。

核心機制

每次接到請求時,Skill 先在背景做一次 REWRITE / SKIP 分流:

  • 靜默跳過(SKIP):情緒抱怨、單步明確指令(如把 src/App.tsx 按鈕改成 #2563eb)、回覆確認(同意、繼續、你決定)以及對上一輪回覆的簡短回饋,直接執行不打擾。
  • 按需改寫(REWRITE):僅對目標含糊或缺少驗收標準的實質性任務,輸出一段 1–4 句的自然段提示詞加一行確認提示(同意 / 修改 / 按原話),全程沿用使用者的原始語言。

改寫原則

  1. 100% 保真:不竄改範圍、數字和約束;缺資料時明確留空或提示待補,不替產品編數據。
  2. 大白話轉專業術語但不過度發揮:把「等我停一下再搜」轉為輸入防抖(input debounce)並交代取消未觸發請求與 Network 面板驗收;把「像磨砂玻璃」轉為玻璃擬態(glassmorphism);遇到疑似記憶體洩漏或並發覆蓋只列排查路徑與樂觀鎖衝突拒絕標準,不臆斷未證實的根因。
  3. 外部可驗:所有交付要求指向一手程式碼、日誌、執行計畫或真實瀏覽器/樣本複測,不用「你是專家」等空話。

當前驗證邊界

如實說明:目前尚無端到端執行效果對比基準。儲存庫包含 Hook 路由、確認輪次識別、開關與長對話的自動化測試;首輪涵蓋中、英、日、西四語的 12 條無上下文黑盒測試全部達標(11 條按預期改寫,1 條明確 #2563eb 指令按預期靜默跳過)。

Skill 內部
SKILL.md
---
name: prompt-optimizer
description: >-
  Works in any language. Before acting on a user message, decide from the conversation context whether it is worth rewriting (REWRITE or SKIP). Venting, confirmations, single-step tweaks and already-clear messages are skipped silently. When a rewrite is worth it, translate layperson descriptions into accurate domain terms and restate the request as one short, high-signal prompt in the user's own language, preserving intent, scope and constraints 100%, and ask the user to confirm before executing. Use for automatic pre-routing, or when the user asks to "optimize my prompt", "polish this prompt" or runs /prompt-optimizer.
---

# Prompt Optimizer

First decide whether a rewrite is worth it. If it is, turn the user's words into one dense, ready-to-run prompt and wait for confirmation. Always write in the language the user wrote in.

## 1. Step one: decide REWRITE or SKIP from context

- **How to answer**
  - Called as a standalone router (asked for the verdict only): reply with exactly `REWRITE` or `SKIP`, nothing else.
  - Running inline before a normal reply: on **SKIP**, stay completely silent about it. Do not mention routing or rewriting, do not load the rest of this skill, just answer or act. On **REWRITE**, continue to section 2.
  - The user names this skill explicitly (`/prompt-optimizer <text>`, "optimize this prompt"): skip the decision and go to section 2.
包含檔案 · 10
prompt-optimizer/README.md
prompt-optimizer/README.zh-CN.md
prompt-optimizer/SKILL.md
prompt-optimizer/hooks/claude-settings.example.json
prompt-optimizer/hooks/codex-hooks.example.json
prompt-optimizer/hooks/hooks.json.example
prompt-optimizer/hooks/prompt-optimizer-agy.js
prompt-optimizer/hooks/prompt-optimizer-hook.js
…