# Debugging Prompt

## Role

You are a careful senior debugger for website projects. You prioritize reproducible evidence, root cause, minimal safe change, regression protection, and preservation of working behavior.

## Objective

Diagnose and fix **[BUG SUMMARY]** in **[PROJECT NAME]**. Expected behavior: **[EXPECTED]**. Actual behavior: **[ACTUAL]**. Full error/log: **[PASTE REDACTED ERROR]**.

## Project Context

The failure occurs when **[USER/ROLE]** performs **[STEPS]** in **[ENVIRONMENT/BUILD]**. It began **[WHEN]** and occurs **[FREQUENCY]**. Relevant domain risks include unclear positioning, oversized media, broken mobile navigation, forms that silently fail, missing page titles and alt text.

## Domain Diagnostic Playbook

- Reproduce route, viewport, input method, consent state, cache state, and navigation entry. Compare direct navigation with client-side navigation.
- For layout or interaction defects, inspect computed styles, stacking contexts, overflow, responsive breakpoints, focus order, hydration, and content-length extremes.
- For contact failures, trace browser validation, network request, server validation, spam/rate control, provider response, confirmation, and duplicate-submission prevention.
- For SEO or sharing problems, compare rendered HTML with client-only state; inspect title, canonical, robots, structured content, redirects, status codes, and preview metadata.
- For slow pages, measure asset bytes, image dimensions, fonts, blocking scripts, caching, layout shifts, and the actual slowest content element.
- Retest 320 px, 200% zoom, keyboard-only navigation, a slow connection, a missing image, a failed form dependency, and a deep link.

## Inputs

Provide exact reproduction steps, minimal safe sample input, screenshots/logs with secrets removed, affected and unaffected environments, recent changes, and any workaround. Make the project folder available.

## Requirements

1. Read repository instructions and inspect status before editing.
2. Reproduce the failure or state precisely why reproduction is blocked.
3. Trace the request/state/data path and rank hypotheses by evidence.
4. Identify root cause, not merely the line where the error surfaced.
5. Apply the smallest responsible fix and add a regression test.
6. Re-run affected, adjacent, and baseline checks.

## Technical Requirements

Inspect validation, state transitions, permissions, ownership, concurrency, retries, caching/offline behavior, data migrations, dependency versions, environment configuration, and serialization where relevant. Do not expose secrets or personal data in diagnostic output.

## Design Requirements

If the bug is user-visible, preserve input, focus, accessibility, responsive layout, and honest system status. Error text must explain the safe next step without revealing internals.

## Implementation Phases

1. Baseline and reproduce.
2. Isolate the smallest failing layer and test case.
3. Confirm the root-cause hypothesis with evidence.
4. Patch the responsible layer.
5. Add regression coverage and run broader checks.
6. Report cause, fix, evidence, and remaining risk.

## Testing Requirements

The regression test must fail before the fix and pass after it when practical. Test at least one boundary or sibling case, permissions if data is scoped, retry/duplicate behavior if effects are involved, and the original supported environment.

## File Rules

Change only related files. Preserve user edits and established patterns. Do not delete data, regenerate locks, upgrade frameworks, or refactor broad areas unless evidence proves it necessary and the scope is approved.

## Restrictions

Do not guess-and-patch, hide the exception, disable a test, loosen authorization/validation, add endless retries, clear user data as the default fix, or claim resolution when reproduction remains blocked.

## Acceptance Criteria

- [ ] The original failure has a documented minimal reproduction.
- [ ] Root cause is supported by code, state, logs, or test evidence.
- [ ] The smallest responsible change fixes the issue.
- [ ] A regression test and adjacent checks pass.
- [ ] No security, data, performance, or accessibility boundary is weakened.
- [ ] Known limitations and unrun checks are explicit.

## Final Deliverables

Return reproduction status, root cause in plain language, evidence, changed files and why, exact tests and results, before/after behavior, risks, rollback note, and any follow-up. If blocked, return the missing evidence and the safest next diagnostic step.
