← All templates

Web Development

Code Review and Refactoring

Ask a coding agent to inspect a change, identify actionable regressions, and optionally refactor within a defined boundary.

EXAMPLE

From prompt to result

Sample prompt

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

# Code Review and Refactoring

Act as a senior code reviewer. Read the change and nearby callers, trace normal and failure paths, and focus on correctness, security, and maintainability.

## Task details

**Code or review scope**
> The pull request that adds retry logic to the payment webhook handler in src/webhooks/payments.ts

**Review mode**
> Findings only

**Behavior to preserve**
> Webhook responses must stay idempotent

## Expected output

Report actionable findings with severity, affected location, impact, and a focused fix. If fixing is requested, summarize changes, checks, and verification gaps.

## Quality checks

Tie findings to evidence. Prioritize regressions introduced by the change. Verify compatibility, partial failure, and concurrency where relevant. Keep edits within the agreed scope.

## Working in Claude Code

If a working project is available, read its instructions and nearby code first. Make focused changes, follow existing conventions, and run relevant checks. State any verification gaps.

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.

Findings

1. High: retries can double-process a payment event
src/webhooks/payments.ts:48. The retry wraps the whole handler, including markInvoicePaid(). If the database write succeeds but the response times out, the retry runs it again.
Fix: check the event ID against a processed-events table before side effects, and retry only the network call.

2. Medium: no backoff limit
retryWithBackoff has no maximum attempts. A permanently failing event retries forever.
Fix: cap at 5 attempts and send failures to a dead-letter queue.

3. Low: error message drops the cause
throw new Error('Webhook failed') loses the original error. Pass {cause}.

Preserved behavior

Responses stay idempotent once Finding 1 is fixed.

Verification gaps

No test covers a timeout after a successful write. Add one before merging.

What you’ll get

Report actionable findings with severity, affected location, impact, and a focused fix. If fixing is requested, summarize changes, checks, and verification gaps.

Built-in quality checks

Tie findings to evidence. Prioritize regressions introduced by the change. Verify compatibility, partial failure, and concurrency where relevant. Keep edits within the agreed scope.

Works with

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

See all