From 88406b0d0953dedf26c5d7237284bd96b5385c2c Mon Sep 17 00:00:00 2001 From: River Bailey Date: Thu, 12 Nov 2026 08:13:41 -0700 Subject: [PATCH 01/10] docs(plans): record the scope boundary for investigation types --- .../artifacts/scope-boundary.md | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 docs/plans/investigate-types/artifacts/scope-boundary.md diff --git a/docs/plans/investigate-types/artifacts/scope-boundary.md b/docs/plans/investigate-types/artifacts/scope-boundary.md new file mode 100644 index 00000000..7b8cb2e1 --- /dev/null +++ b/docs/plans/investigate-types/artifacts/scope-boundary.md @@ -0,0 +1,56 @@ +# Scope Boundary: Investigation Types + +## Work Item + +No work item exists. The operator's request, typed when invoking `/han-planning:plan-a-change`, is the only boundary +this run has. + +## Stated Scope + +> update the `/investigate` skill so that there are investigation types, similar to what was done for the code review +> skill. the initial set of modes are "bug" and "how it works", and "available options". the current implementation is +> built for investigating bugs. but a lot of the investigation i do is not centered around bugs, but rather +> investigation into how the code works and what options are available for doing work. the specifics of each mode, +> including the output template, need to be split around these types. if no type is specified when calling +> `/investigate`, determine the type automatically via the prompt context. if a type is specified, first validate that +> the specified type is acceptable for the prompt, and suggest an alternative type when needed. once a type is +> determined, run the skill with that specific type + +## Stated Exclusions + +None stated. + +## Operator-Stated Scope + +Confirmed in the Step 1.5 confirmation turn, in answer to the proposed area, the `research` overlap, and the plan +location: + +> i agree with your split recommendation between research and investigate. this all looks good + +The confirmed area: + +1. `han-coding/skills/investigate/`: `SKILL.md` (including its `description` and `argument-hint`) and + `references/template.md`, split per type. +2. The documentation that describes `investigate`: `han-coding/docs/skills/investigate.md`, the `han-coding/README.md` + scent line, `docs/skills/README.md`, and the workflow and how-to pages that mention it. +3. `han-atlassian/skills/investigate-to-confluence/`, which wraps `investigate` and describes itself as bug-only, plus + its long-form doc. +4. The `investigate` evals under `evals/investigate/`. +5. The `research` skill's description and docs, reworded to the agreed split: `investigate` answers questions about + this codebase; `research` covers the open web and prior art. + +Plan location confirmed: `docs/plans/investigate-types/`. + +## Direction of Travel + +The bug-only shape of `investigate` is being replaced by a typed shape whose first type, `bug`, carries today's +behavior. Nothing is deprecated outright. The `research` skill stays, with its boundary against `investigate` +redrawn. + +## Visual Material Received + +None received. This skill plans code structure; the visual-material convention does not apply. + +## Record Provenance + +Established by `plan-a-change` on 2026-11-12. No prior record existed and no conflict was resolved. From ba25cf021f98cb644f339e90bfea744254c19a71 Mon Sep 17 00:00:00 2001 From: River Bailey Date: Thu, 12 Nov 2026 08:15:57 -0700 Subject: [PATCH 02/10] docs(plans): record current-state findings for investigation types --- .../artifacts/current-state-findings.md | 286 ++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 docs/plans/investigate-types/artifacts/current-state-findings.md diff --git a/docs/plans/investigate-types/artifacts/current-state-findings.md b/docs/plans/investigate-types/artifacts/current-state-findings.md new file mode 100644 index 00000000..4c1365cd --- /dev/null +++ b/docs/plans/investigate-types/artifacts/current-state-findings.md @@ -0,0 +1,286 @@ +# Current State Findings: Investigation Types + +## Provenance + +Produced by this run's own discovery round on 2026-11-12. No prior findings report existed. + +- `han-core:structural-analyst` was briefed on `han-coding/skills/investigate/` (SKILL.md and `references/template.md`), + the `code-review` type mechanism as precedent, and `han-atlassian/skills/investigate-to-confluence/`. Its findings + are S1 to S6. +- `han-core:behavioral-analyst` was briefed on the same skill plus the agents it dispatches, the evidence and config + rules, the Confluence wrapper, the evals, and the `research` description. Its findings are B1 to B12. +- `han-core:concurrency-analyst` was not dispatched: the area is Markdown prompt instructions with no shared mutable + state. +- The run's own sweep covered CLAUDE.md, `docs/adr/`, the long-form doc, the cross-plugin docs, and git history. + +## Project Context + +- **Stack:** Markdown skill, agent, and doc content, plus Bash scripts with Bats tests. `npm test` runs every `*.bats` + file; `npm run lint` runs Prettier, ShellCheck, and file-hygiene hooks. +- **Conventions source:** CLAUDE.md (`## Conventions`, `## Project Discovery`), and the authoring guidance under + `han-plugin-builder/skills/guidance/references/`. +- **ADRs found:** `docs/adr/0001-project-configurable-default-swarm-size.md`, the one ADR. It does not bear on this + change. +- **Coding standards found:** none as a standalone file. CLAUDE.md conventions govern: one canonical source per + concept, every long-form doc links up, uniform voice, YAGNI for docs, and indexes stay complete. +- **Recent churn:** in the last 90 days, `investigate/SKILL.md` changed in 3 commits, and + `investigate-to-confluence/SKILL.md` and `han-coding/docs/skills/investigate.md` in 1 each. All were cross-skill + sweeps (config probe, readability standard, boundary docs), not investigate-specific redesigns. The most recent + precedent is `code-review` review types, built from `docs/plans/code-review-types/`. + +## Gaps + +- No ADR or coding standard covers how a skill declares and parses typed arguments. The only precedent is + `code-review`'s `## Review Types` section and its `review-types.bats` test. +- `investigate` has no Bats test, so no cross-file agreement in it is machine-checked today. +- No agent in the roster compares implementation options within a codebase. `research-analyst` covers the open web. +- No eval exercises a non-bug investigation, an explicit type, or the boundary with `research`. + +## Findings + +### C-1: The bug framing runs through every step of SKILL.md, with no seam + +- **Claim:** The config read, evidence rule, lazy-create rule, E-series compilation, validator mechanics, + readability-editor pass, and user review are type-agnostic. Everything else is phrased around a symptom, a root + cause, and a fix. +- **Location:** `han-coding/skills/investigate/SKILL.md`: Approach bullets L30-34, Step 1 L62, Step 2 L92-104, Step 3 + L106-121, Step 4 L125-132, Step 5 L141-143. +- **Evidence:** + ``` + - Trace backward from symptoms — don't guess, follow the code. + Classify the bug from the user's symptom description before launching. + ## Step 2: Document Root Cause + ## Step 3: Plan the Fix + Design a fix that **directly addresses the root cause** from Step 2 + ``` +- **Raised by:** structural-analyst S1, behavioral-analyst B4 +- **Confidence:** Verified +- **Bears on:** S-3, S-4, S-5 + +### C-2: The description sends "how something works" and "options" to `research` + +- **Claim:** `investigate`'s description excludes both new types by name, and `research`'s description claims them. +- **Location:** `han-coding/skills/investigate/SKILL.md` L8-9; `han-research/skills/research/SKILL.md` L3-6. +- **Evidence:** + ``` + Does not research open-ended options, prior art, or how something works when nothing is broken — use research for that. + ``` + ``` + Researches an open-ended question — options, possible solutions, prior art, trade-offs, or how something works + ``` +- **Raised by:** structural-analyst S1, behavioral-analyst B4 and B10 +- **Confidence:** Verified +- **Bears on:** S-1, S-10 + +### C-3: The argument is one free-text blob with no parsing rule + +- **Claim:** There is no `arguments:` key and no first-token rule. The output path is separated from the symptom by the + model's judgment alone. +- **Location:** `han-coding/skills/investigate/SKILL.md` L12. +- **Evidence:** + ``` + argument-hint: "[symptom or problem description, and optionally an output path]" + ``` +- **Raised by:** behavioral-analyst B1 +- **Confidence:** Verified +- **Bears on:** S-2 + +### C-4: The output file's location and name are never specified, and `Write` is not in `allowed-tools` + +- **Claim:** "The plan file" is referenced four times with no antecedent. `allowed-tools` has no `Write`, `Edit`, or + `Skill`, though the skill writes a file and invokes `readability-guidance`. `code-overview`, a sibling that writes a + file, lists `Write`. +- **Location:** `han-coding/skills/investigate/SKILL.md` L13, L43, L94, L114, L141. +- **Evidence:** + ``` + allowed-tools: Read, Glob, Grep, Agent, Bash(bash "${CLAUDE_PLUGIN_ROOT}/scripts/han-config-dir.sh") + ``` + ``` + Write to the plan file using the template at [template.md](./references/template.md). + ``` +- **Raised by:** behavioral-analyst B2 +- **Confidence:** Verified +- **Bears on:** S-2, S-9 + +### C-5: One template, with shared carriers and bug-only sections + +- **Claim:** The Evidence Summary (E-N), Validation Results (V-N), Adjustments Made, and Confidence Assessment are + generic, about 70 lines. The title, Summary fields, Problem Statement, Root Cause Analysis, and Planned Fix are + bug-only. Coding Standards Reference is tied to "the fix". +- **Location:** `han-coding/skills/investigate/references/template.md` L1, L15-19, L21-64 (bug-only), L66-133 (generic), + L135-141. +- **Evidence:** + ``` + # Investigation: {Issue Title} + - **Root Cause:** + - **Fix:** + - **Why Correct:** + ``` +- **Raised by:** structural-analyst S2, behavioral-analyst B4 +- **Confidence:** Verified +- **Bears on:** S-6, S-7 + +### C-6: The specialist roster, its triggers, and its prompts are inline and symptom-keyed + +- **Claim:** At least two `evidence-based-investigator` agents always run. Three specialists join on symptom triggers, + each with an inline prompt containing `{symptom}`. `## Extra Agents` joins "under the same symptom-driven selection". + There is no separate dispatch file. +- **Location:** `han-coding/skills/investigate/SKILL.md` L55-90. +- **Evidence:** + ``` + Extra agents named in the project config's `## Extra Agents` list join this conditional-specialist pool under the same + symptom-driven selection ... dispatch one only when the classified bug type matches its stated specialty + ``` +- **Raised by:** structural-analyst S3, behavioral-analyst B5 and B7 +- **Confidence:** Verified +- **Bears on:** S-4 + +### C-7: `evidence-based-investigator` is bug-framed; `codebase-explorer` and `behavioral-analyst` are neutral + +- **Claim:** `evidence-based-investigator` describes itself as for "a bug, failure, or unexpected behavior" and runs + five fixed, symptom-first protocols. `codebase-explorer` is built "for documentation or understanding" but runs on + haiku with no git access. `behavioral-analyst` takes a focus area, not a symptom. +- **Location:** `han-core/agents/evidence-based-investigator.md` L3-5; `han-core/agents/codebase-explorer.md` L3-7; + `han-core/agents/behavioral-analyst.md` L3-10. +- **Evidence:** + ``` + Use when thorough, multi-angle research into a bug, failure, or unexpected behavior is needed. + ``` + ``` + Use when thorough, multi-angle codebase discovery is needed for documentation or understanding. + tools: Read, Glob, Grep, Bash(find *) + model: haiku + ``` +- **Raised by:** behavioral-analyst B5 +- **Confidence:** Verified for the descriptions. Unverified for how each agent behaves when briefed off-type; nobody + ran one. +- **Bears on:** S-4 + +### C-8: `adversarial-validator` requires a planned fix and mandates challenging it + +- **Claim:** The validator expects three inputs and must run strategies 1-3 on every run. Strategy 2 attacks a fix, so + a how-it-works run gives it nothing to attack. Strategies 1 and 4 apply to any evidence set. +- **Location:** `han-core/agents/adversarial-validator.md` L13, L40-58. +- **Evidence:** + ``` + You will receive an evidence summary, root cause analysis, and planned fix. Attack all three. + You MUST attempt strategies 1-3 on every run. + ### 2. Challenge the Fix + ``` +- **Raised by:** behavioral-analyst B6 +- **Confidence:** Verified +- **Bears on:** S-5, S-11 + +### C-9: The `code-review` type pattern, and what does not transfer + +- **Claim:** `code-review` keeps the only list of type tokens in a `## Review Types` table, one data file per type under + `references/types/` with a fixed section contract, and a Bats test that holds the table, the files, and the + argument-hints in agreement. Its default run (a union of types), config-declared types, retired size words, and the + rule that a typed run never names another type do not fit `investigate`, which must resolve to exactly one type and + must suggest an alternative. +- **Location:** `han-coding/skills/code-review/SKILL.md` L96-153; `han-coding/skills/code-review/scripts/review-types.bats`. +- **Evidence:** + ``` + A review type names the one concern a run covers. Each shipped type is a data file under `references/types/`, and this + table is the only list of shipped type tokens: + ``` +- **Raised by:** structural-analyst S4 +- **Confidence:** Verified for the contract and test. Unverified for code-review Steps 2-10, which were not read. +- **Bears on:** S-3, S-12 + +### C-10: The type classification is held only in context, with no announcement or tie-break + +- **Claim:** Today's bug classification is held in the model's context and never written out. Nothing covers an + ambiguous prompt, and there is no ask-the-user step. +- **Location:** `han-coding/skills/investigate/SKILL.md` L62, L85. +- **Evidence:** + ``` + Classify the bug from the user's symptom description before launching. + ``` +- **Raised by:** behavioral-analyst B11 and B12 +- **Confidence:** Verified +- **Bears on:** S-2 + +### C-11: The stop point says approval triggers implementation, but nothing implements + +- **Claim:** Step 5 ends with approval "triggering implementation". The Confluence wrapper has to tell `investigate` + not to implement. No mechanism in the skill implements anything. +- **Location:** `han-coding/skills/investigate/SKILL.md` L163; `han-atlassian/skills/investigate-to-confluence/SKILL.md` + L79-81. +- **Evidence:** + ``` + Present the plan file to the user for approval. The user can approve the plan (triggering implementation) or provide + feedback for revisions. + ``` +- **Raised by:** behavioral-analyst B3 and B8 +- **Confidence:** Verified +- **Bears on:** S-8 + +### C-12: `investigate-to-confluence` restates the bug-only shape and rejects non-bug requests + +- **Claim:** The wrapper forwards the user's text verbatim and captures the path written, but it does not parse + headings. It restates today's section list, and its Step 1 checks that the request names "a bug, failure, error, + integration, or unexpected behavior". +- **Location:** `han-atlassian/skills/investigate-to-confluence/SKILL.md` L4-7, L37-39, L57-58, L83. +- **Evidence:** + ``` + `han-coding:investigate` produces a **single** report file (the investigation plan: problem statement, evidence + summary, root cause analysis, planned fix, validation results, and summary) + ``` +- **Raised by:** structural-analyst S5, behavioral-analyst B8 +- **Confidence:** Verified +- **Bears on:** S-11 + +### C-13: Evals assert "Root Cause" and cover only bug triggering + +- **Claim:** Four evals. One asserts the result contains "Root Cause" on a bug prompt, one asserts its absence on a + no-op. None covers a non-bug type, an explicit type, a mismatched type, or the `research` boundary. +- **Location:** `evals/investigate/tests.json` L5-42. +- **Evidence:** + ``` + { "result-contains": "Root Cause" }, + ``` +- **Raised by:** structural-analyst S6, behavioral-analyst B9 +- **Confidence:** Verified for the assertions. Unverified for the scaffold's contents. +- **Bears on:** S-13 + +### C-14: Other surfaces describe `investigate` as bug-only + +- **Claim:** The long-form doc, the `han-coding` README scent line, the skills index, `docs/workflows.md`, the how-to + guides, the `research` long-form doc, and the Confluence wrapper's doc all describe `investigate` as bug-only. The + descriptions of `code-overview` and `code-walkthrough` route "diagnose bugs" to `investigate` and claim explaining + code for themselves. +- **Location:** `han-coding/docs/skills/investigate.md` L13-17 and L55-56; `han-research/docs/skills/research.md` L24, + L79, L238; `docs/skills/README.md` L54-56; `han-coding/README.md` L31; + `docs/how-to/research-a-decision.md` L11; `han-coding/skills/code-overview/SKILL.md` L11. +- **Evidence:** + ``` + - **Open-ended research.** Use [`/research`](...) when nothing is broken and you want options, prior + art, or how something works before committing to a direction. + ``` + ``` + - **Question-shaped, not symptom-shaped.** `/investigate` starts from something broken and ends at a fix. + ``` +- **Raised by:** structural-analyst S6; run's own sweep +- **Confidence:** Verified +- **Bears on:** S-10, S-14 + +### C-15: Web evidence is referenced but unreachable + +- **Claim:** The evidence rule section of SKILL.md talks about web-source context, but neither the skill nor + `evidence-based-investigator` has a web tool. Web context only arrives if the user pastes it. +- **Location:** `han-coding/skills/investigate/SKILL.md` L13, L38-42. +- **Evidence:** + ``` + Web-source context (RFCs, vendor docs, Stack Overflow, blog posts) carries the trust-class label "web" + ``` +- **Raised by:** behavioral-analyst B10 +- **Confidence:** Verified +- **Bears on:** S-4, S-10 + +## Findings No Agent Could Audit + +- Whether an LLM actually classifies a given prompt into the intended type. Only an eval run closes this; nobody ran the + evals. +- How `evidence-based-investigator`, `behavioral-analyst`, and `codebase-explorer` behave when briefed on a non-bug + question. Closing this takes a trial run of each type after the build. From c731a710d005f87b710e370d47e28b3ca27beb34 Mon Sep 17 00:00:00 2001 From: River Bailey Date: Thu, 12 Nov 2026 08:23:31 -0700 Subject: [PATCH 03/10] docs(plans): draft the investigation types change plan --- docs/plans/investigate-types/change-plan.md | 541 ++++++++++++++++++++ 1 file changed, 541 insertions(+) create mode 100644 docs/plans/investigate-types/change-plan.md diff --git a/docs/plans/investigate-types/change-plan.md b/docs/plans/investigate-types/change-plan.md new file mode 100644 index 00000000..956e24f9 --- /dev/null +++ b/docs/plans/investigate-types/change-plan.md @@ -0,0 +1,541 @@ +# Change Plan: Investigation Types + +## Why This Change + +`/investigate` assumes every investigation is a bug, and most of the operator's investigations are not. In their words: +"a lot of the investigation i do is not centered around bugs, but rather investigation into how the code works and what +options are available for doing work." This is a constraint arriving: a new requirement the current structure cannot +absorb, because the bug framing is written into every step. The source is the operator's own request, recorded word for +word in `artifacts/scope-boundary.md`. + +## What Changes, In One Paragraph + +After this change, `/investigate` runs one of three investigation types: `bug`, `how-it-works`, or `available-options`. +Each type is a small data file that says how to recognize it, which agents to dispatch, what the analysis produces, how +the validator is briefed, who the report is for, and how the run ends. Each type has its own report template. The skill +keeps the steps every type shares: reading config, gathering numbered evidence, adversarial validation, the readability +passes, and the review loop. With no type named, the skill picks one from the question and says which it picked. With a +type named, it checks the type fits the question, and asks before switching when it does not. The `bug` type produces +the same report the skill produces today. + +## Current State + +The bug framing runs through every step of `SKILL.md`. The shared parts (config, evidence rule, E-series, validator +mechanics, readability passes) are already type-agnostic, but nothing separates them from the bug-specific parts +([C-1](artifacts/current-state-findings.md#c-1-the-bug-framing-runs-through-every-step-of-skillmd-with-no-seam)). The +skill's own description sends "how something works" and "options" to `research`, which claims both +([C-2](artifacts/current-state-findings.md#c-2-the-description-sends-how-something-works-and-options-to-research)). + +Three properties block the operator's goal directly: + +- **The argument has no parsing rule.** It is one free-text blob, so there is nowhere for a type token to go + ([C-3](artifacts/current-state-findings.md#c-3-the-argument-is-one-free-text-blob-with-no-parsing-rule)). +- **One template serves one shape.** The Evidence, Validation, and Confidence sections are generic, but the title, + Summary, Problem Statement, Root Cause Analysis, and Planned Fix are bug-only + ([C-5](artifacts/current-state-findings.md#c-5-one-template-with-shared-carriers-and-bug-only-sections)). +- **The roster and validator are symptom-keyed.** Specialist prompts carry `{symptom}` + ([C-6](artifacts/current-state-findings.md#c-6-the-specialist-roster-its-triggers-and-its-prompts-are-inline-and-symptom-keyed)), + `evidence-based-investigator` runs symptom-first protocols + ([C-7](artifacts/current-state-findings.md#c-7-evidence-based-investigator-is-bug-framed-codebase-explorer-and-behavioral-analyst-are-neutral)), + and `adversarial-validator` expects a planned fix + ([C-8](artifacts/current-state-findings.md#c-8-adversarial-validator-requires-a-planned-fix-and-mandates-challenging-it)). + +Around the skill, the Confluence wrapper rejects non-bug requests and restates today's section list +([C-12](artifacts/current-state-findings.md#c-12-investigate-to-confluence-restates-the-bug-only-shape-and-rejects-non-bug-requests)), +the evals cover only bug triggering +([C-13](artifacts/current-state-findings.md#c-13-evals-assert-root-cause-and-cover-only-bug-triggering)), and the docs +describe the skill as bug-only +([C-14](artifacts/current-state-findings.md#c-14-other-surfaces-describe-investigate-as-bug-only)). Nothing +machine-checks any cross-file agreement in the skill today. + +## Target State + +`SKILL.md` owns the flow every investigation shares. A type file owns everything that differs by type. A template owns +the type's report layout. The skill reads the type file's sections at fixed steps, and never branches on a type name in +its own prose ([D-1](artifacts/change-decision-log.md#d-1-one-type-file-per-type-read-at-fixed-steps)). + +### What `SKILL.md` owns + +- The config read, the evidence rule, and the lazy-create rule, as today. +- A `## Investigation Types` section holding the only list of shipped tokens: + + ```markdown + | Token | File | Purpose | + | ------------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------- | + | `bug` | [references/types/bug.md](./references/types/bug.md) | Find the root cause of a failure and plan the fix | + | `how-it-works` | [references/types/how-it-works.md](./references/types/how-it-works.md) | Explain how this codebase behaves, with cited evidence | + | `available-options` | [references/types/available-options.md](./references/types/available-options.md) | Compare the ways a piece of work could be done in this codebase | + ``` + +- Argument parsing and type resolution (Step 1, below). +- Evidence gathering: dispatch what the type's `## Dispatch` names, then compile the E-series. +- The `## Extra Agents` rule, reworded: an extra agent joins when the resolved type and the question match its stated + specialty. +- Validation mechanics: the verbatim brief, V-N items, Adjustments Made, Confidence Assessment. +- The readability-guidance invocation and the readability-editor pass, with the audience taken from the type file. +- Output location, and the stop. + +### The argument grammar + +([D-3](artifacts/change-decision-log.md#d-3-the-argument-grammar)) + +``` +args := [ type-token ] question [ out-path ] +type-token := a Token from ## Investigation Types; only the first whitespace-separated token; case-insensitive; never inside quotes +question := the remaining text, verbatim, as $question +out-path := the final token, when it ends in ".md" and starts with "/", "./", "../", or "~/"; removed from $question +``` + +When `$question` is empty and the conversation names no subject, the run stops with: +`investigate needs a question or symptom. Usage: /investigate [bug | how-it-works | available-options] [./path/report.md]. No investigation ran.` + +| Invocation | Type | `$question` | Out path | +| -------------------------------------------------------------------------- | -------------------------------------------- | ---------------------------------------------- | -------------------------- | +| `/investigate bug checkout returns 500 after the coupon change` | `bug`, named | `checkout returns 500 after the coupon change` | none | +| `/investigate how does the retry queue pick a backoff` | `how-it-works`, detected | the whole string | none | +| `/investigate how-it-work retry queue` | not a token; detected | the whole string | none | +| `/investigate bug reports from the importer are dropped` | `bug`, named | `reports from the importer are dropped` | none | +| `/investigate available-options add rate limiting ./docs/inv/rate-limit.md` | `available-options`, named | `add rate limiting` | `./docs/inv/rate-limit.md` | +| `/investigate why does deploy fail on docs/CHANGELOG.md` | `bug`, detected | the whole string | none (no path prefix) | +| `/investigate how-it-works login throws 500 since Tuesday` | `how-it-works`, named; fit check fails; asks | `login throws 500 since Tuesday` | none | + +### Type resolution + +([D-4](artifacts/change-decision-log.md#d-4-detection-tie-break-and-the-fit-check)) + +1. **No token.** Match `$question` against each type's `## Detection signals`. When more than one type matches, the + order is `bug`, then `available-options`, then `how-it-works`: a reported failure outranks everything, and an options + run already includes a current-state account. When none matches, the type is `how-it-works`, which assumes neither a + defect nor a planned change. The run proceeds without asking. +2. **Token named.** The fit check fails only when `$question` matches a signal of another type and no signal of the + named type. On failure, ask once with `AskUserQuestion`: + `You named {given}, but this reads as {suggested}, because it {the signal that matched}. Which type should this run use?` + with the options `{suggested} (suggested)` and `{given} (as named)`. Anything short of a clear mismatch keeps the + operator's choice. + +Once settled, the run prints one line before any dispatch: + +``` +announce := "**Investigation type:** " token ", " source ". " purpose +source := "named" | "detected from the question" | "switched from " token " at your request" +``` + +Example: `**Investigation type:** how-it-works, detected from the question. Explain how this codebase behaves, with cited evidence.` + +### The type-file contract + +([D-2](artifacts/change-decision-log.md#d-2-the-type-file-contract)) + +Each type file is `references/types/{token}.md`, titled `# Investigation type: {token}`, with exactly these seven `##` +sections in this order, outside any fence. A section with nothing to say holds the literal `none`; `## Dispatch` is +never `none`. + +| Section | Value form | Read at | +| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | +| `## Purpose` | one sentence, identical to the table's Purpose cell | Step 1 | +| `## Detection signals` | three or more bullets, `- {signal}` | Step 1 | +| `## Dispatch` | a numbered list, one entry per agent: ``N. `{plugin}:{agent}` ({count}, always \| when {trigger}): "{prompt using {question}}"`` | Step 2 | +| `## Analysis` | a numbered list of steps run between the evidence summary and validation, each naming the template section it fills | Step 3 | +| `## Validation brief` | exactly three bullets: `- Root cause analysis: {what this type passes}`, `- Planned fix: {what this type passes}`, `- Attack focus: {one sentence}` | Step 4 | +| `## Audience` | one sentence naming the reader | Steps 3 and 5 | +| `## Stop` | one blockquote, the closing message, with `{path}` as its only placeholder | Step 6 | + +A worked example, abridged, for `bug`: + +```markdown +# Investigation type: bug + +## Purpose + +Find the root cause of a failure and plan the fix + +## Detection signals + +- something fails, errors, crashes, or returns a wrong result +- something stopped working, or regressed after a change +- an error message, stack trace, or failing test is quoted + +## Dispatch + +1. `han-core:evidence-based-investigator` (2, always): "Investigate from the {angle} angle: {question}. ..." +2. `han-core:concurrency-analyst` (1, when the question involves intermittent failures, races, ordering, or load): "..." + +## Analysis + +1. Write the Problem Statement. +2. Write the Root Cause Analysis, citing E-items. +3. Resolve coding standards, then write the Coding Standards Reference and the Planned Fix. + +## Validation brief + +- Root cause analysis: the Root Cause Analysis section +- Planned fix: the Planned Fix section +- Attack focus: break the fix and the causal chain from root cause to symptom + +## Audience + +The engineer who will implement the fix and may be paged on the bug. + +## Stop + +> Report written to {path}. Approve the Planned Fix to implement it, or reply with corrections to revise the report. +``` + +### Per-type rosters + +([D-5](artifacts/change-decision-log.md#d-5-per-type-rosters-reuse-existing-agents)) + +| Type | Always | When relevant | +| ------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `bug` | `han-core:evidence-based-investigator` ×2 | `concurrency-analyst`, `behavioral-analyst`, `data-engineer`, on today's triggers | +| `how-it-works` | `han-core:codebase-explorer`, `han-core:behavioral-analyst` | `structural-analyst` (organization, dependencies, history), `concurrency-analyst`, `data-engineer` | +| `available-options` | `han-core:codebase-explorer`, `han-core:structural-analyst` | `behavioral-analyst`, `data-engineer`, `concurrency-analyst` | + +`evidence-based-investigator` stays with `bug`, because its protocols start from a symptom. `research-analyst` joins no +type: questions that need the open web or prior art go to `/research`, per the agreed split. + +### Validation per type + +([D-6](artifacts/change-decision-log.md#d-6-validation-maps-inputs-in-the-brief-the-agent-is-unchanged)) + +`han-core:adversarial-validator` is unchanged. Each type's `## Validation brief` says what it passes in the validator's +three input slots: + +| Type | Root cause analysis slot | Planned fix slot | Attack focus | +| ------------------- | --------------------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------ | +| `bug` | Root Cause Analysis | Planned Fix | Break the fix and the causal chain | +| `how-it-works` | the Answer and its flow trace | the Answer's coverage claim: the entry points and paths it calls complete | Find a caller, path, or input the explanation misses or gets wrong | +| `available-options` | Current State and Constraints | the recommended option and its change surface | Break the recommendation; test whether a rejected option rests on a false premise | + +### Per-type reports + +([D-7](artifacts/change-decision-log.md#d-7-per-type-report-templates-with-a-shared-fragment)) + +Each type has `references/templates/{token}.md`. The Evidence Summary, Validation Results, Adjustments Made, and +Confidence Assessment live once, in `references/evidence-and-validation.md`. Each template carries exactly one line +`` where that fragment's sections go. + +| Type | Title | Summary fields | Sections, in order | +| ------------------- | ------------------------------ | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | +| `bug` | `# Investigation: {title}` | Root Cause, Fix, Why Correct, Validation Outcome, Remaining Risks | Problem Statement, Root Cause Analysis, Planned Fix, shared fragment, Coding Standards Reference | +| `how-it-works` | `# How It Works: {subject}` | Answer, Entry Points, Validation Outcome, Remaining Risks | Question, Answer (lead sentence, then a numbered flow walkthrough), Key Components (Component, File, Role), shared fragment | +| `available-options` | `# Available Options: {goal}` | Recommendation, Options Considered, Deciding Factor, Validation Outcome, Remaining Risks | Goal and Constraints, Current State, Options (one `### Option N: {name}` each), Comparison, Recommendation, shared fragment, Coding Standards Reference | + +The `bug` template is today's `template.md` with the shared sections moved into the fragment, so a bug report reads the +same as it does now. + +### Output location and the stop + +([D-8](artifacts/change-decision-log.md#d-8-output-location-keeps-the-documented-contract)) + +The report path resolves in config-rule order: an out-path in the argument wins; otherwise a configured +`output-directory`, with the file written directly beneath it; otherwise the skill proposes a path, as the long-form doc +promises today, and writes there. The proposed filename is `investigate-{token}-{slug}.md`, where the slug is two to six +words from `$question` in `[a-z0-9-]`. "The plan file" becomes "the report file" throughout. + +The run ends by printing the type's `## Stop` +([D-9](artifacts/change-decision-log.md#d-9-the-stop-per-type)): + +- **`bug`:** `Report written to {path}. Approve the Planned Fix to implement it, or reply with corrections to revise the report.` +- **`how-it-works`:** `Report written to {path}. No code was changed. Reply with corrections to revise the report. To change this code next, run /plan-a-change with this report; to build new behavior on it, run /plan-a-feature.` +- **`available-options`:** `Report written to {path}. No code was changed. Reply with corrections to revise the report. To plan the recommended option, run /plan-a-change (restructuring existing code) or /plan-a-feature (new behavior) with this report; to weigh prior art beyond this codebase, run /research.` + +`allowed-tools` adds `Write`, `Skill`, and `AskUserQuestion` +([D-10](artifacts/change-decision-log.md#d-10-allowed-tools)). + +### The guarding test + +`han-coding/skills/investigate/scripts/investigation-types.bats` holds the cross-file agreements +([D-11](artifacts/change-decision-log.md#d-11-a-bats-test-holds-the-token-list-together)): + +1. Every `references/types/*.md` has a matching table row, a `references/templates/{token}.md`, and a token in both the + `argument-hint` and the `description`; every table row names an existing file. +2. Every type file's first line is `# Investigation type: {token}`, its `##` headings outside fences are exactly the + seven in order, and its `## Validation brief` carries the three pinned bullet prefixes. +3. Every agent in a `## Dispatch` entry resolves to an existing `{plugin}/agents/{agent}.md` in the repo. +4. Every template has exactly one `` line. + +## Surface Delta + +### S-1: `references/types/{bug,how-it-works,available-options}.md` — Added + +**Target state.** Three type files exist, each following the type-file contract. `bug.md` carries today's inline bug +content: the symptom-first approach, the two-investigator dispatch, the three specialist triggers with `{question}` in +place of `{symptom}`, the root-cause and fix analysis, today's audience, and today's stop. + +**Behavior.** Preserving for `bug`: the same agents run on the same triggers and the same sections are written. The two +new types are the requested addition. + +**Why.** The bug framing sits in six steps with no seam +([C-1](artifacts/current-state-findings.md#c-1-the-bug-framing-runs-through-every-step-of-skillmd-with-no-seam)). + +**Decision.** [D-1](artifacts/change-decision-log.md#d-1-one-type-file-per-type-read-at-fixed-steps), +[D-2](artifacts/change-decision-log.md#d-2-the-type-file-contract), +[D-5](artifacts/change-decision-log.md#d-5-per-type-rosters-reuse-existing-agents) + +### S-2: `SKILL.md` `## Investigation Types` — Added + +**Target state.** A section in `SKILL.md` holds the three-row token table, the only list of shipped tokens, and the +type-file contract. + +**Behavior.** Preserving. It adds a list; it changes no existing step. + +**Why.** The token list must agree across the table, type files, templates, `argument-hint`, and `description` +([C-9](artifacts/current-state-findings.md#c-9-the-code-review-type-pattern-and-what-does-not-transfer)). + +**Depends on.** S-1. + +**Decision.** [D-1](artifacts/change-decision-log.md#d-1-one-type-file-per-type-read-at-fixed-steps) + +### S-3: `SKILL.md` Step 1, argument parsing and type resolution — Added + +**Target state.** Step 1 parses the argument per the grammar, resolves the type by detection or fit check, asks once on +a clear mismatch, and prints the announcement line before any dispatch. + +**Behavior.** Changing, as requested: a question with no failure in it now runs as `how-it-works` or +`available-options`. The scope boundary records this requirement word for word, so it is not re-asked. A bug question +with no type token still resolves to `bug`. + +**Why.** There is no parsing rule and the classification is held only in context +([C-3](artifacts/current-state-findings.md#c-3-the-argument-is-one-free-text-blob-with-no-parsing-rule), +[C-10](artifacts/current-state-findings.md#c-10-the-type-classification-is-held-only-in-context-with-no-announcement-or-tie-break)). + +**Depends on.** S-2. + +**Decision.** [D-3](artifacts/change-decision-log.md#d-3-the-argument-grammar), +[D-4](artifacts/change-decision-log.md#d-4-detection-tie-break-and-the-fit-check) + +### S-4: `SKILL.md` Steps 2 to 6 — Re-scoped + +**Target state.** The steps own only the shared flow. Step 2 dispatches the type's `## Dispatch` entries plus matching +extra agents and compiles the E-series. Step 3 runs the type's `## Analysis` into its template. Step 4 briefs +`adversarial-validator` from `## Validation brief`. Step 5 writes the Summary and runs the readability-editor with the +type's `## Audience`. Step 6 resolves nothing new and prints the type's `## Stop`. + +**Behavior.** Preserving for `bug`. + +**Why.** [C-1](artifacts/current-state-findings.md#c-1-the-bug-framing-runs-through-every-step-of-skillmd-with-no-seam), +[C-6](artifacts/current-state-findings.md#c-6-the-specialist-roster-its-triggers-and-its-prompts-are-inline-and-symptom-keyed). + +**Depends on.** S-1, S-3. + +**Decision.** [D-1](artifacts/change-decision-log.md#d-1-one-type-file-per-type-read-at-fixed-steps), +[D-6](artifacts/change-decision-log.md#d-6-validation-maps-inputs-in-the-brief-the-agent-is-unchanged) + +### S-5: `references/template.md` — Removed + +**Target state.** `template.md` does not exist. Each type's report layout is `references/templates/{token}.md`, and the +shared Evidence and Validation layout is `references/evidence-and-validation.md`. + +**Behavior.** Preserving: the `bug` template keeps today's title, sections, and order. + +**Depends on.** S-6, S-7. + +**Migration.** The long-form doc's link at `han-coding/docs/skills/investigate.md` L150 points at +`references/templates/bug.md`. + +**Decision.** [D-7](artifacts/change-decision-log.md#d-7-per-type-report-templates-with-a-shared-fragment) + +### S-6: `references/templates/{bug,how-it-works,available-options}.md` — Added + +**Target state.** One template per type, with the title, Summary fields, and sections in the Per-type reports table, +and one shared-fragment marker each. + +**Behavior.** Preserving for `bug`. + +**Why.** [C-5](artifacts/current-state-findings.md#c-5-one-template-with-shared-carriers-and-bug-only-sections) + +**Decision.** [D-7](artifacts/change-decision-log.md#d-7-per-type-report-templates-with-a-shared-fragment) + +### S-7: `references/evidence-and-validation.md` — Added + +**Target state.** One file owns the Evidence Summary (E-N), Validation Results (V-N), Adjustments Made, and Confidence +Assessment layouts every type report carries. Its wording names "the findings" rather than "the fix". + +**Behavior.** Preserving: the sections a bug report carries are unchanged. + +**Why.** [C-5](artifacts/current-state-findings.md#c-5-one-template-with-shared-carriers-and-bug-only-sections) + +**Decision.** [D-7](artifacts/change-decision-log.md#d-7-per-type-report-templates-with-a-shared-fragment) + +### S-8: Output location and the stop — Re-scoped + +**Target state.** The report path resolves as Output location and the stop describes, the filename carries the type, +and the run ends with the type's `## Stop`. + +**Behavior.** Preserving for `bug`: the documented path contract (an explicit path wins; otherwise the skill proposes +one) and the approve-to-implement ending are unchanged. + +**Why.** [C-4](artifacts/current-state-findings.md#c-4-the-output-files-location-and-name-are-never-specified-and-write-is-not-in-allowed-tools), +[C-11](artifacts/current-state-findings.md#c-11-the-stop-point-says-approval-triggers-implementation-but-nothing-implements) + +**Decision.** [D-8](artifacts/change-decision-log.md#d-8-output-location-keeps-the-documented-contract), +[D-9](artifacts/change-decision-log.md#d-9-the-stop-per-type) + +### S-9: `SKILL.md` frontmatter — Re-scoped + +**Target state.** The `description` says `investigate` investigates this codebase in one of three types, named or +detected, and does not research the open web or prior art (use `research`). The `argument-hint` is +`"[type: bug | how-it-works | available-options] [question or symptom] [optional output path: ./path.md or /abs/path.md]"`. +`allowed-tools` adds `Write`, `Skill`, and `AskUserQuestion`. + +**Behavior.** Changing, as requested: the skill now triggers on how-it-works and options questions about the codebase. + +**Why.** [C-2](artifacts/current-state-findings.md#c-2-the-description-sends-how-something-works-and-options-to-research), +[C-4](artifacts/current-state-findings.md#c-4-the-output-files-location-and-name-are-never-specified-and-write-is-not-in-allowed-tools) + +**Decision.** [D-10](artifacts/change-decision-log.md#d-10-allowed-tools), +[D-12](artifacts/change-decision-log.md#d-12-the-research-boundary) + +### S-10: `research` description and docs — Re-scoped + +**Target state.** `research` covers the open web and prior art. Its description and long-form doc send questions about +how this codebase works, or which options it supports, to `investigate`. + +**Behavior.** Changing, as agreed in the confirmation turn. + +**Depends on.** S-9, in the same unit. + +**Decision.** [D-12](artifacts/change-decision-log.md#d-12-the-research-boundary) + +### S-11: `investigate-to-confluence` — Re-scoped + +**Target state.** The wrapper accepts any of the three types, passes a leading type token through first, passes its +`/tmp/investigate-{slug}.md` path as the final token, describes the report as "a single report whose sections follow the +investigation type", and still tells `investigate` to stop after the report. + +**Behavior.** Changing, as agreed: non-bug requests are accepted. + +**Why.** [C-12](artifacts/current-state-findings.md#c-12-investigate-to-confluence-restates-the-bug-only-shape-and-rejects-non-bug-requests) + +**Depends on.** S-3. + +**Decision.** [D-13](artifacts/change-decision-log.md#d-13-the-confluence-wrapper) + +### S-12: `scripts/investigation-types.bats` — Added + +**Target state.** A Bats test asserts the four agreements in The guarding test. + +**Behavior.** Preserving. + +**Depends on.** S-1, S-2, S-6. + +**Decision.** [D-11](artifacts/change-decision-log.md#d-11-a-bats-test-holds-the-token-list-together) + +### S-13: `evals/investigate/` — Re-scoped + +**Target state.** The existing four evals stay. The bug eval also asserts `**Investigation type:** bug`. New evals cover +a how-it-works prompt, an available-options prompt (each asserting its announcement), and a prior-art prompt that must +not trigger `investigate`. + +**Behavior.** Preserving. + +**Why.** [C-13](artifacts/current-state-findings.md#c-13-evals-assert-root-cause-and-cover-only-bug-triggering) + +**Decision.** [D-14](artifacts/change-decision-log.md#d-14-eval-coverage) + +### S-14: Documentation surfaces — Re-scoped + +**Target state.** The long-form doc carries the types table, the grammar examples, each type's report, and the +boundaries with `research`, `code-overview`, and `code-walkthrough`. The `han-coding` README scent line, the skills +index, `docs/workflows.md`, `docs/how-to/research-a-decision.md`, and the Confluence wrapper's long-form doc describe +three types. + +**Behavior.** Preserving. + +**Why.** [C-14](artifacts/current-state-findings.md#c-14-other-surfaces-describe-investigate-as-bug-only) + +**Decision.** [D-15](artifacts/change-decision-log.md#d-15-documentation) + +## Behavior Changes + +Every behavior change here is one the operator asked for: + +- **A question about how the code works, or about the ways to do a piece of work, now gets its own kind of report.** + Today those questions are steered to `/research`, or forced into a bug report. Requested in the operator's own words. +- **A named type that does not fit the question triggers one question before the run starts.** Requested: "validate + that the specified type is acceptable for the prompt, and suggest an alternative type when needed." +- **`/research` stops claiming codebase questions,** and the Confluence wrapper accepts non-bug questions. Agreed in the + confirmation turn. + +A bug investigation produces the same report, with the same ending, that it does today. + +## Change Units + +### Unit 1: Extract the `bug` type with no behavior change + +**What it does.** Moves the bug-specific content into `references/types/bug.md` and `references/templates/bug.md`, +moves the shared sections into `references/evidence-and-validation.md`, removes `template.md`, adds the one-row table +and the type-file contract, points Steps 2 to 6 at the type file, pins the output path and filename, adds `Write` and +`Skill`, and adds the Bats test. The long-form doc's template link moves with it. + +**Delta entries.** S-1 (bug only), S-2, S-4, S-5, S-6 (bug only), S-7, S-8, S-12. + +**How you know it worked.** `npm test` and `npm run lint` pass. The existing bug eval still finds "Root Cause". + +### Unit 2: Add `how-it-works`, type resolution, and the `research` boundary + +**What it does.** Adds the second type file and template, Step 1's grammar, resolution, fit check, and announcement, +`AskUserQuestion`, the new `argument-hint`, and the new `investigate` and `research` descriptions together. + +**Delta entries.** S-1, S-3, S-6, S-9, S-10. + +**Ordering constraint.** After Unit 1. The two descriptions change in one commit, so the two skills never both claim +"how something works". + +**How you know it worked.** `npm test` passes with two types. + +### Unit 3: Add `available-options` + +**What it does.** Adds the third type file, template, table row, and tokens. + +**Delta entries.** S-1, S-6, S-9. + +**How you know it worked.** `npm test` passes with three types. + +### Unit 4: Update the Confluence wrapper and the docs + +**Delta entries.** S-11, S-14. + +**How you know it worked.** Lint passes; no doc describes `investigate` as bug-only. + +### Unit 5: Add the evals + +**Delta entries.** S-13. + +**How you know it worked.** `tests.json` parses, and each new eval names a prompt file that exists. + +## Risks + +- **Detection misroutes.** A question that mentions a failure in passing could resolve to `bug`. The announcement line + makes the type visible before any work, and the operator can re-run with a token. The evals catch the common shapes. +- **Off-type agents underperform.** Nobody has run `codebase-explorer` or `behavioral-analyst` on a question rather than + a feature or a focus area + ([C-7](artifacts/current-state-findings.md#c-7-evidence-based-investigator-is-bug-framed-codebase-explorer-and-behavioral-analyst-are-neutral)). + A trial run of each type after Unit 3 is the early check. + +## Deferred (YAGNI) + +- **Investigation types declared in `.han/config.md`, and per-type config agents.** Not requested, and no second source + of types exists. Reopen when an operator asks for one. +- **A dedicated codebase-options agent.** One caller, no second named. Reopen when trial runs show the explorer and + structural-analyst pair misses the options space. +- **Correcting near-miss tokens such as `how-it-work`.** Reopen when evals or users show misspellings misrouting + despite the announcement. +- **A diagram or "where to change" section in the how-it-works report.** Reopen on reader feedback from trial runs. +- **Type aliases such as `options`.** Reopen on measured misses. + +## Cut for Scope + +- **Rewording `code-overview` and `code-walkthrough` descriptions** to point single-question explanations at + `investigate how-it-works`. The confirmed area in `artifacts/scope-boundary.md` does not list either skill. Their + descriptions stay true as written, since both still send bugs to `investigate`. The boundary is stated from + `investigate`'s side only. + +## Open Items + +None yet. The review round has not run. + +## Review Findings + +Not yet run. From bd47d51889e6216b6407f801e34d76c53e8b19f7 Mon Sep 17 00:00:00 2001 From: River Bailey Date: Thu, 12 Nov 2026 08:34:34 -0700 Subject: [PATCH 04/10] docs(plans): settle the investigation types plan after review --- .../artifacts/change-decision-log.md | 293 +++++++++ .../artifacts/scope-boundary.md | 13 + docs/plans/investigate-types/change-plan.md | 573 ++++++++++++------ 3 files changed, 679 insertions(+), 200 deletions(-) create mode 100644 docs/plans/investigate-types/artifacts/change-decision-log.md diff --git a/docs/plans/investigate-types/artifacts/change-decision-log.md b/docs/plans/investigate-types/artifacts/change-decision-log.md new file mode 100644 index 00000000..07559e95 --- /dev/null +++ b/docs/plans/investigate-types/artifacts/change-decision-log.md @@ -0,0 +1,293 @@ +# Change Decision Log: Investigation Types + + + +## Trivial decisions + +- D-10: allowed-tools — `allowed-tools` adds `Write` (the skill writes a report, C-4), `Skill` (it invokes + `readability-guidance`; `restructure` is the han-coding precedent), and `AskUserQuestion` (the fit check). — + Referenced in plan: Output location and the stop, S-9. +- D-15: Documentation — the long-form doc, README scent line, skills index, `docs/workflows.md`, + `docs/how-to/research-a-decision.md`, and the Confluence wrapper's doc describe three types, per CLAUDE.md's "one + canonical source per concept" and "indexes stay complete". — Referenced in plan: S-15. + +## Full decisions + +### D-1: One type file per type, read at fixed steps + +- **Question:** Where do the per-type specifics live? +- **Decision:** One file per type at `references/types/{token}.md`, plus a `## Investigation Types` table in `SKILL.md` + that is the only list of tokens. `SKILL.md` reads the type file's sections at fixed steps and names no token outside + the table. +- **Rationale:** The operator asked for types "similar to what was done for the code review skill", which uses exactly + this shape. The bug framing touches six steps (C-1), so inline branching would put three variants in each. +- **Evidence:** C-1, C-9, scope-boundary Stated Scope, software-architect A1. +- **Behavior impact:** Preserving for `bug`. +- **Rejected alternatives:** + - Inline `if type is X` branches in `SKILL.md` — rejected because six steps would each carry three variants (C-1). + - Three separate skills — rejected because the operator asked for one `/investigate` with types. +- **Revisit criterion:** A type that needs a step the shared flow does not have. +- **Dissent (if any):** none. +- **Settles delta entry:** S-1, S-2, S-4 +- **Dependent decisions:** D-2, D-4, D-7, D-11 +- **Referenced in plan:** Target State, S-1, S-2, S-4 + +### D-2: The type-file contract + +- **Question:** What sections does a type file carry, and in what form? +- **Decision:** Title `# Investigation type: {token}`, then six `##` sections in order: Detection signals, Dispatch, + Analysis, Validation brief, Audience, Stop. Value forms are pinned in the plan's contract table, including the + Dispatch entry grammar + ``N. `{plugin}:{agent}` ({count}, {when}): "{prompt}"`` with `{question}` as the only placeholder. +- **Rationale:** Each section maps to one bug-framed site in C-1 that differs per type. Purpose stays only in the table + so there is one copy (UX review Y-2). Every section is required, so no `none` literal is needed (UX review Y-1). +- **Evidence:** C-1, C-6, C-9, software-architect A1, junior-developer JD-004, user-experience-designer Y-1 and Y-2. +- **Behavior impact:** Preserving. +- **Rejected alternatives:** + - A seventh `## Purpose` section matching the table — rejected as two copies of one string with nothing reading the + file without the table. + - A separate dispatch file as code-review has — rejected because every prompt is type-framed, so the file would have + one reader per entry. + - An `{angle}` placeholder in the bug Dispatch — rejected; the investigator prompt names the angles and each agent + takes one, keeping `{question}` the only placeholder. +- **Revisit criterion:** A type with nothing to say in a section, or a reader of a type file that bypasses the table. +- **Dissent (if any):** none. +- **Settles delta entry:** S-1 +- **Dependent decisions:** D-11 +- **Referenced in plan:** The type-file contract, S-1 + +### D-3: The argument grammar + +- **Question:** How is a type token, a question, and an output path separated in one argument? +- **Decision:** + ``` + args := [ type-token ] question [ out-path ] + type-token := a Token from ## Investigation Types; only the first whitespace-separated token; case-insensitive; + one trailing ":" is stripped before matching; never inside quotes + question := the remaining text, verbatim, as $question + out-path := the final token, when it ends in ".md" and does not name a file that already exists; removed from $question + ``` +- **Rationale:** Hyphenated tokens are single words that rarely start a prose question. Treating an existing file as + the subject means the run never writes over the file being asked about (UX-001), and accepts a bare relative path + such as `docs/incidents/2026-04-23.md`, which today's long-form doc shows as an output path. +- **Evidence:** C-3, software-architect A3, user-experience-designer UX-001, junior-developer JD-001, + `han-coding/docs/skills/investigate.md` "How to invoke it". +- **Behavior impact:** Changing. A leading type token and a trailing new `.md` path leave the question. The operator's + request asks for a specifiable type, so this follows from it. +- **Rejected alternatives:** + - A prefix rule (`/`, `./`, `../`, `~/`) for out-paths — rejected because it made `./CHANGELOG.md` in a question + the write target and dropped bare relative paths the docs promise. + - Spaced tokens such as `how it works` — rejected because matching would need multi-word lookahead and would steal + the opening words of real questions. +- **Revisit criterion:** Operators passing out-paths that collide with existing files on purpose. +- **Dissent (if any):** none. +- **Settles delta entry:** S-3 +- **Dependent decisions:** D-13 +- **Referenced in plan:** The argument grammar, S-3 + +### D-4: Detection, tie-break, and the fit check + +- **Question:** How is a type chosen with no token, and when does a named type get challenged? +- **Decision:** The model judges the question against each type's Detection signals. With several matches, the + earliest table row wins; with none, the last row (`how-it-works`). With a token, the fit check fails only when the + question clearly meets another type's signals and none of the named type's, and then asks once with the pinned + `AskUserQuestion` wording. The announcement block is pinned in the plan. +- **Rationale:** The operator asked for automatic detection and for validation that suggests an alternative. A + reported failure is the strongest signal, so `bug` is first; an options run already includes a current-state + account, so `available-options` precedes `how-it-works`. Asking only on a clear mismatch keeps the operator's + explicit choice otherwise. Putting the order in the table keeps tokens out of `SKILL.md` prose (JD-003). +- **Evidence:** C-10, scope-boundary Stated Scope, software-architect A3, user-experience-designer UX-002 to UX-005, + junior-developer JD-003. +- **Behavior impact:** Changing, as requested: "if no type is specified ... determine the type automatically via the + prompt context. if a type is specified, first validate that the specified type is acceptable for the prompt, and + suggest an alternative type when needed." A question meeting no signal now runs as `how-it-works` where today it runs + as a bug; the announcement says it defaulted. +- **Rejected alternatives:** + - Defaulting to `bug` when nothing matches — rejected because the bug signals now include "behaves differently from + what was expected", so a question that still meets none is not describing a failure. + - Asking whenever detection is uncertain — rejected because the operator asked for detection to be automatic. + - Stopping with a message on a mismatch instead of asking — rejected because the Confluence wrapper needs the run to + produce a report. +- **Revisit criterion:** Evals or operators showing misroutes the announcement does not prevent. +- **Dissent (if any):** none. +- **Settles delta entry:** S-2, S-3 +- **Dependent decisions:** — +- **Referenced in plan:** What `SKILL.md` owns, Type resolution, S-2, S-3 + +### D-5: Per-type rosters reuse existing agents + +- **Question:** Which agents does each type dispatch? +- **Decision:** `bug` keeps today's roster. `how-it-works` always runs `codebase-explorer` and `behavioral-analyst`. + `available-options` always runs `codebase-explorer` and `structural-analyst`. Specialists join on relevance. No new + agent; `research-analyst` joins no type. +- **Rationale:** `evidence-based-investigator` is symptom-first (C-7). `codebase-explorer` is built "for documentation + or understanding" and `behavioral-analyst` takes a focus area. `structural-analyst` brings the seams that constrain + options and the git history `codebase-explorer` lacks. +- **Evidence:** C-7, C-15, software-architect A4. +- **Behavior impact:** Preserving for `bug`. +- **Rejected alternatives:** + - A new codebase-options agent — rejected under YAGNI: one caller, no second named. + - Briefing `evidence-based-investigator` for all types — rejected because its five fixed protocols start from a + symptom. + - Adding `research-analyst` to `available-options` — rejected by the agreed split: the open web belongs to `research`. +- **Revisit criterion:** Trial runs showing a type's roster misses what its question needs. +- **Dissent (if any):** none. +- **Settles delta entry:** S-1 +- **Dependent decisions:** — +- **Referenced in plan:** Per-type rosters, S-1 + +### D-6: Validation maps inputs in the brief; the agent is unchanged + +- **Question:** How does `adversarial-validator`, which expects a root cause and a planned fix, validate the new types? +- **Decision:** Each type's Validation brief names what goes in the validator's two named slots and an attack focus. + Step 4 builds the brief in the form pinned in the plan. +- **Rationale:** The validator has eight calling skills, at least four of which already brief it with inputs that are + not a fix. Changing its strategies risks all of them for a need the brief meets. +- **Evidence:** C-8, software-architect A5, junior-developer JD-005. +- **Behavior impact:** Preserving for `bug`. +- **Rejected alternatives:** + - Changing the agent's strategy 2 to be conditional — rejected for the blast radius across its callers. + - Skipping validation for non-bug types — rejected because it drops adversarial checking where claims are least + tested. +- **Revisit criterion:** The trial run after Unit 3 showing the validator fabricates or skips on a mapped brief. +- **Dissent (if any):** none. +- **Settles delta entry:** S-4 +- **Dependent decisions:** — +- **Referenced in plan:** Validation per type, S-4 + +### D-7: Per-type report templates with a shared fragment + +- **Question:** One whole template per type, or per-type heads plus a shared fragment? +- **Decision:** `references/templates/{token}.md` per type, plus `references/evidence-and-validation.md` holding the + Evidence Summary and Validation Results layouts, inserted at a one-line marker. Every template's second line names its + type. The `bug` template keeps today's sections and order. +- **Rationale:** The shared layout is one concept read by one shared step; three copies would be about 210 lines kept + equal by convention. CLAUDE.md asks for one canonical source per concept. +- **Evidence:** C-5, software-architect A2, test-engineer S-6 heading sequence, user-experience-designer UX-009. +- **Behavior impact:** Changing for `bug` in one line, the type line under the title. +- **Rejected alternatives:** + - Three whole templates — rejected for the duplication. + - Whole templates with a Bats byte-equality check — rejected as more lines for the same guarantee. +- **Revisit criterion:** A type whose evidence or validation layout must differ. +- **Dissent (if any):** none. +- **Settles delta entry:** S-5, S-6, S-7 +- **Dependent decisions:** D-11 +- **Referenced in plan:** Per-type reports, S-5, S-6, S-7 + +### D-8: Output location keeps the documented contract + +- **Question:** Where does a report land when no path is named? +- **Decision:** An out-path wins, then `output-directory`, then the skill proposes + `{documentation root}/investigations/investigate-{slug}.md` and writes without asking. An existing file gets a + numeric suffix. The path appears in the announcement. +- **Rationale:** The long-form doc promises "otherwise the skill proposes one and writes the plan there". The how-to + guides feed the report to `iterative-plan-review` and `plan-a-change`, so it has to be durable. A temp-directory + default would break those paths. The type stays out of the filename because nothing needs to tell types apart by name + (JD-007). +- **Evidence:** C-4, `han-coding/docs/skills/investigate.md` "How to invoke it", + `docs/how-to/triage-and-investigate-a-bug.md` L116, junior-developer JD-007, user-experience-designer UX-001. +- **Behavior impact:** Changing in small ways: `output-directory` is honored, and the unnamed location is stated rather + than chosen each run. Both follow the documented contract. +- **Rejected alternatives:** + - `${TMPDIR:-/tmp}` as the default, as `code-overview` does — rejected because investigation reports are durable + inputs to later skills. + - `investigate-{token}-{slug}.md` — rejected under YAGNI. +- **Revisit criterion:** An operator asking for reports elsewhere by default. +- **Dissent (if any):** none. +- **Settles delta entry:** S-8 +- **Dependent decisions:** — +- **Referenced in plan:** Output location and the stop, S-8 + +### D-9: The stop per type + +- **Question:** How does each type's run end? +- **Decision:** Each type's `## Stop` text is pinned in the plan. `bug` keeps the approve-to-implement offer, worded so + it says who implements. The other two say no code changed and point at plugin-qualified next skills. A shared line + built from the table shows how to re-run as another type. +- **Rationale:** The skill runs inline, so an operator's "approve" has the same session build the fix. That correction + to C-11 keeps a real behavior. The other types have nothing to implement. Plugin-qualified names resolve even when + the next skill's plugin is installed alone (UX-006). +- **Evidence:** C-11, junior-developer JD-002, user-experience-designer UX-006 to UX-008. +- **Behavior impact:** Changing for `bug` in wording only: "No code was changed." and the re-run line are added. +- **Rejected alternatives:** + - Dropping approve-to-implement — rejected because operators who reply "approve" today get the fix built. +- **Revisit criterion:** An operator asking bug runs to stop at the report. +- **Dissent (if any):** none. +- **Settles delta entry:** S-8 +- **Dependent decisions:** — +- **Referenced in plan:** Current State, Output location and the stop, S-8 + +### D-11: A Bats test holds the token list together + +- **Question:** Is a structural test justified, and what does it assert? +- **Decision:** `scripts/investigation-types.bats` with the six checks pinned in the plan. +- **Rationale:** The token list must agree across five surfaces held only by convention (C-9), and the evals have no + runner in the repo, so Bats is the one check that can fail at each unit. +- **Evidence:** C-9, C-13, test-engineer V-1 and V-2, junior-developer JD-009. +- **Behavior impact:** Changing (docs and tests only). +- **Rejected alternatives:** + - Checking every Dispatch agent exists as a file — deferred under YAGNI; no incident. + - Pinning the bug Stop text in the test — rejected; the Stop format check covers drift that matters. +- **Revisit criterion:** A drift the six checks miss reaching a release. +- **Dissent (if any):** none. +- **Settles delta entry:** S-13 +- **Dependent decisions:** — +- **Referenced in plan:** The guarding test, S-13 + +### D-12: The research and explanation boundaries + +- **Question:** How do `investigate`, `research`, `code-overview`, and `code-walkthrough` divide questions? +- **Decision:** `investigate` answers a question about this codebase. `research` covers the open web and prior art. + `code-overview` writes an orientation to a whole target, and `code-walkthrough` paces a person through code. Each + description says so, and all four change in one commit. +- **Rationale:** Today the descriptions claim each other's territory (C-2, C-14). +- **Evidence:** C-2, C-14, user input in the confirmation turn ("i agree with your split recommendation between research + and investigate"), user input during the run ("Add the line (Recommended)"). +- **Behavior impact:** Changing, as the operator agreed. +- **Rejected alternatives:** + - Stating the boundary from `investigate`'s side only — rejected by the operator. +- **Revisit criterion:** Routing evals showing a prompt landing in the wrong skill. +- **Dissent (if any):** none. +- **Settles delta entry:** S-9, S-10, S-11 +- **Dependent decisions:** — +- **Referenced in plan:** S-9, S-10, S-11 + +### D-13: The Confluence wrapper + +- **Question:** What does `investigate-to-confluence` change? +- **Decision:** Accept all three types; forward a leading type token first and the `/tmp/investigate-{slug}.md` path + last; describe the report as "a single report whose sections follow the investigation type"; keep "stop after + producing the report". +- **Rationale:** The wrapper restates today's sections and rejects non-bug requests (C-12). The new grammar reads its + path as an out-path. +- **Evidence:** C-12, D-3, software-architect A9. +- **Behavior impact:** Changing, as agreed in the confirmation turn. +- **Rejected alternatives:** + - Leaving the wrapper bug-only — rejected by the confirmed area, item 3. +- **Revisit criterion:** none. +- **Dissent (if any):** none. +- **Settles delta entry:** S-12 +- **Dependent decisions:** — +- **Referenced in plan:** S-12 + +### D-14: Eval coverage + +- **Question:** Which evals does the change add? +- **Decision:** The assertions pinned in S-14, a new `ruby-shop` scaffold, and `han-research` added to `plugins`. +- **Rationale:** No eval covers a non-bug type or the research boundary (C-13). The existing scaffold has two obvious + defects that would pull a how-it-works run toward a bug report. +- **Evidence:** C-13, test-engineer S-13 review. +- **Behavior impact:** Changing (docs and tests only). +- **Rejected alternatives:** + - Reusing `ruby-project` — rejected for its defects and lack of options material. + - A fit-check eval — deferred until the runner's `AskUserQuestion` handling is known. +- **Revisit criterion:** A runner that handles `AskUserQuestion`. +- **Dissent (if any):** none. +- **Settles delta entry:** S-14 +- **Dependent decisions:** — +- **Referenced in plan:** S-14 diff --git a/docs/plans/investigate-types/artifacts/scope-boundary.md b/docs/plans/investigate-types/artifacts/scope-boundary.md index 7b8cb2e1..3de2d30c 100644 --- a/docs/plans/investigate-types/artifacts/scope-boundary.md +++ b/docs/plans/investigate-types/artifacts/scope-boundary.md @@ -41,6 +41,18 @@ The confirmed area: Plan location confirmed: `docs/plans/investigate-types/`. +### Added during the run + +Asked whether to add one line to the `code-overview` and `code-walkthrough` descriptions pointing single "how does X +work" questions to `/investigate`, the operator chose: + +> Add the line (Recommended) + +This brings one more surface into the area: + +6. The `code-overview` and `code-walkthrough` descriptions and their long-form docs, each gaining one boundary + sentence that sends a single question about how the code behaves to `/investigate`. + ## Direction of Travel The bug-only shape of `investigate` is being replaced by a typed shape whose first type, `bug`, carries today's @@ -54,3 +66,4 @@ None received. This skill plans code structure; the visual-material convention d ## Record Provenance Established by `plan-a-change` on 2026-11-12. No prior record existed and no conflict was resolved. +Amended on 2026-11-12 with the operator's answer above; it adds to the area and excludes nothing recorded earlier. diff --git a/docs/plans/investigate-types/change-plan.md b/docs/plans/investigate-types/change-plan.md index 956e24f9..5bc159f6 100644 --- a/docs/plans/investigate-types/change-plan.md +++ b/docs/plans/investigate-types/change-plan.md @@ -2,11 +2,11 @@ ## Why This Change -`/investigate` assumes every investigation is a bug, and most of the operator's investigations are not. In their words: +`/investigate` assumes every investigation is a bug, and many of the operator's investigations are not. In their words: "a lot of the investigation i do is not centered around bugs, but rather investigation into how the code works and what options are available for doing work." This is a constraint arriving: a new requirement the current structure cannot -absorb, because the bug framing is written into every step. The source is the operator's own request, recorded word for -word in `artifacts/scope-boundary.md`. +absorb, because the bug framing is written into most of its steps. The source is the operator's own request, recorded +word for word in `artifacts/scope-boundary.md`. ## What Changes, In One Paragraph @@ -14,14 +14,14 @@ After this change, `/investigate` runs one of three investigation types: `bug`, Each type is a small data file that says how to recognize it, which agents to dispatch, what the analysis produces, how the validator is briefed, who the report is for, and how the run ends. Each type has its own report template. The skill keeps the steps every type shares: reading config, gathering numbered evidence, adversarial validation, the readability -passes, and the review loop. With no type named, the skill picks one from the question and says which it picked. With a -type named, it checks the type fits the question, and asks before switching when it does not. The `bug` type produces -the same report the skill produces today. +passes, and the review loop. With no type named, the skill picks one from the question and says which it picked and why. +With a type named, it checks the type fits the question, and asks before switching when it clearly does not. A `bug` run +writes the same report sections it writes today. ## Current State -The bug framing runs through every step of `SKILL.md`. The shared parts (config, evidence rule, E-series, validator -mechanics, readability passes) are already type-agnostic, but nothing separates them from the bug-specific parts +The bug framing runs through most of `SKILL.md`. The shared parts (config, evidence rule, E-series, validator mechanics, +readability passes) are already type-agnostic, but nothing separates them from the bug-specific parts ([C-1](artifacts/current-state-findings.md#c-1-the-bug-framing-runs-through-every-step-of-skillmd-with-no-seam)). The skill's own description sends "how something works" and "options" to `research`, which claims both ([C-2](artifacts/current-state-findings.md#c-2-the-description-sends-how-something-works-and-options-to-research)). @@ -48,32 +48,40 @@ describe the skill as bug-only ([C-14](artifacts/current-state-findings.md#c-14-other-surfaces-describe-investigate-as-bug-only)). Nothing machine-checks any cross-file agreement in the skill today. +One finding needs a correction. C-11 says nothing implements on approval. That holds for the skill's own text, but the +skill runs inline in the operator's session, so an operator who replies "approve" gets the fix built by that same +session. The approve-to-implement ending is real behavior and is kept for `bug` +([D-9](artifacts/change-decision-log.md#d-9-the-stop-per-type)). + ## Target State `SKILL.md` owns the flow every investigation shares. A type file owns everything that differs by type. A template owns -the type's report layout. The skill reads the type file's sections at fixed steps, and never branches on a type name in -its own prose ([D-1](artifacts/change-decision-log.md#d-1-one-type-file-per-type-read-at-fixed-steps)). +the type's report layout. The skill reads the type file's sections at fixed steps, and the only place it names a type +token is the `## Investigation Types` table +([D-1](artifacts/change-decision-log.md#d-1-one-type-file-per-type-read-at-fixed-steps)). ### What `SKILL.md` owns - The config read, the evidence rule, and the lazy-create rule, as today. -- A `## Investigation Types` section holding the only list of shipped tokens: +- A `## Investigation Types` section holding the only list of shipped tokens. Row order is the tie-break order, and the + last row is the default when nothing matches + ([D-4](artifacts/change-decision-log.md#d-4-detection-tie-break-and-the-fit-check)): ```markdown - | Token | File | Purpose | - | ------------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------- | - | `bug` | [references/types/bug.md](./references/types/bug.md) | Find the root cause of a failure and plan the fix | - | `how-it-works` | [references/types/how-it-works.md](./references/types/how-it-works.md) | Explain how this codebase behaves, with cited evidence | + | Token | File | Purpose | + | ------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------- | + | `bug` | [references/types/bug.md](./references/types/bug.md) | Find the root cause of a failure and plan the fix | | `available-options` | [references/types/available-options.md](./references/types/available-options.md) | Compare the ways a piece of work could be done in this codebase | + | `how-it-works` | [references/types/how-it-works.md](./references/types/how-it-works.md) | Explain how this codebase behaves, with cited evidence | ``` -- Argument parsing and type resolution (Step 1, below). +- Argument parsing, type resolution, and output resolution (Step 1). - Evidence gathering: dispatch what the type's `## Dispatch` names, then compile the E-series. - The `## Extra Agents` rule, reworded: an extra agent joins when the resolved type and the question match its stated specialty. -- Validation mechanics: the verbatim brief, V-N items, Adjustments Made, Confidence Assessment. +- Validation mechanics: the brief form, V-N items, Adjustments Made, Confidence Assessment. - The readability-guidance invocation and the readability-editor pass, with the audience taken from the type file. -- Output location, and the stop. +- The stop: the type's `## Stop` text, followed by one shared line generated from the table. ### The argument grammar @@ -81,96 +89,127 @@ its own prose ([D-1](artifacts/change-decision-log.md#d-1-one-type-file-per-type ``` args := [ type-token ] question [ out-path ] -type-token := a Token from ## Investigation Types; only the first whitespace-separated token; case-insensitive; never inside quotes +type-token := a Token from ## Investigation Types; only the first whitespace-separated token; case-insensitive; + one trailing ":" is stripped before matching; never inside quotes question := the remaining text, verbatim, as $question -out-path := the final token, when it ends in ".md" and starts with "/", "./", "../", or "~/"; removed from $question +out-path := the final token, when it ends in ".md" and does not name a file that already exists; removed from $question ``` -When `$question` is empty and the conversation names no subject, the run stops with: -`investigate needs a question or symptom. Usage: /investigate [bug | how-it-works | available-options] [./path/report.md]. No investigation ran.` +A final `.md` token that names an existing file stays in `$question`: it is the subject, and the run never writes over +it. When `$question` is empty and the conversation holds no earlier message describing a problem or question, the run +stops with the usage message, built from the table at run time: + +``` +investigate needs a question or symptom. No investigation ran. +Usage: /investigate [type] [report path ending in .md] +Types: +- bug: Find the root cause of a failure and plan the fix +- available-options: Compare the ways a piece of work could be done in this codebase +- how-it-works: Explain how this codebase behaves, with cited evidence +``` -| Invocation | Type | `$question` | Out path | -| -------------------------------------------------------------------------- | -------------------------------------------- | ---------------------------------------------- | -------------------------- | -| `/investigate bug checkout returns 500 after the coupon change` | `bug`, named | `checkout returns 500 after the coupon change` | none | -| `/investigate how does the retry queue pick a backoff` | `how-it-works`, detected | the whole string | none | -| `/investigate how-it-work retry queue` | not a token; detected | the whole string | none | -| `/investigate bug reports from the importer are dropped` | `bug`, named | `reports from the importer are dropped` | none | -| `/investigate available-options add rate limiting ./docs/inv/rate-limit.md` | `available-options`, named | `add rate limiting` | `./docs/inv/rate-limit.md` | -| `/investigate why does deploy fail on docs/CHANGELOG.md` | `bug`, detected | the whole string | none (no path prefix) | -| `/investigate how-it-works login throws 500 since Tuesday` | `how-it-works`, named; fit check fails; asks | `login throws 500 since Tuesday` | none | +| Invocation | Type | `$question` | Out path | +| ------------------------------------------------------------------------ | ------------------------------------- | ---------------------------------------------- | -------------------------- | +| `/investigate bug checkout returns 500 after the coupon change` | `bug`, named | `checkout returns 500 after the coupon change` | none | +| `/investigate bug: cart total off by one cent` | `bug`, named (colon stripped) | `cart total off by one cent` | none | +| `/investigate how does the retry queue pick a backoff` | `how-it-works`, detected | the whole string | none | +| `/investigate how-it-work retry queue` | not a token; detected `how-it-works` | the whole string | none | +| `/investigate available-options add rate limiting docs/inv/rate-limit.md` | `available-options`, named | `add rate limiting` | `docs/inv/rate-limit.md` | +| `/investigate why does the generator rewrite ./CHANGELOG.md` | `bug`, detected | the whole string | none (the file exists) | +| `/investigate how-it-works login throws 500 since Tuesday` | named `how-it-works`; fit check asks | `login throws 500 since Tuesday` | none | ### Type resolution ([D-4](artifacts/change-decision-log.md#d-4-detection-tie-break-and-the-fit-check)) -1. **No token.** Match `$question` against each type's `## Detection signals`. When more than one type matches, the - order is `bug`, then `available-options`, then `how-it-works`: a reported failure outranks everything, and an options - run already includes a current-state account. When none matches, the type is `how-it-works`, which assumes neither a - defect nor a planned change. The run proceeds without asking. -2. **Token named.** The fit check fails only when `$question` matches a signal of another type and no signal of the - named type. On failure, ask once with `AskUserQuestion`: - `You named {given}, but this reads as {suggested}, because it {the signal that matched}. Which type should this run use?` - with the options `{suggested} (suggested)` and `{given} (as named)`. Anything short of a clear mismatch keeps the - operator's choice. +Detection is a judgment the model makes against each type's `## Detection signals`. The signals are guidance written as +phrases, not literal strings to match. + +1. **No token.** Decide which types' signals the question meets. When more than one does, the earliest row in the table + wins. When none does, the last row (`how-it-works`) is the type, because it presumes neither a defect nor a planned + change. The run proceeds without asking. +2. **Token named.** The fit check fails only when the question clearly meets another type's signals and none of the + named type's. On failure, ask once with `AskUserQuestion`: + - Question: `You named {given}, but "{the operator's words that matched}" reads as {suggested}. Which type should this run use?` + - Options: `{suggested}` with its Purpose cell as the description, and `{given} (as named)` with its Purpose cell. + - When more than one other type matches, `{suggested}` is the earliest such row. + - A free-text answer naming a token uses that token. Any other answer, or a dismissal, keeps the named type. -Once settled, the run prints one line before any dispatch: +Once the type and the report path are settled, the run prints this block before any dispatch: ``` -announce := "**Investigation type:** " token ", " source ". " purpose -source := "named" | "detected from the question" | "switched from " token " at your request" +**Investigation type:** {token}: {Purpose cell} +**Chosen because:** {source} +**Question:** {$question} +**Report:** {path} +Other types: {every other token, comma-separated}. To switch, re-run as /investigate {token} . ``` -Example: `**Investigation type:** how-it-works, detected from the question. Explain how this codebase behaves, with cited evidence.` +``` +source := "you named it" + | "detected from \"" {the operator's words that matched} "\"" + | "detected from \"" {words} "\"; it also read as " {runner-up token} + | "no type signal matched, so it defaulted to the last type" + | "you switched from " {given} " when asked" + | "kept as you named it when asked" +``` + +Example: + +``` +**Investigation type:** how-it-works: Explain how this codebase behaves, with cited evidence +**Chosen because:** detected from "how does the retry queue pick" +**Question:** how does the retry queue pick a backoff +**Report:** docs/investigations/investigate-retry-queue-backoff.md +Other types: bug, available-options. To switch, re-run as /investigate {token} . +``` ### The type-file contract ([D-2](artifacts/change-decision-log.md#d-2-the-type-file-contract)) -Each type file is `references/types/{token}.md`, titled `# Investigation type: {token}`, with exactly these seven `##` -sections in this order, outside any fence. A section with nothing to say holds the literal `none`; `## Dispatch` is -never `none`. +Each type file is `references/types/{token}.md`, titled `# Investigation type: {token}`, with exactly these six `##` +sections in this order, outside any fence. Every section has content. The type's purpose lives only in the table. -| Section | Value form | Read at | -| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -| `## Purpose` | one sentence, identical to the table's Purpose cell | Step 1 | -| `## Detection signals` | three or more bullets, `- {signal}` | Step 1 | -| `## Dispatch` | a numbered list, one entry per agent: ``N. `{plugin}:{agent}` ({count}, always \| when {trigger}): "{prompt using {question}}"`` | Step 2 | -| `## Analysis` | a numbered list of steps run between the evidence summary and validation, each naming the template section it fills | Step 3 | -| `## Validation brief` | exactly three bullets: `- Root cause analysis: {what this type passes}`, `- Planned fix: {what this type passes}`, `- Attack focus: {one sentence}` | Step 4 | -| `## Audience` | one sentence naming the reader | Steps 3 and 5 | -| `## Stop` | one blockquote, the closing message, with `{path}` as its only placeholder | Step 6 | +| Section | Value form | Read at | +| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | +| `## Detection signals` | one or more bullets, `- {phrase}` | Step 1 | +| `## Dispatch` | a numbered list, one entry per agent: ``N. `{plugin}:{agent}` ({count}, {when}): "{prompt}"``, where `{count}` is a number or a number followed by `+`, `{when}` is `always` or `when {trigger}`, and `{question}` is the prompt's only placeholder | Step 2 | +| `## Analysis` | a numbered list of steps run between the evidence summary and validation, each naming in backticks the template heading it fills | Step 3 | +| `## Validation brief` | exactly three bullets, in this order: `- Root cause analysis: {text}`, `- Planned fix: {text}`, `- Attack focus: {text}` | Step 4 | +| `## Audience` | one sentence naming the reader | Steps 3 and 5 | +| `## Stop` | one blockquote line, with `{path}` as its only placeholder | Step 6 | -A worked example, abridged, for `bug`: +A worked example for `bug`, with the prompts abridged: ```markdown # Investigation type: bug -## Purpose - -Find the root cause of a failure and plan the fix - ## Detection signals -- something fails, errors, crashes, or returns a wrong result +- something fails, errors, crashes, hangs, or times out +- something returns a wrong result, or behaves differently from what was expected - something stopped working, or regressed after a change -- an error message, stack trace, or failing test is quoted +- an error message, stack trace, log line, or failing test is quoted ## Dispatch -1. `han-core:evidence-based-investigator` (2, always): "Investigate from the {angle} angle: {question}. ..." -2. `han-core:concurrency-analyst` (1, when the question involves intermittent failures, races, ordering, or load): "..." +1. `han-core:evidence-based-investigator` (2+, always): "Investigate this from one angle only, the one you are assigned (the error path, the data flow, or the recent changes): {question}. ..." +2. `han-core:concurrency-analyst` (1, when the question involves intermittent failures, races, deadlocks, ordering, stale reads, timeouts, dropped messages, or load): "Investigate the concurrency and async behavior of the code paths implicated by this: {question}. ..." +3. `han-core:behavioral-analyst` (1, when the question involves data transformed wrong, values lost between modules, swallowed errors, unexpected state, or bad data at an integration boundary): "Trace the data flow for the code paths implicated by this: {question}. ..." +4. `han-core:data-engineer` (1, when the question involves wrong data in the database, slow queries, N+1, lock contention, migrations, unbounded scans, lost data, referential integrity, or isolation levels): "Investigate the schema, queries, migrations, and data-access code implicated by this: {question}. ..." ## Analysis -1. Write the Problem Statement. -2. Write the Root Cause Analysis, citing E-items. -3. Resolve coding standards, then write the Coding Standards Reference and the Planned Fix. +1. Write `Problem Statement`: symptoms, expected behavior, conditions, impact. +2. Write `Root Cause Analysis`: a one-to-three sentence root cause, then the detailed causal chain citing E-items. +3. Resolve coding standards from CLAUDE.md's Project Discovery section, project-discovery.md, or `docs/`, `docs/adr/`, `docs/coding-standards/`, then write `Coding Standards Reference` and `Planned Fix`. ## Validation brief - Root cause analysis: the Root Cause Analysis section -- Planned fix: the Planned Fix section -- Attack focus: break the fix and the causal chain from root cause to symptom +- Planned fix: the Planned Fix section, with every file change +- Attack focus: break the fix, and the causal chain from root cause to symptom ## Audience @@ -178,18 +217,18 @@ The engineer who will implement the fix and may be paged on the bug. ## Stop -> Report written to {path}. Approve the Planned Fix to implement it, or reply with corrections to revise the report. +> Report written to {path}. No code was changed. Reply "approve" to have this session implement the Planned Fix, or reply with corrections to revise the report. ``` ### Per-type rosters ([D-5](artifacts/change-decision-log.md#d-5-per-type-rosters-reuse-existing-agents)) -| Type | Always | When relevant | -| ------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | -| `bug` | `han-core:evidence-based-investigator` ×2 | `concurrency-analyst`, `behavioral-analyst`, `data-engineer`, on today's triggers | -| `how-it-works` | `han-core:codebase-explorer`, `han-core:behavioral-analyst` | `structural-analyst` (organization, dependencies, history), `concurrency-analyst`, `data-engineer` | -| `available-options` | `han-core:codebase-explorer`, `han-core:structural-analyst` | `behavioral-analyst`, `data-engineer`, `concurrency-analyst` | +| Type | Always | When relevant | +| ------------------- | ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- | +| `bug` | `han-core:evidence-based-investigator`, two or more | `concurrency-analyst`, `behavioral-analyst`, `data-engineer`, on today's triggers | +| `how-it-works` | `han-core:codebase-explorer`, `han-core:behavioral-analyst` | `structural-analyst` (organization, dependencies, history), `concurrency-analyst`, `data-engineer` | +| `available-options` | `han-core:codebase-explorer`, `han-core:structural-analyst` | `behavioral-analyst`, `data-engineer`, `concurrency-analyst` | `evidence-based-investigator` stays with `bug`, because its protocols start from a symptom. `research-analyst` joins no type: questions that need the open web or prior art go to `/research`, per the agreed split. @@ -198,47 +237,79 @@ type: questions that need the open web or prior art go to `/research`, per the a ([D-6](artifacts/change-decision-log.md#d-6-validation-maps-inputs-in-the-brief-the-agent-is-unchanged)) -`han-core:adversarial-validator` is unchanged. Each type's `## Validation brief` says what it passes in the validator's -three input slots: +`han-core:adversarial-validator` is unchanged. Step 4 builds its brief in this form, so the agent receives its three +named inputs and the type's focus: + +``` +This is a {token} investigation. {Purpose cell}. + +Evidence summary: +{every E-item, verbatim, with code} -| Type | Root cause analysis slot | Planned fix slot | Attack focus | -| ------------------- | --------------------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------ | -| `bug` | Root Cause Analysis | Planned Fix | Break the fix and the causal chain | -| `how-it-works` | the Answer and its flow trace | the Answer's coverage claim: the entry points and paths it calls complete | Find a caller, path, or input the explanation misses or gets wrong | -| `available-options` | Current State and Constraints | the recommended option and its change surface | Break the recommendation; test whether a rejected option rests on a false premise | +Root cause analysis (for this investigation type, this is {Root cause analysis text}): +{that section, verbatim} + +Planned fix (for this investigation type, this is {Planned fix text}): +{that section, verbatim} + +Attack focus: {Attack focus text} +``` + +| Type | Root cause analysis slot | Planned fix slot | Attack focus | +| ------------------- | ----------------------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------- | +| `bug` | Root Cause Analysis | Planned Fix | Break the fix and the causal chain | +| `how-it-works` | the Answer and its flow trace | the Answer's coverage claim: the entry points and paths it calls complete | Find a caller, path, or input the explanation misses or gets wrong | +| `available-options` | Current State and Constraints | the recommended option and its change surface | Break the recommendation; test whether a rejected option rests on a false premise | ### Per-type reports ([D-7](artifacts/change-decision-log.md#d-7-per-type-report-templates-with-a-shared-fragment)) -Each type has `references/templates/{token}.md`. The Evidence Summary, Validation Results, Adjustments Made, and -Confidence Assessment live once, in `references/evidence-and-validation.md`. Each template carries exactly one line -`` where that fragment's sections go. +Each type has `references/templates/{token}.md`. The Evidence Summary and Validation Results sections (with Validation +Results' `###` subsections Counter-Evidence Investigated, Adjustments Made, and Confidence Assessment) live once, in +`references/evidence-and-validation.md`. Each template carries exactly one line +``. When writing the report, the skill writes the fragment's sections in that +line's place, and the lazy-create rule applies to them as to every other section. Every template's second line is +`**Investigation type:** {token}: {Purpose cell}`. + +| Type | Title | Summary fields | `##` sections, in order | +| ------------------- | ----------------------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | +| `bug` | `# Investigation: {title}` | Root Cause, Fix, Why Correct, Validation Outcome, Remaining Risks | Summary, Problem Statement, Root Cause Analysis, Planned Fix, shared fragment, Coding Standards Reference | +| `how-it-works` | `# How It Works: {subject}` | Answer, Entry Points, Validation Outcome, Unverified Paths | Summary, Question, Answer, Key Components, shared fragment | +| `available-options` | `# Available Options: {goal}` | Recommendation, Options Considered, Deciding Factor, Validation Outcome, Remaining Risks | Summary, Goal and Constraints, Current State, Options, Comparison, Recommendation, shared fragment, Coding Standards Reference | -| Type | Title | Summary fields | Sections, in order | -| ------------------- | ------------------------------ | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | -| `bug` | `# Investigation: {title}` | Root Cause, Fix, Why Correct, Validation Outcome, Remaining Risks | Problem Statement, Root Cause Analysis, Planned Fix, shared fragment, Coding Standards Reference | -| `how-it-works` | `# How It Works: {subject}` | Answer, Entry Points, Validation Outcome, Remaining Risks | Question, Answer (lead sentence, then a numbered flow walkthrough), Key Components (Component, File, Role), shared fragment | -| `available-options` | `# Available Options: {goal}` | Recommendation, Options Considered, Deciding Factor, Validation Outcome, Remaining Risks | Goal and Constraints, Current State, Options (one `### Option N: {name}` each), Comparison, Recommendation, shared fragment, Coding Standards Reference | +`{title}`, `{subject}`, and `{goal}` are a short noun phrase the skill writes from `$question`. The `how-it-works` +Answer opens with a one-sentence answer, then a numbered walkthrough of the flow citing E-items. Key Components is a +table with the columns Component, File, and Role. The `available-options` Options section holds one +`### Option N: {name}` block per option, each with How it works, Change surface, Fits existing patterns, and Costs and +risks. Comparison is a table of options against the constraints. Recommendation names what would change the call. -The `bug` template is today's `template.md` with the shared sections moved into the fragment, so a bug report reads the -same as it does now. +The `bug` template is today's `template.md` with the shared sections moved into the fragment and the type line added, +so a bug report carries the same sections in the same order. ### Output location and the stop ([D-8](artifacts/change-decision-log.md#d-8-output-location-keeps-the-documented-contract)) -The report path resolves in config-rule order: an out-path in the argument wins; otherwise a configured -`output-directory`, with the file written directly beneath it; otherwise the skill proposes a path, as the long-form doc -promises today, and writes there. The proposed filename is `investigate-{token}-{slug}.md`, where the slug is two to six -words from `$question` in `[a-z0-9-]`. "The plan file" becomes "the report file" throughout. +The report path resolves in config-rule order: -The run ends by printing the type's `## Stop` +1. An out-path from the argument. +2. A configured `output-directory`, with the file written directly beneath it. +3. Otherwise, as the long-form doc promises today, the skill proposes a path and writes there without asking: + `{documentation root}/investigations/investigate-{slug}.md`. The documentation root comes from CLAUDE.md's + `## Project Discovery` section, then `project-discovery.md`, then `docs/` when it exists, then the repository root. + +The slug is two to six words from `$question`, lowercase, in `[a-z0-9-]`. When the resolved file already exists, the +skill appends `-2`, `-3`, and so on. The path appears in the announcement, so the operator sees it before any agent +runs. "The plan file" becomes "the report file" throughout. + +The run ends by printing the type's `## Stop`, then one shared line built from the table ([D-9](artifacts/change-decision-log.md#d-9-the-stop-per-type)): -- **`bug`:** `Report written to {path}. Approve the Planned Fix to implement it, or reply with corrections to revise the report.` -- **`how-it-works`:** `Report written to {path}. No code was changed. Reply with corrections to revise the report. To change this code next, run /plan-a-change with this report; to build new behavior on it, run /plan-a-feature.` -- **`available-options`:** `Report written to {path}. No code was changed. Reply with corrections to revise the report. To plan the recommended option, run /plan-a-change (restructuring existing code) or /plan-a-feature (new behavior) with this report; to weigh prior art beyond this codebase, run /research.` +- **`bug`:** `Report written to {path}. No code was changed. Reply "approve" to have this session implement the Planned Fix, or reply with corrections to revise the report.` +- **`how-it-works`:** `Report written to {path}. No code was changed. Reply with corrections to revise the report. To change this code next, run /han-planning:plan-a-change with this report; to build new behavior on it, run /han-planning:plan-a-feature.` +- **`available-options`:** `Report written to {path}. No code was changed. Reply with corrections to revise the report. To plan the recommended option, run /han-planning:plan-a-change (restructuring existing code) or /han-planning:plan-a-feature (new behavior) with this report; to weigh prior art beyond this codebase, run /han-research:research.` +- **Shared line:** `Wrong kind of report? Re-run as /investigate {other token} , where {other token} is one of: {every other token}.` `allowed-tools` adds `Write`, `Skill`, and `AskUserQuestion` ([D-10](artifacts/change-decision-log.md#d-10-allowed-tools)). @@ -246,22 +317,46 @@ The run ends by printing the type's `## Stop` ### The guarding test `han-coding/skills/investigate/scripts/investigation-types.bats` holds the cross-file agreements -([D-11](artifacts/change-decision-log.md#d-11-a-bats-test-holds-the-token-list-together)): - -1. Every `references/types/*.md` has a matching table row, a `references/templates/{token}.md`, and a token in both the - `argument-hint` and the `description`; every table row names an existing file. -2. Every type file's first line is `# Investigation type: {token}`, its `##` headings outside fences are exactly the - seven in order, and its `## Validation brief` carries the three pinned bullet prefixes. -3. Every agent in a `## Dispatch` entry resolves to an existing `{plugin}/agents/{agent}.md` in the repo. -4. Every template has exactly one `` line. +([D-11](artifacts/change-decision-log.md#d-11-a-bats-test-holds-the-token-list-together)). It resolves files from +`$BATS_TEST_DIRNAME/..`, as `review-types.bats` does, and reuses its fence-aware heading reader. + +1. **Tokens agree in every direction.** The set of `references/types/*.md` basenames, the set of table tokens, the set + of `references/templates/*.md` basenames, and the set of backticked tokens in the `argument-hint` are all equal. + Every table row matches + ``^\| `{token}` +\| \[references/types/{token}\.md\]\(\./references/types/{token}\.md\) +\|`` with variable spacing. + Each token appears backticked in the `description`. +2. **Type files follow the contract.** Each file's first line is `# Investigation type: {token}`. Its `##` headings + outside fences are exactly the six, in order. `## Detection signals` has at least one `- ` line. Every numbered line + under `## Dispatch` matches ``^[0-9]+\. `[a-z0-9-]+:[a-z0-9-]+` \([0-9]+\+?, (always|when .+)\): ".+"$``, and there is + at least one. Every backticked heading under `## Analysis` is a `##` heading in `templates/{token}.md`. + `## Validation brief` has exactly three `- ` lines, starting `- Root cause analysis: `, `- Planned fix: `, and + `- Attack focus: `, in that order. `## Stop` has exactly one line starting `> `, and its only `{...}` is `{path}`. +3. **Templates carry the shared fragment.** `references/evidence-and-validation.md` exists and has the `##` headings + Evidence Summary and Validation Results. Every template has exactly one `` + line, and its second non-blank line starts `**Investigation type:** {token}: `. +4. **The `bug` report keeps today's shape.** `templates/bug.md`, with the marker replaced by the fragment's headings, has + this `##` sequence: Summary, Problem Statement, Root Cause Analysis, Planned Fix, Evidence Summary, Validation + Results, Coding Standards Reference. +5. **The extraction is complete.** `references/template.md` does not exist, and no file under `han-coding/` or + `han-atlassian/` links to it. `SKILL.md` contains no `{symptom}`. `SKILL.md` names each of the six type-file + sections. +6. **The research boundary holds.** `han-research/skills/research/SKILL.md`'s description does not contain + `how something works`. + +Classification quality, the grammar, the announcement, and the fit-check wording are not things a Bats test can hold. +Only the evals reach them. ## Surface Delta +`Behavior` below is about what a person running `/investigate` sees. Doc and test entries say `Changing (docs and tests +only)` when they change what a reader reads but not what a run does. + ### S-1: `references/types/{bug,how-it-works,available-options}.md` — Added **Target state.** Three type files exist, each following the type-file contract. `bug.md` carries today's inline bug -content: the symptom-first approach, the two-investigator dispatch, the three specialist triggers with `{question}` in -place of `{symptom}`, the root-cause and fix analysis, today's audience, and today's stop. +content: the symptom-first approach, two or more investigators on distinct angles, the three specialist triggers with +`{question}` in place of `{symptom}`, the root-cause and fix analysis, today's audience, and the approve-to-implement +stop. **Behavior.** Preserving for `bug`: the same agents run on the same triggers and the same sections are written. The two new types are the requested addition. @@ -275,8 +370,8 @@ new types are the requested addition. ### S-2: `SKILL.md` `## Investigation Types` — Added -**Target state.** A section in `SKILL.md` holds the three-row token table, the only list of shipped tokens, and the -type-file contract. +**Target state.** A section in `SKILL.md` holds the token table, the only list of shipped tokens, whose row order is the +tie-break order and whose last row is the default. It also holds the type-file contract. **Behavior.** Preserving. It adds a list; it changes no existing step. @@ -285,16 +380,17 @@ type-file contract. **Depends on.** S-1. -**Decision.** [D-1](artifacts/change-decision-log.md#d-1-one-type-file-per-type-read-at-fixed-steps) +**Decision.** [D-1](artifacts/change-decision-log.md#d-1-one-type-file-per-type-read-at-fixed-steps), +[D-4](artifacts/change-decision-log.md#d-4-detection-tie-break-and-the-fit-check) -### S-3: `SKILL.md` Step 1, argument parsing and type resolution — Added +### S-3: `SKILL.md` Step 1, parsing, type resolution, and the announcement — Added **Target state.** Step 1 parses the argument per the grammar, resolves the type by detection or fit check, asks once on -a clear mismatch, and prints the announcement line before any dispatch. +a clear mismatch, resolves the report path, and prints the announcement block before any dispatch. -**Behavior.** Changing, as requested: a question with no failure in it now runs as `how-it-works` or -`available-options`. The scope boundary records this requirement word for word, so it is not re-asked. A bug question -with no type token still resolves to `bug`. +**Behavior.** Changing, as requested. A question that meets no type's signals now runs as `how-it-works`, where today +it runs as a bug. A leading type token and a trailing new `.md` path are removed from the question the agents see. +Every run, `bug` included, now opens with the announcement block. **Why.** There is no parsing rule and the classification is held only in context ([C-3](artifacts/current-state-findings.md#c-3-the-argument-is-one-free-text-blob-with-no-parsing-rule), @@ -309,10 +405,11 @@ with no type token still resolves to `bug`. **Target state.** The steps own only the shared flow. Step 2 dispatches the type's `## Dispatch` entries plus matching extra agents and compiles the E-series. Step 3 runs the type's `## Analysis` into its template. Step 4 briefs -`adversarial-validator` from `## Validation brief`. Step 5 writes the Summary and runs the readability-editor with the -type's `## Audience`. Step 6 resolves nothing new and prints the type's `## Stop`. +`adversarial-validator` in the pinned brief form. Step 5 writes the Summary and runs the readability-editor with the +type's `## Audience`. Step 6 prints the type's `## Stop` and the shared line. -**Behavior.** Preserving for `bug`. +**Behavior.** Preserving for `bug`. Extra agents from `## Extra Agents` can now join non-bug runs, which is part of the +requested addition. **Why.** [C-1](artifacts/current-state-findings.md#c-1-the-bug-framing-runs-through-every-step-of-skillmd-with-no-seam), [C-6](artifacts/current-state-findings.md#c-6-the-specialist-roster-its-triggers-and-its-prompts-are-inline-and-symptom-keyed). @@ -338,10 +435,12 @@ shared Evidence and Validation layout is `references/evidence-and-validation.md` ### S-6: `references/templates/{bug,how-it-works,available-options}.md` — Added -**Target state.** One template per type, with the title, Summary fields, and sections in the Per-type reports table, -and one shared-fragment marker each. +**Target state.** One template per type, with the title, type line, Summary fields, and sections in the Per-type +reports table, and one shared-fragment marker each. -**Behavior.** Preserving for `bug`. +**Behavior.** Changing for `bug` in one line: a bug report gains the line +`**Investigation type:** bug: Find the root cause of a failure and plan the fix` under its title. Every section is +unchanged. **Why.** [C-5](artifacts/current-state-findings.md#c-5-one-template-with-shared-carriers-and-bug-only-sections) @@ -349,10 +448,11 @@ and one shared-fragment marker each. ### S-7: `references/evidence-and-validation.md` — Added -**Target state.** One file owns the Evidence Summary (E-N), Validation Results (V-N), Adjustments Made, and Confidence -Assessment layouts every type report carries. Its wording names "the findings" rather than "the fix". +**Target state.** One file owns the Evidence Summary (E-N) and Validation Results (V-N, Adjustments Made, Confidence +Assessment) layouts every type report carries. Its guidance comments speak of "the findings" rather than "the fix". -**Behavior.** Preserving: the sections a bug report carries are unchanged. +**Behavior.** Preserving: the headings and fields a bug report carries are unchanged, and the reworded text is guidance +inside HTML comments, which no report contains. **Why.** [C-5](artifacts/current-state-findings.md#c-5-one-template-with-shared-carriers-and-bug-only-sections) @@ -360,32 +460,38 @@ Assessment layouts every type report carries. Its wording names "the findings" r ### S-8: Output location and the stop — Re-scoped -**Target state.** The report path resolves as Output location and the stop describes, the filename carries the type, -and the run ends with the type's `## Stop`. +**Target state.** The report path resolves as Output location and the stop describes, never overwrites an existing +file, and is shown in the announcement. The run ends with the type's `## Stop` and the shared switch line. -**Behavior.** Preserving for `bug`: the documented path contract (an explicit path wins; otherwise the skill proposes -one) and the approve-to-implement ending are unchanged. +**Behavior.** Changing, in small ways an operator can see. A configured `output-directory` is now honored. When no path +is named, the report lands at a stated location instead of one the model picks each time. The `bug` stop adds "No code +was changed." and the switch line, and keeps the approve-to-implement offer. -**Why.** [C-4](artifacts/current-state-findings.md#c-4-the-output-files-location-and-name-are-never-specified-and-write-is-not-in-allowed-tools), -[C-11](artifacts/current-state-findings.md#c-11-the-stop-point-says-approval-triggers-implementation-but-nothing-implements) +**Why.** "The plan file" has no antecedent and the location is unspecified +([C-4](artifacts/current-state-findings.md#c-4-the-output-files-location-and-name-are-never-specified-and-write-is-not-in-allowed-tools)). +This is cleanup beside the main change, justified on its own by C-4: the announcement has to show a path, so the path +has to be determined before dispatch. **Decision.** [D-8](artifacts/change-decision-log.md#d-8-output-location-keeps-the-documented-contract), [D-9](artifacts/change-decision-log.md#d-9-the-stop-per-type) ### S-9: `SKILL.md` frontmatter — Re-scoped -**Target state.** The `description` says `investigate` investigates this codebase in one of three types, named or -detected, and does not research the open web or prior art (use `research`). The `argument-hint` is -`"[type: bug | how-it-works | available-options] [question or symptom] [optional output path: ./path.md or /abs/path.md]"`. -`allowed-tools` adds `Write`, `Skill`, and `AskUserQuestion`. +**Target state.** The `description` says `investigate` investigates this codebase in one of three types (backticked +`bug`, `how-it-works`, `available-options`), named or detected, and does not research the open web or prior art (use +`research`), write an orientation to a whole area (use `code-overview`), or pace someone through code (use +`code-walkthrough`). The `argument-hint` is +`"[type: `bug` | `how-it-works` | `available-options`] [question or symptom] [optional report path ending in .md]"`, +listing only the tokens shipped so far. `allowed-tools` adds `Write`, `Skill`, and `AskUserQuestion`. **Behavior.** Changing, as requested: the skill now triggers on how-it-works and options questions about the codebase. +The added tools need no new approval from the operator. **Why.** [C-2](artifacts/current-state-findings.md#c-2-the-description-sends-how-something-works-and-options-to-research), [C-4](artifacts/current-state-findings.md#c-4-the-output-files-location-and-name-are-never-specified-and-write-is-not-in-allowed-tools) **Decision.** [D-10](artifacts/change-decision-log.md#d-10-allowed-tools), -[D-12](artifacts/change-decision-log.md#d-12-the-research-boundary) +[D-12](artifacts/change-decision-log.md#d-12-the-research-and-explanation-boundaries) ### S-10: `research` description and docs — Re-scoped @@ -396,13 +502,25 @@ how this codebase works, or which options it supports, to `investigate`. **Depends on.** S-9, in the same unit. -**Decision.** [D-12](artifacts/change-decision-log.md#d-12-the-research-boundary) +**Decision.** [D-12](artifacts/change-decision-log.md#d-12-the-research-and-explanation-boundaries) + +### S-11: `code-overview` and `code-walkthrough` descriptions and docs — Re-scoped + +**Target state.** Each description and long-form doc carries one sentence sending a single question about how the code +behaves to `investigate`. `code-overview` still owns an orientation to a whole target; `code-walkthrough` still owns +pacing a person through code. + +**Behavior.** Changing, as the operator chose during the run. + +**Depends on.** S-9. + +**Decision.** [D-12](artifacts/change-decision-log.md#d-12-the-research-and-explanation-boundaries) -### S-11: `investigate-to-confluence` — Re-scoped +### S-12: `investigate-to-confluence` — Re-scoped **Target state.** The wrapper accepts any of the three types, passes a leading type token through first, passes its `/tmp/investigate-{slug}.md` path as the final token, describes the report as "a single report whose sections follow the -investigation type", and still tells `investigate` to stop after the report. +investigation type", and still tells `investigate` to stop after the report and implement nothing. **Behavior.** Changing, as agreed: non-bug requests are accepted. @@ -412,36 +530,45 @@ investigation type", and still tells `investigate` to stop after the report. **Decision.** [D-13](artifacts/change-decision-log.md#d-13-the-confluence-wrapper) -### S-12: `scripts/investigation-types.bats` — Added +### S-13: `scripts/investigation-types.bats` — Added -**Target state.** A Bats test asserts the four agreements in The guarding test. +**Target state.** A Bats test asserts the six agreements in The guarding test. -**Behavior.** Preserving. +**Behavior.** Changing (docs and tests only). -**Depends on.** S-1, S-2, S-6. +**Depends on.** S-1, S-2, S-6, S-7. **Decision.** [D-11](artifacts/change-decision-log.md#d-11-a-bats-test-holds-the-token-list-together) -### S-13: `evals/investigate/` — Re-scoped +### S-14: `evals/investigate/` — Re-scoped -**Target state.** The existing four evals stay. The bug eval also asserts `**Investigation type:** bug`. New evals cover -a how-it-works prompt, an available-options prompt (each asserting its announcement), and a prior-art prompt that must -not trigger `investigate`. +**Target state.** The four existing evals stay. The bug eval also asserts +`{ "result-contains": "**Investigation type:** bug" }`. Three new `skill-prompt` evals exist: -**Behavior.** Preserving. +- `prompt-how-it-works.md` on a new `ruby-shop` scaffold: `result-contains` `**Investigation type:** how-it-works`, + `result-does-not-contain` `Planned Fix`, and `skill-call` `han-coding:investigate` true. +- `prompt-available-options.md` on `ruby-shop`: `result-contains` `**Investigation type:** available-options`, and + `skill-call` true. +- `prompt-prior-art.md` with no scaffold: `skill-call` `han-coding:investigate` false. + +`tests.json`'s `plugins` adds `han-research`, so the prior-art eval tests the split against a real alternative. The +`ruby-shop` scaffold is a small Ruby project with a cart, a pricing module, and two discount implementations that +duplicate a pattern, so how-it-works and options questions have real material and no obvious defect. + +**Behavior.** Changing (docs and tests only). **Why.** [C-13](artifacts/current-state-findings.md#c-13-evals-assert-root-cause-and-cover-only-bug-triggering) **Decision.** [D-14](artifacts/change-decision-log.md#d-14-eval-coverage) -### S-14: Documentation surfaces — Re-scoped +### S-15: Documentation surfaces — Re-scoped **Target state.** The long-form doc carries the types table, the grammar examples, each type's report, and the boundaries with `research`, `code-overview`, and `code-walkthrough`. The `han-coding` README scent line, the skills index, `docs/workflows.md`, `docs/how-to/research-a-decision.md`, and the Confluence wrapper's long-form doc describe three types. -**Behavior.** Preserving. +**Behavior.** Changing (docs and tests only). **Why.** [C-14](artifacts/current-state-findings.md#c-14-other-surfaces-describe-investigate-as-bug-only) @@ -449,70 +576,95 @@ three types. ## Behavior Changes -Every behavior change here is one the operator asked for: +The operator asked for these: + +- **A question about how the code works, or about the ways to do a piece of work, gets its own kind of report.** Today + those questions are sent to `/research`, or forced into a bug report. +- **A named type that clearly does not fit the question triggers one question before the run starts.** The operator can + switch to the suggested type or keep their own. +- **`/research`, `/code-overview`, and `/code-walkthrough` send single codebase questions to `/investigate`,** and the + Confluence wrapper accepts non-bug questions. -- **A question about how the code works, or about the ways to do a piece of work, now gets its own kind of report.** - Today those questions are steered to `/research`, or forced into a bug report. Requested in the operator's own words. -- **A named type that does not fit the question triggers one question before the run starts.** Requested: "validate - that the specified type is acceptable for the prompt, and suggest an alternative type when needed." -- **`/research` stops claiming codebase questions,** and the Confluence wrapper accepts non-bug questions. Agreed in the - confirmation turn. +These follow from the request rather than being asked for by name. Each is listed so nothing changes unannounced: -A bug investigation produces the same report, with the same ending, that it does today. +- **Every run opens with a five-line block** naming the type, why it was chosen, the question as the skill read it, + where the report will be written, and the other types. +- **A question with no failure, "how", or options wording in it now gets an explanation, not a bug report.** The + announcement says it defaulted, and the shared stop line shows how to re-run as `bug`. +- **A leading type word is no longer part of the question.** `/investigate bug reports are dropped` investigates + "reports are dropped" as a bug. +- **A final `.md` path that does not exist yet is the report destination,** and one that exists stays in the question. +- **A configured `output-directory` is now honored,** and with nothing configured or named, reports land in + `{documentation root}/investigations/`. +- **Bug reports gain one line** naming the type under the title, and the bug stop adds "No code was changed." plus the + re-run line. Replying "approve" still has the session implement the fix. +- **Configured extra agents can join non-bug runs** when their specialty matches the question. + +A bug investigation otherwise runs the same agents and writes the same sections in the same order. ## Change Units -### Unit 1: Extract the `bug` type with no behavior change +The evals cannot be run from this repository: `tests.json` has no runner in the repo, and `claude plugin eval` reads a +different format ([Open Items](#open-items)). Each unit's check is therefore `npm test` and `npm run lint`, with the +Bats test carrying what structure can prove, and a trial run of each type after Unit 3. + +### Unit 1: Extract the `bug` type with no behavior change beyond the visible additions **What it does.** Moves the bug-specific content into `references/types/bug.md` and `references/templates/bug.md`, moves the shared sections into `references/evidence-and-validation.md`, removes `template.md`, adds the one-row table -and the type-file contract, points Steps 2 to 6 at the type file, pins the output path and filename, adds `Write` and -`Skill`, and adds the Bats test. The long-form doc's template link moves with it. +and the type-file contract, points Steps 2 to 6 at the type file, adds Step 1's parsing, announcement, and output +resolution, adds `Write` and `Skill`, sets the `argument-hint` to list `bug`, and adds the Bats test. The long-form +doc's template link moves with it, and the bug eval gains its announcement assertion. -**Delta entries.** S-1 (bug only), S-2, S-4, S-5, S-6 (bug only), S-7, S-8, S-12. +**Delta entries.** S-1 (bug), S-2, S-3 (parsing, announcement), S-4, S-5, S-6 (bug), S-7, S-8, S-9 (hint and tools), +S-13, S-14 (bug assertion). -**How you know it worked.** `npm test` and `npm run lint` pass. The existing bug eval still finds "Root Cause". +**How you know it worked.** `npm test` passes, including all six Bats checks with one type. `npm run lint` passes. -### Unit 2: Add `how-it-works`, type resolution, and the `research` boundary +### Unit 2: Add `how-it-works`, type resolution, and the boundaries -**What it does.** Adds the second type file and template, Step 1's grammar, resolution, fit check, and announcement, -`AskUserQuestion`, the new `argument-hint`, and the new `investigate` and `research` descriptions together. +**What it does.** Adds the second type file and template, Step 1's detection, tie-break, fit check, and +`AskUserQuestion`, adds `how-it-works` to the `argument-hint`, and changes the `investigate`, `research`, +`code-overview`, and `code-walkthrough` descriptions together. Adds the `ruby-shop` scaffold, the how-it-works eval, and +the prior-art eval. -**Delta entries.** S-1, S-3, S-6, S-9, S-10. +**Delta entries.** S-1, S-3 (resolution), S-6, S-9, S-10, S-11, S-14. -**Ordering constraint.** After Unit 1. The two descriptions change in one commit, so the two skills never both claim -"how something works". +**Ordering constraint.** After Unit 1. The four descriptions change in one commit, so no two skills claim the same +question at any commit. -**How you know it worked.** `npm test` passes with two types. +**How you know it worked.** `npm test` passes with two types, including Bats check 6. `tests.json` parses with `jq`. ### Unit 3: Add `available-options` -**What it does.** Adds the third type file, template, table row, and tokens. +**What it does.** Adds the third type file, template, table row, `argument-hint` token, and the available-options eval. -**Delta entries.** S-1, S-6, S-9. +**Delta entries.** S-1, S-6, S-9, S-14. -**How you know it worked.** `npm test` passes with three types. +**How you know it worked.** `npm test` passes with three types. A trial run of each type in this repo produces a +report with that type's sections, which is the check on the off-type agents and the validator. ### Unit 4: Update the Confluence wrapper and the docs -**Delta entries.** S-11, S-14. +**Delta entries.** S-12, S-15. -**How you know it worked.** Lint passes; no doc describes `investigate` as bug-only. - -### Unit 5: Add the evals - -**Delta entries.** S-13. - -**How you know it worked.** `tests.json` parses, and each new eval names a prompt file that exists. +**How you know it worked.** `npm run lint` passes. `grep -rn "bug, failure, or unexpected behavior"` over +`han-coding/README.md`, `docs/skills/README.md`, `han-coding/docs/skills/investigate.md`, and `han-atlassian/` finds +no line describing `investigate` as bug-only. ## Risks -- **Detection misroutes.** A question that mentions a failure in passing could resolve to `bug`. The announcement line - makes the type visible before any work, and the operator can re-run with a token. The evals catch the common shapes. +- **Detection misroutes.** A question that mentions a failure in passing could resolve to `bug`, and a neutral symptom + could resolve to `how-it-works`. The announcement shows the type, the reason, and the runner-up before any agent runs, + and the stop shows how to re-run. The evals check the common shapes once a runner exists. - **Off-type agents underperform.** Nobody has run `codebase-explorer` or `behavioral-analyst` on a question rather than - a feature or a focus area - ([C-7](artifacts/current-state-findings.md#c-7-evidence-based-investigator-is-bug-framed-codebase-explorer-and-behavioral-analyst-are-neutral)). - A trial run of each type after Unit 3 is the early check. + a feature or a focus area, or briefed `adversarial-validator` with a coverage claim in its fix slot + ([C-7](artifacts/current-state-findings.md#c-7-evidence-based-investigator-is-bug-framed-codebase-explorer-and-behavioral-analyst-are-neutral), + [C-8](artifacts/current-state-findings.md#c-8-adversarial-validator-requires-a-planned-fix-and-mandates-challenging-it)). + The trial run after Unit 3 is the early check. +- **The Confluence wrapper's `/tmp` path.** The wrapper names a path that does not exist yet, which the new grammar + reads as the out-path. If a stale file sits at that path, the path stays in the question and the report goes to the + default location instead. The wrapper captures the path `investigate` reports, so it still finds the file. ## Deferred (YAGNI) @@ -520,22 +672,43 @@ and the type-file contract, points Steps 2 to 6 at the type file, pins the outpu of types exists. Reopen when an operator asks for one. - **A dedicated codebase-options agent.** One caller, no second named. Reopen when trial runs show the explorer and structural-analyst pair misses the options space. -- **Correcting near-miss tokens such as `how-it-work`.** Reopen when evals or users show misspellings misrouting - despite the announcement. +- **Correcting near-miss tokens such as `how-it-work`.** The announcement shows the detected type and the other tokens. + Reopen when evals or users show misspellings misrouting anyway. - **A diagram or "where to change" section in the how-it-works report.** Reopen on reader feedback from trial runs. - **Type aliases such as `options`.** Reopen on measured misses. - -## Cut for Scope - -- **Rewording `code-overview` and `code-walkthrough` descriptions** to point single-question explanations at - `investigate how-it-works`. The confirmed area in `artifacts/scope-boundary.md` does not list either skill. Their - descriptions stay true as written, since both still send bugs to `investigate`. The boundary is stated from - `investigate`'s side only. +- **A Bats check that every `## Dispatch` agent exists as a file.** No incident of a missing agent shipping. Reopen when + one does. +- **A `## Purpose` section in each type file.** The table's Purpose cell is the one copy, and every reader goes through + the table. Reopen when something reads a type file without the table. +- **An eval for the fit-check question.** How the eval runner handles an `AskUserQuestion` turn is unknown. Reopen once + a runner exists and handles one. ## Open Items -None yet. The review round has not run. +- **No eval runner in the repository (non-blocking).** `evals/*/tests.json` has no runner in the repo, and + `claude plugin eval` reads `case.yaml` or `prompt.md` with graders instead. The new evals are written in the existing + format so they run wherever the current ones do. Settled by the operator naming the runner, or by porting the suites. ## Review Findings -Not yet run. +`han-core:junior-developer`, `han-core:test-engineer`, and `han-core:user-experience-designer` reviewed the draft in +one round. The findings that changed the plan: + +- **The `bug` run's sameness was overclaimed.** The draft called several visible changes preserving. They are now listed + under Behavior Changes, and S-3, S-6, and S-8 are classified Changing. +- **The Bats test would have failed at Unit 1** because the `argument-hint` changed only in Unit 2, and it checked + tokens in one direction only. The hint now changes in each unit with the tokens shipped so far, and check 1 compares + all four token sets. +- **Unit checks that could not fail.** The eval-based checks had no runner. Each unit now rests on Bats checks that + can fail, and the plan states the runner gap as an open item. +- **The announcement hid the parse, and a trailing path could overwrite the file being asked about.** The announcement + now shows the question, the reason, the report path, and the other types, and an existing file is never an out-path. +- **Tokens appeared outside the table.** The tie-break order and the default are now the table's row order, and the + usage message and shared stop line are built from the table. +- **The `code-overview` and `code-walkthrough` overlap** went to the operator, who chose to add a boundary line to both. +- **Smaller fixes:** the stop pointers name their plugins, the fit-check question quotes the operator's words, the + how-it-works Summary says Unverified Paths, the filename drops the type, the validator brief form is pinned, and the + `## Purpose` section and the agent-existence check moved to Deferred. + +None of the findings rested on an input a specialist could not inspect, except the eval runner's handling of +`AskUserQuestion`, which is deferred. The decisions are in `artifacts/change-decision-log.md`. From 2efde2b6bb9c062c2e1f9bf080c372347869ee01 Mon Sep 17 00:00:00 2001 From: River Bailey Date: Thu, 12 Nov 2026 08:35:36 -0700 Subject: [PATCH 05/10] docs(plans): apply the readability pass and keep AskUserQuestion out of allowed-tools --- .../artifacts/change-decision-log.md | 4 ++- docs/plans/investigate-types/change-plan.md | 33 ++++++++++--------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/docs/plans/investigate-types/artifacts/change-decision-log.md b/docs/plans/investigate-types/artifacts/change-decision-log.md index 07559e95..2750b7f1 100644 --- a/docs/plans/investigate-types/artifacts/change-decision-log.md +++ b/docs/plans/investigate-types/artifacts/change-decision-log.md @@ -10,7 +10,9 @@ as numbered C-N findings. ## Trivial decisions - D-10: allowed-tools — `allowed-tools` adds `Write` (the skill writes a report, C-4), `Skill` (it invokes - `readability-guidance`; `restructure` is the han-coding precedent), and `AskUserQuestion` (the fit check). — + `readability-guidance`; `restructure` is the han-coding precedent), and nothing else. `AskUserQuestion` is called by the fit check but stays out of `allowed-tools`, per + `han-plugin-builder/skills/guidance/references/skill-building-guidance/allowed-tools-AskUserQuestion.md`: listing it + makes the question return empty answers without being shown. Corrected during implementation; the plan first listed it. — Referenced in plan: Output location and the stop, S-9. - D-15: Documentation — the long-form doc, README scent line, skills index, `docs/workflows.md`, `docs/how-to/research-a-decision.md`, and the Confluence wrapper's doc describe three types, per CLAUDE.md's "one diff --git a/docs/plans/investigate-types/change-plan.md b/docs/plans/investigate-types/change-plan.md index 5bc159f6..28ace51f 100644 --- a/docs/plans/investigate-types/change-plan.md +++ b/docs/plans/investigate-types/change-plan.md @@ -4,8 +4,8 @@ `/investigate` assumes every investigation is a bug, and many of the operator's investigations are not. In their words: "a lot of the investigation i do is not centered around bugs, but rather investigation into how the code works and what -options are available for doing work." This is a constraint arriving: a new requirement the current structure cannot -absorb, because the bug framing is written into most of its steps. The source is the operator's own request, recorded +options are available for doing work." This is a new requirement that the current structure cannot absorb, because the bug +framing is written into most of its steps. The source is the operator's own request, recorded word for word in `artifacts/scope-boundary.md`. ## What Changes, In One Paragraph @@ -20,7 +20,7 @@ writes the same report sections it writes today. ## Current State -The bug framing runs through most of `SKILL.md`. The shared parts (config, evidence rule, E-series, validator mechanics, +The bug framing runs through most of `SKILL.md`. The shared parts (config, evidence rule, E-series (the numbered evidence items), validator mechanics, readability passes) are already type-agnostic, but nothing separates them from the bug-specific parts ([C-1](artifacts/current-state-findings.md#c-1-the-bug-framing-runs-through-every-step-of-skillmd-with-no-seam)). The skill's own description sends "how something works" and "options" to `research`, which claims both @@ -311,7 +311,8 @@ The run ends by printing the type's `## Stop`, then one shared line built from t - **`available-options`:** `Report written to {path}. No code was changed. Reply with corrections to revise the report. To plan the recommended option, run /han-planning:plan-a-change (restructuring existing code) or /han-planning:plan-a-feature (new behavior) with this report; to weigh prior art beyond this codebase, run /han-research:research.` - **Shared line:** `Wrong kind of report? Re-run as /investigate {other token} , where {other token} is one of: {every other token}.` -`allowed-tools` adds `Write`, `Skill`, and `AskUserQuestion` +`allowed-tools` adds `Write` and `Skill`. `AskUserQuestion` stays out of it, because listing it makes the question +return empty answers without being shown ([D-10](artifacts/change-decision-log.md#d-10-allowed-tools)). ### The guarding test @@ -480,9 +481,11 @@ has to be determined before dispatch. **Target state.** The `description` says `investigate` investigates this codebase in one of three types (backticked `bug`, `how-it-works`, `available-options`), named or detected, and does not research the open web or prior art (use `research`), write an orientation to a whole area (use `code-overview`), or pace someone through code (use -`code-walkthrough`). The `argument-hint` is +`code-walkthrough`). + +The `argument-hint` is `"[type: `bug` | `how-it-works` | `available-options`] [question or symptom] [optional report path ending in .md]"`, -listing only the tokens shipped so far. `allowed-tools` adds `Write`, `Skill`, and `AskUserQuestion`. +listing only the tokens shipped so far. `allowed-tools` adds `Write` and `Skill`; `AskUserQuestion` stays out of it. **Behavior.** Changing, as requested: the skill now triggers on how-it-works and options questions about the codebase. The added tools need no new approval from the operator. @@ -610,11 +613,11 @@ Bats test carrying what structure can prove, and a trial run of each type after ### Unit 1: Extract the `bug` type with no behavior change beyond the visible additions -**What it does.** Moves the bug-specific content into `references/types/bug.md` and `references/templates/bug.md`, -moves the shared sections into `references/evidence-and-validation.md`, removes `template.md`, adds the one-row table -and the type-file contract, points Steps 2 to 6 at the type file, adds Step 1's parsing, announcement, and output -resolution, adds `Write` and `Skill`, sets the `argument-hint` to list `bug`, and adds the Bats test. The long-form -doc's template link moves with it, and the bug eval gains its announcement assertion. +**What it does.** Moves the bug-specific content into `references/types/bug.md` and `references/templates/bug.md`. +Moves the shared sections into `references/evidence-and-validation.md`, and removes `template.md`. Adds the one-row +table and the type-file contract, and points Steps 2 to 6 at the type file. Adds Step 1's parsing, announcement, and +output resolution. Adds `Write` and `Skill`, sets the `argument-hint` to list `bug`, and adds the Bats test. The +long-form doc's template link moves with it, and the bug eval gains its announcement assertion. **Delta entries.** S-1 (bug), S-2, S-3 (parsing, announcement), S-4, S-5, S-6 (bug), S-7, S-8, S-9 (hint and tools), S-13, S-14 (bug assertion). @@ -623,10 +626,10 @@ S-13, S-14 (bug assertion). ### Unit 2: Add `how-it-works`, type resolution, and the boundaries -**What it does.** Adds the second type file and template, Step 1's detection, tie-break, fit check, and -`AskUserQuestion`, adds `how-it-works` to the `argument-hint`, and changes the `investigate`, `research`, -`code-overview`, and `code-walkthrough` descriptions together. Adds the `ruby-shop` scaffold, the how-it-works eval, and -the prior-art eval. +**What it does.** Adds the second type file and template, and Step 1's detection, tie-break, fit check, and +the fit-check question. Adds `how-it-works` to the `argument-hint`. Changes the `investigate`, `research`, `code-overview`, +and `code-walkthrough` descriptions together. Adds the `ruby-shop` scaffold, the how-it-works eval, and the prior-art +eval. **Delta entries.** S-1, S-3 (resolution), S-6, S-9, S-10, S-11, S-14. From 81a998891f811f548b4b0ad999d5b0b701a5d11c Mon Sep 17 00:00:00 2001 From: River Bailey Date: Thu, 12 Nov 2026 08:42:28 -0700 Subject: [PATCH 06/10] refactor(investigate): extract the bug investigation type Move the bug-specific approach, dispatch, analysis, validation brief, audience, and stop into references/types/bug.md, and the report layout into references/templates/bug.md with the shared evidence and validation sections in references/evidence-and-validation.md. SKILL.md keeps the shared flow, gains the Investigation Types table and type-file contract, parses a leading type token and trailing report path, announces the resolved type before dispatch, and pins where the report is written. A Bats test holds the table, type files, templates, and argument-hint in agreement. --- evals/investigate/tests.json | 1 + han-coding/docs/skills/investigate.md | 2 +- han-coding/skills/investigate/SKILL.md | 307 +++++++++++------- .../references/evidence-and-validation.md | 72 ++++ .../{template.md => templates/bug.md} | 71 +--- .../investigate/references/types/bug.md | 47 +++ .../scripts/investigation-types.bats | 138 ++++++++ 7 files changed, 457 insertions(+), 181 deletions(-) create mode 100644 han-coding/skills/investigate/references/evidence-and-validation.md rename han-coding/skills/investigate/references/{template.md => templates/bug.md} (61%) create mode 100644 han-coding/skills/investigate/references/types/bug.md create mode 100644 han-coding/skills/investigate/scripts/investigation-types.bats diff --git a/evals/investigate/tests.json b/evals/investigate/tests.json index edcbc34b..3f16b46c 100644 --- a/evals/investigate/tests.json +++ b/evals/investigate/tests.json @@ -9,6 +9,7 @@ "scaffold": "ruby-project", "expect": [ { "result-contains": "Root Cause" }, + { "result-contains": "**Investigation type:** bug" }, { "skill-call": { "skill": "han-coding:investigate", "expected": true } } ] }, diff --git a/han-coding/docs/skills/investigate.md b/han-coding/docs/skills/investigate.md index 6b4e439f..2b391a22 100644 --- a/han-coding/docs/skills/investigate.md +++ b/han-coding/docs/skills/investigate.md @@ -147,7 +147,7 @@ The skill walks a five-step process: parallel alongside them based on how you described the symptom. After all complete, the skill compiles a unified numbered evidence list (E1, E2, E3, …), tagging specialist findings with their domain. 2. **Document root cause.** The skill writes Problem Statement, Evidence Summary, and Root Cause Analysis into the plan - file using the template at [`references/template.md`](../../skills/investigate/references/template.md). + file using the template at [`references/templates/bug.md`](../../skills/investigate/references/templates/bug.md). 3. **Plan the fix.** The skill resolves project config (CLAUDE.md → project-discovery.md → docs/ Glob fallback), reads ADRs and coding standards relevant to the fix, and writes the Planned Fix section with file-level changes justified by specific evidence items. diff --git a/han-coding/skills/investigate/SKILL.md b/han-coding/skills/investigate/SKILL.md index dd2056a4..3d7268e9 100644 --- a/han-coding/skills/investigate/SKILL.md +++ b/han-coding/skills/investigate/SKILL.md @@ -2,15 +2,16 @@ name: investigate description: > Evidence-based investigation of issues, bugs, API calls, integrations, and other aspects of software development that - need a deep dive to find the root cause and solutions. Use when you need to debug, troubleshoot, diagnose, or figure - out why something is broken. Does not review code for quality or style — use code-review for auditing changes or - post-code-review-to-pr for posting review feedback to GitHub. Does not assess architectural health or structural risk - — use architectural-analysis for architectural concerns. Does not research open-ended options, prior art, or how - something works when nothing is broken — use research for that. Does not plan the structural change a root cause - calls for — use plan-a-change. Does not map bounded contexts or domain boundaries — use ddd-analysis. Does not - capture feedback on Han's own skills — use han-feedback for that. -argument-hint: "[symptom or problem description, and optionally an output path]" -allowed-tools: Read, Glob, Grep, Agent, Bash(bash "${CLAUDE_PLUGIN_ROOT}/scripts/han-config-dir.sh") + need a deep dive to find the root cause and solutions, run as the `bug` investigation type. Use when you need to + debug, troubleshoot, diagnose, or figure out why something is broken. Does not review code for quality or style — use + code-review for auditing changes or post-code-review-to-pr for posting review feedback to GitHub. Does not assess + architectural health or structural risk — use architectural-analysis for architectural concerns. Does not research + open-ended options, prior art, or how something works when nothing is broken — use research for that. Does not plan + the structural change a root cause calls for — use plan-a-change. Does not map bounded contexts or domain boundaries — + use ddd-analysis. Does not capture feedback on Han's own skills — use han-feedback for that. +argument-hint: "[type: `bug`] [symptom or problem description] [optional report path ending in .md]" +allowed-tools: + Read, Glob, Grep, Agent, Write, Skill, Bash(bash "${CLAUDE_PLUGIN_ROOT}/scripts/han-config-dir.sh") --- ## Project Context @@ -27,138 +28,220 @@ between the two files, relative-path resolution, and what to do with a file that ## Investigation Approach -- Trace backward from symptoms — don't guess, follow the code. -- Launch parallel `han-core:evidence-based-investigator` agents for different angles simultaneously — one for the error - path, one for the data flow, one for recent changes. -- Add one or more specialist analysts **in parallel with** the investigators when the bug type calls for it - (concurrency, data flow across boundaries, database or query behavior). Specialist analysts find root causes - generalists miss. -- The `han-core:adversarial-validator` agent handles all three validation strategies (challenge evidence, challenge fix, - challenge assumptions) internally. +- Every run is one investigation type. The type file says what differs; this file says what every type shares. +- Launch the agents a type dispatches in parallel, in a single message. +- The `han-core:adversarial-validator` agent handles all three validation strategies (challenge evidence, challenge the + conclusion, challenge assumptions) internally. - Apply the evidence rule from [../../references/evidence-rule.md](../../references/evidence-rule.md) to every finding. Codebase findings (file path, line number, log line, test output) carry the trust-class label "codebase" and stand on - their citation. Web-source context (RFCs, vendor docs, Stack Overflow, blog posts) carries the trust-class label "web" - and is subject to the corroboration gate when it drives the proposed fix. When the investigation hits a point where no - evidence at any tier resolves a question, label the no-evidence state rather than guessing. -- Lazy-create the output sections. Include a section in the plan file only when the investigation produced meaningful - content for it; omit any section that would be empty, and keep the sections that remain in the template's order. Never - emit a heading with placeholder or "N/A" content. + their citation. Web-source context the operator pastes in (RFCs, vendor docs, Stack Overflow, blog posts) carries the + trust-class label "web" and is subject to the corroboration gate when it drives a conclusion. When the investigation + hits a point where no evidence at any tier resolves a question, label the no-evidence state rather than guessing. +- Lazy-create the output sections. Include a section in the report file only when the investigation produced meaningful + content for it; omit any section that would be empty, and keep the sections that remain in the template's order. + Never emit a heading with placeholder or "N/A" content. - Invoke `han-communication:readability-guidance` to source the shared readability standard into your context, then - apply it as you write the findings, holding the named audience: the engineer who will implement the fix and may be - paged on the bug. Scope that frame per section so the technical specifics the engineer needs (function names, exact - failing conditions, file:line citations) are preserved, never simplified away. + apply it as you write the findings, holding the named audience from the type file's `## Audience`. Scope that frame + per section so the technical specifics the reader needs (function names, exact conditions, file:line citations) are + preserved, never simplified away. + +## Investigation Types + +An investigation type names the one kind of question a run answers. Each shipped type is a data file under +`references/types/` with a report template under `references/templates/`, and this table is the only list of shipped +type tokens. Row order is the tie-break order when a question reads as more than one type, and the last row is the type +a question gets when it reads as none. + +| Token | File | Purpose | +| ----- | ---------------------------------------------------- | ------------------------------------------------- | +| `bug` | [references/types/bug.md](./references/types/bug.md) | Find the root cause of a failure and plan the fix | + +Templates: [references/templates/bug.md](./references/templates/bug.md). Every template carries one line +``; write the sections of +[references/evidence-and-validation.md](./references/evidence-and-validation.md) in that line's place. + +### The type-file contract + +Every type file has a `# Investigation type: {token}` title and these six `##` sections, in this order, outside any +fence. Every section has content. A short lead paragraph may open `## Dispatch` before its numbered list. + +| Section | Value form | Read at | +| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | +| `## Detection signals` | one or more bullets, `- {phrase}` | Step 1 | +| `## Dispatch` | a numbered list, one entry per agent: ``N. `{plugin}:{agent}` ({count}, {when}): "{prompt}"``, where `{count}` is a number or a number followed by `+`, `{when}` is `always` or `when {trigger}`, and `{question}` is the prompt's only placeholder | Step 2 | +| `## Analysis` | a numbered list of steps run between the evidence summary and validation, each naming in backticks the template heading it fills | Step 3 | +| `## Validation brief` | exactly three bullets, in this order: `- Root cause analysis: {text}`, `- Planned fix: {text}`, `- Attack focus: {text}` | Step 4 | +| `## Audience` | one sentence naming the reader | Steps 3 and 5 | +| `## Stop` | one blockquote line, with `{path}` as its only placeholder | Step 6 | + +[scripts/investigation-types.bats](./scripts/investigation-types.bats) holds the table, the type files, the templates, +and the `argument-hint` in agreement. Run `npm test` after editing any of them. # Investigate -## Step 1: Research and Investigation +## Step 1: Resolve the Type, the Question, and the Report Path + +### Parse the argument + +``` +args := [ type-token ] question [ out-path ] +type-token := a Token from ## Investigation Types; only the first whitespace-separated token; case-insensitive; + one trailing ":" is stripped before matching; never inside quotes +question := the remaining text, verbatim, as $question +out-path := the final token, when it ends in ".md" and does not name a file that already exists; removed from $question +``` + +A first token that is not a type token stays in `$question`. A final `.md` token that names an existing file stays in +`$question` too: it is the subject, and the run never writes over it. + +When `$question` is empty, use the problem or question the conversation's earlier messages describe. When there is +none, stop with this message, listing every row of the `## Investigation Types` table as `- {token}: {Purpose}`: + +``` +investigate needs a question or symptom. No investigation ran. +Usage: /investigate [type] [report path ending in .md] +Types: +- {token}: {Purpose} +``` -### Always dispatch +| Invocation | Type | `$question` | Out path | +| --------------------------------------------------------------- | ----------------------------- | ---------------------------------------------- | ---------------------------- | +| `/investigate bug checkout returns 500 after the coupon change` | `bug`, named | `checkout returns 500 after the coupon change` | none | +| `/investigate bug: cart total off by one cent` | `bug`, named (colon stripped) | `cart total off by one cent` | none | +| `/investigate checkout fails docs/incidents/checkout.md` | detected | `checkout fails` | `docs/incidents/checkout.md` | +| `/investigate why does the generator rewrite ./CHANGELOG.md` | detected | the whole string | none (the file exists) | -Launch at least 2 `han-core:evidence-based-investigator` agents in parallel, each investigating from a different angle — -for example, one tracing the error path and another following the data flow. +### Resolve the type -### Conditional specialist dispatch +Detection is a judgment you make against each type's `## Detection signals`. The signals are guidance written as +phrases, not literal strings to match. -Classify the bug from the user's symptom description before launching. Skip any specialist that does not apply. Dispatch -every applicable specialist in parallel with the `han-core:evidence-based-investigator` agents in the same message. +1. **No type token.** Decide which types' signals the question meets. When more than one does, the earliest row in the + table wins. When none does, the last row is the type. Proceed without asking. +2. **Type token named.** Check the named type fits. The check fails only when the question clearly meets another type's + signals and none of the named type's. Anything short of a clear mismatch keeps the operator's choice. On failure, ask + once with `AskUserQuestion`: + - Question: `You named {given}, but "{the operator's words that matched}" reads as {suggested}. Which type should this run use?` + - Options: `{suggested}`, described by its Purpose cell, and `{given} (as named)`, described by its Purpose cell. + - When more than one other type matches, `{suggested}` is the earliest such row. + - A free-text answer naming a token uses that token. Any other answer, or a dismissal, keeps the named type. -1. **Launch han-core:concurrency-analyst** — when the symptom involves intermittent failures, race conditions, - deadlocks, ordering issues, stale reads after writes, timeouts, dropped messages, or anything that only reproduces - under load or concurrent users. Prompt: "Investigate the concurrency and async behavior of the code paths implicated - by this symptom: {symptom}. Focus on race conditions, lock ordering, shared-resource contention, async error - handling, and missing cancellation/timeout handling. Return numbered findings keyed to file paths and line numbers." +Read the resolved type's file, `references/types/{token}.md`, in full. Its sections drive Steps 2 to 6. -2. **Launch han-core:behavioral-analyst** — when the symptom involves data transformed wrong, values lost between - modules, errors swallowed, state mutated unexpectedly, or integration boundaries passing bad data. Prompt: "Trace the - data flow for the code paths implicated by this symptom: {symptom}. Focus on data transformation across module - boundaries, error propagation and loss, state mutation, and integration-boundary assumptions. Return numbered - findings keyed to file paths and line numbers." +### Resolve the report path -3. **Launch han-core:data-engineer** — when the symptom involves wrong data in the database, slow queries, N+1, lock - contention, migration failures, unbounded scans, lost data, broken referential integrity, or isolation-level - surprises. Prompt: "Investigate the schema, queries, migrations, and data-access code implicated by this symptom: - {symptom}. Focus on the specific data-engineering principles violated and the concrete data-level impact. Return - numbered findings keyed to file paths, line numbers, and schema or migration references." +Resolve where the report is written, per [config-rule.md](../../references/config-rule.md): -Extra agents named in the project config's `## Extra Agents` list join this conditional-specialist pool under the same -symptom-driven selection, per [../../references/config-rule.md](../../references/config-rule.md): dispatch one only -when the classified bug type matches its stated specialty, and skip an entry that does not resolve to a dispatchable -agent with a one-line note. +1. The out-path from the argument, when there is one. A calling skill's explicit path arrives this way. +2. Otherwise, the configured `output-directory`, with the file written directly beneath it. +3. Otherwise, `{documentation root}/investigations/`. The documentation root comes from CLAUDE.md's + `## Project Discovery` section, then `project-discovery.md`, then `docs/` when it exists, then the repository root. -After all agents complete (investigators and specialists), compile an **evidence summary** — a numbered list of concrete -findings (E1, E2, E3, ...) that will feed into the root cause analysis. Specialist findings go into the same E-series -list, tagged with the specialist's domain (e.g., `E3 (concurrency)`). +Under 2 and 3, the filename is `investigate-{slug}.md`, where the slug is two to six words from `$question`, lowercase, +in `[a-z0-9-]`. When that file already exists, append `-2`, `-3`, and so on. Write without asking. -## Step 2: Document Root Cause +### Announce -Write to the plan file using the template at [template.md](./references/template.md). Fill the sections in the workflow -order below; this is deliberately not the template's on-page order, which leads with the Summary and places the -supporting Evidence Summary, Validation Results, and Coding Standards Reference near the end for the reader. Fill in -these sections: +Before any dispatch, print this block. `Other types` lists every other table token; omit that line when the table has +one row. -1. **Problem Statement** — document the symptoms, expected behavior, conditions under which it occurs, and impact. -2. **Evidence Summary** — consolidate evidence from all agents into a unified numbered list (E1, E2, E3, ...); merge - duplicates and resolve conflicting findings while preserving each item's output structure. -3. **Root Cause Analysis** — write a one-to-three sentence summary of the root cause, then a detailed analysis - referencing evidence items by number (e.g., "The handler passes an unvalidated ID (E1) to the service layer, which - assumes non-nil (E3)"). +``` +**Investigation type:** {token}: {Purpose} +**Chosen because:** {source} +**Question:** {$question} +**Report:** {path} +Other types: {every other token, comma-separated}. To switch, re-run as /investigate {token} . +``` -## Step 3: Plan the Fix +``` +source := "you named it" + | "detected from \"" {the operator's words that matched} "\"" + | "detected from \"" {words} "\"; it also read as " {runner-up token} + | "no type signal matched, so it defaulted to the last type" + | "you switched from " {given} " when asked" + | "kept as you named it when asked" +``` -Resolve project config: read CLAUDE.md's `## Project Discovery` section for docs, ADR, and coding-standards directories; -fall back to project-discovery.md; fall back to Glob defaults (`docs/`, `docs/adr/`, `docs/coding-standards/`). Search -found directories for relevant standards, ADRs, and docs. Also check `CLAUDE.md`, `AGENTS.md`, and linter/formatter -configs for coding standards. If none found, infer conventions from surrounding code. +## Step 2: Gather Evidence -Design a fix that **directly addresses the root cause** from Step 2 — fix the underlying problem, not symptoms. Then -fill in the remaining sections of [template.md](./references/template.md) in the plan file: +Dispatch every `## Dispatch` entry whose `{when}` is `always`, at its count, and every entry whose trigger the question +meets. Replace `{question}` with `$question`. When an entry's count ends in `+`, dispatch more than that number when the +question has more distinct angles. Skip any entry that does not apply. Launch all of them in parallel, in one message. -1. **Coding Standards Reference** — for each standard, convention, ADR, or pattern inferred from surrounding code that - governs the fix, document what it is, where it was found (file path, ADR number, or "inferred from surrounding - code"), and which files or changes it governs. If nothing governs the fix, omit the section per the lazy-create rule. -2. **Planned Fix** — write a one-sentence summary, then for each file that needs to change: full path from repo root, - what will be modified/added/removed, which evidence items (E1, E2, ...) justify the change, which coding standards - apply, and implementation specifics (new function signatures, changed logic, updated tests). +Extra agents named in the project config's `## Extra Agents` list join this pool under the same rule, per +[../../references/config-rule.md](../../references/config-rule.md): dispatch one only when the resolved type and the +question match its stated specialty, and skip an entry that does not resolve to a dispatchable agent with a one-line +note. + +After all agents complete, compile an **evidence summary**: a numbered list of concrete findings (E1, E2, E3, ...) that +feeds the analysis. Merge duplicates and resolve conflicting findings while preserving each item's output structure. +Tag a specialist's findings with its domain (e.g., `E3 (concurrency)`). + +## Step 3: Analyze and Write the Report + +Write to the report file using the type's template, `references/templates/{token}.md`. Fill the sections in the order +the type's `## Analysis` lists, which is deliberately not the template's on-page order: the template leads with the +Summary and places the supporting Evidence Summary and Validation Results near the end for the reader. + +Write the Evidence Summary from Step 2 first, then run each `## Analysis` step into the template section it names. + +When an `## Analysis` step resolves coding standards, read CLAUDE.md's `## Project Discovery` section for docs, ADR, +and coding-standards directories; fall back to project-discovery.md; fall back to Glob defaults (`docs/`, `docs/adr/`, +`docs/coding-standards/`). Search found directories for relevant standards, ADRs, and docs. Also check `CLAUDE.md`, +`AGENTS.md`, and linter/formatter configs. If none are found, infer conventions from surrounding code. ## Step 4: Validation (CRITICAL) -Launch `han-core:adversarial-validator` agents and pass them the complete evidence summary (all E1-EN items with full -code snippets), the root cause analysis, and the planned fix with all file changes. Do not summarize — the validator -needs verbatim detail to challenge effectively. Their job is adversarial — they must actively try to disprove the -findings and break the fix. +Launch `han-core:adversarial-validator` agents with a brief in this form, filled from the type's `## Validation brief`: + +``` +This is a {token} investigation. {Purpose}. + +Evidence summary: +{every E-item, verbatim, with code} + +Root cause analysis (for this investigation type, this is {Root cause analysis text}): +{that section, verbatim} + +Planned fix (for this investigation type, this is {Planned fix text}): +{that section, verbatim} + +Attack focus: {Attack focus text} +``` + +Do not summarize. The validator needs verbatim detail to challenge effectively. Its job is adversarial: it must actively +try to disprove the findings and break the conclusion. When counter-evidence is found, document it as a validation finding (V1, V2, ...), investigate whether it changes the -root cause analysis, adjust the plan (evidence, root cause, and fix sections) as needed, and fill in the **Adjustments -Made** section listing what changed and which validation finding triggered each change. When counter-evidence is not -found, document what was checked and why it supports the original findings, recording it as a validation finding -confirming the analysis. +analysis, adjust the report's evidence and analysis sections as needed, and fill in the **Adjustments Made** section +listing what changed and which validation finding triggered each change. When counter-evidence is not found, document +what was checked and why it supports the original findings, recording it as a validation finding confirming the +analysis. -After all validation is complete, incorporate the `han-core:adversarial-validator` agents' Confidence Assessment and -Remaining Risks into the plan. +After all validation is complete, incorporate the validators' Confidence Assessment and Remaining Risks into the report. -## Step 5: Summary and User Review +## Step 5: Summary and Readability -Add the **Summary** section at the top of the plan file with one sentence each for: root cause (what caused the -problem), fix (what the planned changes will do), why correct (reference the strongest evidence), validation outcome -(what validation confirmed or changed), and remaining risks (reference the Confidence Assessment). +Add the **Summary** section at the top of the report file, one sentence for each field the template's Summary lists. +Reference the strongest evidence and the Confidence Assessment where the fields call for them. Once the write-up draft is complete, dispatch `han-communication:readability-editor` (one Agent call) to audit and -rewrite the findings against the readability standard. This is separate from the Step 4 adversarial-validator pass: that -pass checks the fix is correct (accuracy); this pass checks how the write-up reads. Keep both. Pass the editor the plan -file path and the named audience: the engineer who will implement the fix and may be paged on the bug; the editor reads -han-communication's own canonical rule, so pass no rule path. It must preserve every fact and operate on prose regions -only — never inside code fences, function signatures in code blocks, diagram bodies, or file:line citation identifiers. -Apply its rewrite to the plan file. - -Then run the standardized readability self-check (the shared standard is in your context from -`han-communication:readability-guidance`) over the write-up's prose regions only — never inside code fences, function -signatures, diagram bodies, or file:line citation identifiers. Confirm each criterion and fix any failure before -presenting: - -Run the readability rule's standardized self-check, which is already in your context from the `readability-guidance` -invocation above. Correct every failure before presenting. Its fidelity criterion is not optional: the standard governs -how the content is said, and drops a required fact only when the reader asked for less and losing it would not change -what they do next. - -Present the plan file to the user for approval. The user can approve the plan (triggering implementation) or provide -feedback for revisions. +rewrite the findings against the readability standard. This is separate from the Step 4 adversarial-validator pass: +that pass checks the findings are correct (accuracy); this pass checks how the write-up reads. Keep both. Pass the +editor the report file path and the named audience from the type's `## Audience`; the editor reads han-communication's +own canonical rule, so pass no rule path. It must preserve every fact and operate on prose regions only, never inside +code fences, function signatures in code blocks, diagram bodies, or file:line citation identifiers. Apply its rewrite to +the report file. + +Then run the readability rule's standardized self-check, which is already in your context from the +`readability-guidance` invocation above, over the write-up's prose regions only. Correct every failure before +presenting. Its fidelity criterion is not optional: the standard governs how the content is said, and drops a required +fact only when the reader asked for less and losing it would not change what they do next. + +## Step 6: Present the Report + +Print the type's `## Stop` line with `{path}` filled in. When the table has more than one row, follow it with: + +``` +Wrong kind of report? Re-run as /investigate {other token} , where {other token} is one of: {every other token}. +``` diff --git a/han-coding/skills/investigate/references/evidence-and-validation.md b/han-coding/skills/investigate/references/evidence-and-validation.md new file mode 100644 index 00000000..37b5e584 --- /dev/null +++ b/han-coding/skills/investigate/references/evidence-and-validation.md @@ -0,0 +1,72 @@ +# Shared Report Sections: Evidence and Validation + +`; write these sections in that line's place, in the order shown. The lazy-create rule applies here as everywhere: omit a section that would be empty. --> + +## Evidence Summary + + + + + +### E1: {Brief description of finding} + +- **Source:** `path/to/file.ext:line_number` +- **Finding:** + ``` + + ``` +- **Relevance:** + +### E2: {Brief description of finding} + +- **Source:** `path/to/file.ext:line_number` +- **Finding:** + ``` + + ``` +- **Relevance:** + +### E3: {Brief description of finding} + +- **Source:** `path/to/file.ext:line_number` +- **Finding:** + ``` + + ``` +- **Relevance:** + + + +## Validation Results + + + +### Counter-Evidence Investigated + + + +#### V1: {Hypothesis tested} + +- **Hypothesis:** +- **Investigation:** +- **Result:** Confirmed / Refuted / Partially Refuted +- **Impact:** + +#### V2: {Hypothesis tested} + +- **Hypothesis:** +- **Investigation:** +- **Result:** Confirmed / Refuted / Partially Refuted +- **Impact:** + + + +### Adjustments Made + + + + +### Confidence Assessment + +- **Confidence:** High / Medium / Low +- **Remaining Risks:** diff --git a/han-coding/skills/investigate/references/template.md b/han-coding/skills/investigate/references/templates/bug.md similarity index 61% rename from han-coding/skills/investigate/references/template.md rename to han-coding/skills/investigate/references/templates/bug.md index 97d493eb..1652f93e 100644 --- a/han-coding/skills/investigate/references/template.md +++ b/han-coding/skills/investigate/references/templates/bug.md @@ -1,5 +1,7 @@ # Investigation: {Issue Title} +**Investigation type:** bug: Find the root cause of a failure and plan the fix + @@ -63,74 +65,7 @@ -## Evidence Summary - - - - - -### E1: {Brief description of finding} - -- **Source:** `path/to/file.ext:line_number` -- **Finding:** - ``` - - ``` -- **Relevance:** - -### E2: {Brief description of finding} - -- **Source:** `path/to/file.ext:line_number` -- **Finding:** - ``` - - ``` -- **Relevance:** - -### E3: {Brief description of finding} - -- **Source:** `path/to/file.ext:line_number` -- **Finding:** - ``` - - ``` -- **Relevance:** - - - -## Validation Results - - - -### Counter-Evidence Investigated - - - -#### V1: {Hypothesis tested} - -- **Hypothesis:** -- **Investigation:** -- **Result:** Confirmed / Refuted / Partially Refuted -- **Impact:** - -#### V2: {Hypothesis tested} - -- **Hypothesis:** -- **Investigation:** -- **Result:** Confirmed / Refuted / Partially Refuted -- **Impact:** - - - -### Adjustments Made - - - - -### Confidence Assessment - -- **Confidence:** High / Medium / Low -- **Remaining Risks:** + ## Coding Standards Reference diff --git a/han-coding/skills/investigate/references/types/bug.md b/han-coding/skills/investigate/references/types/bug.md new file mode 100644 index 00000000..198cf048 --- /dev/null +++ b/han-coding/skills/investigate/references/types/bug.md @@ -0,0 +1,47 @@ +# Investigation type: bug + +## Detection signals + +- something fails, errors, crashes, hangs, or times out +- something returns a wrong result, or behaves differently from what was expected +- something stopped working, or regressed after a change +- an error message, stack trace, log line, or failing test is quoted +- the operator asks to debug, troubleshoot, diagnose, or find a root cause + +## Dispatch + +Trace backward from the symptom: don't guess, follow the code. Launch the investigators and every applicable specialist +in one message. Specialist analysts find root causes generalists miss. + +1. `han-core:evidence-based-investigator` (2+, always): "Investigate this from one angle only, the one you are assigned (the error path, the data flow, or the recent changes): {question}. Trace backward from the symptom with concrete evidence: file paths, line numbers, code snippets, error messages, git history, and test coverage. Return numbered findings keyed to file paths and line numbers." +2. `han-core:concurrency-analyst` (1, when the question involves intermittent failures, race conditions, deadlocks, ordering issues, stale reads after writes, timeouts, dropped messages, or anything that only reproduces under load or concurrent users): "Investigate the concurrency and async behavior of the code paths implicated by this symptom: {question}. Focus on race conditions, lock ordering, shared-resource contention, async error handling, and missing cancellation/timeout handling. Return numbered findings keyed to file paths and line numbers." +3. `han-core:behavioral-analyst` (1, when the question involves data transformed wrong, values lost between modules, errors swallowed, state mutated unexpectedly, or integration boundaries passing bad data): "Trace the data flow for the code paths implicated by this symptom: {question}. Focus on data transformation across module boundaries, error propagation and loss, state mutation, and integration-boundary assumptions. Return numbered findings keyed to file paths and line numbers." +4. `han-core:data-engineer` (1, when the question involves wrong data in the database, slow queries, N+1, lock contention, migration failures, unbounded scans, lost data, broken referential integrity, or isolation-level surprises): "Investigate the schema, queries, migrations, and data-access code implicated by this symptom: {question}. Focus on the specific data-engineering principles violated and the concrete data-level impact. Return numbered findings keyed to file paths, line numbers, and schema or migration references." + +## Analysis + +1. Write `Problem Statement`: the symptoms, the expected behavior, the conditions under which it occurs, and the impact. +2. Write `Root Cause Analysis`: a one-to-three sentence summary of the root cause under Root Cause, then a detailed + analysis under Detailed Analysis that traces the causal chain from root cause to symptom and references evidence + items by number (e.g., "The handler passes an unvalidated ID (E1) to the service layer, which assumes non-nil (E3)"). +3. Resolve the coding standards that govern the fix, then write `Coding Standards Reference`: for each standard, + convention, ADR, or pattern inferred from surrounding code, what it is, where it was found (file path, ADR number, or + "inferred from surrounding code"), and which files or changes it governs. +4. Design a fix that **directly addresses the root cause**: fix the underlying problem, not symptoms. Write + `Planned Fix`: a one-sentence approach, then for each file that changes, its full path from the repo root, what will + be modified, added, or removed, which evidence items (E1, E2, ...) justify the change, which coding standards apply, + and implementation specifics (new function signatures, changed logic, updated tests). + +## Validation brief + +- Root cause analysis: the Root Cause Analysis section +- Planned fix: the Planned Fix section, with every file change +- Attack focus: break the fix, and the causal chain from root cause to symptom + +## Audience + +The engineer who will implement the fix and may be paged on the bug. + +## Stop + +> Report written to {path}. No code was changed. Reply "approve" to have this session implement the Planned Fix, or reply with corrections to revise the report. diff --git a/han-coding/skills/investigate/scripts/investigation-types.bats b/han-coding/skills/investigate/scripts/investigation-types.bats new file mode 100644 index 00000000..0add579f --- /dev/null +++ b/han-coding/skills/investigate/scripts/investigation-types.bats @@ -0,0 +1,138 @@ +#!/usr/bin/env bats +# +# Tests for investigate's shipped investigation types: the agreements that hold +# the `## Investigation Types` table in SKILL.md, the argument-hint and +# description, the type files under references/types/, the templates under +# references/templates/, and the shared evidence-and-validation fragment +# together. Each agreement spans files and holds only by convention, so it is +# checked here. + +setup() { + SKILL_DIR="$(cd "$BATS_TEST_DIRNAME/.." && pwd)" + REPO_ROOT="$(cd "$SKILL_DIR/../../.." && pwd)" + SKILL="$SKILL_DIR/SKILL.md" + TYPES_DIR="$SKILL_DIR/references/types" + TEMPLATES_DIR="$SKILL_DIR/references/templates" + FRAGMENT="$SKILL_DIR/references/evidence-and-validation.md" + MARKER='' +} + +# Print the body of the `## Investigation Types` section of SKILL.md, up to the next `## ` or `# ` heading. +types_section() { + awk '/^## Investigation Types$/{on=1; next} on && /^#{1,2} /{exit} on' "$SKILL" +} + +# Print each token from the `## Investigation Types` table, one per line, in row order. +table_tokens() { + types_section | awk -F'|' '/^\| `[a-z0-9-]+`/{gsub(/[ `]/, "", $2); print $2}' +} + +# Print the value of a frontmatter key from SKILL.md, joined onto one line (handles folded blocks). +frontmatter_value() { # key + awk '/^---$/{n++; next} n==1' "$SKILL" | + awk -v k="$1" '$0 ~ "^"k":"{on=1; sub("^"k":[ ]*>?[ ]*", ""); print; next} on && /^ /{print; next} {on=0}' | + tr '\n' ' ' +} + +# Print each backticked token in a string, one per line. +backticked() { # text + printf '%s\n' "$1" | grep -oE '`[a-z0-9-]+`' | tr -d '`' +} + +# Print the `## ` headings of a file outside fenced blocks, one per line. +headings() { # file + awk '/^```/{fence=!fence; next} !fence && /^## /' "$1" +} + +# Print the body of one `## ` section of a file, outside fenced blocks. +section_body() { # file heading + awk -v h="## $2" '/^```/{fence=!fence} !fence && $0==h{on=1; next} on && !fence && /^## /{exit} on' "$1" +} + +sorted_basenames() { # dir + for f in "$1"/*.md; do basename "$f" .md; done | sort +} + +@test "type files, table rows, templates, and argument-hint tokens are the same set, and the description names each" { + types="$(sorted_basenames "$TYPES_DIR")" + rows="$(table_tokens | sort)" + templates="$(sorted_basenames "$TEMPLATES_DIR")" + hint="$(backticked "$(frontmatter_value argument-hint)" | sort -u)" + [ "$types" = "$rows" ] || { echo "type files: $types"; echo "table rows: $rows"; return 1; } + [ "$types" = "$templates" ] || { echo "type files: $types"; echo "templates: $templates"; return 1; } + [ "$types" = "$hint" ] || { echo "type files: $types"; echo "argument-hint tokens: $hint"; return 1; } + description="$(frontmatter_value description)" + while read -r token; do + run grep -E "^\| \`$token\` +\| \[references/types/$token\.md\]\(\./references/types/$token\.md\) +\|" <(types_section) + [ "$status" -eq 0 ] || { echo "no well-formed table row for $token"; return 1; } + [[ "$description" == *"\`$token\`"* ]] || { echo "description lacks \`$token\`"; return 1; } + done <<<"$types" +} + +@test "every type file follows the type-file contract" { + expected=$'## Detection signals\n## Dispatch\n## Analysis\n## Validation brief\n## Audience\n## Stop' + for f in "$TYPES_DIR"/*.md; do + token="$(basename "$f" .md)" + [ "$(head -n 1 "$f")" = "# Investigation type: $token" ] || { echo "$f: bad title"; return 1; } + [ "$(headings "$f")" = "$expected" ] || { echo "$f: sections are"; headings "$f"; return 1; } + + section_body "$f" "Detection signals" | grep -qE '^- .+' || { echo "$f: no detection signal"; return 1; } + + entries="$(section_body "$f" "Dispatch" | grep -E '^[0-9]+\. ')" + [ -n "$entries" ] || { echo "$f: no dispatch entry"; return 1; } + while read -r entry; do + [[ "$entry" =~ ^[0-9]+\.\ \`[a-z0-9-]+:[a-z0-9-]+\`\ \([0-9]+\+?,\ (always|when\ .+)\):\ \".+\"$ ]] || + { echo "$f: malformed dispatch entry: $entry"; return 1; } + placeholders="$(printf '%s\n' "$entry" | grep -oE '\{[a-z_]+\}' | sort -u)" + [ "$placeholders" = "{question}" ] || { echo "$f: dispatch placeholders are $placeholders"; return 1; } + done <<<"$entries" + + while read -r named; do + [ -z "$named" ] && continue + grep -qxF "## $named" "$TEMPLATES_DIR/$token.md" || + { echo "$f: Analysis names \`$named\`, which templates/$token.md has no heading for"; return 1; } + done < <(section_body "$f" "Analysis" | grep -E '^[0-9]+\. ' | grep -oE '^[0-9]+\. [^`]*`[^`]+`' | sed -E 's/.*`([^`]+)`$/\1/') + + brief="$(section_body "$f" "Validation brief" | grep -E '^- ')" + [ "$(printf '%s\n' "$brief" | wc -l | tr -d ' ')" -eq 3 ] || { echo "$f: brief needs exactly three bullets"; return 1; } + [ "$(printf '%s\n' "$brief" | sed -E 's/^(- [A-Za-z ]+: ).*/\1/')" = $'- Root cause analysis: \n- Planned fix: \n- Attack focus: ' ] || + { echo "$f: brief bullets are"; echo "$brief"; return 1; } + + stop="$(section_body "$f" "Stop" | grep -E '^> ')" + [ "$(printf '%s\n' "$stop" | grep -c '^> ')" -eq 1 ] || { echo "$f: Stop needs exactly one blockquote line"; return 1; } + [ "$(printf '%s\n' "$stop" | grep -oE '\{[a-z_]+\}' | sort -u)" = "{path}" ] || + { echo "$f: Stop placeholders must be exactly {path}"; return 1; } + done +} + +@test "every template carries the shared fragment marker once and names its type on its second non-blank line" { + [ -f "$FRAGMENT" ] || { echo "missing $FRAGMENT"; return 1; } + [ "$(headings "$FRAGMENT")" = $'## Evidence Summary\n## Validation Results' ] || + { echo "fragment sections are"; headings "$FRAGMENT"; return 1; } + for f in "$TEMPLATES_DIR"/*.md; do + token="$(basename "$f" .md)" + [ "$(grep -cxF "$MARKER" "$f")" -eq 1 ] || { echo "$f: needs exactly one shared-fragment marker"; return 1; } + second="$(grep -v '^$' "$f" | sed -n 2p)" + [[ "$second" == "**Investigation type:** $token: "* ]] || { echo "$f: second line is $second"; return 1; } + done +} + +@test "the bug report keeps today's section order" { + actual="$(awk -v m="$MARKER" -v frag="$FRAGMENT" ' + /^```/{fence=!fence; next} + !fence && $0==m { while ((getline line < frag) > 0) if (line ~ /^## /) print line; next } + !fence && /^## /' "$TEMPLATES_DIR/bug.md")" + expected=$'## Summary\n## Problem Statement\n## Root Cause Analysis\n## Planned Fix\n## Evidence Summary\n## Validation Results\n## Coding Standards Reference' + [ "$actual" = "$expected" ] || { echo "bug report sections are"; echo "$actual"; return 1; } +} + +@test "the extraction from the single bug template is complete" { + [ ! -e "$SKILL_DIR/references/template.md" ] || { echo "references/template.md still exists"; return 1; } + run grep -rlF --exclude='*.bats' 'investigate/references/template.md' "$REPO_ROOT/han-coding" "$REPO_ROOT/han-atlassian" + [ "$status" -ne 0 ] || { echo "files still link to template.md:"; echo "$output"; return 1; } + ! grep -qF '](./references/template.md)' "$SKILL" || { echo "SKILL.md still links to template.md"; return 1; } + ! grep -q '{symptom}' "$SKILL" || { echo "SKILL.md still carries {symptom}"; return 1; } + for section in "Detection signals" "Dispatch" "Analysis" "Validation brief" "Audience" "Stop"; do + grep -qF "\`## $section\`" "$SKILL" || { echo "SKILL.md never names \`## $section\`"; return 1; } + done +} From d9b06dfa3b6e7cac72c32bf69255785b7e7cd955 Mon Sep 17 00:00:00 2001 From: River Bailey Date: Thu, 12 Nov 2026 08:47:31 -0700 Subject: [PATCH 07/10] feat(investigate): add the how-it-works investigation type Add the how-it-works type file and template, the detection and fit-check examples, and the how-it-works token in the argument-hint and description. Redraw the boundaries in the same commit so no two skills claim one question: research covers the open web and prior art, investigate covers questions this codebase alone can answer, and code-overview and code-walkthrough send a single how-it-works question to investigate. Add a ruby-shop eval scaffold, a how-it-works eval, and a prior-art eval that must not trigger investigate. --- .../prompts/prompt-how-it-works.md | 1 + evals/investigate/prompts/prompt-prior-art.md | 1 + evals/investigate/scaffolds/ruby-shop/Gemfile | 2 + .../scaffolds/ruby-shop/lib/shop/cart.rb | 28 ++++++++++++ .../scaffolds/ruby-shop/lib/shop/discounts.rb | 29 ++++++++++++ .../scaffolds/ruby-shop/lib/shop/pricing.rb | 14 ++++++ evals/investigate/tests.json | 21 ++++++++- han-coding/docs/skills/code-overview.md | 2 + han-coding/docs/skills/code-walkthrough.md | 2 + han-coding/skills/code-overview/SKILL.md | 8 ++-- han-coding/skills/code-walkthrough/SKILL.md | 3 +- han-coding/skills/investigate/SKILL.md | 44 +++++++++++-------- .../references/templates/how-it-works.md | 43 ++++++++++++++++++ .../references/types/how-it-works.md | 43 ++++++++++++++++++ .../scripts/investigation-types.bats | 6 +++ han-research/docs/skills/research.md | 21 ++++----- han-research/skills/research/SKILL.md | 26 ++++++----- 17 files changed, 247 insertions(+), 47 deletions(-) create mode 100644 evals/investigate/prompts/prompt-how-it-works.md create mode 100644 evals/investigate/prompts/prompt-prior-art.md create mode 100644 evals/investigate/scaffolds/ruby-shop/Gemfile create mode 100644 evals/investigate/scaffolds/ruby-shop/lib/shop/cart.rb create mode 100644 evals/investigate/scaffolds/ruby-shop/lib/shop/discounts.rb create mode 100644 evals/investigate/scaffolds/ruby-shop/lib/shop/pricing.rb create mode 100644 han-coding/skills/investigate/references/templates/how-it-works.md create mode 100644 han-coding/skills/investigate/references/types/how-it-works.md diff --git a/evals/investigate/prompts/prompt-how-it-works.md b/evals/investigate/prompts/prompt-how-it-works.md new file mode 100644 index 00000000..2e9ce7a7 --- /dev/null +++ b/evals/investigate/prompts/prompt-how-it-works.md @@ -0,0 +1 @@ +how does the shop in lib/shop calculate a cart's total when more than one discount applies? diff --git a/evals/investigate/prompts/prompt-prior-art.md b/evals/investigate/prompts/prompt-prior-art.md new file mode 100644 index 00000000..43f29a67 --- /dev/null +++ b/evals/investigate/prompts/prompt-prior-art.md @@ -0,0 +1 @@ +what open source libraries and prior art exist for representing money and currency in Ruby applications? diff --git a/evals/investigate/scaffolds/ruby-shop/Gemfile b/evals/investigate/scaffolds/ruby-shop/Gemfile new file mode 100644 index 00000000..58688a91 --- /dev/null +++ b/evals/investigate/scaffolds/ruby-shop/Gemfile @@ -0,0 +1,2 @@ +source "https://rubygems.org" +gem "minitest" diff --git a/evals/investigate/scaffolds/ruby-shop/lib/shop/cart.rb b/evals/investigate/scaffolds/ruby-shop/lib/shop/cart.rb new file mode 100644 index 00000000..db8af1e2 --- /dev/null +++ b/evals/investigate/scaffolds/ruby-shop/lib/shop/cart.rb @@ -0,0 +1,28 @@ +require_relative "pricing" + +module Shop + # A cart holds line items and asks Pricing for its total. + class Cart + LineItem = Struct.new(:sku, :unit_price_cents, :quantity) + + attr_reader :items, :discounts + + def initialize(discounts: []) + @items = [] + @discounts = discounts + end + + def add(sku, unit_price_cents, quantity = 1) + items << LineItem.new(sku, unit_price_cents, quantity) + self + end + + def subtotal_cents + items.sum { |item| item.unit_price_cents * item.quantity } + end + + def total_cents + Pricing.new(discounts).total_cents(self) + end + end +end diff --git a/evals/investigate/scaffolds/ruby-shop/lib/shop/discounts.rb b/evals/investigate/scaffolds/ruby-shop/lib/shop/discounts.rb new file mode 100644 index 00000000..76bda0f0 --- /dev/null +++ b/evals/investigate/scaffolds/ruby-shop/lib/shop/discounts.rb @@ -0,0 +1,29 @@ +module Shop + module Discounts + # Takes a percentage off the running total. + class Percentage + def initialize(percent) + @percent = percent + end + + def amount_off_cents(_cart, running_total_cents) + (running_total_cents * @percent / 100.0).round + end + end + + # Takes a percentage off the running total once the cart reaches a minimum subtotal. + # Duplicates Percentage's arithmetic rather than reusing it. + class Threshold + def initialize(percent, minimum_subtotal_cents) + @percent = percent + @minimum_subtotal_cents = minimum_subtotal_cents + end + + def amount_off_cents(cart, running_total_cents) + return 0 if cart.subtotal_cents < @minimum_subtotal_cents + + (running_total_cents * @percent / 100.0).round + end + end + end +end diff --git a/evals/investigate/scaffolds/ruby-shop/lib/shop/pricing.rb b/evals/investigate/scaffolds/ruby-shop/lib/shop/pricing.rb new file mode 100644 index 00000000..0a6701dd --- /dev/null +++ b/evals/investigate/scaffolds/ruby-shop/lib/shop/pricing.rb @@ -0,0 +1,14 @@ +module Shop + # Pricing applies each discount in order, then floors the total at zero. + class Pricing + def initialize(discounts) + @discounts = discounts + end + + def total_cents(cart) + total = cart.subtotal_cents + @discounts.each { |discount| total -= discount.amount_off_cents(cart, total) } + [total, 0].max + end + end +end diff --git a/evals/investigate/tests.json b/evals/investigate/tests.json index 3f16b46c..4c770ca1 100644 --- a/evals/investigate/tests.json +++ b/evals/investigate/tests.json @@ -1,5 +1,5 @@ { - "plugins": ["han-communication", "han-core", "han-coding"], + "plugins": ["han-communication", "han-core", "han-coding", "han-research"], "tests": [ { "name": "Prompt: /investigate", @@ -13,6 +13,25 @@ { "skill-call": { "skill": "han-coding:investigate", "expected": true } } ] }, + { + "name": "Prompt: /investigate how-it-works", + "type": "skill-prompt", + "promptFile": "prompt-how-it-works.md", + "model": "opus", + "scaffold": "ruby-shop", + "expect": [ + { "result-contains": "**Investigation type:** how-it-works" }, + { "result-does-not-contain": "Planned Fix" }, + { "skill-call": { "skill": "han-coding:investigate", "expected": true } } + ] + }, + { + "name": "Prompt: prior art goes to research", + "type": "skill-prompt", + "promptFile": "prompt-prior-art.md", + "model": "sonnet", + "expect": [{ "skill-call": { "skill": "han-coding:investigate", "expected": false } }] + }, { "name": "Prompt: no op", "type": "skill-prompt", diff --git a/han-coding/docs/skills/code-overview.md b/han-coding/docs/skills/code-overview.md index 91652484..2898f505 100644 --- a/han-coding/docs/skills/code-overview.md +++ b/han-coding/docs/skills/code-overview.md @@ -68,6 +68,8 @@ to use the skill. For what the skill does internally, read the skill definition - **Assessing architecture, coupling, or structural risk.** Use [`/architectural-analysis`](./architectural-analysis.md) instead. - **Diagnosing a bug or root-causing a failure.** Use [`/investigate`](./investigate.md) instead. +- **Answering one question about how the code behaves.** Use [`/investigate how-it-works`](./investigate.md), which + answers a single question with cited, adversarially validated evidence. This skill orients you to a whole target. - **Being paced through the code one step at a time.** Use [`/code-walkthrough`](./code-walkthrough.md) instead. It produces a conversation you drive, not a document you read alone. diff --git a/han-coding/docs/skills/code-walkthrough.md b/han-coding/docs/skills/code-walkthrough.md index 745f584f..aa0c4ebd 100644 --- a/han-coding/docs/skills/code-walkthrough.md +++ b/han-coding/docs/skills/code-walkthrough.md @@ -52,6 +52,8 @@ _how_ to use the skill. For what the skill does internally, read the skill defin - **Judging whether the code is any good.** Use [`/code-review`](./code-review.md) instead (or [`/post-code-review-to-pr`](../../../han-github/docs/skills/post-code-review-to-pr.md) to post a review to GitHub). - **Diagnosing a bug or root-causing a failure.** Use [`/investigate`](./investigate.md) instead. +- **Answering one question about how the code behaves.** Use [`/investigate how-it-works`](./investigate.md) for a + written answer with cited evidence. This skill paces you through the code in conversation. - **Assessing architecture, coupling, or structural risk.** Use [`/architectural-analysis`](./architectural-analysis.md) instead. diff --git a/han-coding/skills/code-overview/SKILL.md b/han-coding/skills/code-overview/SKILL.md index 4cac7b47..64c676ec 100644 --- a/han-coding/skills/code-overview/SKILL.md +++ b/han-coding/skills/code-overview/SKILL.md @@ -2,14 +2,14 @@ name: "code-overview" description: > Produces a human-readable, progressive-disclosure overview of unfamiliar code or a pull request's changes — why it - exists (the real problem it solves or goal it serves for the business or a user), and from there what it does, how it + exists (the problem it solves or goal it serves for a business or a user), and from there what it does, how it flows, and where to start — so you can get up to speed before working on or reviewing it. Use when you want to understand, get oriented in, make sense of, explain, or get up to speed on a chunk of code, a file, a directory, a - symbol, or a PR's changes. Writes the overview to a scratch file and changes no code. Does not review code quality or + symbol, or a PR's changes. Writes to a scratch file and changes no code. Does not review code quality or raise findings — use code-review for auditing changes or post-code-review-to-pr for posting them. Does not produce durable feature or system documentation — use project-documentation. Does not assess architecture or structural risk — - use architectural-analysis. Does not diagnose bugs or root-cause failures — use investigate. Does not pace a person - through the code one step at a time in conversation — use code-walkthrough. + use architectural-analysis. Does not diagnose bugs or answer a single question about how the code behaves — use + investigate. Does not pace a person through the code one step at a time in conversation — use code-walkthrough. arguments: size argument-hint: "[size: small | medium | large | dynamic] [target: file, directory, symbol, or PR reference — defaults to the current branch's diff --git a/han-coding/skills/code-walkthrough/SKILL.md b/han-coding/skills/code-walkthrough/SKILL.md index 5bf2a341..ccc8e0e7 100644 --- a/han-coding/skills/code-walkthrough/SKILL.md +++ b/han-coding/skills/code-walkthrough/SKILL.md @@ -8,7 +8,8 @@ description: > around code or a branch step by step, or to learn how a change works before reviewing or extending it. Stops after every step and waits, so the learner sets the pace. Paces through code that already exists and builds nothing — to build new work while being paced through it, use pairing. Does not produce a written overview to read alone — use - code-overview. Does not review code quality — use code-review. Does not diagnose bugs — use investigate. + code-overview. Does not review code quality — use code-review. Does not diagnose bugs or answer a single question + about how the code behaves — use investigate. arguments: size argument-hint: "[size: small | medium | large | dynamic] [target: a file, directory, symbol, PR reference, or plan — defaults to the diff --git a/han-coding/skills/investigate/SKILL.md b/han-coding/skills/investigate/SKILL.md index 3d7268e9..551b2200 100644 --- a/han-coding/skills/investigate/SKILL.md +++ b/han-coding/skills/investigate/SKILL.md @@ -1,15 +1,16 @@ --- name: investigate description: > - Evidence-based investigation of issues, bugs, API calls, integrations, and other aspects of software development that - need a deep dive to find the root cause and solutions, run as the `bug` investigation type. Use when you need to - debug, troubleshoot, diagnose, or figure out why something is broken. Does not review code for quality or style — use - code-review for auditing changes or post-code-review-to-pr for posting review feedback to GitHub. Does not assess - architectural health or structural risk — use architectural-analysis for architectural concerns. Does not research - open-ended options, prior art, or how something works when nothing is broken — use research for that. Does not plan - the structural change a root cause calls for — use plan-a-change. Does not map bounded contexts or domain boundaries — - use ddd-analysis. Does not capture feedback on Han's own skills — use han-feedback for that. -argument-hint: "[type: `bug`] [symptom or problem description] [optional report path ending in .md]" + Evidence-based investigation of a question about this codebase, run as one investigation type: `bug` finds the root + cause of a failure and plans the fix, and `how-it-works` explains how the code behaves today, with cited evidence. + Name a type first, or let the skill detect it from the question. Use when you need to debug, troubleshoot, diagnose, + or figure out why something is broken, or to understand how a flow, an integration, or an API call in this codebase + works. Does not review code for quality or style — use code-review. Does not assess architectural health — use + architectural-analysis. Does not plan the structural change a finding calls for — use plan-a-change. Does not map + bounded contexts — use ddd-analysis. Does not capture feedback on Han's own skills — use han-feedback. Does not + research the open web or prior art — use research. Does not write an orientation to a whole area — use code-overview, + or code-walkthrough to be paced through code step by step. +argument-hint: "[type: `bug` | `how-it-works`] [question or symptom] [optional report path ending in .md]" allowed-tools: Read, Glob, Grep, Agent, Write, Skill, Bash(bash "${CLAUDE_PLUGIN_ROOT}/scripts/han-config-dir.sh") --- @@ -52,11 +53,13 @@ An investigation type names the one kind of question a run answers. Each shipped type tokens. Row order is the tie-break order when a question reads as more than one type, and the last row is the type a question gets when it reads as none. -| Token | File | Purpose | -| ----- | ---------------------------------------------------- | ------------------------------------------------- | -| `bug` | [references/types/bug.md](./references/types/bug.md) | Find the root cause of a failure and plan the fix | +| Token | File | Purpose | +| -------------- | ---------------------------------------------------------------------- | ------------------------------------------------------ | +| `bug` | [references/types/bug.md](./references/types/bug.md) | Find the root cause of a failure and plan the fix | +| `how-it-works` | [references/types/how-it-works.md](./references/types/how-it-works.md) | Explain how this codebase behaves, with cited evidence | -Templates: [references/templates/bug.md](./references/templates/bug.md). Every template carries one line +Templates: [references/templates/bug.md](./references/templates/bug.md) and +[references/templates/how-it-works.md](./references/templates/how-it-works.md). Every template carries one line ``; write the sections of [references/evidence-and-validation.md](./references/evidence-and-validation.md) in that line's place. @@ -104,12 +107,15 @@ Types: - {token}: {Purpose} ``` -| Invocation | Type | `$question` | Out path | -| --------------------------------------------------------------- | ----------------------------- | ---------------------------------------------- | ---------------------------- | -| `/investigate bug checkout returns 500 after the coupon change` | `bug`, named | `checkout returns 500 after the coupon change` | none | -| `/investigate bug: cart total off by one cent` | `bug`, named (colon stripped) | `cart total off by one cent` | none | -| `/investigate checkout fails docs/incidents/checkout.md` | detected | `checkout fails` | `docs/incidents/checkout.md` | -| `/investigate why does the generator rewrite ./CHANGELOG.md` | detected | the whole string | none (the file exists) | +| Invocation | Type | `$question` | Out path | +| --------------------------------------------------------------- | ---------------------------------------- | ---------------------------------------------- | ---------------------------- | +| `/investigate bug checkout returns 500 after the coupon change` | `bug`, named | `checkout returns 500 after the coupon change` | none | +| `/investigate bug: cart total off by one cent` | `bug`, named (colon stripped) | `cart total off by one cent` | none | +| `/investigate checkout fails docs/incidents/checkout.md` | `bug`, detected | `checkout fails` | `docs/incidents/checkout.md` | +| `/investigate why does the generator rewrite ./CHANGELOG.md` | `bug`, detected | the whole string | none (the file exists) | +| `/investigate how does the retry queue pick a backoff` | `how-it-works`, detected | the whole string | none | +| `/investigate how-it-work retry queue` | not a token; detected | the whole string | none | +| `/investigate how-it-works login throws 500 since Tuesday` | named `how-it-works`; the fit check asks | `login throws 500 since Tuesday` | none | ### Resolve the type diff --git a/han-coding/skills/investigate/references/templates/how-it-works.md b/han-coding/skills/investigate/references/templates/how-it-works.md new file mode 100644 index 00000000..6712e73e --- /dev/null +++ b/han-coding/skills/investigate/references/templates/how-it-works.md @@ -0,0 +1,43 @@ +# How It Works: {Subject} + +**Investigation type:** how-it-works: Explain how this codebase behaves, with cited evidence + + + + + + + + +## Summary + + + + +- **Answer:** +- **Entry Points:** +- **Validation Outcome:** +- **Unverified Paths:** + +## Question + + + +## Answer + + + + + +1. +2. + +## Key Components + + + +| Component | File | Role | +| --------- | ----------------------- | ------------------------- | +| `Name` | `path/to/file.ext:line` | What it does in this flow | + + diff --git a/han-coding/skills/investigate/references/types/how-it-works.md b/han-coding/skills/investigate/references/types/how-it-works.md new file mode 100644 index 00000000..ae71ce20 --- /dev/null +++ b/han-coding/skills/investigate/references/types/how-it-works.md @@ -0,0 +1,43 @@ +# Investigation type: how-it-works + +## Detection signals + +- the question asks how something in this codebase works, behaves, or is handled +- the question asks what happens when, where something is decided, or what calls what +- the question asks to trace, explain, or map a flow, a lifecycle, or a data path +- nothing is reported as broken, and no change is being weighed + +## Dispatch + +Start from the entry points the question names, or the ones the codebase exposes for it, and follow the code forward. +Explain what the code does today; do not judge it or propose changes. + +1. `han-core:codebase-explorer` (1, always): "Explore how this codebase handles the following, to answer it accurately: {question}. Find the entry points, the core logic, the data models, the configuration, and the tests that exercise it. Return numbered findings keyed to file paths and line numbers, with the verbatim code that establishes each." +2. `han-core:behavioral-analyst` (1, always): "Your focus area is the code that answers this question: {question}. Trace the runtime behavior from its entry points: data flow, state changes, error propagation, and integration boundaries. Describe what happens rather than what could go wrong. Return numbered findings keyed to file paths and line numbers." +3. `han-core:structural-analyst` (1, when the question involves how the code is organized, which modules depend on which, or how the area came to be shaped this way): "Your focus area is the code that answers this question: {question}. Map the modules involved, their boundaries, their dependency direction, and the recent history that shaped them. Return numbered findings keyed to file paths and line numbers." +4. `han-core:concurrency-analyst` (1, when the question involves async work, background jobs, queues, ordering, locking, or concurrent access): "Explain the concurrency and async behavior of the code that answers this question: {question}. Cover what runs concurrently, what orders it, and what guards shared state. Return numbered findings keyed to file paths and line numbers." +5. `han-core:data-engineer` (1, when the question involves what is stored, how it is queried, or how the schema shapes the behavior): "Explain the schema, queries, and data-access code that answer this question: {question}. Return numbered findings keyed to file paths, line numbers, and schema or migration references." + +## Analysis + +1. Write `Question`: what was asked, restated plainly, and what the answer covers and leaves out. +2. Write `Answer`: one sentence that answers the question, then a numbered walkthrough of the flow in execution order, + each step citing the evidence items that establish it (E1, E2, ...). Name the entry points the walkthrough starts + from, and say where the evidence runs out rather than filling a gap with a guess. +3. Write `Key Components`: a table with the columns Component, File, and Role, one row for each part the walkthrough + depends on. + +## Validation brief + +- Root cause analysis: the Answer and its numbered flow walkthrough +- Planned fix: the Answer's coverage claim, meaning the entry points and paths it presents as complete +- Attack focus: find a caller, path, input, or configuration the explanation misses or gets wrong + +## Audience + +The engineer who will work in this code next and needs an accurate mental model of it, with identifiers and file:line +citations preserved. + +## Stop + +> Report written to {path}. No code was changed. Reply with corrections to revise the report. To change this code next, run /han-planning:plan-a-change with this report; to build new behavior on it, run /han-planning:plan-a-feature. diff --git a/han-coding/skills/investigate/scripts/investigation-types.bats b/han-coding/skills/investigate/scripts/investigation-types.bats index 0add579f..d300655d 100644 --- a/han-coding/skills/investigate/scripts/investigation-types.bats +++ b/han-coding/skills/investigate/scripts/investigation-types.bats @@ -136,3 +136,9 @@ sorted_basenames() { # dir grep -qF "\`## $section\`" "$SKILL" || { echo "SKILL.md never names \`## $section\`"; return 1; } done } + +@test "research does not claim questions about how something works" { + research="$REPO_ROOT/han-research/skills/research/SKILL.md" + description="$(awk '/^---$/{n++; next} n==1' "$research" | awk '/^description:/{on=1; next} on && /^ /{print; next} {on=0}' | tr '\n' ' ')" + [[ "$description" != *"how something works"* ]] || { echo "research's description still claims how something works"; return 1; } +} diff --git a/han-research/docs/skills/research.md b/han-research/docs/skills/research.md index deb1d0a7..25ce4982 100644 --- a/han-research/docs/skills/research.md +++ b/han-research/docs/skills/research.md @@ -21,9 +21,10 @@ use the skill. For what the skill does internally, read the skill definition at ## Key concepts -- **Question-shaped, not symptom-shaped.** `/investigate` starts from something broken and ends at a fix. `/research` - starts from a question and ends at a recommended option among trade-offs. Nothing is "diagnosed" and no fix is - planned. +- **The open web, not this codebase.** `/investigate` answers a question the codebase alone can answer: why it is + broken, how it works, or how a change could be made within it. `/research` answers a question that needs the open web, + prior art, or material you provide, and ends at a recommended option among trade-offs. Nothing is "diagnosed" and no + fix is planned. - **Output-agnostic.** The report is the only thing produced. `/research` never writes a feature spec, a coding standard, a gap report, an architecture assessment, or code. If your question is really one of those, it routes you to the skill that owns it. @@ -71,13 +72,13 @@ use the skill. For what the skill does internally, read the skill definition at - You want the options for a decision and their trade-offs before you commit ("should we use an event bus or polling here"). - You want the prior art or state of the art on a topic, drawn from outside the codebase. -- You want to understand how something works before you build against it. +- You want to understand how an outside technology works before you build against it. - You want a recommendation that has been adversarially validated, not a first-pass opinion. **Do not invoke for:** -- **A bug, failure, or root cause.** Use [`/investigate`](../../../han-coding/docs/skills/investigate.md) for evidence-based diagnosis of - something broken. +- **A question the codebase alone can answer.** Use [`/investigate`](../../../han-coding/docs/skills/investigate.md) to + diagnose something broken, explain how this code works, or compare the ways a change could be made within it. - **Specifying a feature.** Use [`/plan-a-feature`](../../../han-planning/docs/skills/plan-a-feature.md) to turn a decision into a behavioral spec. - **Creating or updating a coding standard.** Use [`/coding-standard`](../../../han-coding/docs/skills/coding-standard.md). @@ -193,8 +194,8 @@ cadence: research the question, get the recommendation, move on. It is not a tig ## In more detail -`/research` is the question-shaped sibling of `/investigate`. It reuses the same proven spine (gather sourced evidence, -number it, synthesize, then adversarially validate before presenting), but every bug-specific stage is gone. There is no +`/research` is the open-web sibling of `/investigate`. It reuses the same proven spine (gather sourced evidence, number +it, synthesize, then adversarially validate before presenting), but every bug-specific stage is gone. There is no symptom to classify, no root cause, no fix. In their place: a request classifier (out-of-scope redirect, hybrid handoff, compound-question split), an options-landscape synthesis, and a recommendation. That recommendation must survive an adversarial pass chartered to attack not only the logic but the trustworthiness of the sources themselves. @@ -235,8 +236,8 @@ URL: https://hbr.org/2007/09/performing-a-project-premortem - [Plugin README](../../README.md). The plugin's front door: its skills, agents, and how they fit together. - [Repo root README](../../../README.md). The Han suite landing page. Start here if you arrived from outside the docs tree. - [Skills Index](../../../docs/skills/README.md). All skills, grouped by purpose. -- [`/investigate`](../../../han-coding/docs/skills/investigate.md). The symptom-shaped sibling. Use it when something is broken; use - `/research` when you have a question. +- [`/investigate`](../../../han-coding/docs/skills/investigate.md). The codebase-shaped sibling. Use it when the answer + lives in this codebase; use `/research` when it lives on the open web or in prior art. - [`/plan-a-feature`](../../../han-planning/docs/skills/plan-a-feature.md). Pair downstream: turn a recommended option into a behavioral spec. - [`research-analyst`](../agents/research-analyst.md). The agent the skill dispatches for the web / diff --git a/han-research/skills/research/SKILL.md b/han-research/skills/research/SKILL.md index 095ab716..85359fc9 100644 --- a/han-research/skills/research/SKILL.md +++ b/han-research/skills/research/SKILL.md @@ -1,14 +1,15 @@ --- name: "research" description: - "Researches an open-ended question — options, possible solutions, prior art, trade-offs, or how something works — and - produces a durable, evidence-backed, adversarially-validated report that recommends an option without committing the - team to any artifact. Use when you want to research approaches, weigh options, survey prior art or the state of the - art, or understand how something works before committing to a direction. Does not diagnose a bug, failure, or root - cause — use investigate. Does not specify a feature — use plan-a-feature. Does not create or update a coding standard - — use coding-standard. Does not compare two concrete artifacts for gaps — use gap-analysis. Does not assess an - existing module's architecture — use architectural-analysis. Does not capture feedback on Han's own skills — use - han-feedback." + "Researches an open-ended question across the open web and the material you provide — options, possible solutions, + prior art, trade-offs, or how an outside technology works — and produces a durable, evidence-backed, + adversarially-validated report that recommends an option without committing the team to any artifact. Use when you + want to research approaches, weigh options, survey prior art or the state of the art, or understand an outside + technology before committing to a direction. Does not answer a question the codebase alone can answer, such as how it + works, why it is broken, or how a change could be made within it — use investigate. Does not specify a feature — use + plan-a-feature. Does not create or update a coding standard — use coding-standard. Does not compare two concrete + artifacts for gaps — use gap-analysis. Does not assess an existing module's architecture — use + architectural-analysis. Does not capture feedback on Han's own skills — use han-feedback." arguments: size argument-hint: '[size: small | medium | large | dynamic] [the open-ended question to research] [optional output path] [optional: "evidence @@ -112,10 +113,11 @@ decision or unknown they need resolved before dispatching anything. Do not guess Before sizing or dispatching, classify what the user actually asked for: -- **Out of scope.** If the request is a bug to diagnose, a feature to specify, a coding standard to set, two concrete - artifacts to compare, or an existing module's architecture to assess, name the correct sibling skill (`investigate`, - `plan-a-feature`, `coding-standard`, `gap-analysis`, `architectural-analysis`), explain in one sentence why it fits - better, and stop. Produce no research report. +- **Out of scope.** If the request is a bug to diagnose, a question the codebase alone can answer (how it works, or how + a change could be made within it), a feature to specify, a coding standard to set, two concrete artifacts to compare, + or an existing module's architecture to assess, name the correct sibling skill (`investigate`, `plan-a-feature`, + `coding-standard`, `gap-analysis`, `architectural-analysis`), explain in one sentence why it fits better, and stop. + Produce no research report. - **Hybrid.** If the request contains an answerable open-ended research question _and_ asks for a sibling's output ("research caching options and write the standard for the one I pick"), run the research portion to a full report, then name the sibling for the rest. Do not produce the sibling's artifact. If nothing research-shaped remains once the From 941dc36348c2905aa14168f4e01f4692f6146f87 Mon Sep 17 00:00:00 2001 From: River Bailey Date: Thu, 12 Nov 2026 08:48:50 -0700 Subject: [PATCH 08/10] fix(investigate): make the investigation-types test pass lint Mark the Bats file executable and tell shellcheck the backticks in its patterns are literal Markdown. --- han-coding/skills/investigate/scripts/investigation-types.bats | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 han-coding/skills/investigate/scripts/investigation-types.bats diff --git a/han-coding/skills/investigate/scripts/investigation-types.bats b/han-coding/skills/investigate/scripts/investigation-types.bats old mode 100644 new mode 100755 index d300655d..c2a45660 --- a/han-coding/skills/investigate/scripts/investigation-types.bats +++ b/han-coding/skills/investigate/scripts/investigation-types.bats @@ -36,6 +36,7 @@ frontmatter_value() { # key # Print each backticked token in a string, one per line. backticked() { # text + # shellcheck disable=SC2016 # the backticks are literal Markdown, not command substitution printf '%s\n' "$1" | grep -oE '`[a-z0-9-]+`' | tr -d '`' } @@ -87,6 +88,7 @@ sorted_basenames() { # dir [ "$placeholders" = "{question}" ] || { echo "$f: dispatch placeholders are $placeholders"; return 1; } done <<<"$entries" + # shellcheck disable=SC2016 # the backticks are literal Markdown, not command substitution while read -r named; do [ -z "$named" ] && continue grep -qxF "## $named" "$TEMPLATES_DIR/$token.md" || From f891a5ca591bca6b1a96d98c4132c43d0ee27dae Mon Sep 17 00:00:00 2001 From: River Bailey Date: Thu, 12 Nov 2026 08:52:41 -0700 Subject: [PATCH 09/10] feat(investigate): add the available-options investigation type Add the available-options type file and template, its table row between bug and how-it-works so it wins the tie-break over how-it-works, its token in the argument-hint and description, detection examples, and an available-options eval on the ruby-shop scaffold. --- .../prompts/prompt-available-options.md | 1 + evals/investigate/tests.json | 11 +++ han-coding/skills/investigate/SKILL.md | 50 +++++++------ .../references/templates/available-options.md | 71 +++++++++++++++++++ .../references/types/available-options.md | 47 ++++++++++++ 5 files changed, 157 insertions(+), 23 deletions(-) create mode 100644 evals/investigate/prompts/prompt-available-options.md create mode 100644 han-coding/skills/investigate/references/templates/available-options.md create mode 100644 han-coding/skills/investigate/references/types/available-options.md diff --git a/evals/investigate/prompts/prompt-available-options.md b/evals/investigate/prompts/prompt-available-options.md new file mode 100644 index 00000000..5f7df272 --- /dev/null +++ b/evals/investigate/prompts/prompt-available-options.md @@ -0,0 +1 @@ +what are our options for adding a fixed-amount coupon to the discounts in lib/shop, and which would fit the existing code best? diff --git a/evals/investigate/tests.json b/evals/investigate/tests.json index 4c770ca1..9241004e 100644 --- a/evals/investigate/tests.json +++ b/evals/investigate/tests.json @@ -25,6 +25,17 @@ { "skill-call": { "skill": "han-coding:investigate", "expected": true } } ] }, + { + "name": "Prompt: /investigate available-options", + "type": "skill-prompt", + "promptFile": "prompt-available-options.md", + "model": "opus", + "scaffold": "ruby-shop", + "expect": [ + { "result-contains": "**Investigation type:** available-options" }, + { "skill-call": { "skill": "han-coding:investigate", "expected": true } } + ] + }, { "name": "Prompt: prior art goes to research", "type": "skill-prompt", diff --git a/han-coding/skills/investigate/SKILL.md b/han-coding/skills/investigate/SKILL.md index 551b2200..22fdf072 100644 --- a/han-coding/skills/investigate/SKILL.md +++ b/han-coding/skills/investigate/SKILL.md @@ -2,15 +2,15 @@ name: investigate description: > Evidence-based investigation of a question about this codebase, run as one investigation type: `bug` finds the root - cause of a failure and plans the fix, and `how-it-works` explains how the code behaves today, with cited evidence. - Name a type first, or let the skill detect it from the question. Use when you need to debug, troubleshoot, diagnose, - or figure out why something is broken, or to understand how a flow, an integration, or an API call in this codebase - works. Does not review code for quality or style — use code-review. Does not assess architectural health — use - architectural-analysis. Does not plan the structural change a finding calls for — use plan-a-change. Does not map - bounded contexts — use ddd-analysis. Does not capture feedback on Han's own skills — use han-feedback. Does not - research the open web or prior art — use research. Does not write an orientation to a whole area — use code-overview, - or code-walkthrough to be paced through code step by step. -argument-hint: "[type: `bug` | `how-it-works`] [question or symptom] [optional report path ending in .md]" + cause of a failure and plans the fix, `how-it-works` explains how the code behaves today, and `available-options` + compares the ways a piece of work could be done. Name a type first, or let the skill detect it from the question. Use + when you need to debug, troubleshoot, or figure out why something is broken, understand how a flow, an integration, + or an API call works, or weigh how to make a change. Does not review code for quality or style — use code-review. + Does not assess architectural health — use architectural-analysis. Does not plan the change a finding calls for — use + plan-a-change. Does not map bounded contexts — use ddd-analysis. Does not capture feedback on Han's own skills — use + han-feedback. Does not research the open web or prior art — use research. Does not write an orientation to a whole + area — use code-overview, or code-walkthrough to be paced through code step by step. +argument-hint: "[type: `bug` | `available-options` | `how-it-works`] [question or symptom] [optional report path ending in .md]" allowed-tools: Read, Glob, Grep, Agent, Write, Skill, Bash(bash "${CLAUDE_PLUGIN_ROOT}/scripts/han-config-dir.sh") --- @@ -53,12 +53,14 @@ An investigation type names the one kind of question a run answers. Each shipped type tokens. Row order is the tie-break order when a question reads as more than one type, and the last row is the type a question gets when it reads as none. -| Token | File | Purpose | -| -------------- | ---------------------------------------------------------------------- | ------------------------------------------------------ | -| `bug` | [references/types/bug.md](./references/types/bug.md) | Find the root cause of a failure and plan the fix | -| `how-it-works` | [references/types/how-it-works.md](./references/types/how-it-works.md) | Explain how this codebase behaves, with cited evidence | +| Token | File | Purpose | +| ------------------- | -------------------------------------------------------------------------------- | --------------------------------------------------------------- | +| `bug` | [references/types/bug.md](./references/types/bug.md) | Find the root cause of a failure and plan the fix | +| `available-options` | [references/types/available-options.md](./references/types/available-options.md) | Compare the ways a piece of work could be done in this codebase | +| `how-it-works` | [references/types/how-it-works.md](./references/types/how-it-works.md) | Explain how this codebase behaves, with cited evidence | -Templates: [references/templates/bug.md](./references/templates/bug.md) and +Templates: [references/templates/bug.md](./references/templates/bug.md), +[references/templates/available-options.md](./references/templates/available-options.md), and [references/templates/how-it-works.md](./references/templates/how-it-works.md). Every template carries one line ``; write the sections of [references/evidence-and-validation.md](./references/evidence-and-validation.md) in that line's place. @@ -107,15 +109,17 @@ Types: - {token}: {Purpose} ``` -| Invocation | Type | `$question` | Out path | -| --------------------------------------------------------------- | ---------------------------------------- | ---------------------------------------------- | ---------------------------- | -| `/investigate bug checkout returns 500 after the coupon change` | `bug`, named | `checkout returns 500 after the coupon change` | none | -| `/investigate bug: cart total off by one cent` | `bug`, named (colon stripped) | `cart total off by one cent` | none | -| `/investigate checkout fails docs/incidents/checkout.md` | `bug`, detected | `checkout fails` | `docs/incidents/checkout.md` | -| `/investigate why does the generator rewrite ./CHANGELOG.md` | `bug`, detected | the whole string | none (the file exists) | -| `/investigate how does the retry queue pick a backoff` | `how-it-works`, detected | the whole string | none | -| `/investigate how-it-work retry queue` | not a token; detected | the whole string | none | -| `/investigate how-it-works login throws 500 since Tuesday` | named `how-it-works`; the fit check asks | `login throws 500 since Tuesday` | none | +| Invocation | Type | `$question` | Out path | +| ----------------------------------------------------------------------------- | ---------------------------------------- | ---------------------------------------------- | ---------------------------- | +| `/investigate bug checkout returns 500 after the coupon change` | `bug`, named | `checkout returns 500 after the coupon change` | none | +| `/investigate bug: cart total off by one cent` | `bug`, named (colon stripped) | `cart total off by one cent` | none | +| `/investigate checkout fails docs/incidents/checkout.md` | `bug`, detected | `checkout fails` | `docs/incidents/checkout.md` | +| `/investigate why does the generator rewrite ./CHANGELOG.md` | `bug`, detected | the whole string | none (the file exists) | +| `/investigate how does the retry queue pick a backoff` | `how-it-works`, detected | the whole string | none | +| `/investigate how-it-work retry queue` | not a token; detected | the whole string | none | +| `/investigate how-it-works login throws 500 since Tuesday` | named `how-it-works`; the fit check asks | `login throws 500 since Tuesday` | none | +| `/investigate available-options add a fixed-amount coupon docs/inv/coupon.md` | `available-options`, named | `add a fixed-amount coupon` | `docs/inv/coupon.md` | +| `/investigate how should we add rate limiting to the API` | `available-options`, detected | the whole string | none | ### Resolve the type diff --git a/han-coding/skills/investigate/references/templates/available-options.md b/han-coding/skills/investigate/references/templates/available-options.md new file mode 100644 index 00000000..f7acd2d4 --- /dev/null +++ b/han-coding/skills/investigate/references/templates/available-options.md @@ -0,0 +1,71 @@ +# Available Options: {Goal} + +**Investigation type:** available-options: Compare the ways a piece of work could be done in this codebase + + + + + + + + +## Summary + + + + +- **Recommendation:** +- **Options Considered:** +- **Deciding Factor:** +- **Validation Outcome:** +- **Remaining Risks:** + +## Goal and Constraints + + + +## Current State + + + +## Options + + + +### Option 1: {Name} + +- **How it works:** +- **Change surface:** +- **Fits existing patterns:** +- **Costs and risks:** + +### Option 2: {Name} + +- **How it works:** +- **Change surface:** +- **Fits existing patterns:** +- **Costs and risks:** + + + +## Comparison + + + +| Constraint | Option 1 | Option 2 | +| ------------ | -------------- | -------------- | +| {constraint} | {how it fares} | {how it fares} | + +## Recommendation + + + + + +## Coding Standards Reference + + + +| Standard | Source | Bears On | +| ------------------------------------- | ---------------------------------------------------------- | -------------------------- | +| Description of standard or convention | File path, ADR number, or "inferred from surrounding code" | Which options this governs | diff --git a/han-coding/skills/investigate/references/types/available-options.md b/han-coding/skills/investigate/references/types/available-options.md new file mode 100644 index 00000000..946243a5 --- /dev/null +++ b/han-coding/skills/investigate/references/types/available-options.md @@ -0,0 +1,47 @@ +# Investigation type: available-options + +## Detection signals + +- the question asks what the options are, or what ways there are, for doing a piece of work in this codebase +- the question asks how a change could be made, where it would fit, or what it would take +- the question asks whether to take one approach or another, or which approach fits the existing code best +- a change is being weighed, and nothing is reported as broken + +## Dispatch + +Establish where the work would land and what constrains it before any option is named. Report what the code supports +today; the run itself enumerates and compares the options. + +1. `han-core:codebase-explorer` (1, always): "Explore the code a change for the following would touch: {question}. Find the entry points, the core logic, the data models, the configuration, the tests, and any existing pattern that already solves a similar problem and could serve as precedent. Return numbered findings keyed to file paths and line numbers, with the verbatim code that establishes each." +2. `han-core:structural-analyst` (1, always): "Your focus area is the code a change for the following would touch: {question}. Map the module boundaries, the dependency direction, the abstractions and extension points, and any duplication, so the ways the change could fit are visible. Return numbered findings keyed to file paths and line numbers." +3. `han-core:behavioral-analyst` (1, when the change would alter runtime flow, state, error handling, or an integration boundary): "Your focus area is the code a change for the following would touch: {question}. Trace the runtime behavior the change would have to preserve or alter: data flow, state, error propagation, and integration boundaries. Return numbered findings keyed to file paths and line numbers." +4. `han-core:data-engineer` (1, when the change would touch a schema, a migration, a query, or stored data): "Describe the schema, queries, migrations, and data-access code a change for the following would touch: {question}. Name the constraints they put on how the change can be made. Return numbered findings keyed to file paths, line numbers, and schema or migration references." +5. `han-core:concurrency-analyst` (1, when the change would touch async work, background jobs, queues, ordering, locking, or shared state): "Describe the concurrency and async behavior of the code a change for the following would touch: {question}. Name the constraints it puts on how the change can be made. Return numbered findings keyed to file paths and line numbers." + +## Analysis + +1. Write `Goal and Constraints`: the work to be done, restated plainly, and the constraints the evidence shows any + option must meet, each citing evidence items (E1, E2, ...). +2. Write `Current State`: what the code does today in the area the work would land, citing evidence items. +3. Resolve the coding standards that govern the area, then write `Coding Standards Reference`: for each standard, + convention, ADR, or pattern inferred from surrounding code, what it is, where it was found, and which options it + bears on. +4. Write `Options`: two or more genuinely different ways to do the work in this codebase, one `### Option N: {name}` + block each, with How it works, Change surface (the files and types it touches), Fits existing patterns (citing + evidence), and Costs and risks. Include an option only when the evidence shows the codebase can support it. +5. Write `Comparison`: a table of the options against the constraints from step 1. +6. Write `Recommendation`: the option that best meets the constraints, why, and what would change the call. + +## Validation brief + +- Root cause analysis: the Current State and the Goal and Constraints sections +- Planned fix: the recommended option and its change surface +- Attack focus: break the recommendation, and test whether a rejected option was dismissed on a false premise + +## Audience + +The engineer choosing an approach before planning it, with identifiers and file:line citations preserved. + +## Stop + +> Report written to {path}. No code was changed. Reply with corrections to revise the report. To plan the recommended option, run /han-planning:plan-a-change (restructuring existing code) or /han-planning:plan-a-feature (new behavior) with this report; to weigh prior art beyond this codebase, run /han-research:research. From 0fb0a2bd11590cd5a19ceea798b2b667c6f84a16 Mon Sep 17 00:00:00 2001 From: River Bailey Date: Thu, 12 Nov 2026 08:55:42 -0700 Subject: [PATCH 10/10] docs(investigate): describe the three investigation types everywhere Rewrite the investigate long-form doc around the bug, how-it-works, and available-options types. Update investigate-to-confluence to accept any type, pass a named type first and its /tmp report path last, and stop before implementing anything. Refresh the han-coding and han-atlassian README scent lines, the skills index, the han-coding plugin description, the workflows map, and the research-a-decision how-to. --- docs/how-to/research-a-decision.md | 5 +- docs/skills/README.md | 5 +- docs/workflows.md | 6 + han-atlassian/README.md | 4 +- .../docs/skills/investigate-to-confluence.md | 25 +- .../skills/investigate-to-confluence/SKILL.md | 45 +-- han-coding/.claude-plugin/plugin.json | 2 +- han-coding/README.md | 5 +- han-coding/docs/skills/investigate.md | 311 ++++++++++-------- 9 files changed, 237 insertions(+), 171 deletions(-) diff --git a/docs/how-to/research-a-decision.md b/docs/how-to/research-a-decision.md index c2e5a845..13e39027 100644 --- a/docs/how-to/research-a-decision.md +++ b/docs/how-to/research-a-decision.md @@ -8,8 +8,9 @@ so the team keeps a single canonical record of what was decided and why. ## Before you begin -- You have a real decision to make, not a bug to diagnose and not a feature to specify. `/investigate` is the right tool - when something is broken; `/plan-a-feature` is the right tool when the decision has already been made and you are +- You have a real decision to make that needs the open web or prior art, not a bug to diagnose and not a feature to + specify. `/investigate` is the right tool when the answer lives in this codebase (something broken, how the code + works, or how a change could be made within it); `/plan-a-feature` is the right tool when the decision has already been made and you are scoping behavior. - You have a question han can frame as a single decision. If the question is too thin, `/research` will ask you to sharpen it before dispatching anything. (Phase 1 step 1 below shows what a sharper framing looks like.) diff --git a/docs/skills/README.md b/docs/skills/README.md index 452ee758..2c928395 100644 --- a/docs/skills/README.md +++ b/docs/skills/README.md @@ -51,8 +51,9 @@ skill-and-agent split is fuzzy, read [Concepts](../concepts.md) first. skills and agents you used, and optionally post it as a GitHub issue to testdouble/han. - [`/html-summary`](../../han-reporting/docs/skills/html-summary.md) — Convert a `stakeholder-summary.md` into a single self-contained HTML executive report; produces the file only, does not publish it. -- [`/investigate`](../../han-coding/docs/skills/investigate.md) — Run an evidence-based investigation of a bug, failure, - or unexpected behavior, with adversarial validation of the proposed fix. +- [`/investigate`](../../han-coding/docs/skills/investigate.md) — Run an evidence-based investigation of a question about + this codebase as one of three types (a bug to root-cause, how the code works, or the options for a piece of work), + with adversarial validation of the findings. - [`/investigate-to-confluence`](../../han-atlassian/docs/skills/investigate-to-confluence.md) — Run `/investigate` (changing no code), show the report for review, then publish it as one Confluence page after confirmation. - [`/issue-triage`](../../han-research/docs/skills/issue-triage.md) — Classify a vague issue or bug report, identify missing diff --git a/docs/workflows.md b/docs/workflows.md index 1b667cc7..a0eeafb7 100644 --- a/docs/workflows.md +++ b/docs/workflows.md @@ -112,6 +112,8 @@ flowchart TD restructure -.runs.-> tdd tdd --> prdesc["/update-pr-description"] investigate["/investigate"] --> iterate["/iterative-plan-review"] + investigate --> change + investigate --> feature ddd["/ddd-analysis"] --> arch ddd --> feature["/plan-a-feature"] pairing["/pairing"] -.drives.-> refactor @@ -149,6 +151,10 @@ flowchart TD - **[`/investigate`](../han-coding/docs/skills/investigate.md) → [`/iterative-plan-review`](../han-planning/docs/skills/iterative-plan-review.md).** Root-cause the bug, then stress-test the proposed fix. +- **[`/investigate how-it-works` or `available-options`](../han-coding/docs/skills/investigate.md) → + [`/plan-a-change`](../han-planning/docs/skills/plan-a-change.md) or + [`/plan-a-feature`](../han-planning/docs/skills/plan-a-feature.md).** Learn how the code works, or pick among the ways + a change could be made, then plan the restructure or specify the new behavior. - **[`/ddd-analysis`](../han-ddd/docs/skills/ddd-analysis.md) → [`/architectural-analysis`](../han-coding/docs/skills/architectural-analysis.md) or [`/plan-a-feature`](../han-planning/docs/skills/plan-a-feature.md).** Map the domain and context boundaries of the whole diff --git a/han-atlassian/README.md b/han-atlassian/README.md index 90d2f304..65f9245b 100644 --- a/han-atlassian/README.md +++ b/han-atlassian/README.md @@ -15,8 +15,8 @@ and `han-coding` (its wrapper skills run skills from each), and requires a confi - [`/project-documentation-to-confluence`](docs/skills/project-documentation-to-confluence.md) — Run `/project-documentation` to write feature documentation, show it for review, then publish it to a user-specified Confluence location after confirmation. -- [`/investigate-to-confluence`](docs/skills/investigate-to-confluence.md) — Run `/investigate` to root-cause a bug - (changing no code), show the report for review, then publish it as one Confluence page after confirmation. +- [`/investigate-to-confluence`](docs/skills/investigate-to-confluence.md) — Run `/investigate` on a bug, on how the + code works, or on the options for a piece of work (changing no code), show the report for review, then publish it as one Confluence page after confirmation. - [`/code-overview-to-confluence`](docs/skills/code-overview-to-confluence.md) — Run `/code-overview` to produce a progressive-disclosure overview (changing no code), show it for review, then publish it as one Confluence page after confirmation. diff --git a/han-atlassian/docs/skills/investigate-to-confluence.md b/han-atlassian/docs/skills/investigate-to-confluence.md index 011f1f08..5d523435 100644 --- a/han-atlassian/docs/skills/investigate-to-confluence.md +++ b/han-atlassian/docs/skills/investigate-to-confluence.md @@ -9,11 +9,11 @@ helps you decide _when_ and _how_ to use the skill. For what the skill does inte ## TL;DR -- **What it does.** Runs the core [`/investigate`](../../../han-coding/docs/skills/investigate.md) skill to root-cause a bug or unexpected - behavior, and writes the investigation report to a temporary file. Shows you the file to review. After you confirm, +- **What it does.** Runs the core [`/investigate`](../../../han-coding/docs/skills/investigate.md) skill as any of its investigation types (a bug + to root-cause, how some part of the code works, or the options for a piece of work), and writes the investigation report to a temporary file. Shows you the file to review. After you confirm, publishes it to a Confluence location you specify by handing the file to [`/markdown-to-confluence`](./markdown-to-confluence.md). -- **When to use it.** You want something diagnosed _and_ the findings posted to a specific Confluence space or page, not +- **When to use it.** You want something diagnosed, explained, or weighed _and_ the findings posted to a specific Confluence space or page, not only to a local file. - **What you get back.** A working-draft markdown report under `/tmp/` that you can review, plus a created or updated Confluence page at the location you named (if you choose to publish). No code is changed. @@ -25,14 +25,14 @@ helps you decide _when_ and _how_ to use the skill. For what the skill does inte work, the location resolution, and the create-or-update call all belong to [`/markdown-to-confluence`](./markdown-to-confluence.md). This skill only validates its inputs, runs the investigation to a temporary file, lets you review it, takes your publish choice, and hands the file to the publisher. -- **One report, one page.** `/investigate` produces a single report file (problem statement, evidence summary, root - cause, planned fix, validation, and summary), with no companion artifacts. So this skill publishes one Confluence +- **One report, one page.** `/investigate` produces a single report file whose sections follow the investigation type + it ran as, with no companion artifacts. So this skill publishes one Confluence page. It is the single-page sibling of [`/project-documentation-to-confluence`](./project-documentation-to-confluence.md), not the parent-plus-children tree of [`/plan-a-feature-to-confluence`](./plan-a-feature-to-confluence.md). -- **It publishes findings, it does not ship them.** `/investigate` on its own ends by presenting the plan for approval - and can trigger the fix's implementation. This wrapper instructs it to stop at the report and change no code, because - the point is to publish the diagnosis, not to apply it. +- **It publishes findings, it does not ship them.** A `bug` investigation on its own ends by offering to implement the + Planned Fix. This wrapper instructs it to stop at the report and change no code, because the point is to publish the + findings, not to apply them. - **The Atlassian MCP server is required.** The skill checks the server is connected before it runs any investigation, so a missing server fails fast. If the server is missing or not authenticated, the skill stops and points you at `/investigate` for a local-only run. It never silently falls back to local. @@ -55,6 +55,8 @@ helps you decide _when_ and _how_ to use the skill. For what the skill does inte - A bug or production incident has been investigated and the root-cause writeup needs to live in Confluence, where your team reads it, not only in the repo. - You want a diagnosis shared with stakeholders or on-call for review before anyone fixes the underlying problem. +- You want an explanation of how part of the codebase works, or a comparison of the options for a piece of work, + published where your team will read it. - You already know the exact Confluence space or page where the report belongs and want it investigated and published in one pass. @@ -102,8 +104,9 @@ Example prompts: Two artifacts: - **The working draft.** A markdown investigation report under `/tmp/` that - [`/investigate`](../../../han-coding/docs/skills/investigate.md) writes: problem statement, evidence summary, root cause analysis, - planned fix, validation results, and a leading summary. This file is the source content for Confluence and the thing + [`/investigate`](../../../han-coding/docs/skills/investigate.md) writes, with the sections of the investigation type it + ran as: for a bug, the problem statement, root cause analysis, planned fix, evidence, validation, and a leading + summary. This file is the source content for Confluence and the thing you review before publishing. It lives in `/tmp/`, not your repo, so it does not get committed unless you move it there yourself. No code is changed. - **The Confluence page.** A page created at, or updated in place at, the location you named, either as an unpublished @@ -148,7 +151,7 @@ The skill walks a short, deterministic five-step process: page tree here; it only confirms a location exists. 2. **Produce the investigation report to a temporary file.** Invoke `/investigate` with all your context forwarded verbatim, plus two added instructions: write the result to a `/tmp/` file rather than the repo, and stop at the - report without implementing the fix. Capture that path. + report without implementing anything. Capture that path. 3. **Show the file for review.** Tell you the exact `/tmp/` path so you can open and read the report before deciding anything. 4. **Confirm the publish choice.** Ask how to publish: save as a draft (the recommended default), publish live, or keep diff --git a/han-atlassian/skills/investigate-to-confluence/SKILL.md b/han-atlassian/skills/investigate-to-confluence/SKILL.md index 023fa847..0aa68b77 100644 --- a/han-atlassian/skills/investigate-to-confluence/SKILL.md +++ b/han-atlassian/skills/investigate-to-confluence/SKILL.md @@ -1,16 +1,17 @@ --- name: investigate-to-confluence description: > - Runs an evidence-based investigation of a bug, failure, or unexpected behavior with investigate and publishes the - resulting investigation report to a user-specified Confluence location. Use when the user wants something debugged, - diagnosed, or root-caused AND the findings posted to a Confluence space or page. Requires a configured Atlassian MCP - server. Does not investigate to a local file only — use investigate. Does not publish an arbitrary existing markdown - file — use markdown-to-confluence. Does not document an already-understood feature to Confluence — use + Runs an evidence-based investigation of a question about this codebase with investigate, as any of its investigation + types (a bug to root-cause, how the code works, or the options for a piece of work), and publishes the resulting + report to a user-specified Confluence location. Use when the user wants something debugged, explained, or weighed AND + the findings posted to a Confluence space or page. Requires a configured Atlassian MCP server. Does not investigate to + a local file only — use investigate. Does not publish an arbitrary existing markdown file — use + markdown-to-confluence. Does not document an already-understood feature to Confluence — use project-documentation-to-confluence. Does not plan or specify a new feature to Confluence — use plan-a-feature-to-confluence. Does not publish to Jira — use work-items-to-jira. argument-hint: - "[symptom or question to investigate] [confluence location: page URL or space + parent] [--mode draft|live (default - draft)]" + "[optional investigation type] [symptom or question to investigate] [confluence location: page URL or space + parent] + [--mode draft|live (default draft)]" allowed-tools: Read, Glob, Grep, Skill, Agent, Bash(find *), mcp__claude_ai_Atlassian__getAccessibleAtlassianResources, Bash(bash "${CLAUDE_PLUGIN_ROOT}/scripts/han-config-dir.sh") @@ -34,8 +35,8 @@ orchestrator: the investigation work belongs to `han-coding:investigate`, and th `han-atlassian:markdown-to-confluence`. This skill only validates its inputs, runs the investigation to a temporary file, gets the user's review and publish choice, and hands the file to the publisher. -`han-coding:investigate` produces a **single** report file (the investigation plan: problem statement, evidence summary, -root cause analysis, planned fix, validation results, and summary). It does not produce companion artifacts, so this +`han-coding:investigate` produces a **single** report file whose sections follow the investigation type it ran as (`bug`, +`how-it-works`, or `available-options`). It does not produce companion artifacts, so this skill publishes that one file as a single Confluence page — the single-page sibling of `han-atlassian:project-documentation-to-confluence`, not the parent-plus-children tree of `han-atlassian:plan-a-feature-to-confluence`. @@ -54,8 +55,8 @@ Confirm the skill has everything it needs before spending effort on an investiga can re-run it once it is connected. Do not fall back to a local-only run; for a local-only investigation, point them at `han-coding:investigate`. This preflight runs first so a missing server fails before any investigation work begins. -2. **A symptom or question to investigate.** Confirm the request names a bug, failure, error, integration, or unexpected - behavior to investigate. This — together with any relevant conversation context — is forwarded to +2. **A symptom or question to investigate.** Confirm the request names something to investigate in this codebase: a bug + or failure, how some part of the code works, or the options for a piece of work. This — together with any relevant conversation context — is forwarded to `han-coding:investigate` verbatim in Step 2. If the request is too thin to start, let `han-coding:investigate` run its own investigation rather than pre-empting it here. 3. **A Confluence destination.** Confirm the request provides a target location: a **Confluence page URL** (to update @@ -68,17 +69,19 @@ Confirm the skill has everything it needs before spending effort on an investiga Invoke the `han-coding:investigate` skill with the **Skill** tool, **forwarding all provided context** verbatim: the symptom or question, any known reproduction steps or error messages, any suspected entry points, and the relevant -conversation context. Do not summarize, trim, or reinterpret the user's context; pass it through so -`han-coding:investigate` runs exactly as it would on its own (parallel investigators, conditional specialist analysts, -adversarial validation, and the final report) — **except** add two explicit instructions: - -- It must write the resulting investigation report to a file under `/tmp/` (for example `/tmp/.md`) rather - than into the project's docs or plans directory. This keeps the working report out of the repo until the user decides +conversation context. When the user named an investigation type, put that type first in the argument. Do not +summarize, trim, or reinterpret the user's context; pass it through so `han-coding:investigate` runs exactly as it would +on its own (type resolution, parallel agents, adversarial validation, and the final report) — **except** add two +explicit instructions: + +- It must write the resulting investigation report to a file under `/tmp/` rather than into the project's docs or plans + directory. Pass the path as the argument's final token, for example `/tmp/investigate-.md`, choosing a + path where no file exists yet, so `han-coding:investigate` reads it as the report path. This keeps the working report out of the repo until the user decides to publish it, and because the path is explicit input it outranks any `output-directory` the project or personal `.han/config.md` supplies (see [../../references/config-rule.md](../../references/config-rule.md)). -- It must **stop after producing the report**. `han-coding:investigate` normally ends by presenting the plan for - approval and can trigger the fix's implementation on approval; this skill wants the report only, so instruct it not to - implement the fix or change any code — this skill publishes findings, it does not ship them. +- It must **stop after producing the report**. A `bug` investigation normally ends by offering to implement the Planned + Fix on approval; this skill wants the report only, so instruct it not to implement anything or change any code. This + skill publishes findings, it does not ship them. Let `han-coding:investigate` complete its full investigation process. **Capture the exact `/tmp/` file path it wrote.** That markdown file is the source content for Confluence. Proceed to Step 3 once it finishes. @@ -123,7 +126,7 @@ page's URL and whether it went live or was saved as a draft. If publishing fails 1. **Inputs validated:** the Atlassian server was reachable, a symptom or question to investigate was present, and a Confluence location was provided — or the skill stopped before doing any work. 2. **Report produced to /tmp:** `han-coding:investigate` ran with the full forwarded context, wrote the investigation - report to a `/tmp/` file whose path was captured, and did not implement the fix or change any code. + report to a `/tmp/` file whose path was captured, and did not implement anything or change any code. 3. **User reviewed:** the `/tmp/` path was shown to the user before any publish. 4. **Explicit choice obtained:** the user chose draft, live, or local-only. 5. **Publish delegated and reported:** when the user chose to publish, `han-atlassian:markdown-to-confluence` created or diff --git a/han-coding/.claude-plugin/plugin.json b/han-coding/.claude-plugin/plugin.json index ff24f469..ff00bf46 100644 --- a/han-coding/.claude-plugin/plugin.json +++ b/han-coding/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "han-coding", - "description": "Coding-facing skills for the Han suite: writing, reviewing, testing, investigating, and standardizing code. Home of the tdd skill, which drives a feature or behavior through a BDD-framed red-green-refactor loop with an enforced observed-failure gate, and the refactor skill, which restructures existing code without changing its behavior through a test-gated refactoring loop, and the restructure skill, which restructures a codebase or large area toward a target layout unit by unit through refactor and tdd, using the Mikado Method to tease apart units too tangled to move in one step, plus design-an-api (designing an interface contract for one stated goal through an options round, a question round, and an adversarial validation round), code-review (comprehensive review of local changes), code-overview (a progressive-disclosure, understand-now overview of unfamiliar code or a PR's changes), code-walkthrough (a paced, one-step-at-a-time walk through a branch's changes in conversation), architectural-analysis (module-level coupling, data flow, concurrency, risk, and SOLID assessment), automated-test-planning (coverage-gap and edge-case test plans), manual-test-planning (plain-language manual test plans a person runs by hand), investigate (evidence-based root-cause debugging), and coding-standard (creating and updating coding standards). Depends on han-core and han-communication; bundled by the han meta-plugin.", + "description": "Coding-facing skills for the Han suite: writing, reviewing, testing, investigating, and standardizing code. Home of the tdd skill, which drives a feature or behavior through a BDD-framed red-green-refactor loop with an enforced observed-failure gate, and the refactor skill, which restructures existing code without changing its behavior through a test-gated refactoring loop, and the restructure skill, which restructures a codebase or large area toward a target layout unit by unit through refactor and tdd, using the Mikado Method to tease apart units too tangled to move in one step, plus design-an-api (designing an interface contract for one stated goal through an options round, a question round, and an adversarial validation round), code-review (comprehensive review of local changes), code-overview (a progressive-disclosure, understand-now overview of unfamiliar code or a PR's changes), code-walkthrough (a paced, one-step-at-a-time walk through a branch's changes in conversation), architectural-analysis (module-level coupling, data flow, concurrency, risk, and SOLID assessment), automated-test-planning (coverage-gap and edge-case test plans), manual-test-planning (plain-language manual test plans a person runs by hand), investigate (evidence-based investigation of a bug, of how the code works, or of the options for a piece of work), and coding-standard (creating and updating coding standards). Depends on han-core and han-communication; bundled by the han meta-plugin.", "version": "3.4.0", "dependencies": ["han-communication", "han-core"] } diff --git a/han-coding/README.md b/han-coding/README.md index 6712106e..4714c5bb 100644 --- a/han-coding/README.md +++ b/han-coding/README.md @@ -28,8 +28,9 @@ it, dispatching specialist agents to cover each dimension in parallel. Reach for - [`/automated-test-planning`](docs/skills/automated-test-planning.md) — Produce a prioritized test plan for a branch or directory. - [`/manual-test-planning`](docs/skills/manual-test-planning.md) — Produce a plain-language manual test plan from supplied context: named tests with by-hand steps and expected outcomes for a person to run. -- [`/investigate`](docs/skills/investigate.md) — Run an evidence-based investigation of a bug, failure, or unexpected - behavior, with adversarial validation of the proposed fix. +- [`/investigate`](docs/skills/investigate.md) — Run an evidence-based investigation of a question about this codebase as + one of three types (a bug to root-cause, how the code works, or the options for a piece of work), with adversarial + validation of the findings. - [`/coding-standard`](docs/skills/coding-standard.md) — Create and update coding standards from existing patterns or evidence-based research. diff --git a/han-coding/docs/skills/investigate.md b/han-coding/docs/skills/investigate.md index 2b391a22..23d46255 100644 --- a/han-coding/docs/skills/investigate.md +++ b/han-coding/docs/skills/investigate.md @@ -9,29 +9,44 @@ to use the skill. For what the skill does internally, read the skill definition ## TL;DR -- **What it does.** Evidence-based investigation of a bug, failure, or unexpected behavior, followed by adversarial - validation of the proposed fix. -- **When to use it.** Something is broken and you want a root cause backed by file-level evidence, not a guess. -- **What you get back.** An investigation report with symptoms, numbered evidence (E1, E2, …), root cause analysis, fix - plan, and validation findings (V1, V2, …). +- **What it does.** Runs an evidence-based investigation of a question about this codebase as one of three types (a bug + to root-cause, how the code works, or the options for a piece of work), with adversarial validation of the findings. +- **When to use it.** You want an answer backed by file-level evidence, not a guess: why something is broken, how + something works, or which way a change should go. +- **What you get back.** A report whose sections follow the type, with numbered evidence (E1, E2, …) and validation + findings (V1, V2, …). A bug report carries a root cause and a planned fix; a how-it-works report carries an answer and + a walkthrough; an available-options report carries options, a comparison, and a recommendation. ## Key concepts -- **Trace backward from symptoms.** Don't guess. Follow the code. The skill works from the observed failure outward to - the data flow, the error path, and the recent changes that might have broken it. -- **Parallel evidence gathering with specialists.** At least two `evidence-based-investigator` agents run in parallel, - each from a different angle: one on the error path, one on the data flow. When the symptom matches, specialist - analysts dispatch in parallel alongside the investigators. `concurrency-analyst` for intermittent / race / timeout - bugs. `behavioral-analyst` for data-flow and error-propagation bugs. `data-engineer` for schema, query, migration, and - isolation bugs. Specialists find root causes generalists miss. -- **Evidence is numbered.** Every finding gets an ID (E1, E2, E3…) so the root-cause analysis and fix plan can reference - specific evidence explicitly (_"the handler passes an unvalidated ID (E1) to the service layer, which assumes non-nil - (E3)"_). -- **Adversarial validation before ship.** After the fix is planned, `adversarial-validator` agents try to falsify the - evidence, break the fix, and challenge the assumptions. Counter-evidence becomes validation findings (V1, V2, …) that - reshape the plan. -- **Coding-standards aware.** The fix plan is written against the project's standards, ADRs, and inferred patterns. Not - against generic best practice. +- **One run, one investigation type.** Every run answers one kind of question: + + | Type | What it answers | What you get | + | ------------------- | --------------------------------------------------------------- | -------------------------------------------------------------- | + | `bug` | Find the root cause of a failure and plan the fix | Problem statement, root cause, planned fix, coding standards | + | `available-options` | Compare the ways a piece of work could be done in this codebase | Goal and constraints, current state, options, comparison, pick | + | `how-it-works` | Explain how this codebase behaves, with cited evidence | The question, a one-sentence answer, a walkthrough, key parts | + +- **Name a type, or let the skill pick.** Put the type first (`/investigate how-it-works …`) to choose it. Leave it out + and the skill reads your question and picks one. A failure outranks everything; an options question outranks a + how-it-works one; a question that reads as none of them runs as `how-it-works`. +- **A type that does not fit gets one question.** When you name a type and your question clearly reads as a different + one (`/investigate how-it-works login throws 500 since Tuesday`), the skill asks once which to use, and suggests the + better fit. Anything short of a clear mismatch keeps your choice. +- **You see what it decided before any work starts.** Every run opens with a short block naming the type, why it was + chosen, the question as the skill read it, where the report will be written, and the other types you could re-run as. +- **Parallel evidence gathering with specialists.** Each type dispatches its own agents in parallel. A bug run sends two + or more `evidence-based-investigator` agents, each from a different angle, plus `concurrency-analyst`, + `behavioral-analyst`, or `data-engineer` when the symptom matches. A how-it-works run sends `codebase-explorer` and + `behavioral-analyst`. An options run sends `codebase-explorer` and `structural-analyst`. Specialists join either when + the question calls for them. +- **Evidence is numbered.** Every finding gets an ID (E1, E2, E3…) so the analysis can cite specific evidence (_"the + handler passes an unvalidated ID (E1) to the service layer, which assumes non-nil (E3)"_). +- **Adversarial validation before you act.** `adversarial-validator` agents try to falsify the evidence and break the + conclusion: the fix for a bug, the completeness of the explanation for how-it-works, the recommendation for options. + Counter-evidence becomes validation findings (V1, V2, …) that reshape the report. +- **This codebase, not the open web.** The skill reads your repository and any material you paste in. For prior art, + outside libraries, or the state of the art, use `/research`. ## When to use it @@ -39,124 +54,152 @@ to use the skill. For what the skill does internally, read the skill definition - A bug, failure, or unexpected behavior needs a root cause backed by code-level evidence. - An integration or API call is misbehaving and you want a trace from symptoms to data flow to recent changes. -- You suspect a regression and want the investigation to consider git history alongside the code. -- You want the proposed fix adversarially validated, not only designed, before writing any code. -- You want a durable report that names the exact file, function, and line where the problem originates, plus the - evidence that proves it. +- You need an accurate account of how a flow, a lifecycle, or an integration in this codebase works before you change it. +- You are weighing how to make a change and want the options this codebase supports, compared against its constraints. +- You want the conclusion adversarially validated, not only drafted, before writing any code. **Do not invoke for:** - **Code review.** Use [`/code-review`](./code-review.md) for a correctness, testing, and compliance audit of a branch. -- **Architectural analysis.** Use [`/architectural-analysis`](./architectural-analysis.md) for coupling, - data flow, concurrency, and SOLID assessment of a module. +- **Architectural analysis.** Use [`/architectural-analysis`](./architectural-analysis.md) for coupling, data flow, + concurrency, and SOLID assessment of a module. - **Test planning.** Use [`/automated-test-planning`](./automated-test-planning.md) when the gap is coverage, not a bug. -- **Plan review.** Use [`/iterative-plan-review`](../../../han-planning/docs/skills/iterative-plan-review.md) for multi-pass review of an - existing plan. -- **Open-ended research.** Use [`/research`](../../../han-research/docs/skills/research.md) when nothing is broken and you want options, prior - art, or how something works before committing to a direction. -- **Planning the structural change a root cause calls for.** Use - [`/plan-a-change`](../../../han-planning/docs/skills/plan-a-change.md) when this skill's report shows the defect is a - responsibility in the wrong place rather than a one-line fix. Its report is a valid input there. +- **Plan review.** Use [`/iterative-plan-review`](../../../han-planning/docs/skills/iterative-plan-review.md) for + multi-pass review of an existing plan. +- **The open web and prior art.** Use [`/research`](../../../han-research/docs/skills/research.md) when the answer lives + outside this codebase: outside libraries, prior art, or how an outside technology works. +- **An orientation to a whole area.** Use [`/code-overview`](./code-overview.md) for a written overview of a file, + directory, or PR, or [`/code-walkthrough`](./code-walkthrough.md) to be paced through code one step at a time. + `/investigate how-it-works` answers one question with cited, validated evidence. +- **Planning the change a finding calls for.** Use [`/plan-a-change`](../../../han-planning/docs/skills/plan-a-change.md) + when the report shows a responsibility in the wrong place rather than a one-line fix, or when you have picked an + option to restructure toward. Its report is a valid input there. - **Mapping bounded contexts or domain boundaries.** Use [`/ddd-analysis`](../../../han-ddd/docs/skills/ddd-analysis.md) - when the question is where the domain's boundaries sit, not why a specific thing is broken. -- **Feedback on Han's own skills.** Use [`/han-feedback`](../../../han-feedback/docs/skills/han-feedback.md) to capture post-session - feedback on the Han skills you ran. + when the question is where the domain's boundaries sit. +- **Feedback on Han's own skills.** Use [`/han-feedback`](../../../han-feedback/docs/skills/han-feedback.md) to capture + post-session feedback on the Han skills you ran. ## How to invoke it -Run `/investigate` in Claude Code with a description of the problem. +Run `/investigate` in Claude Code with an optional type, your question, and an optional report path: + +``` +/investigate [bug | available-options | how-it-works] [report path ending in .md] +``` Give it: -1. **The symptom.** What you observed: the error message, the unexpected value, the failed deploy, the intermittent - timeout. A concrete observation collapses the initial search space. -2. **The reproduction context, if known.** Environment, branch, specific user account, specific data, specific time. The - skill does not need a full reproduction (it can investigate from a single observation), but the more context you - give, the faster the angles converge. -3. **An output path, optional.** The skill writes the investigation plan to a file. Name a path to control where it - lands; otherwise the skill proposes one and writes the plan there. +1. **The type, optional.** The first word, when it is one of the three tokens. A trailing colon is fine (`bug:`). +2. **The question or symptom.** For a bug, what you observed: the error message, the unexpected value, the failed + deploy. For how-it-works, what you want explained. For options, the work you want to do. Concrete wording collapses + the search space. +3. **A report path, optional.** A final word ending in `.md` that does not name an existing file is where the report is + written. A final `.md` that already exists is read as part of your question, and the skill never writes over it. + Otherwise the report goes to your configured `output-directory`, or to `investigations/` under the project's + documentation root, named after your question. Example prompts: -- `/investigate`. _"Why are webhook deliveries failing intermittently in production?"_ -- `/investigate`. _"Users are seeing stale data after updating their profile. The update returns 200 but the next page +- `/investigate`. _"Why are webhook deliveries failing intermittently in production?"_ Runs as `bug`. +- `/investigate bug`. _"Users see stale data after updating their profile. The update returns 200 but the next page load shows the old value."_ -- `/investigate`. _"The background job queue is backing up during peak hours. Jobs enqueued at 9am don't run until - 9:30am."_ -- `/investigate docs/incidents/2026-04-23.md`. Investigate and write the report into the incident folder. +- `/investigate how-it-works`. _"How does the retry queue pick a backoff?"_ +- `/investigate`. _"What happens when a payment webhook arrives for an order that was already refunded?"_ Runs as + `how-it-works`. +- `/investigate available-options`. _"Add rate limiting to the public API."_ +- `/investigate`. _"How should we add a fixed-amount coupon alongside the percentage discounts?"_ Runs as + `available-options`. +- `/investigate the import job drops rows docs/incidents/2026-04-23.md`. Investigate and write the report to that path. ## What you get back -An investigation plan file, plus an in-channel summary. The plan leads with the bottom line and keeps the supporting -detail near the end, so it reads conclusion-first. Sections appear only when the investigation produced meaningful -content for them; one that would be empty is omitted, and the rest keep the order below. So a given report covers some -or all of, in order: +A report file, plus an in-channel summary. Every report leads with the bottom line and keeps the supporting detail near +the end. Sections appear only when the investigation produced meaningful content for them, and the rest keep the order +below. Every report names its type on the line under its title. + +**A `bug` report** carries: -- **Summary.** One sentence each for root cause, fix, why correct, validation outcome, remaining risks. Up top so a - reader gets the verdict before the backing detail. +- **Summary.** One sentence each for root cause, fix, why correct, validation outcome, and remaining risks. - **Problem Statement.** Symptoms, expected behavior, conditions under which it occurs, impact. -- **Root Cause Analysis.** One to three sentences summarizing the root cause, followed by a detailed analysis that - references evidence items by number. -- **Planned Fix.** Per-file changes: full path, what will be modified, which evidence items justify the change, which - standards apply, and implementation specifics (new function signatures, changed logic, updated tests). -- **Evidence Summary.** A numbered list (E1, E2, E3, …) consolidated from the parallel `evidence-based-investigator` - agents. Duplicates merged; conflicts resolved with explicit citations. -- **Validation Findings.** Numbered `V1, V2, …` entries from `adversarial-validator`. Each records the challenge - attempted, whether counter-evidence was found, and what changed in response. Followed by **Adjustments Made** (what - changed after validation, cross-referenced to the `V#` that drove it) and the **Confidence Assessment and Remaining - Risks** that close the validator's judgment. -- **Coding Standards Reference.** For each standard that applies, what it says, where it was found (path, ADR number, or - _"inferred from surrounding code"_), and which files the fix will touch. This keeps the fix consistent with how the - project already works. - -The plan is presented for approval before any code is written. Approve to trigger implementation; push back with -feedback to revise. +- **Root Cause Analysis.** One to three sentences on the root cause, then a detailed analysis citing evidence items. +- **Planned Fix.** Per-file changes: full path, what changes, which evidence justifies it, which standards apply, and + implementation specifics. +- **Evidence Summary and Validation Results.** The shared sections, below. +- **Coding Standards Reference.** Each standard the fix was written against, and where it was found. + +**A `how-it-works` report** carries: + +- **Summary.** The answer, the entry points, the validation outcome, and the paths the evidence did not reach. +- **Question.** What was asked, and what the answer covers and leaves out. +- **Answer.** A one-sentence answer, then a numbered walkthrough of the flow citing evidence items. +- **Key Components.** A table of each part the walkthrough depends on, its file, and its role. +- **Evidence Summary and Validation Results.** + +**An `available-options` report** carries: + +- **Summary.** The recommendation, the options considered, the deciding factor, the validation outcome, and remaining + risks. +- **Goal and Constraints.** The work, and the constraints any option must meet. +- **Current State.** What the code does today where the work would land. +- **Options.** Two or more genuinely different ways to do the work, each with how it works, its change surface, how it + fits existing patterns, and its costs and risks. +- **Comparison.** The options against the constraints. +- **Recommendation.** The pick, why, and what would change the call. +- **Evidence Summary and Validation Results.** +- **Coding Standards Reference.** The standards that bear on the options. + +**Every report shares** an **Evidence Summary** (E1, E2, …, consolidated from every agent, duplicates merged) and +**Validation Results** (V1, V2, … from `adversarial-validator`, each recording the challenge, the result, and its +impact), followed by **Adjustments Made** and the **Confidence Assessment**. + +The run ends by saying where the report is and what to do next. After a bug report, reply "approve" to have the session +implement the Planned Fix, or reply with corrections. After the other two, the skill points you at `/plan-a-change` or +`/plan-a-feature` for the next step, and at `/research` when options need prior art. ## How to get the most out of it -- **Name the symptom concretely.** _"Stale data after update"_ beats _"profile issue."_ The more specific the - observation, the sharper the investigator agents' angles. -- **Drop in any evidence you already have.** Error messages, stack traces, log excerpts, recent deploy notes, the commit - you suspect. Paste them. The skill's agents read the codebase, but they cannot see your production logs unless you - bring them in. -- **Let the validator push back.** The adversarial validation step is not ceremony. It frequently reshapes the root - cause analysis. Treat validation findings as first-class input. -- **Pair with `/iterative-plan-review`** if the fix plan needs further stress-testing before implementation, especially - when the fix touches cross-cutting concerns. -- **Re-run after the fix.** Once the fix has shipped, re-run against the incident context with _"did this fix hold?"_ - framing. Validation findings from the new run confirm or falsify the hypothesis under production conditions. -- **For the full end-to-end bug-handling workflow**, including when to triage instead of investigating now and how to - bring in production logs and browser integrations, see +- **Name the symptom or the question concretely.** _"Stale data after update"_ beats _"profile issue."_ _"How does the + retry queue pick a backoff"_ beats _"explain the queue."_ +- **Name the type when you know it.** Detection is good at the common shapes, but a question that mentions a failure in + passing reads as a bug. If the opening block shows the wrong type, re-run with the type first. +- **Drop in any evidence you already have.** Error messages, stack traces, log excerpts, recent deploy notes, vendor + docs. Paste them. The agents read the codebase, but they cannot see your production logs or the web unless you bring + them in. +- **Let the validator push back.** The adversarial validation step frequently reshapes the conclusion. Treat validation + findings as first-class input. +- **Pair with `/iterative-plan-review`** if a bug's fix plan needs further stress-testing before implementation. +- **Re-run after the fix.** Once a fix has shipped, re-run against the incident context with _"did this fix hold?"_ + framing. +- **For the full end-to-end bug-handling workflow**, see [How to triage and investigate a bug](../../../docs/how-to/triage-and-investigate-a-bug.md). ## Cost and latency -The skill dispatches at least two `evidence-based-investigator` agents in parallel, plus zero to three specialist -analysts (`concurrency-analyst`, `behavioral-analyst`, `data-engineer`) depending on bug classification. -`adversarial-validator` agents then run the validation pass, followed by one `han-communication:readability-editor` -rewrite of the write-up. Agents run on their default models. For a medium-complexity bug, expect one investigation -round, one validation round, and one readability pass, roughly five to eight sub-agent dispatches. The skill is built -for per-bug cadence, not tight-loop iteration. Fix the bug and move on. +Each type dispatches two to five agents in parallel for evidence, then `adversarial-validator` agents for validation, +then one `han-communication:readability-editor` rewrite. A bug run sends at least two `evidence-based-investigator` +agents plus zero to three specialists. A how-it-works or options run sends two agents plus zero to three specialists. +Agents run on their default models. Expect one evidence round, one validation round, and one readability pass, roughly +five to eight sub-agent dispatches. The skill is built for per-question cadence, not tight-loop iteration. ## In more detail -The skill walks a five-step process: - -1. **Research and investigation.** At least two `evidence-based-investigator` agents run in parallel, each from a - different angle. Specialist analysts (`concurrency-analyst`, `behavioral-analyst`, `data-engineer`) dispatch in - parallel alongside them based on how you described the symptom. After all complete, the skill compiles a unified - numbered evidence list (E1, E2, E3, …), tagging specialist findings with their domain. -2. **Document root cause.** The skill writes Problem Statement, Evidence Summary, and Root Cause Analysis into the plan - file using the template at [`references/templates/bug.md`](../../skills/investigate/references/templates/bug.md). -3. **Plan the fix.** The skill resolves project config (CLAUDE.md → project-discovery.md → docs/ Glob fallback), reads - ADRs and coding standards relevant to the fix, and writes the Planned Fix section with file-level changes justified - by specific evidence items. -4. **Adversarial validation.** `adversarial-validator` agents receive the full evidence summary, root cause analysis, - and planned fix. They challenge evidence, challenge the fix, and challenge assumptions. Counter-evidence becomes `V#` - findings that reshape the plan. -5. **Summary and user review.** The skill writes the Summary section at the top of the report. It then dispatches - `readability-editor` to rewrite the write-up for the engineer who will implement the fix, preserving every fact and - `file:line` reference. Finally it runs a readability self-check over the prose and presents the plan for approval. +The skill walks a six-step process. The type file under `references/types/` drives every step that differs by type. + +1. **Resolve the type, the question, and the report path.** The skill parses a leading type token and a trailing report + path, detects or checks the type, asks once on a clear mismatch, resolves where the report goes, and prints the + opening block. +2. **Gather evidence.** The type's agents run in parallel. Extra agents from `.han/config.md` join when their specialty + matches. The skill compiles one numbered evidence list (E1, E2, E3, …), tagging specialist findings with their domain. +3. **Analyze and write the report.** The skill runs the type's analysis steps into the type's template under + `references/templates/`, for example [`references/templates/bug.md`](../../skills/investigate/references/templates/bug.md). + The evidence and validation sections every type shares live in + [`references/evidence-and-validation.md`](../../skills/investigate/references/evidence-and-validation.md). +4. **Adversarial validation.** `adversarial-validator` agents receive the full evidence and the type's conclusion. They + challenge the evidence, the conclusion, and the assumptions. Counter-evidence becomes `V#` findings that reshape the + report. +5. **Summary and readability.** The skill writes the Summary, then dispatches `readability-editor` to rewrite the + write-up for the type's reader, preserving every fact and `file:line` reference, and runs a readability self-check. +6. **Present the report.** The skill prints the type's closing line and how to re-run as another type. ## Sources @@ -166,7 +209,7 @@ review. ### Toyota Production System: The Five Whys Root-cause analysis via repeated "why" questioning, popularized at Toyota and adopted widely across software and -operations. The skill applies it to the evidence chain: every root-cause claim must trace back to at least one `E#` +operations. The `bug` type applies it to the evidence chain: every root-cause claim must trace back to at least one `E#` evidence item and survive the adversarial-validator's counter-evidence search. URL: https://www.toyota-industries.com/company/history/toyoda_precepts/ @@ -174,23 +217,23 @@ URL: https://www.toyota-industries.com/company/history/toyoda_precepts/ ### John Allspaw: Blameless Post-Mortems and the Art of Learning from Incidents Allspaw's work at Etsy on blameless post-mortems reframed incident analysis around understanding cause, not assigning -blame. The skill's evidence summary, root-cause analysis, and validation sections follow this posture: findings cite -code and behavior, not people or teams. +blame. The skill's evidence summary, analysis, and validation sections follow this posture: findings cite code and +behavior, not people or teams. URL: https://www.etsy.com/codeascraft/blameless-postmortems ### Klein: Pre-Mortem (The Power of Intuition) Gary Klein's pre-mortem technique (imagining the plan has already failed and asking why, before it ships) maps directly -to the skill's adversarial-validator step. The validator assumes the fix will fail and hunts for why. The resulting -counter-evidence reshapes the plan before it becomes production code. +to the skill's adversarial-validator step. The validator assumes the conclusion is wrong and hunts for why. The resulting +counter-evidence reshapes the report before anyone acts on it. URL: https://hbr.org/2007/09/performing-a-project-premortem ### The Pragmatic Programmer (Hunt and Thomas): Bisecting and Rubber Duck Debugging -The Pragmatic Programmer formalized rubber-duck debugging and evidence-bisection as core debugging disciplines. The -skill's parallel-angle investigation (error path vs. data flow vs. recent changes) is evidence-bisection applied at the +The Pragmatic Programmer formalized rubber-duck debugging and evidence-bisection as core debugging disciplines. The bug +type's parallel-angle investigation (error path vs. data flow vs. recent changes) is evidence-bisection applied at the agent level. URL: https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/ @@ -202,27 +245,35 @@ URL: https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary - [Skills Index](../../../docs/skills/README.md). All skills, grouped by purpose. - [`/issue-triage`](../../../han-research/docs/skills/issue-triage.md). Run before investigation when the incoming report is too vague to trace; triage produces the sharp problem statement investigation needs. -- [`/research`](../../../han-research/docs/skills/research.md). The question-shaped sibling. Use it when nothing is broken and you want - options, prior art, or how something works before committing. -- [`evidence-based-investigator`](../../../han-core/docs/agents/evidence-based-investigator.md). The agent the skill dispatches - in parallel for multi-angle evidence gathering. -- [`adversarial-validator`](../../../han-core/docs/agents/adversarial-validator.md). The agent that challenges evidence and fix - after the plan is drafted. -- [`readability-editor`](../../../han-communication/docs/agents/readability-editor.md). Dispatched after validation to rewrite - the write-up for the engineer who will implement the fix, preserving every fact and `file:line` reference. Separate - from the accuracy validation pass. +- [`/research`](../../../han-research/docs/skills/research.md). The open-web sibling. Use it when the answer lives + outside this codebase: prior art, outside libraries, or how an outside technology works. +- [`evidence-based-investigator`](../../../han-core/docs/agents/evidence-based-investigator.md). The agent a bug run + dispatches in parallel for multi-angle evidence gathering. +- [`codebase-explorer`](../../../han-core/docs/agents/codebase-explorer.md). The agent how-it-works and options runs + dispatch to find entry points, core logic, and precedent. +- [`adversarial-validator`](../../../han-core/docs/agents/adversarial-validator.md). The agent that challenges the + evidence and the conclusion after the report is drafted. +- [`readability-editor`](../../../han-communication/docs/agents/readability-editor.md). Dispatched after validation to + rewrite the write-up for the type's reader, preserving every fact and `file:line` reference. Separate from the + accuracy validation pass. - [Evidence](../../../docs/evidence.md). The canonical evidence rule the skill applies to every finding. Codebase findings stand - on their citation; web-source context is subject to the corroboration gate when it drives the proposed fix; - no-evidence states are labeled rather than guessed at. + on their citation; pasted web context is subject to the corroboration gate when it drives a conclusion; no-evidence + states are labeled rather than guessed at. - [`concurrency-analyst`](../../../han-core/docs/agents/concurrency-analyst.md), [`behavioral-analyst`](../../../han-core/docs/agents/behavioral-analyst.md), - [`data-engineer`](../../../han-core/docs/agents/data-engineer.md). Specialist analysts dispatched alongside the investigators - when the symptom classification calls for them. -- [`/iterative-plan-review`](../../../han-planning/docs/skills/iterative-plan-review.md). Pair when the fix plan needs further + [`structural-analyst`](../../../han-core/docs/agents/structural-analyst.md), + [`data-engineer`](../../../han-core/docs/agents/data-engineer.md). Specialist analysts dispatched when the question + calls for them. +- [`/iterative-plan-review`](../../../han-planning/docs/skills/iterative-plan-review.md). Pair when a bug's fix plan needs further stress-testing before implementation. +- [`/plan-a-change`](../../../han-planning/docs/skills/plan-a-change.md) and + [`/plan-a-feature`](../../../han-planning/docs/skills/plan-a-feature.md). The next step after a how-it-works or + options report, when you are ready to plan the change. - [`/code-review`](./code-review.md). Run before merge when the fix lands, to audit the change end-to-end. -- [`/code-walkthrough`](./code-walkthrough.md). The learning-shaped sibling. Use it when nothing is broken and you want - to be paced through how a change works, rather than to diagnose why it fails. +- [`/code-overview`](./code-overview.md). The orientation sibling. Use it for a written overview of a whole target + rather than an answer to one question. +- [`/code-walkthrough`](./code-walkthrough.md). The learning-shaped sibling. Use it when you want to be paced through + how a change works in conversation. - [`/runbook`](../../../han-documentation/docs/skills/runbook.md). Pair after the investigation lands a procedure the team will reuse. Investigate captures the root cause and fix; the runbook captures the procedure for the next engineer who sees the same symptom. - [`SKILL.md` for /investigate](../../skills/investigate/SKILL.md). The internal process definition.