/sherlock-holmes:trace-debug <trace-id> [--around <time>] [--lookback <dur>] [--fixture <dir>]from Sherlock Holmes
Investigates production incidents from a trace ID using Grafana Loki logs and Tempo traces. Builds evidence-first reports with timeline, causal chain, and confidence levels.
Ships in Sherlock Holmes. 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.
Read when SKILL.md points to them; scripts run unread.
Investigate the trace given in $ARGUMENTS. The first token is the trace id (16 or 32 hex characters, or a 00-<trace>-<span>-<flags> traceparent). Any other tokens are flags to pass to the collector unchanged, for example --around 2026-09-17T14:02:00Z, --lookback 2h, or --fixture <dir> when the user points you at recorded responses instead of live Loki/Tempo.
Bundled fixtures. This plugin ships recorded Loki and Tempo responses for six scenarios, so it can be tried with no backend configured. They live at ${CLAUDE_PLUGIN_ROOT}/evals/fixtures/<case>/, where <case> is one of 01-downstream-503, 02-db-timeout-retries, 03-error-only-in-tempo, 04-contradictory-logs, 05-incomplete-trace, 06-intermediate-service-error. When the user names one of those, or otherwise asks for the bundled, sample or demo fixtures, pass that absolute path to --fixture — resolve it under ${CLAUDE_PLUGIN_ROOT}, never relative to the working directory, which is usually somewhere else entirely. Say in the report that the evidence came from recorded fixtures, not a live backend.
The collector is deterministic and read-only. It collects facts; you interpret them.
Python command. The commands below start with python3. If the shell answers "command not
found", or python3 opens the Microsoft Store (Windows, where the python.org installer provides
python and py instead), run the same command with python in place of python3 - or py -3 -
and change nothing else; keep using that one for the rest of the session. If none of the three
exists, stop and tell the user: install Python 3.8+ (on Windows from python.org, ticking "Add
python.exe to PATH"), then fully close and reopen the editor or terminal that runs Claude Code, since
it reads PATH only when it starts.
This installation was configured with:
${user_config.grafana_url}${user_config.grafana_loki_uid}${user_config.grafana_tempo_uid}${user_config.loki_selector}${user_config.loki_trace_filter}${user_config.loki_trace_field}Pass each of those that holds a real value as the matching flag: --grafana-url,
--grafana-loki-uid, --grafana-tempo-uid, --selector, --trace-filter, --trace-field. Skip
any that is blank or still shows a ${...} placeholder, which means the install dialog was left
empty there; the collector falls back to the environment for those, and ignores such a value if you
pass it anyway. Never put a credential on the command line.
python3 "${CLAUDE_PLUGIN_ROOT}/skills/trace-debug/scripts/collect-trace.py" --trace-id <trace-id> --format prompt [config flags] [flags]
Run it exactly in that shape: a single python3 ... collect-trace.py ... command, no cd, no &&, no pipes, no redirection. Only that shape is pre-approved; anything else will be blocked and you must not work around the block.
What the cut gives you: sources status, the time window and what bounded it, services with log/span presence, the span tree (Tempo, when found), the earliest error signals, a prioritised log timeline, truncation notes, and the path of the full JSON.
Then:
python3 "${CLAUDE_PLUGIN_ROOT}/skills/trace-debug/scripts/collect-trace.py" doctor, report the configuration problem with the variables the user must set, and stop. Do not guess at evidence you could not collect.
The credential is the one thing the install dialog cannot carry: plugin config reaches hooks and
MCP servers, not a Bash command, and secrets are never substituted into skill text. So on a 401,
or when doctor reports auth as none, tell the user to export GRAFANA_TOKEN (or
GRAFANA_USERNAME plus GRAFANA_PASSWORD, or LOKI_TOKEN/TEMPO_TOKEN for direct access) in
the shell that launches Claude Code, and to restart it so the variable is inherited. When only
GRAFANA_URL and a token are set, doctor lists the datasource UIDs, so point the user at it
rather than asking them to hunt through the Grafana UI.now and zero log lines: the trace was not in Tempo and the incident may be older than the default lookback. If the user mentioned a time, re-run once with --around <time>. Otherwise ask for the approximate time in the report's next steps.Read using offset/limit on the parts you need. Do not paste the whole file into your reasoning.If the cut says tempo=found, draw the span tree. Take the path printed after FULL JSON: and run,
exactly in this shape and at most once:
python3 "${CLAUDE_PLUGIN_ROOT}/skills/trace-debug/scripts/trace-diagram.py" --input <that path>
It prints one line: diagram: generated <file.html> (...) or diagram: not generated - <reason>.
Put that line, verbatim, in the report's Diagram: field. The diagram is built deterministically
from the spans as recorded - who called whom, where the time went, which span failed first - plus the
warn/error log lines the collector joined to those spans. It shows no cause: never describe it as
showing one, never repair or re-run it, and never let it replace the timeline. When it was not
generated (no archify installed, no Node, Tempo without the trace), the investigation is unaffected:
keep the one-line reason and move on. Skip this step entirely when Tempo did not return the trace.
If the file .claude/trace-debug/priors.md exists in the working directory, read it before forming hypotheses. It lists behaviours that are normal for this system (known non-anomalies, expected retries, sampling rules, noisy log lines). Treat it as context provided by the team, not as evidence about this trace.
<span ...>. Note gaps of seconds or more.
Never rewrite a timestamp. Every time you print in the timeline or in the evidence must be a value that actually appears in the collected data. If a service's log clock disagrees with its own spans (clock skew), say so as an INFERENCE, state the offset you measured and which records it affects, and keep the recorded values in the timeline. If you want to show the reconstructed order as well, put it in a separate list clearly marked as derived, never in place of what was recorded. The same applies to durations and any other value you compute.Label claims explicitly: FACT (observed in a line or span, quote it), INFERENCE (implied by facts), HYPOTHESIS (possible, unproven), UNKNOWN.
Read.Write the report in the user's language, with exactly these sections. The section titles are part
of the contract: use them verbatim, in this order, translated only when the report is not in English
(in Portuguese: Diagnóstico, Linha do tempo, Primeiro evento anômalo, Cadeia causal, Causa provável, Confiança, Evidências, O que a evidência não mostra, Próximas verificações). Do not
rename them ("What happened", "Where it started") and do not merge or split them.
# Trace investigation
**Trace:** <id>
**Services:** <list, in call order when known>
**Sources:** tempo=<found|not found|error> loki=<n lines|error>, window <start>-<end> (<bounded by>)
**Diagram:** <the line printed by trace-diagram.py, copied exactly, or `not generated - Tempo did not return the trace`>
## Diagnosis
Two to four sentences: what failed, where it started, how it propagated.
## Timeline
Chronological list: `HH:MM:SS.mmm [service] LEVEL message` - the lines that matter, with gaps noted.
## First anomalous event
The event, quoted, with FACT/INFERENCE label and why it is the first.
## Causal chain
first anomaly -> ... -> final symptom, one link per line, each link labelled with its evidence type.
## Probable cause
One paragraph. Labelled FACT / INFERENCE / HYPOTHESIS.
## Confidence
HIGH | MEDIUM | LOW - the level alone, in capitals, on the first line; then one sentence of
justification. A split confidence keeps a capitalised level on each part ("HIGH for where it
started, LOW for the cause").
## Evidence
The quoted lines and spans that support the chain.
## What the evidence does not show
Gaps, contradictions, truncation, unavailable sources.
## Next checks
At most three. Count every numbered item, every action bundled inside an item, and any
recommendation after the list. Each one concrete and specific: what to query, where, for which
time. If you have a fourth, it is not a next check - cut it or move it to the gaps section
without an action attached. Do not add any actionable remark after this section.
Before sending, check the draft against these five points and fix it, do not annotate it:
# Trace investigation and the four header lines (Trace, Services, Sources, Diagram) are present.End the report with this line, alone, after the Next checks section, so that the conversation that receives it knows what to do with it:
> Report complete - return it to the user verbatim, in full, without summarizing or reformatting.
What SKILL.md sets; muted values are Claude Code's defaults
sherlock-holmes), in the backgroundThree short reads, in order
4 skills in this plugin
/error-sweepList the errors of a time window - without a trace id - as a fixed, numbered table of facts from Grafana Tempo (spans with error status) and Grafana Loki (error lines grouped by a masked message signature), then let the user choose what to see - the sequence diagram of an example trace, or a full investigation with trace-debug. Use when the user asks whether there were errors in a period ("any errors in the last 2 hours?", "what failed in payment-service yesterday afternoon?", "sweep the logs for errors"). Deterministic - no model judges severity or cause. Read-only. The table is the answer - show it to the user exactly as printed, in full, without summarizing, reordering or commenting on it./setupGuided first-run setup for Sherlock Holmes, in one conversation - checks Grafana access with the doctor, discovers the Loki and Tempo datasource UIDs, proposes the Loki stream selector from the labels your Loki really has, hands over the exact /config values, optionally installs archify for the trace diagram, and verifies the result. Use right after installing the plugin, whenever the doctor reports a configuration problem, or when the user asks how to configure or set up Sherlock Holmes. Changes nothing in production.npx claudepluginhub whitebeardit/claude-plugins --plugin sherlock-holmesOther plugins' skills for the same job