Generate Reproducible Bug Fix Specs for Coding Agents

Get a standalone reproduction test script and a precise technical plan to fix a bug, ensuring your AI agent stays focused and avoids unnecessary file changes.

Agent prompt for Claude Code and Cursor

Prompt

Prompt
Act as a Senior Software Engineer. I will provide a bug description. Your job is to create a reproduction script and a fix brief for an AI coding agent. Follow these rules: 1. Write a standalone bash script that reproduces the bug using only local file operations or standard library assertions. 2. Define the exact error message or state change that confirms the bug is fixed. 3. List only the specific files the agent is permitted to modify; explicitly forbid touching any other files. 4. Do not include conversational filler; provide only the script and the plan. Output format: # Reproduction Script: [Code block] # Expected Assertion: [One sentence] # Fix Brief: 1. Goal 2. Files to modify 3. Verification steps. This tool does not replace manual code review; always verify changes in a sandbox environment before merging.

Example output

From bug report to fix briefExample: server failing on empty JSON payloads
  1. Reproduction scriptStep 1POST empty JSON; exit 1 if server returns 500
  2. Expected assertionStep 2Exit code 0 and a 400 Bad Request status
  3. Fix briefStep 3Add empty-body check in app/controllers/api_controller.py
  4. VerificationStep 4Rerun script, then existing unit tests for regressions

Example for: a Python web server failing to handle empty JSON payloads. # Reproduction Script: python import requests, sys response = requests.post('http://localhost:8000/api', json=None) if response.status_code == 500: print('Bug reproduced: Received 500 on empty JSON') sys.exit(1) print('Bug not found') sys.exit(0) # Expected Assertion: The script must exit with code 0 and receive a 400 Bad Request status code. # Fix Brief: 1. Goal: Implement a check for empty request bodies in the API controller. 2. Files to modify: app/controllers/api_controller.py. Do not modify any files in the /config or /tests directories. 3. Verification steps: Run the reproduction script to confirm it now exits with code 0, then run existing unit tests to ensure no regressions in valid payload handling.

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Forces the agent to create an objective, binary pass-fail test case.
  • Explicitly restricts file scope to prevent accidental collateral damage.
  • Separates the verification logic from the implementation plan for clarity.

Use this prompt when you have a specific bug report or stack trace. Paste the bug details immediately after the prompt. This works effectively in Claude Code, Cursor, and GitHub Copilot to prevent agents from wandering into unrelated parts of your codebase.

Common edits

  • Add a constraint to use a specific testing framework like Pytest or Jest.
  • Include a requirement to add a permanent regression test to the repository.

Reuse it: Use in a workflowAdapt in the builder

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

AI Coding AgentsClaude Code

Create Automated Verification Loops for Long-Running Coding Agents

Generate a deterministic shell pipeline that combines linting, isolated unit testing, and diff-budget monitoring to validate AI agent code changes.

AI Coding AgentsClaude Code

Design a Sandbox Security Policy for Autonomous Coding Agents

Generate a rigorous security policy for autonomous agents to define allowed shell commands, file access boundaries, and network restrictions.

AI Coding AgentsClaude Code

Root-Cause Bug Fix With a Failing Test and a Minimal Patch

Get a reproduced bug, a regression test that fails before the fix and passes after it, the smallest patch and a log of the commands Claude Code actually ran.

AI Coding AgentsClaude Code

Claude Code Repo Recon and Implementation Plan for a New Feature

Has Claude Code inspect a repository read-only and produce an evidence-based implementation plan with file-level changes, tests, risks, and open questions. Use it to decide whether to start, split, or clarify a feature before any code is written.

AI Coding AgentsClaude Code

Systematic Debugging: Agent Skill (SKILL.md) for Claude Code, Codex and Cursor

Hunts down bugs whose cause isn't obvious: flaky or intermittent failures, 'works locally but fails in CI', regressions nobody can place, or a fix that didn't stick.

AI Coding AgentsClaude Code

Convert User Stories into Strict Acceptance Test Assertions

This prompt transforms vague business requirements into precise Given-When-Then test assertions with exact HTTP status codes and JSON payload structures for AI coding agents.