debug-tests

Diagnose failing pytest tests using root-cause-first analysis before changing application code.

Updated Jul 9, 2026
One-click install
npx skills add https://github.com/ByronWilliamsCPA/plugin --skill debug-tests-byronwilliamscpa
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: debug-tests
Source: https://github.com/ByronWilliamsCPA/plugin/tree/main/plugins/wff-code/skills/debug-tests
Command: npx skills add https://github.com/ByronWilliamsCPA/plugin --skill debug-tests-byronwilliamscpa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Failing tests often get patched with quick fixes like sleeps, mocks, or re-runs that hide the real defect. This Skill enforces a structured debugging workflow that classifies the true root cause of a test failure before any application code is touched. ## Core Features & Use Cases - Root-Cause Classification: Investigates failures in a fixed order: fixtures and conftest configuration, environment mismatches (SQLite vs Postgres, env vars), dependency drift, test isolation issues, and only then application logic. - Reproduce-Fix-Verify Workflow: Captures full pytest output, applies a minimal targeted fix, re-runs the failing test in isolation, then runs the full suite to check for side effects. - uv Environment Stability: Documents how to pin a uv environment with uv sync --all-extras and uv run --no-sync so iterative debug runs do not silently drop extras and cause misleading ModuleNotFoundError failures. - Use Case: A CI pipeline reports a failing auth test that passes locally. Invoke the skill with the test path to reproduce the failure, classify it as an environment mismatch, and fix the missing env var instead of mocking the failure away. ## Quick Start Ask the AI to debug the failing test at tests/unit/test_auth.py using root-cause-first analysis.

Frequently Asked Questions about debug-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I debug a failing pytest test?▼

Reproduce the failure with pytest -v --tb=long to capture full output, then classify the root cause in order: fixtures and conftest, environment mismatches, dependency drift, test isolation, and only lastly application logic. Apply a minimal fix and re-run the test in isolation.

Why does my test pass locally but fail in CI?▼

CI-only failures usually indicate environment differences such as missing env vars, database engine differences like SQLite versus Postgres, or test ordering and parallelism. Treat CI as the honest environment and classify the difference as an environment mismatch.

Why does uv run pytest cause ModuleNotFoundError between runs?▼

uv run re-syncs to the default dependency set on every invocation, uninstalling optional extras like hypothesis or pytest-cov. Run uv sync --all-extras once, then use uv run --no-sync python -m pytest for stable repeated runs.

Should I add a sleep or mock to fix a flaky test?▼

No. Sleeps and mocks mask the underlying defect, which is usually shared state, timing, or ordering. Flakiness is itself a root cause that should be classified under test isolation and fixed directly.

When should I investigate application logic for a test failure?▼

Only after ruling out fixtures and configuration, environment mismatches, dependency drift, and test isolation. Most test failures originate in the test setup or environment rather than the code under test.