description:Use when Codex needs to diagnose and fix a web-application defect whose root cause is not yet known, especially across React/frontend behavior, browser console/network requests, Flask/backend routes, authentication/authorization, relational data, migrations, Docker/reverse-proxy/runtime configuration, tests, or logs; when the goal is to reproduce the failure, gather evidence, isolate the smallest root cause, implement a minimal fix, add regression coverage, validate the result, and avoid speculative or unrelated changes.
---
# Webapp Debug
Version: **2.0**.
Diagnose before changing code. Reproduce the reported failure, trace it through the application's actual architecture, identify evidence-backed root cause, make the smallest coherent fix, prove the regression where practical, and stop.
This skill is designed to compose with `bortstack-context`. The context skill owns project/task/decision/handoff semantics; this skill owns the debugging workflow. If diagnosis shows the request is actually a new feature or broad refactor rather than a defect, stop and switch workflows instead of stretching debugging into unrelated implementation.
## Repository workflow
In a BortStack project, use `bortstack-context` with the applicable repository `AGENTS.md` before task work. They govern scope and authorisation, branch/worktree policy, lifecycle, manual acceptance, and handoff. Find the maintained overview, current state, decisions, task and handoff records through repository instructions and layout. Use the paths and task IDs the project already uses. Follow context's canonical discussion, mission and lifecycle guidance when interpreting authority or changing task status. If a required BortStack skill is unavailable, report the dependency. If an installed skill lacks a required reference, use the reference from a verified Forge package with a matching manifest. If the required guidance is unavailable, pause the affected action.
For edits, inspect Git status and worktrees, confirm authorised scope and the source candidate, and follow the current branch policy. Use direct integration-branch work where authorised and a dedicated branch/worktree where required. Preserve unrelated work. Read-only specialist work does not require a new worktree. When acting as an authorised contributor, use `bortstack-contributor` for contributor permissions, finalisation and submission. For ordinary specialist work, use the project's normal authority.
When manual testing is relevant, discover the documented commands, configuration and hooks in the target repository. Use its supported workflow, including an existing `testtask` wrapper and its project-specific config or hook where documented. Preserve a working adapter and its supported invocation. Before use, inspect its supported arguments, candidate handling, runtime and cleanup behavior. If no adapter is required, use the established development environment. Record candidate identity, actual checks, limitations and pending human acceptance in the project's handoff. Refresh stale candidates after edits and make fixes in the authoritative source. A source snapshot, wrapper, automated check or startup alone does not establish a manual pass. Follow context and repository rules for task transitions and closure.
Outside BortStack, follow the repository's own scope, branch, test and reporting conventions and proceed with the specialist workflow. BortStack skills and records are optional there.
## Core rules
1.**Read repository instructions and context first.** Obey root/nested `AGENTS.md`, current-state/task/decision rules, and repository-specific validation requirements.
2.**Reproduce before fixing whenever practical.** A symptom report is a lead, not proof of root cause. Establish the failing behavior or the strongest available evidence before editing.
3.**Separate symptom, hypothesis, evidence, and conclusion.** Do not present a guess as a diagnosis.
4.**Trace the actual request/data path.** For web apps this commonly means browser/UI → client state/API call → proxy/network → Flask route/auth/validation → domain/data layer → database/external dependency → response → frontend rendering.
5.**Change the smallest layer that is actually wrong.** Do not paper over a backend defect in the frontend, weaken authorization to make a request work, or add retries/timeouts without evidence they address the cause.
6.**Preserve unrelated behavior.** Avoid cleanup, redesign, dependency churn, renames, architecture migration, or opportunistic fixes while debugging one defect.
7.**Prefer instrumentation and existing observability over speculation.** Use tests, logs, console output, network responses, stack traces, database state, configuration, and neighboring code patterns.
8.**Do not destroy evidence.** Avoid clearing databases/logs/caches, resetting branches, deleting state, regenerating migrations, or restarting/redeploying production systems merely to get a clean slate unless explicitly authorized and safe.
9.**Treat production/external systems conservatively.** Read-only inspection may be appropriate when authorized; mutation, deployment, credential changes, DNS changes, destructive SQL, or service restarts require explicit authority or an existing approved operational workflow.
10.**Add regression coverage when practical.** A bug fix should normally gain a targeted test that fails before the fix and passes after it, or an equivalent reproducible validation when automated coverage is not feasible.
11.**Validate both the fix and its blast radius.** Run targeted checks first, then the relevant broader repository checks. Never claim a check passed if it was not run.
12.**Update durable context after an evidence-backed fix.** Use the repository workflow for task, current state, decisions and handoff updates.
13.**Do not commit, push, switch branches, deploy, provision infrastructure, or start another task unless explicitly requested.**
14.**Stop when the reported defect is resolved or when evidence is insufficient.** Do not turn debugging into general code improvement.
## Establish the debugging contract
Before editing, identify:
- the reported symptom and expected behavior;
- affected user/workflow/environment;
- reproducible steps or triggering conditions;
- whether the issue is deterministic, intermittent, environment-specific, data-specific, or concurrency-sensitive;
- relevant recent changes when repository evidence makes them available;
- the accepted task/incident if the project uses BortStack;
- constraints and non-goals;
- what validation would demonstrate resolution.
If the report is too vague to identify a testable symptom, gather repository/runtime evidence first. Ask the user only for information that cannot be recovered from available code, logs, tests, configuration, or supplied artifacts.
Do not invent timestamps, production state, user actions, credentials, or request payloads.
## 1. Reproduce or establish the failure
Prefer the smallest reliable reproduction.
Depending on the defect, use one or more of:
- an existing failing automated test;
- a new minimal regression test written against the current behavior;
- DNS/TLS only when the symptom reaches those layers.
### Flask/backend
Inspect when relevant:
- route registration and method/path;
- authentication and authorization;
- request parsing and validation;
- error handlers/status conventions;
- domain/service logic;
- serialization;
- database transaction lifecycle;
- external API/email/storage client behavior;
- exception/logging path.
### Database/migrations/data
Inspect when relevant:
- model/schema versus migration state;
- constraints, nullability, uniqueness, foreign keys and indexes;
- query/filter/join behavior;
- transaction/locking/concurrency behavior;
- fixture/data assumptions;
- migration ordering/version state;
- database-engine differences between test/dev/production.
Search for consumers before modifying a shared helper, model field, endpoint contract, environment variable, or component API.
Use `references/debug-evidence-checklist.md` when the defect crosses multiple layers.
## 3. Form ranked hypotheses
After reproduction and path inspection, form the smallest set of plausible hypotheses supported by evidence.
For each important hypothesis, identify:
- evidence supporting it;
- evidence that would falsify it;
- the cheapest safe check to discriminate it from alternatives.
Test hypotheses rather than making several unrelated changes at once. Prefer one discriminating observation over broad instrumentation churn.
Examples of useful discriminators:
- request never leaves browser vs backend returns error;
- route not registered vs authorization rejects it;
- application validation vs database constraint failure;
- stale frontend state vs wrong API response;
- code defect vs environment/config mismatch;
- migration absent vs schema/model mismatch;
- deterministic logic bug vs race/concurrency issue.
## 4. Identify root cause
Call something the root cause only when the evidence explains the observed symptom and the reproduction path.
A useful root-cause statement is specific, for example:
> The PATCH route accepts an empty `name` because it bypasses the create/update validation helper; the database permits the empty string, so the request succeeds and the UI later renders a blank service name.
Avoid vague conclusions such as “state issue”, “CORS problem”, “database bug”, or “React timing”.
If multiple independent defects contribute, distinguish primary cause from secondary/contributing conditions. Do not silently expand scope to fix every contributing weakness.
## 5. Design the minimal fix
Choose the smallest coherent change that removes the root cause at the authoritative layer.
Guidelines:
- validation/invariant defects belong at the backend/database boundary as appropriate, not only in UI guards;
- authorization defects must preserve server-side enforcement and the project's existing auth model;
- frontend rendering/state defects should not require backend contract changes unless the backend contract is actually wrong;
- proxy/config defects should use existing operational conventions rather than application workarounds;
- data/schema defects require an explicit migration/data-safety assessment;
- race conditions require atomicity/locking/constraints appropriate to the existing architecture, not timing sleeps;
- flaky tests should be debugged for the actual race/assumption rather than simply increasing arbitrary waits.
Before editing, check whether the proposed fix changes a durable product/API/data/security decision. If it does, use the context decision workflow instead of silently choosing a new behavior.
## 6. Capture the regression
When feasible, create or identify a test that demonstrates the bug before the fix.
A good regression test:
- exercises the observed behavior, not a private implementation detail;
- fails for the root cause you identified;
- passes after the minimal fix;
- protects the boundary most likely to regress;
- does not require weakening or deleting unrelated tests.
Depending on the issue, this may be:
- Flask/API test;
- model/database test;
- React unit/component test;
- browser/end-to-end test;
- migration test;
- configuration validation;
- deterministic reproduction script/command when automated test infrastructure is unsuitable.
If a regression test cannot reasonably be added, explain why and document the concrete manual/runtime reproduction used instead.
Before editing, confirm the repair is authorised and apply the repository workflow to the source checkout.
## 7. Implement one focused fix
Make the change with tight scope.
During implementation:
- retain useful diagnostic logging only if it belongs in normal operation;
- remove temporary prints, debug endpoints, screenshots, dumps, test credentials, or ad-hoc instrumentation before finishing;
- do not hide exceptions or convert failures into false success;
- do not broaden exception handling merely to suppress the symptom;
- do not disable tests/lint/security controls to get green validation;
- do not upgrade dependencies unless evidence shows the dependency version is the root cause and that upgrade is within scope.
If the first fix does not resolve the original reproduction, revert/reassess that hypothesis rather than stacking speculative changes.
## 8. Validate the fix in layers
Use repository-supported commands and environments as authority.
A sensible order is:
1. original reproduction/regression test;
2. neighboring targeted tests;
3. relevant backend/frontend suite;
4. lint/type/static checks affected by the change;
5. production build when frontend/build configuration changed;
6. migration/configuration checks when relevant;
7. browser/runtime reproduction when the defect was user-visible and safe tooling/environment is available;
8. repository-specific completion gates.
Also verify the **negative path** where relevant: unauthorized request still fails, invalid input still fails, unrelated route still works, stale record still handled, etc.
Distinguish clearly between:
- freshly passed checks;
- historical evidence;
- checks blocked by environment/dependency/network/credential limitations;
- manual verification still required.
Use `references/regression-validation.md` for the final pass.
## 9. Review the final diff and context
Before declaring resolution:
- compare the final behavior with the original reproduction;
- inspect the diff for unrelated cleanup or accidental contract changes;
- check for debug artifacts, secrets, logs/dumps, generated junk, or dependency churn;
- run `git diff --check` when Git is available;
- update the project’s current-state record with the verified defect/resolution where materially useful;
- update the accepted task/incident status according to repository rules;
- record a durable decision only if the fix establishes/changes a durable rule;
- refresh the project’s handoff record when the repository workflow calls for it;
- do not start the next task.
Report blocked or pending runtime and manual checks. Leave task state to the project’s lifecycle and acceptance rules.
## Stop conditions
Stop and report rather than guessing when:
- the target repository/environment is unavailable or cannot be identified safely;
- the reported failure cannot be reproduced and there is insufficient evidence to identify root cause;
- logs/evidence point to an external system you are not authorized or able to inspect;
- diagnosis requires credentials/secrets the user has not supplied through an appropriate secure mechanism;
- the apparent fix requires destructive data operations, production mutation, deployment, branch reset, or infrastructure changes outside the authorized task;
- resolving the symptom requires an unapproved product/security/data-model decision;
- repository evidence shows the request is actually a new feature or broad refactor;
- available evidence contradicts the user's initial theory: report the evidence and debug the observed defect, not the requested theory.
A safe evidence-backed stop is preferable to a speculative “fix”.
## Completion report
Give a concise debugging report containing:
1. reported/reproduced symptom;
2. evidence inspected and reproduction method;
3. root cause, with the key evidence supporting it;
4. fix implemented and why that layer was authoritative;
5. files/areas materially changed;
6. regression coverage added/updated;
7. tests and validation actually run, with exact results;
8. anything not verified and why;
9. context/task/decision updates made;
10. final task/incident status and any remaining manual step.
If no safe root cause/fix was established, say so explicitly and report the narrowed hypotheses/evidence instead of pretending the issue is resolved.
## When not to use this skill
Do not use this workflow for:
- implementing a known, scoped new feature — use `webapp-feature`;
- choosing the next task — use `bortstack-context` in BortStack or the repository’s own planning workflow;
- broad behavior-preserving restructuring — use `safe-refactor`;
- review-only auditing — use `code-review` or `production-readiness-review`;
- deployment/release execution where the code defect is already understood — use `deployment-check`;
- creating a new project — use `roborto-new-project` as the temporary scaffolding route.
## Resources
-`references/debug-evidence-checklist.md` — layer-by-layer evidence checklist for tracing web failures.
2. Run the new/updated regression test and confirm it passes.
3. Run nearby tests that protect the same contract.
4. Verify important negative behavior still holds (auth, validation, error path, constraints).
5. Run repository-required lint/static/build/migration checks relevant to the change.
6. Reproduce in the relevant browser/runtime when practical and safe.
7. Inspect the final diff for unrelated changes and temporary diagnostics.
8. Run `git diff --check` when Git is available.
9. Distinguish fresh validation from historical evidence and unavailable checks.
10. Report blocked runtime or manual checks and follow the project’s lifecycle before closing the task.
For intermittent defects, one successful run is weak evidence. Use a deterministic regression when possible or repeat the triggering scenario enough to support the claim without pretending probabilistic evidence is certainty.
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.