do-diagnose
Unified diagnostic and code remediation engine — root cause analysis, performance profiling, security auditing, and targeted refactoring. Use whenever something is broken, failing tests, throwing errors, slow, insecure, or in need of cleanup, and the user wants root-cause evidence before any fix (e.g. 'why is this crashing', 'debug this failure', 'this endpoint feels slow', 'audit for security issues'). Always activate this skill when investigating defects, performance bottlenecks, or code smells before modifying code.
- License 许可
- MIT
- 最近更新
- 2026-11-10
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- do-diagnose
- effort
- medium
- description
- Unified diagnostic and code remediation engine — root cause analysis, performance profiling, security auditing, and targeted refactoring. Use whenever something is broken, failing tests, throwing errors, slow, insecure, or in need of cleanup, and the user wants root-cause evidence before any fix (e.g. 'why is this crashing', 'debug this failure', 'this endpoint feels slow', 'audit for security issues'). Always activate this skill when investigating defects, performance bottlenecks, or code smells before modifying code.
- argument-hint
- [target|issue] [--focus quality|security|performance|architecture] [--fix]
02 资源文件 3
- 参考文档references/code_audit.md863 B
- 参考文档references/refactoring.md565 B
- 参考文档references/root_cause.md750 B
03 SKILL.md 正文
do-diagnose
Unified diagnostic and code improvement engine. Replaces separate analyze/troubleshoot/reflect/improve tools with a single evidence-first diagnostic workflow.
Invocation
/do-diagnose [target|issue] [--focus quality|security|performance|architecture] [--fix]
Behavioral Flow
- Resolve the Runtime Seam — every DoFlow runtime call in this skill goes through the seam.
Resolve it once here and reuse
$DOFLOWfor every later call in this skill:
# Resolve the DoFlow runtime: nearest project install wins, then the global one.
D=$PWD; while [ "$D" != / ] && [ ! -x "$D/.doflow/scripts/doflow/bin/doflow-run" ]; do D=$(dirname "$D"); done
DOFLOW="$D/.doflow/scripts/doflow/bin/doflow-run"
[ -x "$DOFLOW" ] || DOFLOW="$HOME/.doflow/scripts/doflow/bin/doflow-run"
[ -x "$DOFLOW" ] || { echo "doflow: no runtime found in any .doflow/ above $PWD, nor at $HOME/.doflow. Run: npx @khoavu882/doflow install -t <harness>" >&2; exit 2; }
Run every command below from the project root — the walk-up starts at $PWD. On exit 2, print the message verbatim and stop; it names every path searched.
"$DOFLOW" paths --json
Once per stage, after feature_slug resolves, run "$DOFLOW" attendance --task-id "<feature_slug>"; unattended → the guidance tree's WORKFLOW_HANDOFF.md § Unattended stage.
- Propose the Task Class; the Runtime Validates It — the investigation mode is not a flag, it is the task class, so settle the class first. Propose exactly one id:
"$DOFLOW" classify --task-class "<proposed>" --calling-skill do-diagnose --view brief --json
Branch on outcome, not the exit code.
ACCEPTED— the returnedworkflowis this run's plan of record; readstages,gatesandhandoffoff it rather than from memory.REJECTED— stop. Printmessageverbatim (it already namesvalidClassesand anysuggestions), ask the user to choose fromvalidClasses, then re-validate. Never substitutefeature. A rejection may be about you rather than the class (reason: caller-not-a-stage). Then the fix is to propose one of the classes infit.hostingClasses, or to hand the work to the skill this class names for the stage you meant — not to re-propose the same class.- Exit 2 — surface the message verbatim and stop.
This skill is one of the accepted workflow's analysis stages — root-cause for bug,
architecture-mapping for refactor, usage-impact for dependency-change. A workflow that
declares no analysis stage is not a workflow to diagnose under: say so and re-propose the class.
- A performance or security investigation is not its own class: it is classed by what the work
is —
bugwhen behavior is wrong now,refactorwhen structure changes with behavior held fixed,researchwhen the deliverable is a written answer.--focusis what narrows such a run to one domain; it never changes the class. - While diagnosing, no stage this skill serves has a readiness template — do not call
readinessand do not report one as skipped. Step 6's--fixpath is different: it enters the validated class's implementation stage, which does.
-
Derive Intent & Scope from the Accepted Class:
bug→ reproduce the issue, isolate the cause via stack traces/diffs, formulate a hypothesis. Consult this skill's ownreferences/root_cause.md.refactor→ identify dead code, code smells, god functions, and structure cleanups. Consultreferences/refactoring.md.dependency-change→ map who uses the dependency and what the change reaches.--focus performance→ profile execution, detect hot paths, identify algorithmic complexity (O(n²)) or N+1 queries, within whichever class was accepted.--focus security→ static scan for secrets, unsanitized inputs, auth gaps, or vulnerability signatures. Consultreferences/code_audit.md.--focus quality|architecture→ narrow to maintainability or to boundary/structure concerns.- With no
--focus, investigate the whole reported symptom rather than picking a domain.
-
Evidence-First Diagnosis:
- Confirm root cause with concrete evidence before proposing any changes.
- Resolve each retrieval need through the router rather than reaching for a habitual tool:
"$DOFLOW" route --intent <locate-known-symbol|locate-concept|trace-dependency|estimate-blast-radius|inspect-history|verify-runtime-behavior> --json. - MCP
context7: when diagnosing library or dependency behavior, verify interface claims perMCP_Context7.md.
Discovery first. A broad pass over reported scope to find terminology, surfaces, and competing readings before concluding. Then targeted passes per question.
Name competing hypotheses from discovery before testing; state what falsifies each. Hypotheses that cannot be falsified warrant no retrieval.
Stop when every hypothesis the contract names has an answer or a stated gap, and the last round produced no new hypothesis. A round that only restates what you already have is the last round. Report the remaining gaps rather than continuing.
- Then propose ranked fix options with blast-radius ratings (Low / Medium / High). Those ranked options are the remediation plan step 6 asks the user to approve. Stops after producing them; never begins edits here.
- Batch This Stage's Evidence:
- One pass at the end of the diagnosis, never one call per finding.
<task id>is the unit these stores key on: the plan task id when one exists, otherwise the feature slug or the issue id you are diagnosing. Use the same id for everyevidence,claimandreadinesscall in the run."$DOFLOW" evidence --task-id "<task id>" --action add --batch <batch>.json --json "$DOFLOW" claim --task-id "<task id>" --action add --role root-cause --statement "<the root cause, in one sentence>" - This stage's items are what the investigation observed: stack frames, log lines, test results and diff hunks are extracted; your reading of them is inferred. A diagnosis is where inference most easily passes for observation, so never merge the two into one reported line.
- One pass at the end of the diagnosis, never one call per finding.
Item schema, provenance rules, and the refused-field list: the guidance tree's references/EVIDENCE_LEDGER.md. Read it before writing the batch.
- The root cause enters as a claim and is stored as a
hypothesis.--role root-causedeclares what the claim is to the task — the bug class's readiness contract only accepts a supported claim carrying that role, so a supported claim about something unrelated cannot stand in for the cause. It becomes supported only through linked evidence, recorded after the batch lands:
An evidence id the ledger does not hold is refused (exit 2), not graded — so write the batch first, then link. A plausible story that explains the symptom is not support, and a symptom reproducing is evidence of the symptom, not of the cause."$DOFLOW" claim --task-id "<task id>" --action link --claim-id "<claim id>" --evidence-id "<evidence id>" --relation supports
-
Remediation (
--fix):- Only apply modifications when
--fixis passed and after the user approves the remediation plan. --fixperforms the edit that the validated class's workflow places behind its implementation stage, so consult that same contract first — never a new one. A--fixrun is a declared one-off edit, not an orchestrated run, and states that mode explicitly:"$DOFLOW" readiness --task-class "<validated class>" --task-id "<task id>" --mode standalone --json. Both--task-classand--task-idare required; omitting either exits 2 and names the valid set. Act onstageEntry.decision, never the exit code or your own reading ofstate:STOP→ do not edit, surface the conflicted claim;ASK_USER→ ask the owed decision and wait;ENTER→ proceed — in standalone mode that includesNEEDS_EVIDENCE, where the unmet contract is reported, not enforced, so relay what is missing rather than presenting the fix as fully evidenced. The verb exits 0 for every state it computes, so a zero exit is not a green light, and no state is ever expressed as a number or a percentage.- All four states are reachable, so the verdict is about this task:
NEEDS_EVIDENCEuntil step 5's batch is recorded,READYonce it covers the contract,BLOCKEDon a claim whose evidence contradicts itself. Run step 5's write before this call — grading an empty ledger reports a missing diagnosis you have already done.--verification-plan,--scopeand--invariantsare inputs you state, not evidence the gate measured: the report echoes them back ascallerAsserted, so pass them when true and say which requirements rest on a statement rather than on a record. Never writeREADYthe gate did not give. - If the validated class declares no readiness template — the resolved workflow's
requiresImplementationReadinessisfalseand the verb exits 1 saying so — do not invent one and do not proceed anyway: the change is its own task under its own class. Say that and stop. - Verify fixes immediately by re-running tests.
- Only apply modifications when
-
Iteration is Bounded by the Runtime, Not by You:
- After a remediation pass that does not hold, classify the failure and take the action it
returns rather than choosing your own retry count:
"$DOFLOW" recover --error "<message>" --failed-check "<name>" --iteration <n> --json. Exit 0 means a bounded retry is available — repeat steps 3–5 under it. Exit 1 means the loop must stop; report where it stopped instead of trying again. - Risk assessment before remediating production or shared infrastructure is step 6's readiness call, which always runs. There is no separate opt-in for it.
- Every runtime call above is recorded in the run ledger as it happens;
"$DOFLOW" tracereads it back. Nothing needs to be switched on for that.
- After a remediation pass that does not hold, classify the failure and take the action it
returns rather than choosing your own retry count:
Failure Investigation Invariants
- Root cause always — understand WHY, not just THAT; fix the cause, not the symptom.
- Never skip, disable, or comment-out tests or validation checks to pass builds.
Red Flags
Rows come only from recorded bench failures (case id in brackets).
| Rationalization | Reality | Required action |
|---|---|---|
"It's a slow-suite report, so --focus performance settles it; what to measure can wait." |
[do-diagnose/1] routed the report but never named the repo's test command as the thing to measure. | Name the repo's own test command (its package.json script or CI command) and time it as the baseline before any hypothesis. |
Boundaries
Will: Propose a task class and have the runtime validate it, reproduce active issues, perform
multi-domain static/runtime audits, batch the stage's evidence and claims, and rank remediation
strategies.
Will Not: Apply edits without --fix and explicit confirmation; bypass or disable tests to
force passing status; diagnose under a class the runtime rejected or replaced with feature;
call readiness for a stage that declares no template; or express evidence, an estimate or readiness as a number, a percentage or a confidence.
04 同仓库更多 Skills
beta
暂无简介
alpha
暂无简介
do
DoFlow universal dispatcher and the entry point for a plain code-change request: it classifies the task, routes it to the matching /do-* workflow and applies that workflow's gates. Use whenever the user asks to add, fix, change or build something in code without naming a /do-* skill, a request bundles several unrelated asks, or needs a tool recommendation or effort estimate first (e.g., 'add a retry to the upload client in src/upload.js', 'give me a rough estimate for this change', 'first do X, then document Y'). Skip it for questions about how existing code behaves, explanations, reviews, and work already inside a /do-* skill.
do-test
Execute project builds, automated test suites, and coverage verification with intelligent error reporting across whatever toolchain the repo already uses. Use whenever the user wants to run existing tests, execute test suites, verify builds, check test coverage, or check compile status (e.g., 'run the tests', 'execute test suite', 'check coverage', 'verify build', 'does this still build'). Always activate this skill when verifying test suites or running builds without writing new application code.
do-plan
Generate the implementation plan (HOW) and dependency-ordered task checklist from requirement.md + design.md (plus design/specs.md's IC-### interface contracts when the feature has one), with a Constitution Check gate, as Phase 3 of the doflow chain. Use whenever requirement.md and design.md exist and the next step is creating an actionable, owner-and-file-scoped task breakdown before implementation, or when the user says 'create an implementation plan', 'break this down into tasks', 'plan the work', or 'plan Phase 3'. Always activate this skill before executing feature implementation.
do-implement
Direct, standalone code implementation from a description, /do-code-review findings, or an existing task — no DoFlow chain artifacts required. Use when the user names /do-implement, says 'now implement that', 'fix what the review found' or 'address these comments', or /do routed a bug, refactor, dependency change or small edit here. A plain change request that names no /do-* skill goes to /do first, which classifies it and routes it back here when it fits. Skip it for questions, reviews, and new features that need the full chain.