| name | boo-diagnose |
| description | Performs root-cause diagnosis for Ruby on Rails issues across performance, correctness, architecture, security, and reliability. Use when requests involve bugs, regressions, N+1 queries, slow endpoints, flaky tests, unexpected behavior, or unclear failures. Triggers on words like diagnose, debug, investigate, root cause, slowdown, flaky, regression, N+1, timeout. |
Rails Diagnose
Overview
Use this skill to move from symptom to root cause with evidence, not guesses.
LSP Recommendation
Strongly recommend enabling LSP before running this skill:
ENABLE_LSP_TOOL=1 in the shell running Claude/Codex.
- Run from the Rails app root directory.
- Ensure a Ruby LSP backend is available in the app bundle (
ruby-lsp and/or solargraph).
If LSP is not enabled, continue execution but mark reduced confidence for symbol-resolution findings.
Diagnostic Workflow
- Reproduce: Confirm the problem and capture exact failure signal.
- Scope: Identify impacted code paths, models, endpoints, and environments.
- Observe: Inspect logs, queries, stack traces, and recent changes.
- Hypothesize: List candidate causes and rank by probability.
- Prove: Validate or invalidate each hypothesis with targeted checks.
- Conclude: Report root cause, fix plan, and prevention step.
Investigation Matrix
- Performance: query count, N+1 patterns, missing indexes, cache misses.
- Correctness: wrong assumptions, nil handling, callback side effects.
- Security: unsafe params, interpolation in SQL, authorization gaps.
- Reliability: flaky specs, race conditions, background retry behavior.
Evidence Requirements
Never close diagnosis without at least one direct evidence source:
- Repro steps.
- Log/trace evidence.
- Query or timing evidence.
- Test demonstrating failure and/or fix.
Scripted Execution
Use the bundled diagnostic runner for repeatable investigation:
scripts/run_diagnose.sh
scripts/run_diagnose.sh --project-dir /path/to/rails-app
scripts/run_diagnose.sh --mode advisory --output-file tmp/diagnose-report.md
scripts/run_diagnose.sh --require-lsp (hard fail if ENABLE_LSP_TOOL!=1)
Default behavior:
- Scans for likely N+1 hotspots, broad rescue patterns, callback overload, oversized controllers, flaky test hints, and job idempotency risk.
- Categorizes findings into
HIGH, MEDIUM, and LOW.
- Persists logs in
tmp/rails-diagnose-<timestamp>/.
In strict mode, HIGH findings return exit code 1.
Output Contract
- Symptom.
- Root Cause.
- Evidence.
- Primary Fix.
- Alternative Fix.
- Guardrail to prevent recurrence.
Final Summary (Required)
Always end execution with:
- Diagnostic outcome: confirmed root cause or pending unknown.
- Top findings by severity.
- Recommended fix and one alternative.
- Evidence references used.
- Immediate next step.
References
Load references/external-resources.md for canonical debugging and Active Record references.