root-cause-finder
Root-Cause Finder
Core Instruction
Before fixing the error, prove whether the code path that produced it was intended.
Do not stop at the first contract, parsing, type, null, or schema error. Treat it as a possible symptom.
Default Workflow
- State the expected behavior in plain language.
- State the invariant in one sentence.
- State what definitely did not happen.
- Trace the causal chain from the intended action or system event to the observed system effect.
- Ask whether the request or mutation should have happened at all.
- Identify the canonical source of truth and every competing source.
- Find the first unintended side effect or write.
- Only then decide whether a downstream contract fix is still necessary.
Questions To Answer In Order
- What user action or system event was supposed to happen?
- What exact call path caused this request or response?
- Should this request, mutation, or side effect have happened at all under the expected behavior and invariants?
- Who owns the state at each layer?
- Is there observer-driven syncing, lifecycle startup code, persistence restore, retry logic, background work, or multiple sources of truth causing an unintended side effect?
- If a contract is violated, is the contract wrong, or did unintended logic reach the contract?
Rules
- Do not make the contract more permissive unless you can prove the observed payload is intended in the final design.
- Prefer fixing the upstream logic bug over accepting bad downstream data.
- Separate symptom, trigger, root cause, minimal safe fix, and architectural follow-up.
- If a low-level fix is still needed, explain why the upstream fix is not sufficient or why both are required.
- Identify the correct layer to fix first.
- Name the first visible wrong behavior, not only the final error.
Hidden Write Checks
Treat non-explicit writes as suspicious by default.
- Audit lifecycle hooks, callbacks, subscribers, watchers, interceptors, middleware, retries, background jobs, cache refreshers, persistence restore, scheduled tasks, and startup code.
- Check whether derived data is being mirrored into another store, cache, file, queue, session, or database through an observer or helper layer.
- Prefer explicit command handlers, request handlers, job runners, or user actions as writers; treat startup-time and background writes as suspects until proven intentional.
- If a framework has automatic reactivity or lifecycle execution, map this rule onto its equivalent constructs without assuming the framework behavior is correct.
Output Format
Use this structure:
- Expected behavior
- Invariant
- What definitely did not happen
- Bug class
- Causal chain from intended action to system effect
- First unintended side effect
- Canonical source of truth
- Competing sources of truth
- Symptom
- Trigger
- Root cause
- Correct layer to fix first
- Minimal safe fix
- Architectural follow-up
- Proposed patch
More from regenrek/agent-skills
hard-cut
Enforce a hard-cut cleanup policy: keep one canonical implementation and delete compatibility, migration, fallback, adapter, coercion, and dual-shape code. Use for pre-release or internal-draft refactors where the goal is one final shape, especially when changing schemas, contracts, persisted state, routing, configuration, feature flags, enum/value sets, or architecture.
14consolidate-test-suites
Decide exactly where bug-fix test coverage belongs. Use before adding, moving, or deleting tests after a bug fix or architectural change. Select one owning layer, reuse existing canonical suites, block redundant or weakly placed tests, and remove weaker duplicates.
7git-safe-workflow
Safely inspect, stage, commit, and (only if asked) push changes made by an AI agent. Use for commit/push requests, end-of-task checkpoints, merge conflict resolution, worktree safety checks, or deciding whether to use git commit --amend.
4shellck
Run shellcheck on shell scripts after editing scripts or when debugging shell errors. Use for linting scripts in a repo (especially scripts/), catching issues like set -u with unset vars, bad subshell usage, or quoting mistakes.
3codex-analysis
Run Codex CLI for deep code analysis and second-opinion reviews. Use when the user explicitly asks for Codex analysis, Codex help, or wants a second opinion from Codex on code, architecture, or debugging questions.
3pr-commiter
Agentic PR committer with deterministic commits, enforced branch/PR workflow, and explicit paths (no git add .).
3