Turn Bug Reports into Agent Reproduction Scripts and Fix Briefs

Generates a standalone reproduction script, expected assertion logs, and strict edit boundaries for coding agents like Claude Code or Cursor.

Agent prompt for Claude Code and Cursor

Prompt

Prompt
Act as a principal software engineer preparing an automated bug-fix task for an autonomous coding agent.

I will paste an error log, bug description, or failing stack trace below. If I have not provided enough detail, ask me up to 3 clarifying questions first.

Rules:
1. Provide a standalone reproduction script (bash script or single test runner command) that fails with the reported error and exits with code 1, and exits with 0 once fixed.
2. State the exact log output assertions: write the exact substring or regex that signals failure versus success.
3. Include a strict edit boundary: explicitly name the only allowed files to modify, and ban modifying configuration files, dependencies, or unrelated test files.
4. Provide a step-by-step fix hypothesis describing root cause and the expected logic change.

Output format:### 1. Standalone Reproduction Script
(Code block)

### 2. Log Assertions
- Failure assertion: (exact text)
- Success assertion: (exact text)

### 3. Strict Scope & Edit Boundaries
- Allowed files: (list)
- Forbidden files: (list)

### 4. Root Cause Hypothesis & Fix Checklist
- (Numbered steps)

End with one sentence noting risks or dependencies outside the reproduction sandbox.

Example output

From bug report to agent fix briefFour-part output for an orphaned session TTL bug
  1. Reproduction script1Run the Vitest refresh-token test against local Redis
  2. Log assertions2Expected -1 to be greater than 0 on failure, pass on success
  3. Edit boundaries3Two allowed files, package.json and redis.ts forbidden
  4. Fix checklist4Use KEEPTTL in rotateRefreshToken, then rerun the script

Example for: an orphaned session issue where Redis TTL is dropped during token refresh in a Node.js API.

1. Standalone Reproduction Script
#!/usr/bin/env bash
set -euo pipefail

# Run the isolated token rotation test against local test redis
npx vitest run tests/auth/refresh-token.test.ts --testNamePattern="preserves TTL on session key"
2. Log Assertions
  • Failure assertion: AssertionError: expected -1 to be greater than 0
  • Success assertion: ✓ tests/auth/refresh-token.test.ts > preserves TTL on session key (passed)
3. Strict Scope & Edit Boundaries
  • Allowed files:

    • src/services/auth/session-store.ts
    • tests/auth/refresh-token.test.ts
  • Forbidden files:

    • package.json
    • src/config/redis.ts
    • Any other test or configuration file outside the auth directory
4. Root Cause Hypothesis & Fix Checklist
  1. Locate the rotateRefreshToken function inside src/services/auth/session-store.ts.
  2. Check lines 42-48 where redis.set(key, sessionData) is executed without propagating the remaining TTL parameter.
  3. Update the call to use redis.set(key, sessionData, 'KEEPTTL') or fetch remaining TTL with redis.ttl(key) before updating.
  4. Run the reproduction script to confirm the Vitest assertion exits with code 0.

Assumes a local Redis test container is already running on port 6379 without password authentication.

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

Tips and common edits

Why this works

  • Eliminates hallucinated fixes by demanding a runnable repro that exits non-zero before the fix and zero after.
  • Prevents scope creep by strictly defining allowed files and banning edits to package manifests and configs.
  • Specifies exact assertion strings so agents can verify their own fixes without manual developer oversight.

Use before handing a bug to Claude Code, Cursor, or Codex. Paste your stack trace and repository structure directly after the prompt text.

Common edits

  • Switch the reproduction script from a Bash test runner command to a single Python unittest or pytest invocation.
  • Add a maximum retry count or token budget limit before the agent must revert and yield to human review.

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

Verify the Coding Agent's 'Done' Claim Against the Diff and Test Output

Checks each claim in a coding agent's final summary against the actual diff and test runs, marks it verified, unverified or contradicted with evidence, and lists unmentioned changes, skipped tests and stubs.

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

Audit AI Code Diffs for Performance Regressions

This prompt scans code changes for silent performance killers like N+1 queries, unindexed filters, and memory leaks before you merge them.

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.

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.