subagent-diagnose

subagent-diagnose is a command for coding agents from damusix/atomic-claude. It costs 0 tokens per session (4,369 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

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.

agentmods
npx agentmods add commands/damusix/atomic-claude/subagent-diagnose
Clone the repo
git clone --depth 1 https://github.com/damusix/atomic-claude

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.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.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,369 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00000 $0.04369
Opus 5 $0.00000 $0.02184
Sonnet 5 $0.00000 $0.00874
Haiku 4.5 $0.00000 $0.00437

Measured 5d ago against content hash e5cb8f289931, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 5d 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 · 240 lines

How it starts

The opening of the file, as written. The whole thing — 240 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

Step Action
0.1 Resolve argument to a run ID. If no arg given: gh run list --status failure --branch <current-branch> --limit 1 --json databaseId,name,headSha,createdAt. Refuse if no failed run found: no failed run found on branch <branch>. provide a run-id, pr#, or workflow.yml as argument.
0.2 Capture into BRIEF.md source-pointer section: branch, head SHA, base SHA (git merge-base HEAD origin/main), workflow name, failed step name (from gh run view <id> --json jobs), failure timestamp, provider URL.
0.3 Topic: diagnose-ci-<run-id> — the run id distinguishes the bundle, not a date. Concurrent-run guard: if atomic scratchpad path "<topic>" resolves, refuse: scratchpad already exists for <topic>; atomic scratchpad archive it or pick a different topic suffix. Stop. Per axiom 3, no silent overwrite. Otherwise run atomic repo init if command -v atomic succeeds (guarantees the .claude/ layout and ignore rules; skip silently otherwise), then SCRATCH=$(atomic scratchpad new "<topic>" --purpose diagnose).
0.4 Dispatch a general-purpose subagent (model: haiku, foreground, read-only) with this brief: Fetch full logs for CI run <id>, failed step "<step-name>". 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>".
0.5 Read CONTEXT.md. Copy top_level_error value into STATE.md as ## Iteration 0 — baseline entry: top_level_error: <value> + normalized_hash: <sha256 of normalized string, first 12 chars>.

Read the full file on GitHub · 240 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. 5d 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 (84 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 4,369 tokens. 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.