Debug investigate

From AndrewDryga/emisar · View interactive version

Debug investigate is an AI agent skill from the GitHub repository AndrewDryga/emisar. Root-cause a crash, exception, stacktrace, failing test, or wrong behavior in portal/ — reproduce, read the real error, trace to the actual cause, propose the minimal fix. Use when something raises/fails/misbehaves and you need the cause, not a guess (Ecto changeset/constraint errors, recurrent job

How to use this skill

Skill file

Investigate (find the cause, not a symptom)

Do not propose a fix until you can point at the line that's wrong and say

why. Never edit a test to make a real failure pass.

Method

Reproduce the failure before theorizing: the exact failing command

(./run test portal <path>:<line>), the LiveView action, the MCP call, or the

failing context function in iex -S mix. Read the full error (stacktrace,

changeset errors, SQL) and the code and data it touched; confirm any contract

you're unsure of with /tooling-verify-api. Fix only once the evidence confirms

the cause, fix it at the cause, and add a regression test that fails before

and passes after (plus the denial / cross-account variant for a context bug, §7).

emisar error catalogue (where to look first)

error (unique/foreign_key) means the DB rejected it: the matching

unique_constraint/foreign_key_constraint is missing from the Changeset, or the

migration lacks the index/FK. A validate_* error is just invalid input.

list), or ensure_has_permissions is checking the wrong one.

it out (cross-account). Check the subject's account vs the row's.

it polls; a job that isn't idempotent (IL-13) corrupts state when a tick repeats.

silent form failure → check the {:error, changeset} branch is handled, not the UI.

(get_operation / MCPOperations.fetch_recovery); MCP mutations

dedupe on the bridge's operation ID (mcp-api.md); there is no caller-supplied

idempotency key. An auth error → the subject built at the MCP boundary.

(Runners.apply_state, connect_runner, disconnect_runner,

record_heartbeat; §1.4); a crash shouldn't take down other runners (IL-17).

side effects not made sync in test (the notify_approvers_async? flag pattern).

Never Process.sleep it away; use assert_receive with a timeout.

Output

Cause: <file:line — what's wrong and why> → Fix: <the minimal change> →

Regression test: <what it asserts>. If you can't isolate it, say what you ruled

out and what you'd instrument next. Don't ship a guess.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.