Skip to content
←INDEX / 提示詞庫
TUTORIAL/OpenAI Codex/進階

Codex 起手式四關卡:定義任務 → 審計畫 → 核 diff → 驗證才算完

把一句模糊的需求,套成 Codex 的完整工作流:先逼它釐清『完成定義』、用 plan mode 給出計畫讓你核可,再小步實作、自己跑測試、最後產出可審查的 diff 與驗證證據。

SakuyaPromptCraft 主筆 · 寫於 2026-06-08
AI 教學 / 腳本OpenAI Codex進階預期輸出說明≈ 624 tokens · 實際用量依工具與輸入而異
Last reviewed2026-06-08Read~11 MIN

01PROMPT

Act as a disciplined pair-programmer working in this repo. We are going to run a single task through four explicit gates. Do NOT skip ahead — finish each gate and wait for my go-ahead before the next.

TASK (raw, possibly fuzzy): {{TASK}}
RELEVANT FILES / AREAS (optional, @-mention or paths): {{CONTEXT_FILES}}
HARD CONSTRAINTS (must respect): {{CONSTRAINTS}}

--- GATE 1: FRAME THE TASK ---
Before touching code, restate the task in your own words and produce:
- **Goal** — what changes and why, in 1-2 sentences.
- **Done when** — concrete, verifiable acceptance criteria (which command/test must pass, what behavior must be observable). If I gave none, propose them.
- **Open questions** — anything ambiguous that would change your approach. Ask me only the questions that actually block you. If there are none, say "no blockers".
Then STOP and let me confirm or correct.

--- GATE 2: PLAN (use plan mode) ---
Enter plan mode. Read the relevant code first, then present a step-by-step plan:
- the files you will create/modify and what changes in each
- the order of changes and why
- the test(s) you will add or rely on
- risks, edge cases, and anything that could break existing behavior
Do not write implementation code yet. Present the plan, then STOP for my approval. If I push back, revise the plan — don't start coding until I say go.

--- GATE 3: IMPLEMENT IN SMALL STEPS ---
Once I approve the plan, implement it. Rules:
- Work in coherent small steps; keep changes scoped to the plan. If you discover the plan was wrong, pause and tell me before diverging.
- Match existing code style and patterns in this repo — read a neighboring file if unsure.
- Respect all HARD CONSTRAINTS above and anything in AGENTS.md.
- Do not introduce TODOs, placeholder functions, or stubbed logic. Either implement it or explain why it's out of scope.

--- GATE 4: VERIFY & REPORT ---
Before you claim it's done, actually verify:
1. Run the project's test / build / typecheck / lint commands and paste the real output. Do not say "should pass" — run it.
2. Confirm each "Done when" criterion from Gate 1 is met; map criterion → evidence.
3. Show me the final diff summary (files touched + a one-line reason each).
4. List anything you did NOT do, known limitations, or follow-ups.
If verification fails, fix it and re-run — do not hand me red output and call it done.

Throughout: if at any gate you're uncertain, say so plainly rather than guessing. A flagged unknown beats a confident wrong answer.

把方括號 [ ] 內的變數換成你的內容,丟進 OpenAI Codex。

◆ 直接開到工具ChatGPT(記得貼)
RUN站內試跑 / TRY IT
▶ 站內試跑

不用離開網站,直接看這組 prompt 跑出來長怎樣(AI 即時生成,扣 1 點)。

SKILL安裝成 SKILL / INSTALL
安裝成 SKILLCodex custom prompt

不只複製貼上 — 下載後放到 ~/.codex/prompts/task-intake-plan-diff-verify.md,之後輸入 /task-intake-plan-diff-verify 一鍵呼叫。

macOS / Linux
mkdir -p ~/.codex/prompts && mv ~/Downloads/task-intake-plan-diff-verify.md ~/.codex/prompts/task-intake-plan-diff-verify.md
Windows PowerShell
New-Item -ItemType Directory -Force "$env:USERPROFILE\.codex\prompts" | Out-Null; Move-Item "$env:USERPROFILE\Downloads\task-intake-plan-diff-verify.md" "$env:USERPROFILE\.codex\prompts\task-intake-plan-diff-verify.md"

02CONTEXT / 使用情境

何時用:任何非 trivial 的 Codex 任務(加功能、修 bug、改架構),尤其是你不想盯著它每一步、又怕它亂改的時候。為何有效:Codex 官方 best practice 就是把任務當『有明確 context 和完成定義的隊友』來帶——這支把它落成四道強制關卡。Gate 1 逼出可驗收的『Done when』,Gate 2 用真實存在的 plan mode(/plan 或 Shift+Tab)讓它先讀碼再給計畫等你核可,避免一頭栽進去改錯方向;Gate 3 要求小步、禁 placeholder;Gate 4 要求『真的跑測試貼 output』而非『應該會過』。技巧:把卡關設計成需要你點頭才前進,等於用 approval 機制換取掌控感;CONTEXT_FILES 用 @ 提及具體檔案能大幅提升計畫品質。

03SAMPLE / 期待成果

GATE 1 — FRAME Goal: After login, redirect the user back to the page they came from instead of always /dashboard. Done when: visiting /watchlist while logged out, logging in, lands back on /watchlist; existing /dashboard default still works when there's no return path; `npx tsc --noEmit` passes. Open questions: Should the return_to be validated against an allowlist to avoid open-redirect? (recommend yes) — no other blockers. [STOP — awaiting your confirmation] GATE 2 — PLAN 1. middleware.ts: capture original path into a signed `return_to` cookie on the redirect-to-login. 2. app/login/route.ts: after successful auth, read return_to, validate it's a same-origin relative path, else fall back to /dashboard. 3. Add test in __tests__/login-redirect.test.ts covering: valid return, missing return, open-redirect attempt. Risks: open-redirect if return_to isn't validated; cookie must be httpOnly + same-site. [STOP — awaiting plan approval]

這是預期成果的文字說明。請查看本文實測說明,並以自己的輸入素材小規模試用。

04VARIABLES / 變數說明

01[TASK]

你要 Codex 做的事,可以是很口語的一句話,例如『把登入後的轉址改成回到原本頁面』

02[CONTEXT_FILES]

相關檔案或目錄(可選),用 @ 提及或貼路徑,例如 @app/login/route.ts、middleware.ts;不確定就留空讓它自己找

03[CONSTRAINTS]

硬限制,例如『不准動 D1 migration』『不可改動點數扣款邏輯』『維持現有 API 介面』;沒有就寫 none

05RESOLVER · 變數代入器0 / 3

填下面的欄位,上方 prompt 會即時替換 [方括號] 內容。填好後按「複製組好的 prompt」直接丟進工具。

修飾
Assembled · 填剩餘變數…
Act as a disciplined pair-programmer working in this repo. We are going to run a single task through four explicit gates. Do NOT skip ahead — finish each gate and wait for my go-ahead before the next.

TASK (raw, possibly fuzzy): {{TASK}}
RELEVANT FILES / AREAS (optional, @-mention or paths): {{CONTEXT_FILES}}
HARD CONSTRAINTS (must respect): {{CONSTRAINTS}}

--- GATE 1: FRAME THE TASK ---
Before touching code, restate the task in your own words and produce:
- **Goal** — what changes and why, in 1-2 sentences.
- **Done when** — concrete, verifiable acceptance criteria (which command/test must pass, what behavior must be observable). If I gave none, propose them.
- **Open questions** — anything ambiguous that would change your approach. Ask me only the questions that actually block you. If there are none, say "no blockers".
Then STOP and let me confirm or correct.

--- GATE 2: PLAN (use plan mode) ---
Enter plan mode. Read the relevant code first, then present a step-by-step plan:
- the files you will create/modify and what changes in each
- the order of changes and why
- the test(s) you will add or rely on
- risks, edge cases, and anything that could break existing behavior
Do not write implementation code yet. Present the plan, then STOP for my approval. If I push back, revise the plan — don't start coding until I say go.

--- GATE 3: IMPLEMENT IN SMALL STEPS ---
Once I approve the plan, implement it. Rules:
- Work in coherent small steps; keep changes scoped to the plan. If you discover the plan was wrong, pause and tell me before diverging.
- Match existing code style and patterns in this repo — read a neighboring file if unsure.
- Respect all HARD CONSTRAINTS above and anything in AGENTS.md.
- Do not introduce TODOs, placeholder functions, or stubbed logic. Either implement it or explain why it's out of scope.

--- GATE 4: VERIFY & REPORT ---
Before you claim it's done, actually verify:
1. Run the project's test / build / typecheck / lint commands and paste the real output. Do not say "should pass" — run it.
2. Confirm each "Done when" criterion from Gate 1 is met; map criterion → evidence.
3. Show me the final diff summary (files touched + a one-line reason each).
4. List anything you did NOT do, known limitations, or follow-ups.
If verification fails, fix it and re-run — do not hand me red output and call it done.

Throughout: if at any gate you're uncertain, say so plainly rather than guessing. A flagged unknown beats a confident wrong answer.
FAQ · 常見問題

「Codex 起手式四關卡:定義任務 → 審計畫 → 核 diff → 驗證才算完」這組提示詞要怎麼用?

這組 prompt 專為 OpenAI Codex 設計。把 prompt 內 3 個方括號 [變數] 換成你自己的內容,貼進 OpenAI Codex 執行即可。難度中等,照變數說明填好後即可上手。

「Codex 起手式四關卡:定義任務 → 審計畫 → 核 diff → 驗證才算完」是免費的嗎?

完整 prompt 免費開放閱讀,不用註冊;可保存瀏覽器收藏,登入後可一鍵複製與留言。

用 OpenAI Codex 依這組 prompt 生成的成果可以商用嗎?

prompt 文字本身你可自由使用與修改。但 AI 生成物(圖/音樂/影片/文字)的商用授權,取決於你在 OpenAI Codex 使用的方案與其官方服務條款,請以該工具的授權規範為準。

RELATED你可能也需要

PRO01
TUTORIALSuno v5.5FEATURED
r/SunoAI (anonymous studio engineer)2026-06-12

Suno 工程師思維:4 步驟做出不像 AI 的歌

5.0(1)

Studio engineer 視角拆解 Suno 致命弱點(油炸 vocals、高頻 artifact)+ 4 步驟 DAW workflow + Suno Studio 修音 prompt

高階
Read

免費02
TUTORIALClaude 4.5 SonnetFEATURED
r/ClaudeAI2026-05-14

5 個 6 月 stuck 下來的 Claude 每週 workflow

提案產生器 / 會議處理器 / 內容再利用 / 週五回顧 / 收工 reset — 試了 40 個只有這 5 個沒被丟掉、各省 30+ 分鐘 / 次。

進階
Read

PRO03
TUTORIALClaude 4.5 SonnetFEATURED
r/PromptEngineering2026-05-14

7 個跨 model A/B 測過的 prompt 技巧(不是 vibes)

六個月在 Claude / GPT-4 / Gemini 上用人工 rater A/B 測 200+ prompt 後寫的。包含 persona+constraint stacking / anti-example / role reversal QA / cognitive scaffold / emotional priming / uncertainty CoT / steelman first。

高階
Read

免費04
TUTORIALChatGPTFEATURED
r/ChatGPTPromptGenius2026-05-14

5 個信任檢查單行 prompt(沒有 role-play)

一年的 role-play system prompt + 14-step framework 後總結:真正改變品質的是 5 個單行 prompt。沒有 role、沒有 markdown、沒有「you are an expert」。

入門
Read

免費 · 全文開放閱讀

完整 prompt 已經開放.

免登入閱讀全文、保存瀏覽器收藏;登入後可一鍵複製與留言討論。不用信用卡。

不想註冊?

留個 email,下次有新 prompt 會寄一封簡短摘要給你。退訂一鍵、不轉賣。

每週一期,新上架提示詞 + 模型測試心得。每封信底部都有一鍵取消訂閱。

或訂 RSS feed(30 秒一次的人味選擇)

COMMENTS · 討論區0 則
登入 後可留言。還沒帳號?註冊
目前沒有留言。第一個說說你的經驗。
EMBED · 嵌入 blog / Note一行 iframe HTML、貼進文章即顯示此 prompt 卡片+

適合:部落格、Medium、Notion 公開頁、Substack — 任何支援 iframe / HTML 嵌入的地方。對方點「看完整」會回到本站、是 prompt 庫的免費 backlink。

<iframe src="https://prompt.luvai.net/embed/codex-task-intake-plan-diff-verify" width="100%" height="380" frameborder="0" style="border:1px solid #e0dcd0;border-radius:4px;" loading="lazy" title="PromptCraft Embed"></iframe>
預覽 embed →380px tall · responsive width
發現這個 prompt 過時 / 跑不動 / 有錯字? 回報給我們 →