/corgi:debugfrom corgi
Diagnoses broken stacks, runtime bugs, CI failures, and environment version skew by pulling logs, traces, and provider data. Local-first with structured entry modes for each scenario.
Ships in corgi. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Read ../_shared/conventions.md first (finish what you start, attribution, unattended runs).
Done when: the cause is named with its evidence (the log line, trace or failing command) and, for a broken stack, the stack is healthy again - or the one missing access is named.
Four entry modes:
Local-first. Exhaust the fast local probes before anything external. The
provider is read from the repo (README/CLAUDE.md), never hard-coded, queried on
demand. Work in order; stop the moment the cause is explained - don't run the
whole ladder for a one-liner.
corgi run from a Bash call - beforeStart runs inline
before run-state is written and corgi run streams forever, so a sync call hangs
(10-min timeout) and never reaches the next step. Always --detach (or
run_in_background: true). See ../corgi/references/long-running.md.corgi logs --service <x> --wait-for "<regexp>" --timeout <d> - it blocks, exits 0
on match and 1 on timeout. A sleep-and-read loop costs a tool call per iteration.corgi logs (--idle <Ns>); raw files
via Read(limit: ~100). Never an unbounded read of a .log/.state.json (logs
cap at 50MB).ps →
status → doctor → logs before any analytics MCP (most "won't start" bugs are
ports/docker/env, found locally). Bug-investigation mode, symptom is
deployed/remote (a staging/prod 500 that may not reproduce locally) → go straight
to Step 4; local probes only if it reproduces.--force, dropping a DB,
killing a port the user may want, anything hitting a deployed env).main HEAD or theorize about data until you know which
commit/version each env actually runs - the report's own version string (a
screenshot build number, "broke in the latest release") is evidence; use it, don't substitute main.needs attention + what you saw.corgi why firstIf the user named a service ("why is the api down", "the worker keeps dying"), run this before the ladder. It is the whole of Steps 0-2 for one service, in one call:
corgi why api --json # MCP: corgi_why { service: "api" }
Returns a single verdict plus the evidence behind it: unmet dependencies,
port ownership (who holds it), lastExitCode, env findings (absent env file,
missing keys, unfilled placeholders), and logTail. Exit is 1 for anything but
healthy, so it gates in a script.
verdict | means | next |
|---|---|---|
dependency_unready | a depends_on target is not running | start that one first |
port_taken | another process holds the port | Step 1 (--kill-port) |
env_missing | env file absent, keys missing, or placeholders unfilled | fix env, then corgi env check |
crashed | it started and exited | Step 2, using the returned logTail |
no_start_command | nothing declared to launch | compose bug, not runtime |
not_started | no run state at all | corgi run --services <x> --detach |
unhealthy | process alive, port not answering | Step 2 (may still be compiling) |
healthy | not the problem | look elsewhere |
Env is checked as part of this - do not run a separate corgi env check first.
If why does not explain it, fall through to the ladder below.
corgi context --json # orientation in one call: topology, ports, status, each repo's branch/dirty, tier, validation (MCP: corgi_context)
corgi ps --json # name/kind/port/status/url (+ startedAt); reconciles .corgi/corgi_services/.state.json
corgi status --json # live TCP/HTTP probe - the ONLY liveness truth
# uptime = startedAt from `corgi ps --json`; an older corgi omits it → cat .corgi/corgi_services/.state.json
Trust corgi status (live probe) for liveness, not corgi ps status. ps
status only means the PID/container exists - db_services only go
running/stopped, never crashed, and a container-backed service (docker runner,
pid 0) isn't refreshed by a liveness check, so a crash won't flip it to crashed.
Judge those by corgi status + docker ps.
Classify on real signals (JSON keys lowercase):
| State | Tell | Next |
|---|---|---|
| healthy | corgi status healthy:true | not the problem |
| crashed | ps status:"crashed" OR a newest *.crashed.log | Step 2 |
| up but probe red | ps status:"running" BUT corgi status healthy:false | Step 2 + check the healthCheck: path |
| never spawned / mid-beforeStart | entry absent from .state.json | Step 1 |
Uptime = now − startedAt; call out "X up 4m, Y never came up". No exit code in
.state.json - read it from the log body (Step 2), not the file or the .crashed
suffix.
Seen this before? If .corgi/memory/ exists, scan incidents/
(corgi memory list --type incident --json) for a past failure matching the
symptom and reuse the recorded fix before re-deriving it (see the memory skill).
Absent → skip.
"Stuck" splits (corgi has no booting-vs-ready flag):
beforeStart → corgi run --detach itself never returned; service
absent from .state.json. Launched in a Bash call → still blocking; check that
run's output / --logs; --omit beforeStart to isolate.start: running, port never opens → tail logs: advancing = slow boot, a stack
trace = real failure.corgi status --json after ~30s, compare the healthy count
(never corgi status --watch - it blocks until Ctrl+C and hangs an agent).
Cross-ref ../corgi/references/debugging.md.corgi doctor when something won't startcorgi doctor --json # tools installed, Docker up, ports free - and ONLY those
First thing on "doesn't work". Fixes (offer, then run the safe one): port busy →
corgi run --services <x> --kill-port --detach (ask if it's a port the user wants);
Docker down → start it, re-doctor; missing tool → install (required:
names it).
Doctor does NOT cover - route elsewhere: clone not done → service dir empty /
"failed to clone" in run output (corgi init, fix branch/URL/token); seed/dump
failure → only on corgi run -s; check seedFrom*; env unset/wrong →
corgi env <x>; wrong healthCheck: path → service binds the port but
corgi status gets 404/5xx; bad compose → corgi validate.
Needs a prior corgi run (capture is on unless --logs=false). Default = bounded, single service:
corgi logs --service <x> --json --idle 3s # the stuck/crashed one, bounded
Cross-service correlation only (reads each newest file in full, no idle - pricier):
corgi logs --all --json. Find the first error / stacktrace / crash marker
(*.crashed.log) + the exit code from the log body. No logs captured → re-run
just that service with --logs (Step 3).
Smallest change that could work, then re-gate. Never foreground a corgi run.
Minimal code comments. Don't narrate the change in code comments - it should read from the diff and the PR/commit message. Add a comment only for a genuinely non-obvious invariant that would otherwise be lost, and only where the file already comments. No "// added/changed X" notes.
corgi run --services <x> --with-deps --detach --logs.
Without --with-deps an isolated retry against a down dependency just re-crashes.corgi env <consumer> for a stale or wrong dependency URL - a prior --host/remote
run rewrote it, the producer was excluded from the run set so no
depends_on_services alias got generated, or the .env was hand-edited. Re-run
without the override / with --with-deps so corgi regenerates the wiring.corgi run --services <x> --with-deps --detach --logs --service-branch <x>=<branch>
(corgi makes a non-destructive worktree off the pushed branch; main checkout
untouched), or --service-dir <x>=<worktree-dir> for live/uncommitted code.corgi run --dbServices <db> --services none --detach, then corgi status --json / its logs.corgi restart.beforeStart step wrongly skipped → --no-cache (re-runs every
beforeStart step, ignoring cacheKey - not an image/deps rebuild). Truly
stale generated artifacts → corgi clean -i corgi_services / corgi run --fromScratch.corgi env <x>. Compose wrong → corgi validate.Re-gate: corgi status --ready --service <x> --timeout 120s --json. Green → report.
Red after ~2 tries → needs attention + the error, move on.
Use when the ticket needs runtime/deployed data (a staging/prod request, a 500 you can't reproduce locally, or a slow backend path's trace/timing - APM / slow-query log) or local logs don't explain a local bug. For a bug investigation this is first-class, not a last resort.
Before the ask-gate: (a) if the symptom carries a ticket key whose tracker MCP is
connected, read the ticket first (mcp__linear-server__get_issue /
mcp__atlassian__getJiraIssue) - it usually already holds the endpoint / request-id
/ timestamp / env to scope the query; (b) verify the provider's MCP is actually
connected - absent → jump to step 4 (connect-this-MCP message + docs pointer); don't
collect scoping you can't use.
grep -liE 'coralogix|cloudwatch|ecs|datadog|sentry|new ?relic|grafana|loki|kibana|elastic|splunk|honeycomb' README.md CLAUDE.md Claude.md claude.md 2>/dev/null
(filename casing varies - Claude.md vs CLAUDE.md.) Map the hit to its access
path - a connected MCP for that provider if one exists (e.g. Coralogix →
DataPrime; CloudWatch/ECS → the AWS MCP; Datadog/Sentry/Grafana → their MCP), else
the provider's CLI/API. Multiple providers named (e.g. APM + logs) → pick the one
the repo ties to logs for the affected service, not the APM/metrics one. Then
read that provider's own section in the repo docs for the exact fields to scope the
query (application/subsystem, environment, request id / endpoint / error class). None found → infer from the deploy target and say
so: "no logs provider named in the docs - this stack deploys on <infer>; connect
its MCP/CLI or paste logs," and stop.A pushed branch's checks failed. corgi has no CI command - pull the failing job's log from the forge CLI, then reproduce with the service's own gate.
gh pr checks <n> (which failed) →
gh run view <run-id> --log-failed. GitLab - glab ci status -R <repo> →
glab ci trace -R <repo> (the failing job).corgi test --service <x> (or
corgi exec <x> --ensure-deps -- <lint/build cmd>). Green locally but red in CI →
an env gap (a CI-only var, a tool/node version, stale cache) - name it.gh pr checks / glab ci status. ~2 tries, then report
needs attention + the failing job.Same code, different behavior across environment or app version. Not a crash, not in
the stack logs - a deploy-state + contract problem. Don't read main HEAD; read
what's actually deployed.
main. Missing
a cell → ask
("which version/env reproduces, when did it last work") before digging./version//health
endpoint, a build-embedded SHA, the container image tag/label, the forge's
deployments/releases, CI's last-deploy. Can't find it → ask; never speculate on
data you can't see. Watch for a frozen prod or a hotfix/* branch that diverges
from main.main. Client↔server skew:
does the client call a field / route / param the deployed server actually has? For
GraphQL an unknown field is a validation error that rejects the WHOLE operation
(no partial data, errorPolicy can't save it) → one new field blanks the entire
query/screen. Decisive 2-command check: git grep <field> <deployed-sha> vs the
client query. Same shape for REST (new required param, dropped response field),
enums, or a missing DB column.grep CLAUDE.md + recent
commits + hotfix/* branches for prior deploy-lag / dropped-or-renamed-field
incidents, and .corgi/memory/incidents/. A documented precedent is a strong prior -
check it early, not after theorizing.Cannot query field …, the 4xx body, the stack line) settles
it in one read - pull it before building data / edge-case theories.Root cause is usually deploy order: a client shipped a contract change before the peer reached that env. Fix = deploy the lagging peer (often API-first) and/or a client-side tolerance net; always flag the order so it doesn't recur.
What was wrong, what you ran, what fixed it (or what's still needs attention and
why). Stopped at the analytics ask-gate → name the provider and the query you'd run.
Posting to the ticket (only if asked): human and concise - symptom → why, framed in the repro matrix (which env/version breaks and why the others don't) → fix → one prevention line. Link SHAs / PRs, don't dump them. Preview before posting; don't post-then-revise.
The stories skill (or any investigation) can invoke debug mid-flight when it
needs runtime data - jump to Step 4 (provider data) or Steps 0-2 (reproduce
locally). Return the findings; don't take over the parent flow.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
debugging, stack-diagnostics, log-analysis, ci-failure, environment-skew
33 skills in this plugin
/agentUse for corgi agent mode: Remote Control from a phone, the session board ("who is waiting on me"), watching trackers and PRs ("tell me when someone comments"), why a watch fired, and handoffs ("leave a handoff for ABC-7"). NOT compose authoring (corgi), starting a stack (run), debugging (debug)./alignUse when the user says "align", "let's agree first", or a request can be read two ways before any code. Reaches a shared understanding cheaply, then codes. NOT a plan gate or a long interview./autopilotUse for a SUPERVISED loop that drains the ticket queue into draft PRs: "autopilot", "keep shipping the queue", "drain the backlog overnight". One spec gate per batch, never merges. NOT a single batch (/corgi-queue).npx claudepluginhub andriiklymiuk/corgi --plugin corgiOther plugins' skills for the same job