Codex: Fix a Bug From a Repro Recipe

OpenAI's Codex bug-fix prompt: describe the bug, give numbered repro steps and constraints, and have Codex reproduce it locally before proposing a patch and running checks.

  • 🤖 Codex
  • 🗂️ Coding

Last verified: write-up checked

Prompt by OpenAI · Original source (opens in a new tab)

Codex: Fix a Bug From a Repro Recipe — prompt preview

The prompt

prompt
Bug: Clicking "Save" on the settings screen sometimes shows "Saved" but doesn't persist the change.

Repro:
1) Start the app: npm run dev
2) Go to /settings
3) Toggle "Enable alerts"
4) Click Save
5) Refresh the page: the toggle resets

Constraints:
- Do not change the API shape.
- Keep the fix minimal and add a regression test if feasible.

Start by reproducing the bug locally, then propose a patch and run checks.

What it is

This is the CLI workflow for "Fix a bug" in OpenAI's prompting docs (the Codex section on learn.chatgpt.com). You start Codex at the repo root and give it a reproduction recipe plus the files you suspect. The prompt has three parts: the bug in one sentence, numbered repro steps, and constraints (don't change the API shape, keep the fix minimal, add a regression test if feasible). It ends by telling Codex to reproduce first, then patch and run checks.

Who it's for

  • Developers using the Codex CLI
  • Anyone with a bug they can reproduce locally

Requirements

Requirements

  • OpenAI Codex (CLI, IDE extension or cloud)

طلب OpenAI لإصلاح الأخطاء في Codex: صف الخطأ وأعطِ خطوات إعادة إنتاجه وقيوداً واضحة، ليعيد Codex إنتاجه محلياً قبل اقتراح التصحيح وتشغيل الفحوص.

Examples

From the source

Prompt
prompt
Bug: Clicking "Save" on the settings screen sometimes shows "Saved" but doesn't persist the change.

Repro:
1) Start the app: npm run dev
2) Go to /settings
3) Toggle "Enable alerts"
4) Click Save
5) Refresh the page: the toggle resets

Constraints:
- Do not change the API shape.
- Keep the fix minimal and add a regression test if feasible.

Start by reproducing the bug locally, then propose a patch and run checks.

Expected output: Exact prompt from OpenAI prompting docs.

Follow-up from the source: run checks

Prompt
prompt
After the fix, run lint + the smallest relevant test suite. Report the commands and results.

Expected output: Also from OpenAI prompting docs.

Pros & cons

Pros

  • Pro:Forces reproduction before patching, so the fix is verified
  • Pro:Constraints keep the patch minimal and add a regression test

Cons

  • Con:Only works for bugs you can reproduce locally

Tips

  • The source says your repro steps and constraints matter more than a high-level description
  • Codex should re-run the repro steps after the fix