← All templates

Web Development

Bug Investigation and Troubleshooting

Gather expected and actual behavior, environment details, and reproduction evidence for a coding agent.

EXAMPLE

From prompt to result

Sample prompt

Built from example inputs for Codex. Choose “Try an example” above to load these inputs and adjust them.

# Bug Investigation and Troubleshooting

Act as a debugging partner. Reproduce the ordinary workflow where possible, gather evidence before changing code, and narrow the cause by testing plausible hypotheses.

## Task details

**Actual and expected behavior**
> Saving a draft drops the last edited field. Expected: every field is saved, including the one that still has focus.

**Steps, environment, or logs**
> Chrome on macOS. Edit the title, then press Cmd+S without leaving the field.

**Requested scope**
> Diagnose and fix

## Expected output

Describe reproduction, root cause and evidence, the proposed or implemented fix, and regression checks with actual results.

## Quality checks

Do not treat correlation as root cause. Preserve unrelated changes, avoid logging secrets, and test the original failure path and adjacent normal behavior.

## Working in Codex

If repository access is available, inspect the relevant instructions, code, and tests first. Keep changes scoped and verify through normal entry points. Report actual checks and blockers.

Sample result

An illustrative answer written by xuvo. to show the format and depth to expect. It is not live AI output, and names, figures and sources are placeholders. Always review real AI output.

Reproduction

Confirmed in Chrome on macOS: edit the title, press Cmd+S without leaving the field, and the saved draft keeps the old title.

Root cause

The form state updates on blur, not on input. Cmd+S triggers save before the field blurs, so the last edit is not in state yet.
Evidence: logging state in saveDraft() shows the stale title. Tabbing out before saving works.

Fix

Update form state on input events in src/editor/useDraftForm.js, and keep blur for validation only.

Regression checks

CheckResult
Edit title, Cmd+S immediatelySaved correctly ✅
Edit body, click SaveSaved correctly ✅
Existing editor tests42 passed ✅

Added a test: "saves the focused field's latest value on shortcut save."

What you’ll get

Describe reproduction, root cause and evidence, the proposed or implemented fix, and regression checks with actual results.

Built-in quality checks

Do not treat correlation as root cause. Preserve unrelated changes, avoid logging secrets, and test the original failure path and adjacent normal behavior.

Works with

Codex, Claude Code, ChatGPT, Claude, Gemini, Universal / Other

See all