subagent-diagnose

subagent-diagnose is a command for Claude Code from damusix/atomic-claude. It costs 70 tokens per session (5,023 once invoked), scanned A, original, MIT.

A command that coordinates several fresh-context coding agents to investigate and resolve a failure. It can start from a failed continuous-integration run, which is an automated build or test check, or from a described bug.

In plain words
What is it for?
Use it to diagnose failed CI checks or reported bugs, then guide the investigation and fix through repeated review until the problem is resolved.
Why use it?
It separates investigation, implementation, review, and follow-up work so failures are examined systematically instead of guessed at.

Command for Claude Code

Written for Claude Code: $ARGUMENTS substitution. Also seen: mentions subagents.

Good fit Use it to diagnose failed CI checks or reported bugs, then guide the investigation and fix through repeated review until the problem is resolved.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/damusix/atomic-claude/subagent-diagnose
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/damusix/atomic-claude

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for subagent-diagnose

README.md
[![agentmods](https://agentmods.dev/badge/commands/damusix/atomic-claude/subagent-diagnose/github.svg)](https://agentmods.dev/commands/damusix/atomic-claude/subagent-diagnose)
Your own site
<a href="https://agentmods.dev/commands/damusix/atomic-claude/subagent-diagnose"><img src="https://agentmods.dev/badge/commands/damusix/atomic-claude/subagent-diagnose/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for subagent-diagnose

Your own site · 80×15
<a href="https://agentmods.dev/commands/damusix/atomic-claude/subagent-diagnose"><img src="https://agentmods.dev/badge/commands/damusix/atomic-claude/subagent-diagnose.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 70 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 5,023 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00070 $0.05023
Opus 5.5 $0.00028 $0.02009
Sonnet 5.5 $0.00014 $0.01005
Haiku 4.5 $0.00007 $0.00502

Measured 16d ago against content hash 0774fe9d9d45, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

subagent-diagnose scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 16d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

context/commands/subagent-diagnose.md · 315 lines

How it starts

The opening of the file, as written. The whole thing — 315 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are the orchestrator. The user has invoked /subagent-diagnose. You will NOT implement the fix yourself. You drive a loop of fresh-context subagents until the failure is resolved, then triage follow-ups. The scratchpad bundle stays — it is retired later, via /git-cleanup or an explicit atomic scratchpad archive, not by this command.

Spec: docs/spec/subagent-diagnose.md — canonical contract. Read it if anything below is ambiguous.

Scratchpad paths come from atomic scratchpad / atomic where --json; if what you find on disk does not match, run atomic migrate --show-log for the change history.

Phase 0 — Context capture (mode-specific)

Parse mode

First positional arg ($ARGUMENTS) must be ci or bug. Anything else → refuse:

Stop. Do not proceed until mode is valid.


ci mode — Phase 0 steps

A ci run starts only from a resolved failed run and a topic with no existing scratchpad.

flowchart TD
    S["CI source"] --> A{"Argument given?"}
    A -->|yes| C["Capture source pointer"]
    A -->|no| L{"Failed run found?"}
    L -->|no| X1["Stop: no failed run"]
    L -->|yes| C
    C --> G{"Scratchpad exists?"}
    G -->|yes| X2["Stop: scratchpad exists"]
    G -->|no| N["Create scratchpad"]
    N --> F["Fetch logs"]
    F --> B["Record baseline"]
  • CI source: {{ template "resolved-provider" "source-control" }} Then detect the CI provider and its CLI the way /watch-ci does (signals, then the file tree). For GitHub, GitLab, Bitbucket, or Codeberg CI, read that provider's file under the atomic-git-discipline skill's references/source-control/, whatever the resolved value, and use its auth-check and ci-target-resolve rows; for any other CI, use its own CLI.
  • Argument given?: a run-id, branch, pr#, or workflow.yml resolves to a run ID. A pr# resolves to a head SHA through ci-target-resolve, then to that SHA's failed run.
  • Failed run found?: the CI source lists the most recent failed run on <current-branch> with its id, workflow name, head SHA, and time.
  • Stop: no failed run: refuse with no failed run found on branch <branch>. provide a run-id, pr#, or workflow.yml as argument.
  • Capture source pointer: into the BRIEF.md source-pointer section: branch, head SHA, base SHA (git merge-base HEAD <base>), workflow name, failed step name (from the CI source's job detail for the run), failure timestamp, provider URL. <base> comes from: {{ template "base-resolution" . }}
  • Scratchpad exists?: the concurrent-run guard. Topic: diagnose-ci-<run-id> — the run id distinguishes the bundle, not a date. Exists when atomic scratchpad path "<topic>" resolves.
  • Stop: scratchpad exists: refuse with scratchpad already exists for <topic>; atomic scratchpad archive it or pick a different topic suffix. Per axiom 3, no silent overwrite.
  • Create scratchpad: atomic repo init (guarantees the <state-root>/ layout and ignore rules; <state-root> is the state_root field of atomic where --json, .atomic by default), then SCRATCH=$(atomic scratchpad new "<topic>" --purpose diagnose).
  • Fetch logs: Dispatch the harness's default general agent, by name, in the foreground, on the economical reasoning tier, read-only, with this brief: Fetch full logs for CI run <id>, failed step "<step-name>". CI provider: <detected provider>, CLI: <its CLI>, reference: <absolute path of the source-control reference read above, or none>. Write to <SCRATCH>/CONTEXT.md. If logs exceed 64KB, truncate with footer: "[truncated, full log at <provider-url>]". Extract the primary failing assertion / panic / error line and append as a trailing YAML key: top_level_error: "<exact error string>".
  • Record baseline: read CONTEXT.md and copy the top_level_error value into STATE.md as the ## Iteration 0 — baseline entry: top_level_error: <value> + normalized_hash: <sha256 of normalized string, first 12 chars>.

Read the full file on GitHub · 315 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 16d ago Changed · +75 lines · +70 tokens per session 0774fe9d9d45
  2. 2mo ago Changed a6b9582dca81
  3. 3mo ago First seen · 240 lines · 0 tokens per session scan A e5cb8f289931

Subscribe to this mod's changes

subagent-diagnose is a command published in the GitHub repository damusix/atomic-claude (118 stars, last pushed today), licensed MIT. It adds 70 tokens to every session and 5,023 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

subagent-diagnose compared with commands from other repositories

subagent-diagnose next to 6 commands from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
subagent-diagnosedamusix/atomic-claudeCommand118todayMITA70Claude Code
agentloop-audit-queryalibaba/loongsuite-pilotCommand275todayApache-2.0A20Claude Code
maintainrandomittin/heimdallCommand5todayMITA40Claude Code
optimizewesammustafa/opencode-primerCommand4225mo agoMITA10Claude Code, OpenCode
dev-error-handlingchristopherlouet/claude-baseCommand64d agoMITA0Claude Code
ops-hotfixchristopherlouet/claude-baseCommand64d agoMITA0Claude Code
perf-profile.templateevan043/claude-cli-advanced-starter-packCommand624mo agoMITA0Claude Code