Root Cause Analysis Implementation Guide
By Nicolas Narbais
Equip a read-only investigation agent with Tsuga access, code context, incident facts, guardrails, and a repeatable validation process.
Set up a human-led, read-only root-cause-analysis (RCA) workflow inside an engineer’s local coding agent (Claude Code, Codex, Cursor, or another CLI/MCP agent) across seven steps. The agent gathers evidence and tests hypotheses locally; humans retain ownership of incident communication, severity, and remediation.
| Step | Goal | Gate / output |
|---|---|---|
| 1 | Choose agent & read-only scope | Approved local CLI agent; read-only vs remediation split |
| 2 | Connect Tsuga (CLI or MCP) | Individual OAuth (preferred) or scoped Operation key |
| 3 | Connect GitHub & local repos | Read-only repo/PR/release access mapped to service.version |
| 4 | Supply incident facts | Bounded question, impact, and exact UTC window |
| 5 | Add curated ops context | Service owners, runbooks, and Saw → Check → Confirms RCAs |
| 6 | Enforce investigation contract | Cited claims, counter-evidence, read-only command allowlist |
| 7 | Replay a past incident | Reproducible RCA matching history with honest gaps |
Use this guide when responders want to investigate live or historical failures from a local coding agent without granting broad write permissions.
Step 1 - Choose the local agent and scope its authority
Pick an agent that runs local CLI commands and connects to MCP servers (browser-only chat cannot inspect local Git history or run repeatable commands). Before installing, agree on:
- Pilot scope & model policy: approved pilot team, model provider, data residency, and whether code, telemetry, and incident transcripts may enter model context.
- Read-only authority: separate investigation (read-only by default) from remediation (human-approved only).
- Individual identity: use OAuth (recommended) or per-person credentials (never shared Tsuga or GitHub tokens) so access review and revocation stay auditable.
Exit criteria: One approved local agent runs commands under a written policy separating read-only investigation from production changes.
Step 2 - Connect the agent to Tsuga (CLI or MCP)
Prefer the Tsuga CLI as the primary interface (explicit, testable outside the agent, lower context cost); add Tsuga MCP when interactive tool discovery improves the workflow. Default to OAuth for individual engineers so requests inherit personal Tsuga permissions without storing static keys. Use a named, read-only Operation key (scoped to the owning team, named after person + machine) only when OAuth is unavailable or for shared automation.
CLI setup with OAuth (default)
npm install -g @tsuga/cli
tsuga auth login
tsuga auth status
# Smoke test with scoped, time-bounded reads
tsuga services list
tsuga logs search \
--query 'context.service.name:<service>' \
--from -15m \
--to now \
--max-results 10
tsuga traces search \
--query 'context.service.name:<service>' \
--from -15m \
--to now \
--max-results 10
tsuga monitors list -d '{"limit":50}'
Require a service filter and explicit time range on every search to keep model context focused. Install the Tsuga investigation skills so the agent constructs valid queries (for Claude Code):
claude plugin marketplace add tsuga-dev/agent-plugins
claude plugin install tsuga@tsuga
CLI setup with an Operation key (fallback)
Store the key in your secret store or shell environment, never in a repo. Omit tsuga auth operation-key if you want to keep the key purely in the environment without overwriting a saved OAuth session:
export TSUGA_OPERATION_API_KEY="<TSUGA_OPERATION_KEY>"
tsuga auth operation-key "$TSUGA_OPERATION_API_KEY"
tsuga auth status
MCP setup (https://mcp.tsuga.com/v0/mcp)
- Claude Code (OAuth): register without a header, then complete browser sign-in (run
/mcpif the browser does not open automatically):
claude mcp add --transport http tsuga https://mcp.tsuga.com/v0/mcp
- Codex (OAuth): add to
~/.codex/config.toml, then runcodex mcp login tsuga:
[mcp_servers.tsuga]
url = "https://mcp.tsuga.com/v0/mcp"
- Operation-key fallback (clients without OAuth): keep
TSUGA_MCP_TOKENin the environment/secret store and re-register after rotating the key (for Cursor and other clients, follow your client’s streamable HTTP MCP config):
export TSUGA_MCP_TOKEN="<TSUGA_OPERATION_KEY>"
claude mcp add --transport http tsuga https://mcp.tsuga.com/v0/mcp \
--header "Authorization: Bearer $TSUGA_MCP_TOKEN"
Exit criteria: Both outside and inside the agent, tsuga services list and a scoped log/trace search succeed using read-only credentials.
Step 3 - Connect GitHub and local code repositories
Telemetry shows what broke; Git history shows why. Grant read access only to in-scope code, IaC, and CI/CD repos (no admin, secrets, merge, or deploy rights):
gh auth login
gh auth status
mkdir -p ~/repos/<organization>
cd ~/repos/<organization>
git clone git@github.com:<organization>/<repository>.git
Document the local repo root and map each service to its source directory, deployment manifests, and workflows (including monorepo subpaths).
Exit criteria: Given a service.version or deployment revision from Tsuga, the agent locates the matching commit, PR, release, and workflow run.
Step 4 - Supply bounded incident context
Feed recorded incident facts from incident.io, PagerDuty, FireHydrant, Opsgenie, Jira, or ChatOps rather than letting the agent guess impact from raw spikes. Choose the simplest pattern first:
- Incident prompt/export (preferred pilot): paste incident summary, links, and exact UTC timestamps.
- Read-only API/MCP connection: expose timeline, severity, and linked assets only.
- Curated incident archive: distilled prior incidents stored locally.
Keep all live status updates, severity edits, and incident resolution under human approval. Frame a bounded starting prompt before the first query:
Investigate the production checkout failure from 10:03 to 10:19 UTC.
Start with the frontend error-rate alert. Determine the affected operation,
the earliest error, the downstream propagation path, relevant changes, and
the strongest supported root-cause hypothesis. Cite evidence and open questions.
Exit criteria: Every investigation begins with an explicit UTC time window and impact statement.
Step 5 - Add curated ownership, runbooks, and prior RCAs
Provide small, reviewed read-only sources instead of broad noisy wiki search: service catalog/owners, runbooks, architecture notes, deploy/rollback docs, and resolved post-mortems.
Structure prior incident summaries as Saw → Check → Confirms (for example: “Saw checkout errors after version X → Checked quote-service traces and logs → Confirmed uncaught exception from deploy”). That gives agents testable hypotheses without biasing them toward stale causes.
Exit criteria: For each pilot service, the agent can locate an owner, a runbook/architecture doc, and relevant prior RCAs.
Step 6 - Enforce the investigation contract and guardrails
Standardize how the agent narrows evidence:
1. Restate the incident question, time range, service, and environment.
2. Find onset and affected operation from monitor and metric evidence.
3. Inspect representative failing traces and follow the downstream path.
4. Pivot between traces and correlated logs for concrete failure detail.
5. Compare affected versions and changes against a pre-incident baseline.
6. Inspect code, deployment history, and runbooks only after a lead exists.
7. Report observations, hypothesis, counter-evidence, confidence, and next checks.
Require five elements in every output: impact/scope, short causal chain (symptom vs likely cause), citations (links, queries, commands), uncertainty and rejected alternatives, and suggested next actions clearly labeled as proposals. Pre-approve only read-only tools (tsuga reads, gh reads, git log, rg); gate deploys, repo writes, secrets, and DB changes behind human approval.
Exit criteria: Two responders running the same prompt reproduce the key evidence and clearly distinguish proven facts from hypotheses.
Step 7 - Validate by replaying a resolved incident
Pick a resolved incident from the past 6–12 months and withhold the post-mortem conclusion to prevent answer leakage. Confirm the agent connects cleanly, locates the alert/onset/telemetry, links the observed service.version to Git history, reaches a consistent RCA, and flags missing evidence instead of guessing.
Track time to conclusion, wasted queries, token spend, and citation quality, then close gaps in telemetry, skills, or docs and replay after every material change.
Exit criteria: The replayed RCA matches historical findings, cites the backing trace/log/commit for every material claim, and explicitly flags unknowns while staying read-only.
Troubleshooting path
| Symptom | Check first | Fix |
|---|---|---|
| Agent cannot query Tsuga | Run tsuga services list outside the agent | Refresh OAuth login or scoped Operation key; restart MCP client after setting env vars |
| Telemetry visible, no code link | service.version immutability + local repo access | Emit commit SHA in service.version and verify read access to code + deploy repos |
| Symptom found, failure detail missing | Log trace_id/span_id + matching service.name | Fix trace-to-log correlation and async queue/worker context propagation |
| Agent makes unsupported claims | Citation enforcement + prompt scope | Require backing queries per claim, narrow scope, and force explicit next checks |
Completion criterion and iteration
Replaying a historical incident under read-only access produces a reviewable RCA matching the recorded cause, backed by cited queries/traces/logs/commits and explicit gaps. After each live incident, compare the agent’s report with human findings, patch the missing skill, doc, or telemetry gap, and re-run the replay benchmark.
Optional (observe investigator agents): If you emit telemetry from the investigation agents themselves (duration, model usage, tokens, tool calls), choose metadata-only vs content capture deliberately and use a separate ingestion key from the investigation credential.
Written by
Nicolas Narbais
Nicolas Narbais builds, breaks, debugs, and scales observability systems using OpenTelemetry and modern telemetry pipelines. He shares practical, opinionated lessons to help engineers get better signal with less noise.
Olatuak Editorial Philosophy
Better signal, not more telemetry.
Olatuak helps platform engineers, SREs, and observability teams turn noisy telemetry into clear operational decisions without blindly collecting more data.
