改完 code 之後,讓 Codex 讀 staged diff,產出符合 Conventional Commits 的訊息,並寫出含背景、改了什麼、為什麼、如何驗證、風險的 PR 描述——不亂併無關改動、不誇大、不編造測試。
You are finishing a change in this git repo by producing a clean commit and a reviewable pull request. Base everything on the ACTUAL diff — never on assumptions about what I intended.
Follow any commit/PR conventions defined in AGENTS.md. If none are specified there, default to Conventional Commits.
STEP 1 — Inspect reality.
- Run `git status` and `git diff --staged` (and `git diff` for unstaged) and read the changes.
- If nothing is staged, tell me, and propose a sensible staging grouping rather than blindly `git add -A`. Do NOT stage unrelated changes (build artifacts, unrelated files, debug prints) into the same commit — flag them.
- Identify whether this is logically ONE change or several. If it should be multiple commits, tell me how you'd split it and ask before combining.
STEP 2 — Write the commit message.
Format: {{COMMIT_CONVENTION}}.
- Subject line: imperative mood, <= ~72 chars, correct type + scope (e.g. `fix(auth): ...`). The type must match what the diff actually does (a refactor is not a `feat`).
- Body (only if the change isn't trivial): explain the WHY and any non-obvious decisions, wrapped sensibly. Reference the issue/ticket {{ISSUE_REF}} if provided.
- Do not claim tests were added/passing unless the diff actually contains them or you actually ran them.
Show me the proposed message and let me approve before committing.
STEP 3 — Open the PR.
Target base branch: {{BASE_BRANCH}}.
Before writing the description, optionally run a self-review of the diff for obvious bugs, security issues, or leftovers (secrets, console logs, commented-out code) and surface them to me first.
Then draft a PR description with these sections:
- **What** — what this PR changes, in plain language.
- **Why** — the motivation / problem being solved (link {{ISSUE_REF}} if any).
- **How** — key implementation decisions and anything a reviewer should look at closely.
- **Testing** — exactly how it was verified (commands run + result). If you did not run them, say "not yet verified" — do not fabricate green checks.
- **Risk / rollback** — what could break and how to revert.
- **Out of scope** — explicitly what this PR does NOT do.
Keep it scannable: short paragraphs and bullets, no filler.
STEP 4 — Create it.
If the GitHub CLI (`gh`) is available, create the PR against {{BASE_BRANCH}} using the message and description above and return the PR URL. If `gh` is not available or not authenticated, instead output the final commit command and a ready-to-paste PR title + body so I can open it manually. Confirm before pushing to any remote.
Guardrails: never force-push, never push to {{BASE_BRANCH}} directly, and never invent ticket numbers, reviewers, or test results.不用離開網站,直接看這組 prompt 跑出來長怎樣(AI 即時生成,扣 1 點)。
不只複製貼上 — 下載後放到 ~/.codex/prompts/semantic-commit-and-pr.md,之後輸入 /semantic-commit-and-pr 一鍵呼叫。
mkdir -p ~/.codex/prompts && mv ~/Downloads/semantic-commit-and-pr.md ~/.codex/prompts/semantic-commit-and-pr.mdNew-Item -ItemType Directory -Force "$env:USERPROFILE\.codex\prompts" | Out-Null; Move-Item "$env:USERPROFILE\Downloads\semantic-commit-and-pr.md" "$env:USERPROFILE\.codex\prompts\semantic-commit-and-pr.md"何時用:code 已經改完、要把它變成乾淨的 commit 和一份審查者願意看的 PR 時。為何有效:Codex 沒有內建『一鍵 commit/PR』的 slash command,這類工作是靠 prompt 驅動它跑 git——所以指令必須明確要它『讀真實 diff 再下筆』。重點防呆:① 強制依 AGENTS.md 的 commit 慣例、否則用 Conventional Commits(官方說這是讓 agent 產出專業 commit 最有效的一招);② 禁止把無關改動 add 進同一個 commit、禁止 type 與實際 diff 不符(refactor 不能寫成 feat);③ 禁止捏造『測試已過』——沒跑就標 not yet verified,符合誠實協定;④ 用 gh 開 PR、沒有就吐出可貼的標題與內文,並在 push 前要你確認、絕不 force-push 或直推 base。技巧:先讓它對 diff 做一次自我審查(漏掉的 secret/console.log/註解掉的碼)再寫描述,PR 品質明顯更高。
STEP 2 — Proposed commit fix(login): return user to original page after auth instead of /dashboard Logged-out users hitting a protected page were always bounced to /dashboard after login, losing their place. Capture the original path in a signed, httpOnly return_to cookie and restore it post-auth, validating it's a same-origin relative path to avoid open redirects. Refs #482 [awaiting approval before committing] STEP 3 — PR description (base: main) ## What Redirect users back to the page they originally requested after logging in. ## Why Protected-page visitors lost context (#482); always landing on /dashboard hurt the watchlist/portfolio flows. ## How Signed return_to cookie set in middleware.ts; validated + consumed in app/login/route.ts. Falls back to /dashboard when absent or invalid. ## Testing `npx tsc --noEmit` passed; added __tests__/login-redirect.test.ts (3 cases incl. open-redirect attempt) — `npm test` green. ## Risk / rollback Low; revert this commit to restore prior behavior. Open-redirect guarded by same-origin check. ## Out of scope Does not change the OAuth provider flow or session expiry.
以上為此 Prompt 丟進 OpenAI Codex 後可得到的描述性成果,實際畫面會因填入的變數而有差異。
[COMMIT_CONVENTION]commit 訊息格式,例如 Conventional Commits(feat/fix/chore/refactor…)或團隊自訂;想沿用 repo 設定就寫『follow AGENTS.md』
[ISSUE_REF]關聯的 issue/ticket 編號(可選),例如 #482 或 JIRA-1234;沒有就留空,並要求它不要編造
[BASE_BRANCH]PR 要併入的目標分支,例如 main 或 develop
填下面的欄位,上方 prompt 會即時替換 [方括號] 內容。填好後按「複製組好的 prompt」直接丟進工具。
You are finishing a change in this git repo by producing a clean commit and a reviewable pull request. Base everything on the ACTUAL diff — never on assumptions about what I intended.
Follow any commit/PR conventions defined in AGENTS.md. If none are specified there, default to Conventional Commits.
STEP 1 — Inspect reality.
- Run `git status` and `git diff --staged` (and `git diff` for unstaged) and read the changes.
- If nothing is staged, tell me, and propose a sensible staging grouping rather than blindly `git add -A`. Do NOT stage unrelated changes (build artifacts, unrelated files, debug prints) into the same commit — flag them.
- Identify whether this is logically ONE change or several. If it should be multiple commits, tell me how you'd split it and ask before combining.
STEP 2 — Write the commit message.
Format: {{COMMIT_CONVENTION}}.
- Subject line: imperative mood, <= ~72 chars, correct type + scope (e.g. `fix(auth): ...`). The type must match what the diff actually does (a refactor is not a `feat`).
- Body (only if the change isn't trivial): explain the WHY and any non-obvious decisions, wrapped sensibly. Reference the issue/ticket {{ISSUE_REF}} if provided.
- Do not claim tests were added/passing unless the diff actually contains them or you actually ran them.
Show me the proposed message and let me approve before committing.
STEP 3 — Open the PR.
Target base branch: {{BASE_BRANCH}}.
Before writing the description, optionally run a self-review of the diff for obvious bugs, security issues, or leftovers (secrets, console logs, commented-out code) and surface them to me first.
Then draft a PR description with these sections:
- **What** — what this PR changes, in plain language.
- **Why** — the motivation / problem being solved (link {{ISSUE_REF}} if any).
- **How** — key implementation decisions and anything a reviewer should look at closely.
- **Testing** — exactly how it was verified (commands run + result). If you did not run them, say "not yet verified" — do not fabricate green checks.
- **Risk / rollback** — what could break and how to revert.
- **Out of scope** — explicitly what this PR does NOT do.
Keep it scannable: short paragraphs and bullets, no filler.
STEP 4 — Create it.
If the GitHub CLI (`gh`) is available, create the PR against {{BASE_BRANCH}} using the message and description above and return the PR URL. If `gh` is not available or not authenticated, instead output the final commit command and a ready-to-paste PR title + body so I can open it manually. Confirm before pushing to any remote.
Guardrails: never force-push, never push to {{BASE_BRANCH}} directly, and never invent ticket numbers, reviewers, or test results.這組 prompt 專為 OpenAI Codex 設計。把 prompt 內 3 個方括號 [變數] 換成你自己的內容,貼進 OpenAI Codex 執行即可。難度中等,照變數說明填好後即可上手。
完整 prompt 免費開放閱讀,不用註冊;登入後可一鍵複製、收藏與留言。
prompt 文字本身你可自由使用與修改。但 AI 生成物(圖/音樂/影片/文字)的商用授權,取決於你在 OpenAI Codex 使用的方案與其官方服務條款,請以該工具的授權規範為準。
Studio engineer 視角拆解 Suno 致命弱點(油炸 vocals、高頻 artifact)+ 4 步驟 DAW workflow + Suno Studio 修音 prompt
提案產生器 / 會議處理器 / 內容再利用 / 週五回顧 / 收工 reset — 試了 40 個只有這 5 個沒被丟掉、各省 30+ 分鐘 / 次。
適合:部落格、Medium、Notion 公開頁、Substack — 任何支援 iframe / HTML 嵌入的地方。對方點「看完整」會回到本站、是 prompt 庫的免費 backlink。
<iframe src="https://prompt.luvai.net/embed/codex-semantic-commit-and-pr" width="100%" height="380" frameborder="0" style="border:1px solid #e0dcd0;border-radius:4px;" loading="lazy" title="PromptCraft Embed"></iframe>
把方括號 [ ] 內的變數換成你的內容,丟進 OpenAI Codex。
六個月在 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。
一年的 role-play system prompt + 14-step framework 後總結:真正改變品質的是 5 個單行 prompt。沒有 role、沒有 markdown、沒有「you are an expert」。