diff --git a/README.md b/README.md index c823aea..89bc4b8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Grok Build port of [pstack](https://github.com/cursor/plugins/tree/c742dd61706fbacc1b95f1a20b7b988cf096ce6c/pstack) (`0.15.36`) by [Lauren Tan (poteto)](https://x.com/poteto). +Grok Build port of [pstack](https://github.com/cursor/plugins/tree/bf0c7cd80abdbf7fe47b634978a7d1b4071f71a7/pstack) (`0.15.42`) by [Lauren Tan (poteto)](https://x.com/poteto). # pstack @@ -106,7 +106,7 @@ type `/poteto-mode` at the start of each task. the skill has `disable-model-invo ## skills -[`/poteto-mode`](./skills/poteto-mode/SKILL.md) runs most of these for you when a step needs them (`how`, `why`, `architect`, `arena`, `swarm`, `interrogate`, `unslop`, `no-comments`, `technical-writing`, `tdd`, and the principles). the table below is for when you want one directly: +[`/poteto-mode`](./skills/poteto-mode/SKILL.md) runs most of these for you when a step needs them (`why`, `architect`, `arena`, `swarm`, `interrogate`, `unslop`, `no-comments`, `technical-writing`, `tdd`, and the principles). the table below is for when you want one directly: ``` /how do we cancel runs? do we have an n+1 when we look up every run to cancel? @@ -124,9 +124,9 @@ type `/poteto-mode` at the start of each task. the skill has `disable-model-invo | [`/poteto-mode`](./skills/poteto-mode/SKILL.md) | default entry point for any non-trivial task. | | [`/poteto-help`](./skills/poteto-help/SKILL.md) | you're new to pstack, or unsure which skill, playbook, or principle fits. finds out what you're trying to do, answers that part, and hands you a prompt to type. runs only when you type `/poteto-help`. | | [`/in-your-own-words`](./skills/in-your-own-words/SKILL.md) | you want the agent to play back your goal and the problem before it starts. runs only when you type `/in-your-own-words`. | -| [`/sharpen`](./skills/sharpen/SKILL.md) | you want a prompt made deeper, not bigger, before you send it: what a top professional would do that you didn't ask for, the raw material they'd start from, their methods and tools, and an outside check that the result is right. hands back the rewritten prompt and leaves your choices open. doesn't do the task. runs only when you type `/sharpen`. | +| [`/sharpen`](./skills/sharpen/SKILL.md) | you want a prompt made deeper, not bigger, before you send it: what a top professional would do that you didn't ask for, the raw material they'd start from, their methods and tools, and an outside check that the result is right. hands back the rewritten prompt, which asks the agent to prototype any choice an experiment can settle and leaves product and preference choices to you. doesn't do the task. runs only when you type `/sharpen`. | | [`/how`](./skills/how/SKILL.md) | you want a walkthrough of how a subsystem works. | -| [`/why`](./skills/why/SKILL.md) | you want to know why something was built this way. discovers available MCPs at run time and queries each evidence category in parallel (source control, issue tracker, long-form docs, real-time chat, infra observability, error tracking, analytics warehouse). | +| [`/why`](./skills/why/SKILL.md) | you want to know why something was built this way. answers from the record, not the code: the commits and pr discussions that introduced it and each later change, and other sources when that trail is thin. cites what the authors wrote, marks its own inferences, and says what the record does not answer. | | [`/recall`](./skills/recall/SKILL.md) | you're starting or resuming work and want your recent context on a topic rebuilt from your own chat history and the shared record, handed back as a tight current-state brief. | | [`/ketchup`](./skills/ketchup/SKILL.md) | you want what changed in this chat since your last message, in plain words and small visuals, with every item waiting on you listed and decidable from the reply alone, even when that makes the reply long. | | [`/ketchup-video`](./skills/ketchup-video/SKILL.md) | you want the `/ketchup` catch-up as a short subtitled video of slides, with the calls waiting on you as text under it. | @@ -269,7 +269,7 @@ type [`/automate-me`](./skills/automate-me/SKILL.md). it mines your recent trans models are configurable too. type [`/setup-pstack`](./skills/setup-pstack/SKILL.md). it detects the models you have access to and writes a small always-applied rule mapping each role (code, judgment, the review panels) to a model. every skill reads it and falls back to sensible defaults when the rule is absent, so you override only what you want. -when a default changes, a rule written before the change still pins the old default. delete those role lines, or delete the file, then run `/setup-pstack` again. a rerun keeps any role whose model differs from the default. +when a default changes, a rule written before the change still pins the old default until you run `/setup-pstack` again. that run drops retired roles it recognizes, such as `how explorer` and `why investigators`, and keeps any other role whose model differs from the default, including every `grok-*` slug. to drop a pin it does not recognize, delete that role's line or the file first. ## automations diff --git a/agents/comment-sicko.md b/agents/comment-sicko.md index 209e370..14c2402 100644 --- a/agents/comment-sicko.md +++ b/agents/comment-sicko.md @@ -23,7 +23,7 @@ That list is my only leash. When I am not sure a keep clause applies, the commen `eslint-disable`, `@ts-ignore`, `@ts-expect-error`, and similar suppressions stink. Look up the rule. If it catches real bugs or protects correctness or safety, kill the suppression and mark the exact guilty symbol `MUST KILL`. -`IMPORTANT`, `do not remove`, `too risky`, `fine for now`, and long justifications are scent, not conviction. Before judging, I read nearby code. If its claim is not obvious there, I run `/how`, `/why`, or both from the **how** and **why** skills on the named symbol or call. Only a foreign keep-list gotcha proven true today on a live path crawls away. Our-code surprises die with the reshape flag above. Doubt after the hunt is meat. +`IMPORTANT`, `do not remove`, `too risky`, `fine for now`, and long justifications are scent, not conviction. Before judging, I read nearby code. If its claim is not obvious there, I trace the named symbol or call, run `/why` from the **why** skill on it, or both. Only a foreign keep-list gotcha proven true today on a live path crawls away. Our-code surprises die with the reshape flag above. Doubt after the hunt is meat. A long justification without a proven keep-list exception is a confession. Kill it. Never polish meat into a shorter alibi. Mark the exact guilty symbol `MUST KILL`. My kill ends there. I do not touch the code. diff --git a/automations/benny/FOR_AGENTS.md b/automations/benny/FOR_AGENTS.md index 6d39636..c0d2edd 100644 --- a/automations/benny/FOR_AGENTS.md +++ b/automations/benny/FOR_AGENTS.md @@ -29,7 +29,7 @@ i want two wakes that work together in one slack issue channel. grok build has n - i treat utility and debug bots as evidence, not delegation or fix ownership. - i allow subagents to help, but they cannot post to slack or receive slack credentials. - i want this entire pack committed at `.grok/automations/benny/` in the target repository. its `SKILL.md` files are direct automation instructions, not registered plugin skills. -- i want pstack enabled through the target repository's committed `.grok/config.toml` only for shared dependencies such as `how`, `why`, `tdd`, `unslop`, and the required principle skills. +- i want pstack enabled through the target repository's committed `.grok/config.toml` only for shared dependencies such as `why`, `tdd`, `unslop`, and the required principle skills. - i want each live automation prompt to read its committed operational file directly. i do not want plugin cache paths, copied excerpts, or slash-skill discovery. - i keep user-owned configuration, feature maps, routing maps, and secrets outside `.grok/automations/benny/` so pack refreshes cannot overwrite them. - i want both automations to fail closed when channel coordinates, tracker access, the control adapter, or the feature map are missing or uncertain. @@ -73,7 +73,7 @@ enabled = ["pstack"] preserve every unrelated setting. project config only honors `mcp_servers`, `plugins`, and `permission`. -i want verification from a fresh agent rooted in the target repository. confirm that pstack's `how`, `why`, `tdd`, `unslop`, and the principle skills used by benny resolve in project scope. do not count skills loaded from the current session or a user-scoped install. +i want verification from a fresh agent rooted in the target repository. confirm that pstack's `why`, `tdd`, `unslop`, and the principle skills used by benny resolve in project scope. do not count skills loaded from the current session or a user-scoped install. if project-scoped plugins are unavailable or any shared dependency does not resolve, stop and explain what failed. do not add `.grok/automations/benny/skills/` to a plugin manifest or expect its files to appear in the slash-skill list. diff --git a/automations/benny/skills/reproduce-and-fix-issues/SKILL.md b/automations/benny/skills/reproduce-and-fix-issues/SKILL.md index 8d67044..a5874ba 100644 --- a/automations/benny/skills/reproduce-and-fix-issues/SKILL.md +++ b/automations/benny/skills/reproduce-and-fix-issues/SKILL.md @@ -158,7 +158,7 @@ Collect: Inspect screenshots and video. Use read-only parallel workers for code history, test ideas, blast-radius mapping, and media review when useful. Each worker gets a narrow question and the Slack-write prohibition. -Use pstack's `how` skill to trace the action through the repository. Use `why` for regression history and defensive code. Form competing cause hypotheses and identify evidence that would separate them. +Trace the action through the repository. Use pstack's `why` skill for regression history and defensive code. Form competing cause hypotheses and identify evidence that would separate them. ## 7. Reproduce diff --git a/automations/benny/skills/setup-benny/SKILL.md b/automations/benny/skills/setup-benny/SKILL.md index 7dee9c4..3b8028f 100644 --- a/automations/benny/skills/setup-benny/SKILL.md +++ b/automations/benny/skills/setup-benny/SKILL.md @@ -42,7 +42,6 @@ Preserve every unrelated setting. If `pstack` is already in `enabled`, leave it. Reload the target project or start a fresh agent rooted there. Verify that these shared pstack skills resolve from project scope: -- `how` - `why` - `tdd` - `unslop` diff --git a/automations/benny/skills/triage-issue-reports/SKILL.md b/automations/benny/skills/triage-issue-reports/SKILL.md index d691672..93c138d 100644 --- a/automations/benny/skills/triage-issue-reports/SKILL.md +++ b/automations/benny/skills/triage-issue-reports/SKILL.md @@ -68,7 +68,7 @@ Use evidence already in the thread before asking the reporter for more. ## 3. Trace cause before routing -Do a bounded source and history pass before choosing an owner or destination. Use pstack's `how` skill to trace the path from the reported action to the observed result. Use `why` when the report looks like a regression or touches defensive code. +Do a bounded source and history pass before choosing an owner or destination. Trace the path from the reported action to the observed result. Use pstack's `why` skill when the report looks like a regression or touches defensive code. 1. Identify the likely code path from the reported action to the observed result. 2. Check whether the visible symptom belongs to that code path or a dependency below it. diff --git a/docs/guide/01-setup.md b/docs/guide/01-setup.md index d12c612..0d2ee33 100644 --- a/docs/guide/01-setup.md +++ b/docs/guide/01-setup.md @@ -27,9 +27,9 @@ Run: [`/setup-pstack`](../../skills/setup-pstack/SKILL.md) detects the models you have access to, asks for a reasoning budget, shows you each role (code delegates, judgment, the review panels), and asks what you want. Answer the questions. It writes `~/.grok/rules/pstack-models.md`, a small rule every pstack skill reads. -The budgets are `unlimited — max reasoning`, `large — xhigh reasoning`, `medium — high reasoning`, and `small — medium reasoning`. `unlimited`, `large`, `medium`, and `small` set the effort of every real model entry, panel entries included, to `max`, `xhigh`, `high`, or `medium`, on the ladder `max` > `xhigh` > `high` > `medium` > `low`. Effort is a separate field, written after the model id (`grok-4.6 xhigh`). If the model does not offer that effort, use its highest offered effort at or below the target, else mark the role as needing a choice. On grok 1.0.62, `unlimited` keeps `grok-4.6` at `xhigh`, `large` keeps the defaults, and `small` turns them into `grok-4.6 medium` and `grok-4.5 medium`. If `spawn_subagent` has no `model` argument, `/setup-pstack` sets `[features] subagent_model_inheritance = false` in `~/.grok/config.toml` when no requirements pin or `GROK_SUBAGENT_MODEL_INHERITANCE` blocks it. Role models start in the next session. This session still inherits the parent. +The defaults are the same as the `large` budget. Most roles run at `xhigh` reasoning. A panel's second entry runs at `high`. `unlimited` raises each entry one level, up to `max`. If the model does not offer that effort, it stays at its highest offered effort at or below the target. `medium` lowers each entry one level and `small` lowers it two, and both spend fewer tokens. Effort is a separate field, written after the model id (`grok-4.6 xhigh`). If `spawn_subagent` has no `model` argument, `/setup-pstack` sets `[features] subagent_model_inheritance = false` in `~/.grok/config.toml` when no requirements pin or `GROK_SUBAGENT_MODEL_INHERITANCE` blocks it. Role models start in the next session. This session still inherits the parent. -You only override what you care about. A role with no line in the rule keeps the skill's default. To restore a default, delete that role's line. A rerun of `/setup-pstack` keeps any role whose model differs from the default. When a default changes, a rule written before the change still pins the old default, so delete those role lines, or delete the file, then run `/setup-pstack` again. +You only override what you care about. A role with no line in the rule keeps the skill's default. To restore a default, delete that role's line. A rerun of `/setup-pstack` keeps any role whose model differs from the default. When a default changes, a rule written before the change still pins the old default until you run `/setup-pstack` again. That run drops retired roles it recognizes, such as `how explorer` and `why investigators`, tells you which, and keeps your other choices, including every `grok-*` slug. To drop a pin it does not recognize, delete that role's line or the file first. You might be wondering what happens if you use Auto. Set a role to `inherit-parent` or `auto` and pstack omits the subagent `model` field, so the subagent inherits your parent chat model. Both values mean the same thing, and neither is a model slug. For a panel role the value is a list, and one subagent runs per entry, so the list length sets the panel size. Setup also configures `swarm workers`, the default model for every `/swarm` worker unless a race names a model for each arm. diff --git a/docs/guide/02-poteto-mode.md b/docs/guide/02-poteto-mode.md index 55d08cd..6008e51 100644 --- a/docs/guide/02-poteto-mode.md +++ b/docs/guide/02-poteto-mode.md @@ -72,7 +72,7 @@ When you're unsure whether a prompt is aimed right, run [`/sharpen`](../../skill /sharpen write a migration guide for the v2 config format. ``` -The agent says what a top professional would do that you didn't ask for, the rawest material they would start from, the methods and tools they would use, and what other than you or the agent would show the result is right. Then it rewrites your prompt to ask for exactly that, deeper but not bigger, and leaves your choices open. It doesn't do the task. Read the rewrite, then send it, for example with `/poteto-mode`. +The agent says what a top professional would do that you didn't ask for, the rawest material they would start from, the methods and tools they would use, and what other than you or the agent would show the result is right. Then it rewrites your prompt to ask for exactly that, deeper but not bigger. The rewrite asks the agent to prototype any choice an experiment can settle and to recommend an option from what it observed, and it leaves product and preference choices to you. It doesn't do the task. Read the rewrite, then send it, for example with `/poteto-mode`. ## Follow up short @@ -132,7 +132,7 @@ When you step away, say what done means and go: Work you'll review later routes through [`/figure-it-out`](../../skills/figure-it-out/SKILL.md), which designs the run's phases and keeps a [`/show-me-your-work`](../../skills/show-me-your-work/SKILL.md) decision log. [Run work while you sleep](./07-overnight.md) covers the full overnight contract. -**Pitfall:** don't enumerate skills in your prompt ("use /how, then /architect, then /arena..."). The playbook already sequences them, and a hand-written sequence usually reorders or drops steps the playbook would have kept. Name a skill only when you want to override a specific choice. +**Pitfall:** don't enumerate skills in your prompt ("use /architect, then /arena, then /interrogate..."). The playbook already sequences them, and a hand-written sequence usually reorders or drops steps the playbook would have kept. Name a skill only when you want to override a specific choice. Read [`poteto-mode`](../../skills/poteto-mode/SKILL.md) itself for the full routing rules. diff --git a/docs/guide/03-understand.md b/docs/guide/03-understand.md index e26661f..f07db11 100644 --- a/docs/guide/03-understand.md +++ b/docs/guide/03-understand.md @@ -14,7 +14,7 @@ When the cause is unclear, ask for findings, not a fix: /poteto-mode investigate why background jobs time out every few hours. give me what we know, what data you used, and your best hypotheses. don't change any code yet. ``` -"don't change any code yet" routes this to the [Investigation playbook](../../skills/poteto-mode/playbooks/investigation.md). It runs `/how`, adds `/why` for questions about motivation, and returns a cited explanation. For a choice between options, it returns a recommendation with a trade-offs table. Asking "what data you used" makes the agent separate its evidence from its guesses. When the findings point at a fix, start the fix as a new task. +"don't change any code yet" routes this to the [Investigation playbook](../../skills/poteto-mode/playbooks/investigation.md). It traces the code, adds `/why` for questions about motivation, and returns a cited explanation. For a choice between options, it returns a recommendation with a trade-offs table. Asking "what data you used" makes the agent separate its evidence from its guesses. When the findings point at a fix, start the fix as a new task. ## Trace behavior with `/how` @@ -22,7 +22,7 @@ When the cause is unclear, ask for findings, not a fix: /how do we dedupe notifications? is there an n+1 when we look up subscribers? ``` -Ask the question you actually have. [`/how`](../../skills/how/SKILL.md) reads the code and answers at the level of a senior engineer onboarding you onto the subsystem, with the runtime flow, the key types, and the non-obvious parts. For a big subsystem it fans out two to four read-only explorers first. For a narrow question it just reads and explains. +Ask the question you actually have. [`/how`](../../skills/how/SKILL.md) reads the code and answers at the level of a senior engineer onboarding you onto the subsystem, with the runtime flow, the key types, and the non-obvious parts. It starts one subagent, with a prompt that forbids file edits, that explores the code and writes the explanation. ## Dig up history with `/why` @@ -30,7 +30,7 @@ Ask the question you actually have. [`/how`](../../skills/how/SKILL.md) reads th /why was the retry limit set to five? does the reason still hold? ``` -[`/why`](../../skills/why/SKILL.md) starts from source control, then queries whatever evidence categories your MCPs expose, such as the issue tracker, long-form docs, team chat, observability, error tracking, and analytics, all in parallel. The report cites everything, separates direct evidence from inference, and says "appears to" when the record is thin. A null result gets reported too, because "nobody wrote down why" is itself an answer. +[`/why`](../../skills/why/SKILL.md) answers from the record, not the code. It reads the commits and PR discussions that introduced the code and each later change, and looks at other sources when that trail is thin. The answer cites what the authors wrote, marks the agent's own inferences as inferences, and says what the record does not answer, because "nobody wrote down why" is itself an answer. The two compose naturally. `do why first then how` is a good prompt when you suspect the history explains the mess. diff --git a/docs/guide/04-design.md b/docs/guide/04-design.md index 745393e..1c56b65 100644 --- a/docs/guide/04-design.md +++ b/docs/guide/04-design.md @@ -12,7 +12,7 @@ The two most common design mistakes are taking the agent's first design and poli /architect design the import pipeline before writing any code. i care most about how callers use it. ``` -[`/architect`](../../skills/architect/SKILL.md) grounds itself first, running `/how` over the code the design touches and `/why` when it moves ownership or layers. Then it runs `/arena` to produce competing design sketches, with the caller's usage written first in each, followed by types, signatures, and a module map. +[`/architect`](../../skills/architect/SKILL.md) grounds itself first, tracing the code the design touches and running `/why` when it moves ownership or layers. Then it runs `/arena` to produce competing design sketches, with the caller's usage written first in each, followed by types, signatures, and a module map. By default it proceeds straight from the synthesized design into implementation. If you want to see the design first, say so: diff --git a/docs/guide/10-recipes-and-pitfalls.md b/docs/guide/10-recipes-and-pitfalls.md index b12202e..038cd69 100644 --- a/docs/guide/10-recipes-and-pitfalls.md +++ b/docs/guide/10-recipes-and-pitfalls.md @@ -162,7 +162,7 @@ To watch the catch-up instead, run [`/ketchup-video`](../../skills/ketchup-video ## The pitfalls -- **Enumerating skills in the prompt.** "use /how then /architect then /arena" reorders steps the playbook already sequences. State the goal and constraints. Name a skill only to override a default. +- **Enumerating skills in the prompt.** "use /architect then /arena then /interrogate" reorders steps the playbook already sequences. State the goal and constraints. Name a skill only to override a default. - **A vague finish condition.** "make it better" gives `/loop` nothing to check. Give a command or artifact that can pass or fail. - **Leading with your theory of the cause.** The agent searches wherever you pointed. Ask it to restate the problem first, then share your hunch. - **Taking the first design.** One attempt locks in the first shape the model thought of. Ask for prototypes or `/architect` and pick from evidence. diff --git a/plugin.json b/plugin.json index 14b42b7..c461ff0 100644 --- a/plugin.json +++ b/plugin.json @@ -1,7 +1,7 @@ { "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json", "name": "pstack", - "version": "0.15.36", + "version": "0.15.42", "description": "if you want to go fast, go deep first. pstack helps you write less, but higher quality code. rigorous agent workflows you can parallelize with confidence.", "author": { "name": "Lauren Tan" diff --git a/skills/architect/SKILL.md b/skills/architect/SKILL.md index d6fa3ee..7d63372 100644 --- a/skills/architect/SKILL.md +++ b/skills/architect/SKILL.md @@ -20,7 +20,7 @@ Open a todolist with one entry per phase before starting. ## Phase A: Ground the problem -Build a real mental model of every system the new code touches. Run the **how** skill over the relevant subsystems. Naming a file isn't grounding. Produce the architectural explanation `how` prescribes. If the design redefines ownership or layering, also run the **why** skill on the existing shape so the rationale becomes a constraint, not a guess. +Build a real mental model of every system the new code touches. Trace the relevant subsystems. Naming a file isn't grounding. Write an architectural explanation of each. If the design redefines ownership or layering, also run the **why** skill on the existing shape so the rationale becomes a constraint, not a guess. Skip Phase A only when the work is genuinely greenfield with no surrounding system to integrate. @@ -69,7 +69,7 @@ Use judgment. A few edge cases don't condemn an architecture. Some problems are When you scrap: -1. Re-run the **how** skill over what's been built. +1. Trace what's been built. 2. Redesign as if the new constraints had been day-one assumptions, per redesign-from-first-principles. 3. Subtract before adding, per the **subtract-before-you-add** principle skill. The new sketch should be smaller than the old one before it grows. 4. Return to Phase B and re-run arena. diff --git a/skills/blast-radius/SKILL.md b/skills/blast-radius/SKILL.md index b296cce..1f5c951 100644 --- a/skills/blast-radius/SKILL.md +++ b/skills/blast-radius/SKILL.md @@ -30,10 +30,10 @@ Step 4 is usually one small script that imports the same library the app ships a ## Steps -1. Read the change. The diff, the symbols it adds, changes, and deletes, and what it now does differently, including the part the diff doesn't spell out. Use `why` step 2 to pull the PR and commits. +1. Read the change. The diff, the symbols it adds, changes, and deletes, and what it now does differently, including the part the diff doesn't spell out. Pull the PR and its commits. 2. Find the one fact it's safe because of. Most changes that look risky are safe because of a single fact, like "this call only drops already-dead cache entries and does nothing else". Find that fact. If it holds, most risky cases are cleared at once. Spend your time here, not on a long list of maybes. 3. Look where grep stops. Read the source of the library you call, and check its pinned version and any local patch. Work out when things run: microtasks, unmount and teardown, Solid versus React. Follow what a symbol search misses: the JSON an API returns, a DB column, a wire format, another language reading the same bytes, a feature flag, code three hops downstream. -4. Be honest about each risk. Give it a real chance of happening and a real cost if it does. Keep the risks you confirmed. List the ones you checked and cleared separately. Same rules as `why`. Cite a real `file:line`, a search that finds nothing is still an answer, and never make up a caller or an API. +4. Be honest about each risk. Give it a real chance of happening and a real cost if it does. Keep the risks you confirmed. List the ones you checked and cleared separately. Cite a real `file:line`, a search that finds nothing is still an answer, and never make up a caller or an API. 5. Prove the one fact. Write a script or test that runs the real code, run it, and paste what happened. 6. For a big or wide change, run it as an `arena`. Ask more than one model the same question and merge the answers. Different models catch different real bugs. diff --git a/skills/how/SKILL.md b/skills/how/SKILL.md index 7519c36..fef28ed 100644 --- a/skills/how/SKILL.md +++ b/skills/how/SKILL.md @@ -6,31 +6,16 @@ disable-model-invocation: true # How -Explore the codebase to answer "how does X work?" questions. Produce architectural explanations at the level of a senior engineer onboarding onto a subsystem, enough to build a working mental model, not so much that it reads like annotated source code. - -Every spawn is a `spawn_subagent` call with no `subagent_type` and a prompt that forbids file edits (there is no readonly flag). Explorers use the `how explorer` line in the `pstack-models.md` rule (default `grok-4.6` at `xhigh`), and every explainer uses the `how explainer` line (default `grok-4.6` at `xhigh`). Set `model` to the model id in that line's value (`grok-4.6` from `grok-4.6 xhigh`), or to the default model id if the rule or the line is missing. Validate the id against `grok models`. Leave `model` unset when the value is `auto` or `inherit-parent`. If `spawn_subagent` has no `model` argument, omit it for this session so the child inherits the parent, and apply step 1 of **setup-pstack** so the next session can pass `model`. If it rejects a slug, use the closest slug from `grok models` and say so. Pick each subagent's reasoning effort for the job, per the Subagents section of the **poteto-mode** skill. - -## 1. Assess complexity +Explore the codebase to answer "how does X work?" questions. If the scope is ambiguous, state your interpretation and explore. The user can redirect. -- **Simple** (a single module, a small utility, a narrow question such as "how does function X work"): no explorers. Spawn one explainer that explores and explains in one pass, built from `references/explainer-prompt.md` without the explorer-findings section. Go to step 4. -- **Complex** (a subsystem spanning multiple files or services, a cross-cutting feature, a full architectural overview): go to step 2. - -When in doubt, take the simple path. - -## 2. Explore (complex only) - -Decompose the question into 2 to 4 angles, each a distinct slice of the subsystem. Spawn all explorers in a single message, each with `references/explorer-prompt.md` and its angle filled in. - -## 3. Synthesize (complex only) - -Once all explorers have returned, spawn one explainer with `references/explainer-prompt.md` and every explorer's findings filled in. +## 1. Explain -## 4. Present +Spawn one `spawn_subagent` call with no `subagent_type` and a prompt that forbids file edits (there is no readonly flag) that explores and explains in one pass. Give it the user's question and this brief: -Present the explainer's output. Light edits for clarity or context from the conversation are fine. Do not substantially rewrite it. +> You are writing an architectural explanation for a senior engineer. Explore the codebase and write an explanation that a senior engineer unfamiliar with this area could read and walk away with a solid mental model. They should understand the architecture well enough to start working in it confidently. You have read-only access to the codebase. -## Output format +## 2. Present -The explanation uses the sections defined in `references/explainer-prompt.md`, dropping any that do not apply: Overview, Key Concepts, How It Works, Where Things Live, Gotchas. +Present the subagent's output. Light edits for clarity or context from the conversation are fine. Do not substantially rewrite it. diff --git a/skills/how/references/explainer-prompt.md b/skills/how/references/explainer-prompt.md deleted file mode 100644 index f88f190..0000000 --- a/skills/how/references/explainer-prompt.md +++ /dev/null @@ -1,55 +0,0 @@ -# Explainer Prompt Template - -Build the explainer subagent's prompt from this template. Fill in the placeholders. - ---- - -You are writing an architectural explanation for a senior engineer. Multiple explorer agents have traced different slices of the codebase in parallel and gathered findings. Synthesize their findings into one coherent, well-structured explanation. - -## Original Question - -> {QUESTION} - -## Explorer Findings - -{EXPLORER_FINDINGS_ALL} - -## Instructions - -The explorers each investigated a different angle of the same subsystem. Their findings will overlap in places and may occasionally contradict. Reconcile them. Merge overlapping descriptions, resolve contradictions by checking the code yourself, and combine the separate slices into a unified picture. - -Write an explanation a senior engineer unfamiliar with this area could read and walk away with a solid mental model, understanding the architecture well enough to start working in it confidently. - -You have read-only access to the codebase to check anything, clarify a detail, or fill a gap. Use `read_file`, `grep`, and `list_dir`. Do not edit files or run commands that change the tree. The explorers did the work, so you shouldn't need to re-explore from scratch. - -## Output Format - -Use this structure, adapted to what makes sense for the question. Not every section is needed for every question. - -### Overview -1-2 paragraphs. What is this thing, what does it do, why does it exist. Someone should be able to read just this and decide whether to keep reading. - -### Key Concepts -The important types, services, or abstractions needed to follow the rest. Brief definitions, not exhaustive. - -### How It Works -The core of the explanation, and the longest section. Walk through the flow: what triggers it, what happens step by step, where data goes, what the decision points are. - -Use prose, not pseudocode. Reference specific files and functions so the reader knows where to look, but don't dump large code blocks unless a snippet is essential to a point. - -When the flow involves multiple components talking to each other, or data transforming through stages, include a diagram. Use mermaid (```mermaid) for structured flows (sequence diagrams, flowcharts, component graphs) or ASCII art for simpler relationships where mermaid would be overkill. Use your judgment. A diagram should clarify, not decorate. If prose covers the flow, skip the diagram. - -### Where Things Live -A brief file/directory map. Just the ones someone would need to start working here. - -### Gotchas -Non-obvious things, surprising behavior, historical context, pitfalls. Skip this section if there's nothing worth calling out. - -## Communication Style - -- Use concrete language, not abstractions-about-abstractions -- Say "the `UserService` calls `AuthClient.refresh()`" not "the service delegates to the client" -- When something is complex, explain why it's complex. Don't just describe the complexity -- When something is simple, don't pad it out -- If there's a helpful analogy, use it. If there isn't, don't force one -- If the explorers flagged open questions or gaps, acknowledge them rather than hiding them diff --git a/skills/how/references/explorer-prompt.md b/skills/how/references/explorer-prompt.md deleted file mode 100644 index 724bacf..0000000 --- a/skills/how/references/explorer-prompt.md +++ /dev/null @@ -1,35 +0,0 @@ -# Explorer Prompt Template - -Build each explorer subagent's prompt from this template. Fill in the placeholders. - ---- - -Other explorers are investigating different slices of the same subsystem in parallel. Don't try to cover everything. Focus on your assigned angle and go deep. - -## Question - -> {QUESTION} - -## Your Exploration Angle - -{EXPLORATION_ANGLE} - -## Output - -### Components Found -The key types, services, classes, and abstractions. For each: name, file path, and a one-sentence description of what it does. - -### Flow -The execution flow step by step. For each step: what function/method runs, what file it's in, what it does, what it calls next. Include the data that flows between steps. - -### Files Read -Every file you read during exploration, so the explainer can reference them. - -### Boundaries -Where this subsystem connects to other parts of the codebase. The inputs and outputs. - -### Non-Obvious Things -Anything surprising, historically motivated, or easy to get wrong. Things that look like they should work one way but work another. - -### Open Questions -Anything you couldn't fully trace or understand. Be honest about gaps. diff --git a/skills/no-comments/SKILL.md b/skills/no-comments/SKILL.md index f2bdf17..a9c6a0b 100644 --- a/skills/no-comments/SKILL.md +++ b/skills/no-comments/SKILL.md @@ -17,7 +17,7 @@ Use the caller's files or diff. Otherwise use the current diff against the base ## Steps 1. Spawn `spawn_subagent` with `subagent_type: "pstack:comment-sicko"`. Pass the scope. Pick each subagent's reasoning effort for the job, per the Subagents section of the **poteto-mode** skill. Do not restate its rules. -2. Inspect its report and diff. Reject application-code edits, scope escapes, exception-protected deletions, misstated `MUST KILL` reasons, and flags that treat kept intentional code as guilty. Reshape flags on our-code surprises stay actionable. Do not restore those comments. A keep survives only with proof it is about something we cannot change. Audit missed scoped lint and TypeScript suppressions. Correctness or safety suppressions stay actionable `MUST KILL`s. Restore deletions only with exact exceptions and scoped proof. Before accepting thin `IMPORTANT` or `do not remove` kills or keeps, run `/how` or `/why` on their symbol. If a kill is ambiguous, do not restore. If a keep is refuted or still ambiguous, delete it. Revert and rerun one rejected report with the failure named. Reject a second, report it open, and fail `/no-comments`. +2. Inspect its report and diff. Reject application-code edits, scope escapes, exception-protected deletions, misstated `MUST KILL` reasons, and flags that treat kept intentional code as guilty. Reshape flags on our-code surprises stay actionable. Do not restore those comments. A keep survives only with proof it is about something we cannot change. Audit missed scoped lint and TypeScript suppressions. Correctness or safety suppressions stay actionable `MUST KILL`s. Restore deletions only with exact exceptions and scoped proof. Before accepting thin `IMPORTANT` or `do not remove` kills or keeps, trace their symbol or run `/why` on it. If a kill is ambiguous, do not restore. If a keep is refuted or still ambiguous, delete it. Revert and rerun one rejected report with the failure named. Reject a second, report it open, and fail `/no-comments`. 3. Fix trivial accepted flags directly by deleting a dead path, dropping a parameter, or using the real API. If any fix needs a shape, run `/architect` once for the accepted set and surrounding code. Stop at the sketch. Architect shapes. Step 4 implements. 4. Implement the smallest root-cause fix in scope. Remove every named workaround. If the root cause is out of scope, land the smallest in-scope fix and report the rest open. The **principle-fix-root-causes** and **principle-redesign-from-first-principles** skills guide intent only. Neither authorizes widening the fence nor fixing instances outside it. Never bolt on symptom guards. 5. Constraint comments say `do not remove`, `do not change wording`, or `talk to X before changing`. Leave keeps about things we cannot change. Offer the cheapest in-scope type, runtime, test, or CI lint. Wait for interactive approval. Unattended and eval require caller pre-approval. If approved, encode then delete. Otherwise delete, report the constraint open, and sketch out-of-scope work. diff --git a/skills/poteto-help/SKILL.md b/skills/poteto-help/SKILL.md index 3593336..d91805a 100644 --- a/skills/poteto-help/SKILL.md +++ b/skills/poteto-help/SKILL.md @@ -10,7 +10,7 @@ Answer the user's question about pstack, hand them a prompt they can send, and l A message that asks for work, such as "use pstack to fix this bug", is not a help question. Read [`poteto-mode`](../poteto-mode/SKILL.md), do the work under it, and mention once that the user types `/poteto-mode` per task. -This file maps questions to the skills and guide pages that hold the answers. Those files own the details. Read the file you route to before you quote it, and trust it when it disagrees with this map. The links here point into the installed plugin. Give the user the path inside the installed plugin. The upstream copy is `https://github.com/cursor/plugins/blob/c742dd61706fbacc1b95f1a20b7b988cf096ce6c/pstack/` followed by its path. This checkout is the Grok Build port, so prefer the installed file when the two differ. +This file maps questions to the skills and guide pages that hold the answers. Those files own the details. Read the file you route to before you quote it, and trust it when it disagrees with this map. The links here point into the installed plugin. Give the user the path inside the installed plugin. The upstream copy is `https://github.com/cursor/plugins/blob/bf0c7cd80abdbf7fe47b634978a7d1b4071f71a7/pstack/` followed by its path. This checkout is the Grok Build port, so prefer the installed file when the two differ. ## Find out what they need diff --git a/skills/poteto-mode/SKILL.md b/skills/poteto-mode/SKILL.md index 2721a76..7f8e59a 100644 --- a/skills/poteto-mode/SKILL.md +++ b/skills/poteto-mode/SKILL.md @@ -17,7 +17,6 @@ The Principles section below grounds every trigger. In your reply, name each pri Remaining triggers: - Your first message on a task → tell the user, in your own words, their goal, the problem they are solving, and, if the task ships a change, the smallest change you expect to meet it. Don't wait for confirmation. If the evidence rules out the change the user asked for, show it and stop. Restate the user's goal in each subagent brief, and open each PR's `## Why` with it. Open each final report with it too, your final reply included, except after a fully specified one-line edit. -- Nontrivial change, architecture decision, or "are we sure?" → the **how** skill. - About to `ask_user_question` on a "which approach", "how should I", or "what should this do" fork → classify it before you ask. If the answer is a fact you could observe by running something (behavior, timing, layout, output, perf, even whether an eval separates), it is not the human's to answer. Sketch it via the Prototype playbook (`playbooks/prototype.md`) and let the result decide. If the task is a read-only Investigation whose deliverable is a cited answer, stay in it and answer from the evidence rather than building a sketch. Reserve the question for a genuine product or preference call no experiment can settle. Under a full-autonomy grant, decide a call the grant covers, act on it, and report it, with no reply word and no offer. Under the grant, for a call only the operator can make, apply a default, report it with a full explanation, and say in plain words what the operator could tell you to do instead. The operator answers in their own words. Never give a shorthand token to type back. Gates the operator named and the Always-pause list in Autonomy still need the operator. - Any code → name the data shape first, and choose its organizing structure per **principle-model-the-domain**. - Code crossing a function boundary → the **architect** skill, parallel design exploration before implementing. @@ -91,9 +90,9 @@ Read the leaf skill in full for any principle you apply. Each entry names when i ## Subagents -**Use `subagent_type: "pstack:poteto-agent"` for any subagent you spawn inside a playbook step** (code-writing delegates, ad-hoc helpers). The chat that receives `/poteto-mode` runs the playbook and is the only chat that may call `spawn_subagent`. A child cannot spawn. Never spawn a `poteto-agent` to run the playbook itself. Routed workflow skills (`how`, `why`, `interrogate`, `reflect`, `swarm`) omit `subagent_type`, or set the type they name. Respect what the skill prescribes, don't override to `poteto-agent`. +**Use `subagent_type: "pstack:poteto-agent"` for any subagent you spawn inside a playbook step** (code-writing delegates, ad-hoc helpers). The chat that receives `/poteto-mode` runs the playbook and is the only chat that may call `spawn_subagent`. A child cannot spawn. Never spawn a `poteto-agent` to run the playbook itself. Routed workflow skills (`interrogate`, `reflect`, `swarm`) omit `subagent_type`, or set the type they name. Respect what the skill prescribes, don't override to `poteto-agent`. -**Defaults for every `spawn_subagent` call.** `run_in_background: true` (a steer or resume of a running agent too, because a foreground call holds your turn while other reports wait). There is no readonly flag. When a child must not edit files, say so in the prompt. MCP stays available through `search_tool` and `use_tool`. Pass file pointers, not inlined context. Pass `model` only when the tool schema includes it. Otherwise omit `model` so the child inherits the parent. If it rejects a slug, use the closest slug from `grok models` and say so. Defaults are `grok-4.6` at `xhigh` for code and for prose and judgment. Code delegates tier by difficulty. The hardest changes (cross-cutting design, gnarly concurrency, subtle algorithms) go to your strongest judgment model (`grok-4.6` at `xhigh`), whether the task needs judgment on vague intent or is a precisely specified sequence of steps to execute to the letter. Trivial mechanical edits go to your fast code model. Per-role lines in `~/.grok/rules/pstack-models.md` (written by `/setup-pstack`) override these defaults and the model choices in the routed skills (`how`, `why`, `arena`, `swarm`, `architect`, `interrogate`, `reflect`). A role with no line keeps its default, and a role line of `inherit-parent` or `auto` runs that role on the parent chat model (omit `model`). Each code playbook passes only the model id from its line (`feature, refactoring`, `bug-fix`, `perf-issue`, or `hillclimb`), validated against `grok models`, and the hardest changes read `hardest tasks`. Prose and judgment read `judgment and prose`. When `spawn_subagent` has no `model` argument, omit `model` for this session so every role inherits the parent, and apply step 1 of **setup-pstack** so the next session can pass `model`. +**Defaults for every `spawn_subagent` call.** `run_in_background: true` (a steer or resume of a running agent too, because a foreground call holds your turn while other reports wait). There is no readonly flag. When a child must not edit files, say so in the prompt. MCP stays available through `search_tool` and `use_tool`. Pass file pointers, not inlined context. Pass `model` only when the tool schema includes it. Otherwise omit `model` so the child inherits the parent. If it rejects a slug, use the closest slug from `grok models` and say so. Defaults are `grok-4.6` at `xhigh` for code and for prose and judgment. Code delegates tier by difficulty. The hardest changes (cross-cutting design, gnarly concurrency, subtle algorithms) go to your strongest judgment model (`grok-4.6` at `xhigh`), whether the task needs judgment on vague intent or is a precisely specified sequence of steps to execute to the letter. Trivial mechanical edits go to your fast code model. Per-role lines in `~/.grok/rules/pstack-models.md` (written by `/setup-pstack`) override these defaults and the model choices in the routed skills (`arena`, `swarm`, `architect`, `interrogate`, `reflect`). A role with no line keeps its default, and a role line of `inherit-parent` or `auto` runs that role on the parent chat model (omit `model`). Each code playbook passes only the model id from its line (`feature, refactoring`, `bug-fix`, `perf-issue`, or `hillclimb`), validated against `grok models`, and the hardest changes read `hardest tasks`. Prose and judgment read `judgment and prose`. When `spawn_subagent` has no `model` argument, omit `model` for this session so every role inherits the parent, and apply step 1 of **setup-pstack** so the next session can pass `model`. If the rule has no `# defaults: 2` line, an older setup wrote it. Keep honoring its lines, and tell the user once per session to rerun `/setup-pstack`. **Match the model to the job.** Before each spawn, start from the role's line or default and pick the reasoning level the job needs. The `/setup-pstack` budget sets each role's starting level, xhigh by default. Raise it one step, up to max, for the hardest or subtlest work. Lower it one step for judgment and two or more steps for routine work. Verification is the exception and stays on the `swarm workers` model id (`grok-4.6` at `xhigh` by default). Change only the effort and keep the model the role names, so a diverse panel stays diverse. If the model does not offer that effort, use its nearest offered effort. A role on `auto` or `inherit-parent` stays on the parent model. Set the effort only when `spawn_subagent` lists an effort argument. This CLI does not, so the child keeps the parent's effort. If the `spawn_subagent` tool rejects the adjusted slug, do not try another adjusted slug. Use the model id from the role's line or default and say so. If `spawn_subagent` rejects that too, continue with the calling skill's fallback. A slug counts as rejected once a `spawn_subagent` error says that the model is not valid, or leaves the slug out of its list of valid slugs. Never pass a rejected slug, and skip any fallback whose slug is already rejected. When the calling skill has no fallback, use the closest slug from `grok models`, or omit `model` so the subagent runs on the parent model when the list has none. When the calling skill's fallback runs out of slugs without saying what to do next, omit `model` too. Say so in both cases. diff --git a/skills/poteto-mode/playbooks/bug-fix.md b/skills/poteto-mode/playbooks/bug-fix.md index f89f4fb..3b06688 100644 --- a/skills/poteto-mode/playbooks/bug-fix.md +++ b/skills/poteto-mode/playbooks/bug-fix.md @@ -5,7 +5,7 @@ Be scientific. Every shipped line traces to runtime evidence. Belt-and-suspenders that "might help" is a hypothesis, not a fix. It does not ship. When evidence refutes a hypothesis, revert what it motivated. The smallest change the evidence justifies ships, nothing more. 1. Reproduce it yourself on the matching surface via the control skill (Non-negotiables), even when a debug or instrumentation protocol says to ask the user to reproduce. Ask the user only with a stated, specific reason the control surface cannot reach the target, and only after driving it as far as it goes. If it won't reproduce directly, synthesize the trigger, tighten conditions, or instrument until it fires. -2. Binary-search the cause. Form the candidate hypotheses, then rule them out until one survives. Seed them with `how` over the affected subsystem and the **why** skill for regression history. Each pass, take the split that cuts the most remaining problem space, get runtime evidence, eliminate. When program state is unclear, add instrumentation or logging and read it as the code runs. Don't guess. Drive a long or stubborn hunt with `/loop`. Each fire cannot see this chat, so the stored prompt must stand alone. Confirm the surviving *mechanism* with runtime evidence before the step-3 architect/interrogate fan-out. +2. Binary-search the cause. Form the candidate hypotheses, then rule them out until one survives. Seed them with a trace of the affected subsystem and the **why** skill for regression history. Each pass, take the split that cuts the most remaining problem space, get runtime evidence, eliminate. When program state is unclear, add instrumentation or logging and read it as the code runs. Don't guess. Drive a long or stubborn hunt with `/loop`. Each fire cannot see this chat, so the stored prompt must stand alone. Confirm the surviving *mechanism* with runtime evidence before the step-3 architect/interrogate fan-out. 3. Plan the fix. If it crosses a function boundary, `architect` first. Delegate implementation to a subagent using your configured bug-fix model (default `grok-4.6` at `xhigh`) with a specific scope. 4. Verify on the same surface. The original repro now passes. "Inconclusive" or wrong-surface is not a pass. Flag it. Unit tests show branch behavior, not bug absence. 5. Stage the commits so the failing repro lands before the fix in git history. See the **tdd** skill for the failing-test-first cadence when the bug has a cheap local test path. Skip it when the test would be expensive, integration-heavy, or unclear. diff --git a/skills/poteto-mode/playbooks/feature.md b/skills/poteto-mode/playbooks/feature.md index fe79d43..0fd0c3c 100644 --- a/skills/poteto-mode/playbooks/feature.md +++ b/skills/poteto-mode/playbooks/feature.md @@ -2,7 +2,7 @@ **You own the design. Plan, review, verify.** Delegate implementation. Stay in the lead. -1. `how` over the affected subsystem. +1. Trace the affected subsystem. 2. `architect` for parallel design exploration. 3. Write the throughput checkpoint as four todo items. A dimension that genuinely does not apply (single file, no fan-out) keeps its item with `n/a: ` rather than being dropped: - **Blocking first steps.** Gates run before fan-out. diff --git a/skills/poteto-mode/playbooks/hillclimb.md b/skills/poteto-mode/playbooks/hillclimb.md index 9a744e1..0282140 100644 --- a/skills/poteto-mode/playbooks/hillclimb.md +++ b/skills/poteto-mode/playbooks/hillclimb.md @@ -4,7 +4,7 @@ Core discipline: one change, one measurement, keep or revert. Never stack untested changes, and never claim a win from code inspection (the **prove-it-works** principle skill). -1. Ground the workload and architecture before choosing the metric. Run the **how** skill over the target, name the realistic workload dimensions that can move the result (data size, history, state, concurrency), and select a case that reproduces the user's complaint. If no case reproduces it, fix the repro instead of hillclimbing. Then fix one metric, the direction that counts as better, and a checkable stop predicate that pairs a target with a floor on attempts so a lucky early win can't end the run (the example "at least 50% better than baseline and at least 10 iterations" is this shape). Use the user's numbers when given, otherwise agree them. +1. Ground the workload and architecture before choosing the metric. Trace the target, name the realistic workload dimensions that can move the result (data size, history, state, concurrency), and select a case that reproduces the user's complaint. If no case reproduces it, fix the repro instead of hillclimbing. Then fix one metric, the direction that counts as better, and a checkable stop predicate that pairs a target with a floor on attempts so a lucky early win can't end the run (the example "at least 50% better than baseline and at least 10 iterations" is this shape). Use the user's numbers when given, otherwise agree them. 2. Build the measurement harness, prove its sensitivity, then freeze it (the **build-the-lever** principle skill). Run contrasting realistic workloads and confirm the target case reproduces the symptom while easier cases separate as expected. If the harness cannot distinguish them, revise the workload or metric. Vet the harness with the **benchmark-checklist** skill before you freeze it, and make it print its error count and a count of the work done. Once frozen, one repeatable command emits the metric, sampled enough to clear the noise (median of N, not a single run). Record the baseline metric and a green run of the regression gate (the tests that must keep passing) before any change. 3. Open the decision log via the **show-me-your-work** skill. A `decision.tsv`, one row per attempt: id, hypothesis, change, before, after, delta, tests, verdict (kept or reverted), note. Read it before each attempt. Keep it out of the tree (gitignored). 4. Ground each hypothesis in the architecture model from step 1, so it names a specific mechanism ("defer X off the boot path because it blocks first paint"), not "try memoizing something". For a perf metric, order hypotheses by the performance mantras in step 2 of the Perf issue playbook (`playbooks/perf-issue.md`). Borrow only their order, not that step's stop rule. diff --git a/skills/poteto-mode/playbooks/investigation.md b/skills/poteto-mode/playbooks/investigation.md index cd119f0..854d56f 100644 --- a/skills/poteto-mode/playbooks/investigation.md +++ b/skills/poteto-mode/playbooks/investigation.md @@ -4,9 +4,9 @@ Investigation requests are read-only. They produce a cited explanation or a recommendation, not a code change. -1. Route through the **how** skill. For motivation questions, also route through the **why** skill. +1. Trace the code the question is about. For motivation questions, also route through the **why** skill. 2. Throughput checkpoint stays one line: `throughput checkpoint: n/a, read-only investigation`. -3. Produce the `how`-shaped output (Overview / Key Concepts / How It Works / Where Things Live / Gotchas), or a recommendation with a tradeoffs table if the request is a decision between alternatives. +3. Produce the output (Overview / Key Concepts / How It Works / Where Things Live / Gotchas), or a recommendation with a tradeoffs table if the request is a decision between alternatives. 4. Apply the **unslop** skill to the reply. No PR, no babysit, no `architect` unless the investigation precedes a code change. If it does, hand back to the user and re-route to Bug fix or Feature. diff --git a/skills/poteto-mode/playbooks/multi-phase-plan.md b/skills/poteto-mode/playbooks/multi-phase-plan.md index 2f734d8..8b4cbcc 100644 --- a/skills/poteto-mode/playbooks/multi-phase-plan.md +++ b/skills/poteto-mode/playbooks/multi-phase-plan.md @@ -149,7 +149,7 @@ Each live lane runs in its own worktree at the PR head, with `isolation: "worktr ## Appendix D. Links and reading list -/skills/how/SKILL.md` and `/skills/interrogate/SKILL.md`. The trail per `/skills/show-me-your-work/SKILL.md`.> +/skills/interrogate/SKILL.md`. The trail per `/skills/show-me-your-work/SKILL.md`.> ```` **Reply:** the plan path, the PR ids with their dependencies and the review-gated set, what the prototypes proved and what stays unproven, and the check script's output. diff --git a/skills/poteto-mode/playbooks/perf-issue.md b/skills/poteto-mode/playbooks/perf-issue.md index ea5f18d..f3a522d 100644 --- a/skills/poteto-mode/playbooks/perf-issue.md +++ b/skills/poteto-mode/playbooks/perf-issue.md @@ -3,7 +3,7 @@ **You own the measurement story. Plan, review, verify the numbers.** Tie every fix to a measurement, don't read source instead of measuring. 1. Capture a baseline trace via the matching control skill. Vet the baseline, and each later number, with the **benchmark-checklist** skill. -2. `how` to ground hypotheses. Don't claim a perf ceiling without running it first. +2. Trace the code to ground hypotheses. Don't claim a perf ceiling without running it first. Try the performance mantras in order, cheapest first: 1. Don't do it. Stop work whose result nothing uses rather than cheapening it. 2. Do it, but don't do it again. diff --git a/skills/poteto-mode/playbooks/refactoring.md b/skills/poteto-mode/playbooks/refactoring.md index 259e301..9da3b72 100644 --- a/skills/poteto-mode/playbooks/refactoring.md +++ b/skills/poteto-mode/playbooks/refactoring.md @@ -4,7 +4,7 @@ If the cleanup reveals a missing feature or a real bug, split it out and ship the structural change first against the pinned contract. A redesign is allowed, but name it and route to Feature. Large or cross-cutting structural work belongs to the **figure-it-out** skill. This playbook is the focused-to-medium change. -1. Pin the behavior contract first. Run the **how** skill over the affected subsystem to learn the contract, then write a characterization test, snapshot, or equivalence harness that captures current behavior before any structure moves. If the area has no coverage, write the pin before touching structure. Type check and lint are not a pin. +1. Pin the behavior contract first. Trace the affected subsystem to learn the contract, then write a characterization test, snapshot, or equivalence harness that captures current behavior before any structure moves. If the area has no coverage, write the pin before touching structure. Type check and lint are not a pin. 2. Name the structure the code is missing per **principle-model-the-domain**. Boring code stays when the shape is already clear and local. The reshape must delete branches or invalid states, not add indirection. 3. Name the target shape. State what the module layout, types, and call graph should be if built today (**principle-foundational-thinking**, **principle-redesign-from-first-principles**). If the target crosses a function boundary, run the **architect** skill for parallel design exploration of the shape before the move. 4. Subtract before you add. Delete dead code, collapse one-caller wrappers, drop redundant validators, and remove orphan references before introducing the new shape (**principle-subtract-before-you-add**). The smallest change that reaches the target shape ships (**principle-laziness-protocol**). A speculative cleanup that "might help" gets reverted. diff --git a/skills/recall/SKILL.md b/skills/recall/SKILL.md index 3bd63d9..e33e0b4 100644 --- a/skills/recall/SKILL.md +++ b/skills/recall/SKILL.md @@ -10,14 +10,14 @@ disable-model-invocation: true Keep it tight and on-topic. Read only what the in-scope threads need, then stop. -Your context lives in two records. Your own chat history holds what you did and decided. The shared record holds everything that happened around the same code under other names: the symptoms users keep reporting, the fixes that shipped and got reverted, the errors still firing in prod. That second record is what the **why** skill searches, across source control, the issue tracker, chat and issue channels, long-form docs, and error tracking. A feature with a long bug tail keeps most of its story there, so don't reconstruct it from your transcripts alone. +Your context lives in two records. Your own chat history holds what you did and decided. The shared record holds everything that happened around the same code under other names: the symptoms users keep reporting, the fixes that shipped and got reverted, the errors still firing in prod. That second record lives in source control, the issue tracker, chat and issue channels, long-form docs, and error tracking. A feature with a long bug tail keeps most of its story there, so don't reconstruct it from your transcripts alone. Transcripts live at `~/.grok/sessions///chat_history.jsonl`, with `updates.jsonl` beside it. Percent-encoding turns `/` into `%2F`, so `/Users/you/proj` is `%2FUsers%2Fyou%2Fproj`. `GROK_HOME` overrides `~/.grok`. Names longer than 255 bytes use a slug plus a hash and a `.cwd` file. Every line of `chat_history.jsonl` is one chat message. Do not glob `~/.grok/sessions/*/`. 1. Classify, then route. One specific prior chat to resume is the `session-pickup` playbook, not this. Turning habits into a durable skill is `automate-me`. A human-readable summary of your work is a different task. Recall loads working context across recent chats before you act. If the user already gave you a full state capsule (paths, branch, the change), use it and skip the mining. 2. Lock the scope before searching. Pin the window ("recent" is a real range, default the last 7 days), the topic if named, and the workspace (default the active one. Never read another project's transcripts without being asked). State the scope back. Never quietly turn "all" into "recent N". 3. Fan out across your chat history. Spawn parallel subagents on a fast, cheap model, each taking a slice of the corpus. Tell every subagent to order candidates by real modification time (`ls -t`) and never by UUID name, grep the topic first and then read only the matching chats and only their relevant regions, and skip the current chat plus obvious noise (subagent, eval, and test chats). Each returns the same schema, one block per chat: topic, the user's goal, decisions, open threads, struggles and corrections, and artifacts (PRs, tickets, branches), each citing the chat UUID. For one or two chats, skip the fan-out and search directly. The raw transcripts stay in the subagents. The main thread gets only their findings. Pick each subagent's reasoning effort for the job, per the Subagents section of the **poteto-mode** skill. -4. Sweep the shared record whenever the topic names a feature, file, subsystem, area, or bug. This is the default, not a judgment call, and "my work on X" does not exempt it. Hand it to the **why** skill's source investigators, but steer their question from "why was this built this way" to "what's the current state, what's been tried and didn't hold, and what are users still reporting". Reuse its per-source playbooks, run the investigators in parallel with the chat-history mining, and inherit its posture: one investigator per source, null results are findings, skip an unavailable MCP and say so. Fold what comes back into the brief. Skip this step only for pure activity recall with no named target ("what did I do this week"), where your own history and live state are the entire answer. +4. Sweep the shared record whenever the topic names a feature, file, subsystem, area, or bug. This is the default, not a judgment call, and "my work on X" does not exempt it. Spawn one investigator subagent per source. There is no readonly flag, and MCP stays available through `search_tool` and `use_tool`. Ask each "what's the current state, what's been tried and didn't hold, and what are users still reporting". Run them in parallel with the chat-history mining. Null results are findings. Skip an unavailable MCP and say so. Fold what comes back into the brief. Skip this step only for pure activity recall with no named target ("what did I do this week"), where your own history and live state are the entire answer. 5. Verify against live state. Take the PRs, branches, and tickets that the mining and the sweep surfaced and check them with `git` and `gh`. When the answer hinges on what an agent actually did (the tools it ran, files it read, errors it hit), read the full transcript, not just a trimmed local copy. 6. Write the brief to the contract below. Group by thread. Stay on the named topic. diff --git a/skills/reflect/references/synthesizer.md b/skills/reflect/references/synthesizer.md index 1a090d8..60f2f9d 100644 --- a/skills/reflect/references/synthesizer.md +++ b/skills/reflect/references/synthesizer.md @@ -25,7 +25,7 @@ Drop (implementation details that drift): - "linter at SHA `bd91aa7` uses chars/4 heuristic" - "`` has 175 tokens at limit 80" - "Bugbot flagged regex backtracking on May 2" -- "we renamed `gpt-4` to `gpt-4o` in `encodingForModel`" +- "we renamed `parseConfig` to `loadConfig` in `settings.ts`" Keep (durable patterns): - "closed regex enums for trigger detection are brittle. Prefer schema-validated structures" diff --git a/skills/setup-pstack/SKILL.md b/skills/setup-pstack/SKILL.md index 5b0bf7f..2c4b115 100644 --- a/skills/setup-pstack/SKILL.md +++ b/skills/setup-pstack/SKILL.md @@ -22,7 +22,9 @@ Pass `model` only in a session whose schema includes it. Pass the effort only wh ### 2. Load current state -The default role-to-model mapping is the rule shape shown in step 5 below. If `~/.grok/rules/pstack-models.md` already exists, read it and treat its `# budget` line and its role values as the current choices. Otherwise start from those defaults. A line whose role is not in step 5, such as `how critics`, is from a retired role. Drop it. +The default role-to-model mapping is the rule shape shown in step 5 below. If `~/.grok/rules/pstack-models.md` already exists, read it and treat its `# budget` line and its role values as the current choices. Otherwise start from those defaults. A line whose role is not in step 5, such as `how explorer` or `why investigators`, is from a retired role. Drop it. + +A rule without the `# defaults: 2` line comes from an older setup. That setup wrote lines for `how explorer`, `how explainer`, `why investigators`, and `why synthesizer`. Drop those lines. Do not replace a `grok-*` slug. Every other value is the user's choice and stays, including every `inherit-parent` or `auto` value. Tell the user which lines you dropped. ### 3. Budget, map, and confirm @@ -33,7 +35,7 @@ The default role-to-model mapping is the rule shape shown in step 5 below. If `~ - `medium — high reasoning` - `small — medium reasoning` -**(b) Apply it.** Build the working table from the skill defaults, and on a re-run keep any role you changed by slug, list, or alias (`inherit-parent`, `auto`). `unlimited`, `large`, `medium`, and `small` set the effort of every real model entry, panel entries included, to `max`, `xhigh`, `high`, or `medium`, on the ladder `max` > `xhigh` > `high` > `medium` > `low`. Effort is a separate field, written after the model id (`grok-4.6 xhigh`). If the model does not offer that effort, use its highest offered effort at or below the target, else mark the role as needing a choice. `inherit-parent` and `auto` do not change. So on grok 1.0.62, `unlimited` keeps `grok-4.6` at `xhigh`, `large` keeps the defaults, and `small` turns them into `grok-4.6 medium` and `grok-4.5 medium`. A panel list stays two entries when two different detected slugs exist. When the budget collapses a panel onto one slug, write that slug twice and tell the user the panel has no second model. If `spawn_subagent` has no `model` argument, still write the intended slugs. They take effect in the next session, after step 1 exposes `model`. +**(b) Apply it.** Build the working table from the skill defaults, and on a re-run keep any role you changed by slug, list, or alias (`inherit-parent`, `auto`). Each entry has a target effort, which is its default's effort moved by the budget. `large` keeps it, `unlimited` raises it one step, `medium` lowers it one step, and `small` lowers it two steps, on the ladder `max` > `xhigh` > `high` > `medium` > `low`. A target at either end of the ladder stays there. Most defaults are at `xhigh`, and each budget label names where those land. Set the effort of every real model entry in the role, panel entries included, to that entry's target. Effort is a separate field, written after the model id (`grok-4.6 xhigh`). If the model does not offer that effort, use its highest offered effort at or below the target, else mark the role as needing a choice. `inherit-parent` and `auto` do not change. So `unlimited` turns `grok-4.6 xhigh` into `grok-4.6 max` when `max` is offered, and otherwise keeps `xhigh`. `large` keeps the defaults. `small` turns `grok-4.6 xhigh` into `grok-4.6 medium` and `grok-4.5 high` into `grok-4.5 low`. A panel list stays two entries when two different detected slugs exist. When the budget collapses a panel onto one slug, write that slug twice and tell the user the panel has no second model. If `spawn_subagent` has no `model` argument, still write the intended slugs. They take effect in the next session, after step 1 exposes `model`. **(c) Show the roles and confirm.** Show every role with its model, marking any real slug not in the detected set as needing a choice. Also list each line step 2 dropped. Ask whether to accept as-is or change specific roles, offering the detected models plus `inherit-parent` and `auto` (both mean this role runs on the parent chat model, so omit `model`) as the options. Prefer ask_user_question over free text. For panel roles (arena runners, architect runners, interrogate reviewers) the value is a list, and one subagent runs per entry, alias entries included, so the list length sets the count. `arena cross-judge pool` is also a list, but Arena runs one judge. It tries only values on a detected slug other than the parent's, in list order, so order it by preference. An `inherit-parent` or `auto` value never judges. `swarm workers` is the default model for every worker unless a race or comparison assigns another model per arm. @@ -43,12 +45,13 @@ Every real model id written must be in the detected set. The effort word after t ### 5. Write the rule -Write `~/.grok/rules/pstack-models.md` as plain Markdown. No YAML frontmatter. Include a `# budget` line and one line per role, using the same labels poteto-mode uses. Overwrite the whole file so re-runs stay idempotent. Shape for `large` when `grok-4.6` and `grok-4.5` are detected: +Write `~/.grok/rules/pstack-models.md` as plain Markdown. No YAML frontmatter. Include the `# defaults: 2` line, a `# budget` line with the chosen label and the effort that label names, and one line per role, using the same labels poteto-mode uses. Overwrite the whole file so re-runs stay idempotent. Shape for `large` when `grok-4.6` and `grok-4.5` are detected: ``` # pstack model configuration. One line per role. Delete a line to fall back to the skill default. # `inherit-parent` or `auto` as a value: the role runs on the parent chat model (omit `model`). Alias entries in a panel list still count toward its fan-out. # Pass model only when spawn_subagent lists it. Step 1 exposes that argument for the next session. +# defaults: 2 # budget: large (xhigh) feature, refactoring: grok-4.6 xhigh bug-fix: grok-4.6 xhigh @@ -56,10 +59,6 @@ perf-issue: grok-4.6 xhigh hillclimb: grok-4.6 xhigh judgment and prose: grok-4.6 xhigh hardest tasks: grok-4.6 xhigh -how explorer: grok-4.6 xhigh -how explainer: grok-4.6 xhigh -why investigators: grok-4.6 xhigh -why synthesizer: grok-4.6 xhigh reflect tooling: grok-4.6 xhigh reflect judgment, divergent, synthesizer: grok-4.6 xhigh arena runners: grok-4.6 xhigh, grok-4.5 high diff --git a/skills/sharpen/SKILL.md b/skills/sharpen/SKILL.md index 5b4a7b1..2a03402 100644 --- a/skills/sharpen/SKILL.md +++ b/skills/sharpen/SKILL.md @@ -13,4 +13,4 @@ I want a deeper version of this task, not a bigger one. Before rewriting it, do Then rewrite my prompt to ask for exactly that. -Leave choices that are mine to make open instead of deciding them. +Have the rewritten prompt ask the agent to prototype any choice an experiment can settle and recommend an option based on what it observed. Leave product or preference choices that no experiment can settle for me to make. diff --git a/skills/statechart/scripts/backends/mermaid.ts b/skills/statechart/scripts/backends/mermaid.ts index 327220c..21ad39c 100644 --- a/skills/statechart/scripts/backends/mermaid.ts +++ b/skills/statechart/scripts/backends/mermaid.ts @@ -93,6 +93,52 @@ const esc = (s: string, quoted = false) => { const or = (names: Iterable) => [...names].sort(byText).join(" or "); +type Edge = { from: string[]; start: boolean; to: string[]; label: string | undefined }; + +const within = (parent: string[], path: string[]) => + path.length >= parent.length && parent.every((p, i) => path[i] === p); +const wayIn = (e: Edge) => tupleKey([e.start, e.from]); + +export function drawnEdges(r: Region): Edge[] { + let out: Edge[] = []; + for (const s of r.states) + if (s.start) out.push({ from: [], start: true, to: s.path, label: undefined }); + for (const s of r.steps) + out.push({ + from: s.from, + start: false, + to: s.to, + label: s.label + (s.when ? ` [${s.when}]` : ""), + }); + const parents = new Map(); + for (const s of r.states) + for (let i = 1; i < s.path.length; i++) { + const prefix = s.path.slice(0, i); + parents.set(tupleKey(prefix), prefix); + } + for (const parent of [...parents.values()].sort((a, b) => a.length - b.length)) { + const into = out.filter( + (e) => e.to.length > parent.length && within(parent, e.to) && !within(parent, e.from), + ); + if (!into.length || into.some((e) => wayIn(e) !== wayIn(into[0]))) continue; + const one = into.length === 1; + const at = out.indexOf(into[0]); + out = out.filter((e) => !into.includes(e)); + out.splice( + at, + 0, + { ...into[0], to: parent, label: one ? into[0].label : undefined }, + ...into.map((e) => ({ + from: parent, + start: true, + to: e.to, + label: one ? undefined : e.label, + })), + ); + } + return out; +} + const MARK_STYLES = { breaks: "fill:#ffecee,stroke:#e72e3b,stroke-width:2.5px,color:#cd2834", mayBreak: "fill:#fff3e6,stroke:#e8730c,stroke-width:2.5px,color:#b85a06", @@ -121,6 +167,9 @@ export function mermaidLines(chart: Chart) { if (s === undefined) known.set(path, (s = id(path))); return s; }; + const drawn = drawnEdges(r); + const line = (e: Edge, indent: string) => + `${indent}${e.start ? "[*]" : idOf(e.from)} --> ${idOf(e.to)}${e.label === undefined ? "" : `: ${esc(e.label)}`}`; const tree = (prefix: string[], indent: string, below: ChartState[]) => { const heads = new Map(); for (const s of below) append(heads, s.path[prefix.length], s); @@ -134,6 +183,9 @@ export function mermaidLines(chart: Chart) { if (inner.length) { out.push(`${indent}state "${esc(head, true)}" as ${id(path)} {`); tree(path, indent + " ", inner); + const key = tupleKey(path); + for (const e of drawn) + if (e.start && tupleKey(e.from) === key) out.push(line(e, `${indent} `)); out.push(`${indent}}`); } else if (leaf) { const sid = idOf(leaf.path); @@ -153,11 +205,7 @@ export function mermaidLines(chart: Chart) { } }; tree([], " ", r.states); - for (const s of r.states) if (s.start) out.push(` [*] --> ${idOf(s.path)}`); - for (const s of r.steps) - out.push( - ` ${idOf(s.from)} --> ${idOf(s.to)}: ${esc(s.label + (s.when ? ` [${s.when}]` : ""))}`, - ); + for (const e of drawn) if (!e.start || !e.from.length) out.push(line(e, " ")); return out; }; let body: string[]; diff --git a/skills/statechart/scripts/run.ts b/skills/statechart/scripts/run.ts index 4efd368..017684f 100644 --- a/skills/statechart/scripts/run.ts +++ b/skills/statechart/scripts/run.ts @@ -68,6 +68,7 @@ const TLC_TOOL = "http:tla2tools[url=https://github.com/tlaplus/tlaplus/releases/download/v1.7.4/tla2tools.jar,checksum=sha256:936a262061c914694dfd669a543be24573c45d5aa0ff20a8b96b23d01e050e88]@1.7.4"; const JAVA_TOOL = "java@temurin-25"; export const PINNED_FLAGS = ["-workers", "1", "-fp", "0", "-lncheck", "final"]; +const SANY_ERRORS = /^\*\*\* ?(?:Errors|Abort messages|Parse Error)/m; type ChildResult = { status: number | null; @@ -227,6 +228,12 @@ const tail = (r: FileResult) => { return kept.join("").trim().split("\n").slice(-30).join("\n"); }; +const firstLines = (text: string) => { + const lines = text.trim().split("\n"); + if (lines.length > 40) lines.splice(40, Infinity, `... ${lines.length - 40} more lines`); + return lines.join("\n"); +}; + const stopOf = (r: FileResult): Stop => { const errors: Part[] = []; for (const m of r.error ? [] : messagesOf(r.output)) @@ -238,9 +245,14 @@ const stopOf = (r: FileResult): Stop => { ) errors.push(m); if (!errors.length) return { status: r.status, message: tail(r) }; - const lines = [...plainText(errors)].join("").trim().split("\n"); - if (lines.length > 40) lines.splice(40, Infinity, `... ${lines.length - 40} more lines`); - return { status: r.status, message: lines.join("\n") }; + return { status: r.status, message: firstLines([...plainText(errors)].join("")) }; +}; + +const sanyErrors = (r: FileResult) => { + if (r.error) return undefined; + const text = [...plainText(messagesOf(r.output))].join(""); + const at = text.search(SANY_ERRORS); + return at === -1 ? undefined : firstLines(text.slice(at)); }; const names = (rules: Rule[], kind: Rule["kind"]) => { @@ -305,8 +317,21 @@ export async function check(specFile: string, configFile: string): Promise path.join(here, "corpus", name, file); @@ -693,6 +694,48 @@ test("a step that leaves every child of a parent the same way is one arrow from assert.deepEqual(quits, [[open, closed]]); }); +test("a parent's only way in ends at the parent, and its start marker goes on to each state with that step's label", () => { + const graph = graphOf( + [ + ["ask", { at: "Asking" }, true], + ["flat", { at: "Layout.Flat" }], + ["parents", { at: "Layout.Parents" }], + ["drawn", { at: "Done.Drawn" }], + ], + [ + ["ask", "flat", "String"], + ["ask", "parents", "Array"], + ["flat", "drawn", "Draw"], + ], + ); + const { chart } = draw(graph, { state: (v) => String(v.at).split(".") }); + assert.deepEqual(drawn(chart).arrows.sort(), [ + "Asking --> Layout", + "Done start --> Drawn", + "Flat --> Done: Draw", + "Layout start --> Flat: String", + "Layout start --> Parents: Array", + ]); +}); + +test("a parent that two states lead into keeps an arrow from each, since one start marker cannot say where each came from", () => { + const graph = graphOf( + [ + ["a", { at: "A" }, true], + ["b", { at: "B" }], + ["p", { at: "P.p" }], + ["q", { at: "P.q" }], + ], + [ + ["a", "b", "Go"], + ["a", "p", "Left"], + ["b", "q", "Right"], + ], + ); + const { chart } = draw(graph, { state: (v) => String(v.at).split(".") }); + assert.deepEqual(drawn(chart).arrows.sort(), ["A --> B: Go", "A --> p: Left", "B --> q: Right"]); +}); + test("a label codes only the characters that Mermaid reads as syntax, so TLA+ values stay as TLC prints them", () => { const graph = graphOf( [ diff --git a/skills/statechart/scripts/test/cli.test.ts b/skills/statechart/scripts/test/cli.test.ts index 97b71c3..11f06a6 100644 --- a/skills/statechart/scripts/test/cli.test.ts +++ b/skills/statechart/scripts/test/cli.test.ts @@ -9,6 +9,7 @@ import { setTimeout as sleep } from "node:timers/promises"; import { fileURLToPath, pathToFileURL } from "node:url"; import { plainText } from "../backends/plain-text.ts"; import { readMessages } from "../frontends/messages.ts"; +import { drawn } from "./drawn.ts"; const here = path.dirname(fileURLToPath(import.meta.url)); const corpus = path.join(here, "corpus"); @@ -881,18 +882,6 @@ test("a view with a group in a theme color draws that color and names the group assert.match(chart, new RegExp(`^ {2}class ${legend} teal$`, "m")); }); -const shown = (text: string) => text.replace(/#(\d+);/g, (_, n) => String.fromCodePoint(Number(n))); - -const drawn = (chart: string) => { - const names = new Map(); - for (const m of chart.matchAll(/^ *(?:state "(.*)" as (s\d+) \{|(s\d+): (.*))$/gm)) - names.set(m[2] ?? m[3], shown(m[1] ?? m[4])); - const arrows: string[] = []; - for (const [, from, to, text] of chart.matchAll(/^ *(s\d+) --> (s\d+): (.*)$/gm)) - arrows.push(`${names.get(from)} --> ${names.get(to)}: ${shown(text)}`); - return { states: [...names.values()], arrows }; -}; - const byX = (labels: unknown[]) => `export const state = (v) => ${JSON.stringify(labels)}[v.x];\n`; const fanOut = (n: number) => { @@ -926,7 +915,7 @@ for (const [what, c] of [ view: byX([["a\0b"], ["a", "b"], ["c"], ["d"]]), status: 0, states: ["ab", "a", "b", "c", "d"], - arrows: ["ab --> b: Inc", "b --> c: Inc", "c --> d: Inc"], + arrows: ["a start --> b", "ab --> a: Inc", "b --> c: Inc", "c --> d: Inc"], says: /^TLC reached 4 states and 3 steps\. The chart draws 4 states and 3 arrows\.$/m, }, ], @@ -942,7 +931,14 @@ for (const [what, c] of [ ]), status: 0, states: ["R f", "S p", "R ab", "S q", "R a", "R b", "S r"], - arrows: ["S p --> S q: Inc", "S p --> S r: Inc"], + arrows: [ + "R f start --> S p", + "R ab start --> S q", + "R b start --> S r", + "R a start --> R b", + "S p --> R ab: Inc", + "S p --> R a: Inc", + ], says: /^The regions chart lets R f, S p go to R a\0b, S r by Inc, which the model never does\. So the chart draws parent states in place of regions\.$/m, }, ], @@ -964,7 +960,7 @@ for (const [what, c] of [ view: byX([["a\u0001b"], ["a", "b"], ["c"], ["d"]]), status: 0, states: ["a\u0001b", "a", "b", "c", "d"], - arrows: ["a\u0001b --> b: Inc", "b --> c: Inc", "c --> d: Inc"], + arrows: ["a start --> b", "a\u0001b --> a: Inc", "b --> c: Inc", "c --> d: Inc"], says: /^TLC reached 4 states and 3 steps\. The chart draws 4 states and 3 arrows\.$/m, }, ], @@ -1002,7 +998,7 @@ for (const [what, c] of [ view: byX([["a"], ["P", "b\u0002c"], ["d"], ["e"]]), status: 1, states: ["a", "P", "b\u0002c", "d", "e"], - arrows: ["a --> b\u0002c: Next", "b\u0002c --> d: Next", "d --> e: Next"], + arrows: ["P start --> b\u0002c", "a --> P: Next", "b\u0002c --> d: Next", "d --> e: Next"], says: /^## NotOne breaks\nThe shortest path has 1 step:\n0\. a\n1\. Next: P \/ b\cBc$/m, }, ], @@ -1039,10 +1035,15 @@ for (const [what, c] of [ status: 0, states: ["R f", "S p", "R a", "S r", "R b", "S q", "R X\u0003a", "S q", "R X\u0003b", "S r"], arrows: [ - "S p --> S r: Go\u0003X", - "S p --> S q: Go\u0003X", - "S p --> S q: Go", - "S p --> S r: Go", + "R f start --> S p", + "R a start --> S r", + "R b start --> S q", + "R X\u0003a start --> S q", + "R X\u0003b start --> S r", + "S p --> R a: Go\u0003X", + "S p --> R b: Go\u0003X", + "S p --> R X\u0003a: Go", + "S p --> R X\u0003b: Go", ], says: /^The regions chart lets R f, S p go to R a, S q by Go\cCX, which the model never does\. So the chart draws parent states in place of regions\.$/m, }, diff --git a/skills/statechart/scripts/test/corpus.test.ts b/skills/statechart/scripts/test/corpus.test.ts index 8934373..90a4104 100644 --- a/skills/statechart/scripts/test/corpus.test.ts +++ b/skills/statechart/scripts/test/corpus.test.ts @@ -383,6 +383,44 @@ for (const [width, height, config, status, drawn, chart, header] of [ }, ); +for (const [what, tla, where] of [ + [ + "an unknown name", + ["---- MODULE Broken ----", "VARIABLE x", "Init == x = 0", "Next == x' = y", "===="], + /^line 4, col 14 to line 4, col 14 of module Broken\n+Unknown operator: `y'\.$/m, + ], + [ + "a parse error", + ["---- MODULE Broken ----", "VARIABLE x", "Init == x = = 0", "Next == x' = x", "===="], + /^Encountered "0" at line 3, column 15/m, + ], + [ + "twelve unknown names", + [ + "---- MODULE Broken ----", + "VARIABLE x", + "Init == x = 0", + ...Array.from({ length: 12 }, (_, i) => `D${i} == u${i}`), + "Next == x' = x", + "====", + ], + /^\*\*\* Errors: 12\n+line 4, col 7 to line 4, col 8 of module Broken\n+Unknown operator: `u0'\.$/m, + ], +] as const) + test( + `a spec with ${what} gets SANY's line and column, not a Java stack trace`, + { skip }, + async () => { + const base = writeSpec("Broken", [...tla], "INIT Init\nNEXT Next\n"); + await assert.rejects(check(`${base}.tla`, `${base}.cfg`), (error: Error) => { + assert.match(error.message, /^SANY could not read .*Broken\.tla \(exit 1\):\n/); + assert.match(error.message, where); + assert.doesNotMatch(error.message, /^\s+at tla2sany\./m); + return true; + }); + }, + ); + test( "check() leaves no statechart- folder in the temp dir when it returns and when it throws", { skip }, diff --git a/skills/statechart/scripts/test/corpus/Login/chart.mmd b/skills/statechart/scripts/test/corpus/Login/chart.mmd index 9733b21..547bd3e 100644 --- a/skills/statechart/scripts/test/corpus/Login/chart.mmd +++ b/skills/statechart/scripts/test/corpus/Login/chart.mmd @@ -6,12 +6,13 @@ stateDiagram-v2 s4: Checking second try s5: Wrong password, 1 try left s6: Checking last try + [*] --> s2 } s7: Reset email sent s8: Signed in s9: Locked out [*] --> s0 - s0 --> s2: YouSubmitAPassword + s0 --> s1: YouSubmitAPassword s2 --> s8: ThePasswordIsRight s2 --> s3: ThePasswordIsWrong s7 --> s0: YouSetANewPassword diff --git a/skills/statechart/scripts/test/drawn.ts b/skills/statechart/scripts/test/drawn.ts new file mode 100644 index 0000000..1290403 --- /dev/null +++ b/skills/statechart/scripts/test/drawn.ts @@ -0,0 +1,20 @@ +const shown = (text: string) => text.replace(/#(\d+);/g, (_, n) => String.fromCodePoint(Number(n))); + +export const drawn = (chart: string) => { + const names = new Map(); + for (const m of chart.matchAll(/^ *(?:state "(.*)" as (s\d+) \{|(s\d+): (.*))$/gm)) + names.set(m[2] ?? m[3], shown(m[1] ?? m[4])); + const arrows: string[] = []; + const blocks: string[] = []; + for (const line of chart.split("\n")) { + const block = line.match(/^ *state ".*" as (\w+) \{$/); + if (block) blocks.push(block[1]); + if (/^ *\}$/.test(line)) blocks.pop(); + const m = line.match(/^ *(s\d+|\[\*\]) --> (s\d+)(?:: (.*))?$/); + const parent = names.get(blocks.at(-1) ?? ""); + if (!m || (m[1] === "[*]" && parent === undefined)) continue; + const from = m[1] === "[*]" ? `${parent} start` : names.get(m[1]); + arrows.push(`${from} --> ${names.get(m[2])}${m[3] === undefined ? "" : `: ${shown(m[3])}`}`); + } + return { states: [...names.values()], arrows }; +}; diff --git a/skills/statechart/scripts/test/labels.ts b/skills/statechart/scripts/test/labels.ts index a3d1499..8249724 100644 --- a/skills/statechart/scripts/test/labels.ts +++ b/skills/statechart/scripts/test/labels.ts @@ -1,5 +1,5 @@ import { inspect } from "node:util"; -import { mermaid as chartText } from "../backends/mermaid.ts"; +import { drawnEdges, mermaid as chartText } from "../backends/mermaid.ts"; import { checkView } from "../frontends/view.ts"; import type { Chart, ChartState, State, Step, View } from "../ir.ts"; import { walk } from "../passes/reach.ts"; @@ -398,6 +398,7 @@ function expected(chart: Chart): Want { const region = chart.regions[i]; const wrap = multi ? `r${i}` : null; if (wrap) nodes.set(wrap, { text: region.name, parent: "all", group: true }); + const drawn = drawnEdges(region); const tree = (prefix: string[], parent: string | null, below: ChartState[]) => { const heads = new Map(); for (const s of below) { @@ -413,19 +414,23 @@ function expected(chart: Chart): Want { else leaf = s; const node = id(region.name, path); nodes.set(node, { text: head, parent, group: inner.length > 0 }); - if (inner.length) tree(path, node, inner); - else if (leaf?.group !== undefined) used.add(chart.colors[String(leaf.group)]); + if (inner.length) { + tree(path, node, inner); + const key = JSON.stringify(path); + for (const e of drawn) + if (e.start && JSON.stringify(e.from) === key) + edges.push([`${node}_start`, id(region.name, e.to), e.label ?? ""]); + } else if (leaf?.group !== undefined) used.add(chart.colors[String(leaf.group)]); } }; tree([], wrap, region.states); - for (const s of region.states) - if (s.start) edges.push([`${wrap ?? "root"}_start`, id(region.name, s.path), ""]); - for (const s of region.steps) - edges.push([ - id(region.name, s.from), - id(region.name, s.to), - s.label + (s.when ? ` [${s.when}]` : ""), - ]); + for (const e of drawn) + if (!e.start || !e.from.length) + edges.push([ + e.start ? `${wrap ?? "root"}_start` : id(region.name, e.from), + id(region.name, e.to), + e.label ?? "", + ]); } let legend = 0; for (const [text, cls] of Object.entries(chart.colors)) diff --git a/skills/statechart/scripts/test/render.test.ts b/skills/statechart/scripts/test/render.test.ts index 5309a92..57ff41e 100644 --- a/skills/statechart/scripts/test/render.test.ts +++ b/skills/statechart/scripts/test/render.test.ts @@ -6,6 +6,10 @@ import os from "node:os"; import path from "node:path"; import { before, test } from "node:test"; import { fileURLToPath, pathToFileURL } from "node:url"; +import { mermaid as chartText } from "../backends/mermaid.ts"; +import type { Graph } from "../ir.ts"; +import { walk } from "../passes/reach.ts"; +import { project } from "../pipeline.ts"; import { fuzz, type Html, type Mermaid, type Render } from "./labels.ts"; const here = path.dirname(fileURLToPath(import.meta.url)); @@ -75,6 +79,66 @@ test("random labels and colors keep their text and the chart's shape in Mermaid assert.ok(drawn > 400 && refused > 20, `${drawn} charts drawn, ${refused} refused`); }); +const pathPoints = (d: string) => { + const points: number[][] = []; + let [ax, ay] = [0, 0]; + for (const [, cmd, args] of d.matchAll(/([MLC])([^MLC]*)/g)) { + const n = args.split(/[ ,]/).filter(Boolean).map(Number); + const [x, y] = n.slice(-2); + if (cmd !== "M") + for (let t = 0; t <= 1; t += 1 / 64) { + const u = 1 - t; + points.push( + cmd === "L" + ? [ax + (x - ax) * t, ay + (y - ay) * t] + : [ + u ** 3 * ax + 3 * u * u * t * n[0] + 3 * u * t * t * n[2] + t ** 3 * x, + u ** 3 * ay + 3 * u * u * t * n[1] + 3 * u * t * t * n[3] + t ** 3 * y, + ], + ); + } + [ax, ay] = [x, y]; + } + return points; +}; + +test("an arrow into a parent from its only way in stays out of the parent's title bar in Pele 1.9.0", () => { + const graph: Graph = { states: new Map(), steps: [] }; + for (const [id, at] of [ + ["ask", "Asking your view for labels"], + ["flat", "Laying out the chart/Flat"], + ["parents", "Laying out the chart/Parent states"], + ["regions", "Laying out the chart/Regions"], + ]) + graph.states.set(id, { vars: { at }, start: id === "ask", breaks: [] }); + for (const [to, action] of [ + ["flat", "String"], + ["parents", "Array"], + ["regions", "Object"], + ]) + graph.steps.push({ from: "ask", to, action }); + const { chart } = project(graph, walk(graph), { state: (v) => String(v.at).split("/") }, []); + const { svg } = render(chartText(chart)); + const bars = [ + ...svg.matchAll( + /]*\/> x > bar.left && x < bar.right && y > bar.top && y < bar.bottom, + ) + ) + crossings.push(`${id} crosses the title bar of ${bar.id}`); + assert.deepEqual(crossings, []); +}); + test("the theme in references/render.md colors each class that the charts use", () => { assert.ok(classes.size > 0); for (const name of classes) assert.match(theme, new RegExp(`\\.pele \\.${name} rect \\{`), name); diff --git a/skills/teach/SKILL.md b/skills/teach/SKILL.md index 25369f3..6146b65 100644 --- a/skills/teach/SKILL.md +++ b/skills/teach/SKILL.md @@ -11,7 +11,7 @@ disable-model-invocation: true Teach sits on top of `how` and `why`. Get your bearings on what the work is and what it touches, then run `how` for how it works and `why` for why it's that way. Those are real skill invocations that do their own digging. Blend what they find into one plain explanation, lead with what matters to the person, and go deeper when they ask. Reword freely for teaching, with one exception. Keep `why`'s confidence language intact (its hedges are findings, not style). 1. Decide the few things they should walk away understanding. Choose them from why they're asking (about to change it, reviewing it, debugging it, new to it) and what they already know, both read from the conversation, not quizzed out of them. Skip what they plainly already know. Put the depth where their question is. -2. Let `how` and `why` do the work, don't redo it. Read the code yourself to get oriented, then run `how` for how it works and `why` for why. Run them in parallel and combine the results. Match the size to the question. Run both for a subsystem, maybe one is enough for a small change. Keep `why` narrow by default since its full sweep is slow. Put the narrowing in the ask itself (a scoped question, git plus a source or two) so `why` records the skipped categories per its own contract, and widen it only when the reasons are the point. +2. Let `how` and `why` do the work, don't redo it. Read the code yourself to get oriented, then run `how` for how it works and `why` for why. Run them in parallel and combine the results. Match the size to the question. Run both for a subsystem, maybe one is enough for a small change. 3. Start with a plain definition. Name the thing and say what it is in general terms, the way a senior engineer would say it out loud, with its common name if it has one. Then tie it to the case in front of you ("in X, we use this to ...") and build from there: how it works, the deeper reasons, the edge cases. For each part, explain the idea so it clicks: the problem it solves and how it actually works. Walk through what happens as the person does the thing (opens a long chat, scrolls up) when that is what makes it land. Listing functions and constants is reference, not teaching. Don't print framing labels ("the one idea to hold onto", "the thing to walk away with", "the key insight", "at its core", "TL;DR"). Give the smallest complete answer first, a sentence or two, not a dense paragraph, then stop. Add layers when they ask. Never a wall of text. 4. Keep it a conversation, not a lecture or a performance. Offer to go deeper or move on, and follow their lead. No quizzes. No pacing theater. Don't print "Pause", don't ask them to say it back, don't announce "the sentence to nail", and don't flag a part as important or hard ("here is the part worth slowing down on", "this is the tricky part", "here is where it gets interesting"). Just say it. When you would pause, stop and let them respond. Running one-shot with no live human, deliver it cleanly and put any offer to go deeper at the end. 5. Show, don't only tell, and build the picture up diagram by diagram. Open the diff, the code, or the debugger when that is the fastest way to land it. Draw when a picture lands faster than words. For anything with three or more moving parts, do not draw one diagram with all of them at once. Draw a short series instead, where each diagram redraws the last and adds a single part, so the reader watches the system assemble. A single all-at-once diagram, especially one saved for the end, is a reference, not teaching. Concretely, to teach a flow from A to B to C, draw it three times. First A to B. Then redraw and add C. Then redraw and add the return edge or the next piece. Match the medium to the idea, and use both kinds when both help. A mermaid diagram fits a flow or structure where the labels carry the meaning. When the idea is spatial, like layout, overlap, scroll position, or a before and after, reach for the image-generation tool and draw it marker-on-whiteboard style with a few short labels, since image models garble long text. Generate that picture, don't settle for describing it in words. The build-up rule holds for generated images too. A single simple point needs no figure. diff --git a/skills/why/SKILL.md b/skills/why/SKILL.md index 3af91e3..9939783 100644 --- a/skills/why/SKILL.md +++ b/skills/why/SKILL.md @@ -1,98 +1,9 @@ --- name: why -description: "Use for 'why does X work this way', 'why we picked Y', design rationale, regressions, postmortems, or data-backed thresholds. Discovers available MCPs and queries each evidence category (source control, issue tracker, long-form docs, real-time chat, infrastructure observability, error tracking, product analytics warehouse) in parallel, then returns a cited read on decisions and tradeoffs. Use how for runtime behavior." +description: "Use for 'why does X work this way', 'why we picked Y', design rationale, regressions, postmortems, or data-backed thresholds. Returns a cited read on decisions and tradeoffs. Use how for runtime behavior." disable-model-invocation: true --- # Why -Investigate the motivation and intent behind code. The companion `how` skill answers what the code does and how it works. `why` answers what forces led to its shape. - -Each spawn below names a role line in the `pstack-models.md` rule and a default. Set `model` to the model id in that line's value (`grok-4.6` from `grok-4.6 xhigh`), or to the default model id if the rule or the line is missing. Validate the id against `grok models`. Leave `model` unset when the value is `auto` or `inherit-parent`. If `spawn_subagent` has no `model` argument, omit it for this session so the child inherits the parent, and apply step 1 of **setup-pstack** so the next session can pass `model`. If it rejects a slug, use the closest slug from `grok models` and say so. Pick each subagent's reasoning effort for the job, per the Subagents section of the **poteto-mode** skill. - -Every spawn omits `subagent_type`. There is no readonly flag. Investigators must not write files. Say that in the prompt. MCP stays available through `search_tool` and `use_tool`, which the investigators and the synthesizer's citation spot-checks need. - -## Operating Posture - -Operate as a **careful, cautious, and precise investigator**. Be honest about what you know vs what you're inferring. Read `references/epistemics.md` for the full confidence framework and phrasing guide. The synthesizer must follow it. - -## Step 1. Understand the Target and the Question - -The **target** is usually a chunk of code, a pattern, a feature, or a named design decision. The **question** is usually a design rationale, a tradeoff, a motivating edge case, an external constraint, dead code, or a broad history sweep. - -If the target is vague ("why do we do it this way?" with no clear referent), make your best guess from conversation context (open files, recent edits, cursor location, what was just discussed). State your interpretation briefly so the user can redirect if you're off, then proceed. - -## Step 2. Establish the Code Anchor - -Before spawning investigators, build the seed context inline: file paths and line ranges, key symbols (functions, classes, constants), the last few commits touching the target, PR numbers from merge commits (pattern `(#1234)` in the subject line), and any linked ticket IDs. Run `git blame -L , ` for last-touch commits, `git log --follow -p -- ` for full history with patches through renames, `git log --oneline -20 -- ` for recent commits with PR numbers visible, and `git log -1 --format=%B ` to extract PR numbers. Then pull the PR bodies and discussion for any substantive commit: `gh pr view --json title,body,author,createdAt,mergedAt,labels,closingIssuesReferences,comments,reviews`. This anchor goes to every investigator and to the synthesizer. - -## Step 3. Spawn Parallel Investigators - -**Default to the full parallel investigation.** The goal is a complete coverage map, not a minimal one. Document the null, don't skip the search. - -### Discovery - -Before spawning investigators, list the available MCP tools with `search_tool`. Classify each connected server from its name, description, and tool schemas. - -Map each available MCP to one evidence category: - -1. Source control history -2. Issue / ticket tracker -3. Long-form documents -4. Real-time team chat -5. Infrastructure observability -6. Error / exception tracking -7. Product analytics warehouse - -Source control is always available through git and `gh`. For the other six, classify using the MCP name, server instructions, tool names, and resource descriptors. If an MCP could fit more than one category, choose the one matching its primary evidence. Record ambiguous cases in the coverage map. - -Spawn one investigator per category that has a matching MCP, all in a single message so they run concurrently, each owning exactly one tool or MCP. Don't ask one agent to cover multiple MCPs. `model`: the `why investigators` line, default `grok-4.6` at `xhigh`. - -Each investigator's prompt is `references/investigator-prompt.md` filled in, plus: -- the category playbook `references/sources/.md` for the selected MCP, adapted from the examples in `references/source-playbook.md` -- `references/sources/incident-postmortem.md` **if the target code looks defensive** (null checks, retry logic, timeout handling, rate limiting, feature flags, egress guards, OOM handlers) -- the code anchor and the user's original question - -### Investigator roster, one per available evidence category - -Each category below is uniquely positioned to surface one shape of "why", shown after "Best at". Use it to know what to expect back, to name a gap when a category returns empty, and, only in the rare provably-irrelevant case, to justify a skip. - -1. **Source control** (git history, `gh` for PRs, code comments, tests). Always spawn, the only guaranteed source. Best at *implementation-time rationale captured during review*. -2. **Issue / ticket tracker** (e.g. Linear, Jira, GitHub Issues, Plane, Shortcut MCP). Best at *the product or business forcing function*. Strongest when the why is external to engineering. -3. **Long-form documents** (e.g. Notion, Confluence, Google Docs, Coda MCP). Best at *long-form design rationale*, written out before it becomes code. -4. **Real-time team chat** (e.g. Slack, Discord, Microsoft Teams, Mattermost MCP). Best at *real-time deliberation that never reached a doc*. Especially important when the source control, ticket, and doc paper trail is thin. -5. **Infrastructure observability** (e.g. Datadog, New Relic, Honeycomb, Grafana, Splunk MCP). Best at *infrastructure and runtime reality that motivated the code*. Strongest when the target reacts to an infra signal (timeouts, retries, rate limits, circuit breakers). -6. **Error / exception tracking** (e.g. Sentry, Rollbar, Bugsnag, Airbrake MCP). Best at *the specific exceptions and error trajectories that motivated defensive or corrective code*. Strongest for catch blocks, null guards, type checks, retries, and other defenses. -7. **Product analytics warehouse** (e.g. Databricks, Snowflake, BigQuery, ClickHouse, dbt, Redshift MCP). Best at *product and data reality that shaped the code*. Strongest for flag-gated code, experiment-driven ships, data migrations, and "where did this number come from" questions. - -### When to skip an investigator - -Only with an **explicit, written justification** that goes in the final Sources Consulted. Two valid reasons: - -- **No MCP is available for that category** in this environment. Flag it as a gap, not a choice: "Real-time team chat skipped. No matching MCP available, so the conversational record was not searchable." -- **The source is provably irrelevant**, not just "probably irrelevant." A high bar: "Error / exception tracking skipped. Target is a build-time script with no runtime code path." - -If your scope assessment suggests a single-commit trivial target where the PR description already contains the complete answer, you may answer inline **only after** confirming all seven available category searches would be redundant. Say so explicitly. This should be rare. - -## Step 4. Synthesize - -Spawn one synthesizer. `model`: the `why synthesizer` line, default `grok-4.6` at `xhigh`. It gets: -1. The investigator findings, including any null results and any categories skipped with justification -2. The code anchor -3. The user's original question -4. The epistemics framework from `references/epistemics.md` -5. The synthesizer prompt template from `references/synthesizer-prompt.md` - -## Step 5. Present - -Present the synthesizer's output to the user. You may lightly edit for clarity or add context from the conversation, but **do not rewrite the confidence language**. - -## Output Format - -The structure is the one in `references/synthesizer-prompt.md`: The Question, The Code in Question, What We Found, What We Can Reasonably Infer, Competing Hypotheses, What We Don't Know, Sources Consulted, Confidence Summary. Adapt as needed, but keep the confidence separation intact, and keep Sources Consulted as one line per investigator, including the ones that returned nothing or were skipped, with the reason. - -After Sources Consulted, if the user's `why` question is a precursor to changing this code, convert the lineage findings into a Preserve / Change / Avoid / Risk constraint set for planning the change. - -## Common Failure Modes to Avoid - -- **Recency bias**. Assuming the most recent commit is authoritative. The current shape is often the accretion of many earlier decisions. Trace back. +Answer from the record, not the code: read the commits and PR discussions that introduced the target and each later change, and other sources if the trail is thin. Cite what the authors wrote, mark your own inferences as inferences, and say what the record does not answer. diff --git a/skills/why/references/epistemics.md b/skills/why/references/epistemics.md deleted file mode 100644 index b18abf4..0000000 --- a/skills/why/references/epistemics.md +++ /dev/null @@ -1,71 +0,0 @@ -# Epistemics - -How to reason about confidence when evidence is historical, fragmentary, and sometimes contradictory, and how to tell the user without flattening it into false certainty. Code shows what it does, not *why it exists*. The why lives in commits, PRs, tickets, docs, and conversations, all incomplete, biased, and sometimes missing. Pretending otherwise produces confident-sounding guesses that mislead the user. - -## Confidence Tiers - -Every claim in the output must sit in one tier. The tier sets its section and its phrasing. - -### 1. Direct - -An explicit, textual citation answers the question: something an author actually *wrote* that says why, not "the code does X so the author must have wanted X." For example, a PR description "this fixes the bug where users with >1000 items couldn't paginate", a ticket "we're adding this because customer Acme requested it in their security review", a code comment "// clamp to 100 because the upstream API rejects larger values", a design doc "we chose option A over option B because we need persistence across restarts", or a chat message from the author "switching to this approach since the old one was flaky in tests". - -Phrasing: confident, present tense, cited. "This exists because X." - -### 2. Supported - -Multiple pieces of indirect evidence converge on one conclusion. No single source states it explicitly, but the pattern across sources makes it likely. For example, the PR title says "improve performance", the ticket is labeled "perf", and the surrounding commits all touch the same hot path. Or several tests added with the change all exercise very large inputs. Or the author's other PRs from the same week all name the same incident. - -Phrasing: confident but clearly derived, citing each item. "The evidence points strongly to X: [the specific pieces]." - -### 3. Inferred - -A reasonable reading of the context that nothing explicitly supports. It is *your interpretation*, not a fact from the record. For example, the PR doesn't say why, but the error was happening in production (per the incident channel timing) and the fix was rushed (merged the same day), so it was likely a hotfix. Or the function name suggests retry logic, and its retry count of 3 matches the team's 3-retry convention elsewhere in the codebase. - -Phrasing: hedged, with the chain explicit. "Given A and B, C seems likely because D." - -### 4. Speculative - -A plausible hypothesis on thin evidence, where other explanations fit equally well. Worth presenting, since the user may know which is right, but mark it as a guess. For example, "This might be a workaround for a browser bug that's since been fixed, but we found no contemporary evidence of that", or "It's possible this threshold was chosen to match an SLA commitment, but no SLA doc references it." - -Phrasing: "One possibility is X, but we have no direct evidence." Usually lives in Competing Hypotheses, alongside other possibilities. - -### 5. Unknown - -You looked and couldn't find out. A valid, important outcome. Document it. - -Phrasing: "We searched X, Y, and Z and found no evidence of why." Be specific about *what* you searched. "We couldn't find out" is less useful than "We searched the ticket tracker with keywords A and B, scanned the 6 PRs that touched this file since 2023, and grep'd the repo for string literals matching the threshold. None surfaced a rationale." - -## Phrasing Guide - -**Confidence words** imply Direct or Supported evidence and need a citation immediately adjacent. Never use them for inferences: "because", "the reason is", "was designed to" (claims author intent), "fixes" / "addresses" / "solves" (claims the change achieved its goal), "the team decided" (claims a group decision happened). - -**Hedges** signal interpretation, not report. Use them liberally in What We Can Reasonably Infer: "appears to", "seems to", "likely", "suggests", "is consistent with", "one reading is", "plausibly", "may have been", "the evidence points toward". - -**Words to avoid:** - -- "obviously". If it were obvious, the user wouldn't be asking -- "clearly". Almost always precedes a claim that isn't clear -- "of course". Same -- "just" (as in "it's just X for performance"). Dismissive and usually hides uncertainty -- "I think" / "I believe". You're synthesizing evidence, not giving a personal opinion. Use "the evidence suggests" instead. - -## Avoid Rationalization - -Code that "makes sense" today may have been written for reasons that no longer apply, or that were wrong at the time. Don't retrofit a clean rationale onto messy history. Don't assume the author did the "right" thing and work backward to justify it. Don't assume a consistent pattern was intentional when it might be copy-paste. Don't turn an absence of evidence into evidence of absence ("no one mentioned security concerns, so it must not have been a concern"). - -## The Sycophancy Trap - -Users often embed a hypothesis: "Why do we do it this way, I assume it's for performance?" Don't simply confirm it. The guess is a prompt for investigation, not a conclusion to validate. Treat it as one candidate among others and check the evidence independently. If the evidence supports it, say so with citations. If not, say so, and present what the evidence *does* support. - -## When Evidence Contradicts - -Surface both sources in the output, with citations. Don't pick the one that fits a tidier narrative. For example, the ticket says "we need this for customer X's compliance requirement" and the PR says "cleaning up tech debt in this area". Both may be true (the ticket motivated the work, the PR gave the author's framing), or one may be wrong. Let the user make the call. - -## When Evidence Is Missing - -An honest "we don't know" is one of the most valuable outputs. The user learns the answer isn't in the obvious places, that they'll need to ask a human (the original author, the product owner, the team lead), or that they can decide the question isn't worth pursuing further. Failing to mark a gap, and instead filling it with a confident guess, actively harms the user, because they'll act on the guess. Name each gap concretely: the question, the sources searched, what you searched for in each, and what you found (nothing, or only tangential material). - -## Before Finalizing - -Before the synthesizer delivers the output, it checks every claim in "What We Found" and "What We Can Reasonably Infer". Each claim has a citation or moves to Inferred or Hypotheses. Its phrasing matches its tier. It doesn't treat code as evidence for its own intent (if it does, remove or reclassify it). The output has a "What We Don't Know" section. If no gaps are mentioned, that's suspicious. Either the evidence was unusually complete or something is being swept under the rug. diff --git a/skills/why/references/investigator-prompt.md b/skills/why/references/investigator-prompt.md deleted file mode 100644 index e1c2bbf..0000000 --- a/skills/why/references/investigator-prompt.md +++ /dev/null @@ -1,84 +0,0 @@ -# Investigator Prompt Template - -Fill in the placeholders. Append the one category playbook `sources/.md` for this investigator's evidence category (index: `source-playbook.md`). If the target code looks defensive (null checks, retry logic, timeout handling, rate limiting, feature flags, egress guards, OOM handlers), also append `sources/incident-postmortem.md` so the investigator runs incident-flavored queries inside its own source. - ---- - -You are investigating the historical context and motivation behind a piece of code. Other investigators search other sources in parallel, and a separate synthesizer combines all findings into the final answer. Go deep on your assigned source only. Gather evidence accurately rather than writing prose. - -Work like a **careful, cautious, and precise investigator**. Surface evidence and describe it accurately, including the parts that don't fit a tidy story. Boring and exact beats plausible. One verbatim quote with a precise citation is worth more than a paragraph of summary. - -## The Question - -> {QUESTION} - -## The Code Anchor - -**Target files:** {FILES_WITH_LINE_RANGES} - -**Key symbols:** {SYMBOLS} - -**Initial commits touching this code (most recent first):** -{COMMIT_LIST} - -**PR numbers extracted from commit messages:** {PR_NUMBERS} - -**Ticket IDs mentioned in commits or PR bodies (if any):** {TICKET_IDS} - -## Your Assigned Source - -{SOURCE_NAME} - -{SOURCE_PLAYBOOK_SECTION} - -## Investigation Loop - -1. **Cast a wide net first** so you don't miss related context. Only then narrow in on specific items. -2. **Read the whole thing.** Read each PR, ticket, doc, or thread fully, not just the title or summary. The key evidence is often in a comment, a subtask, or a follow-up. -3. **Follow links within your source only.** Pull the PR or commit a PR references, the parent or sibling of a ticket, the doc a doc links. Do NOT chase a cross-source reference. Record it under Additional Leads for that source's investigator. The one-investigator-per-category design depends on this. Chasing it duplicates work and confuses scope. -4. **Quote verbatim**, with the exact location (PR number, ticket ID, URL, commit hash, file:line), so the reader can confirm the claim in seconds. -5. **Record what you searched, not just what you found.** Write queries verbatim. An empty search is a finding. -6. **Resist the story.** If two items in your source disagree, record both. Don't suppress the inconvenient one. If three items line up and a fourth contradicts them, the contradiction is the most interesting finding. - -Before reporting a finding as strong, ask whether you would expect to find it if your current reading were wrong, and how the evidence would differ. **Never invent.** If you're tempted to round a partial finding up into a confident statement, stop and label it partial. The synthesizer counts on your output being accurate. - -## Epistemic Discipline - -- **Mechanics are not motivation.** A commit changing `limit = 50` to `limit = 100` shows the change, not necessarily why. Look for the reason in the commit message, PR description, linked ticket, or review comments. -- **No intent from code behavior or style.** You may read code to learn what the target *is*. "The author chose a functional approach" is an observation about code, not evidence of intent. Claim intent only where the author stated it. -- **Preserve uncertainty.** Say when evidence is ambiguous, or when one reading is more plausible but not certain. Don't collapse ambiguity to look decisive. -- **No silent substitutions.** If the question is about feature X and you only find evidence about feature Y, don't present Y's evidence as if it answers X. -- **Gather, don't conclude.** Collect the raw material honestly and completely. Don't answer the question, form a final opinion on "the why", or pick sides in contradictions. Don't speculate beyond what the evidence supports. A hunch with no evidence isn't evidence. The synthesizer does the reasoning. - -## Output Format - -Return your findings in this structure. The synthesizer reads it directly. - -### Source -Which source you investigated (source control, issue / ticket tracker, long-form documents, real-time team chat, infrastructure observability, error / exception tracking, product analytics warehouse, code comments, etc.). - -### What I Searched -The queries you ran, items you opened, and places you looked. Be specific. This shows how thorough the search was and what is still unsearched. - -### Direct Evidence Found -For each item that explicitly addresses the question: -- **What it says**: verbatim quote or accurate paraphrase -- **Where it's from**: PR #123, ticket ID, doc URL, chat permalink, commit hash, or file:line -- **Author and date** (if available) -- **Relevance**: one sentence on how it bears on the question - -### Indirect / Circumstantial Evidence -For each item that bears on the question without answering it: -- **What it is**: brief description -- **Where it's from**: location -- **What it suggests**: what a careful reader might infer, and the inference chain -- **Alternative readings**: if the same evidence could support a different interpretation, note it - -### Contradictions -Items that disagree with each other, with both citations. - -### Gaps -What you searched for and didn't find, specifically: "Searched the issue tracker for [query] across [time range]. No matching issues." - -### Additional Leads -Anything that suggests further investigation in a different source, for its investigator or a follow-up pass. For example, a chat thread that a PR mentions. diff --git a/skills/why/references/source-playbook.md b/skills/why/references/source-playbook.md deleted file mode 100644 index aa3d877..0000000 --- a/skills/why/references/source-playbook.md +++ /dev/null @@ -1,17 +0,0 @@ -# Source playbooks - -The why skill spawns one investigator per available evidence category, each reading a single source-specific playbook below. The playbooks are concrete examples for common MCPs. Adapt them for a different MCP in the same category. - -| Category | Playbook | Example MCP it documents | -|---|---|---| -| Source control history | [`code-archaeology.md`](./sources/code-archaeology.md) | git, `gh` | -| Issue / ticket tracker | [`linear.md`](./sources/linear.md) | Linear (adapt for Jira, GitHub Issues, Plane, Shortcut) | -| Long-form documents | [`notion.md`](./sources/notion.md) | Notion (adapt for Confluence, Google Docs, Coda) | -| Real-time team chat | [`slack.md`](./sources/slack.md) | Slack (adapt for Discord, Microsoft Teams, Mattermost) | -| Infrastructure observability | [`datadog.md`](./sources/datadog.md) | Datadog (adapt for New Relic, Honeycomb, Grafana, Splunk) | -| Error / exception tracking | [`sentry.md`](./sources/sentry.md) | Sentry (adapt for Rollbar, Bugsnag, Airbrake) | -| Product analytics warehouse | [`databricks.md`](./sources/databricks.md) | Databricks SQL (adapt for Snowflake, BigQuery, ClickHouse, dbt) | - -Cross-cutting: - -- [`incident-postmortem.md`](./sources/incident-postmortem.md). Add this if the target code looks defensive (null checks, retry, timeout, rate limit, feature flag, egress guard, OOM handler). diff --git a/skills/why/references/sources/code-archaeology.md b/skills/why/references/sources/code-archaeology.md deleted file mode 100644 index e3555f8..0000000 --- a/skills/why/references/sources/code-archaeology.md +++ /dev/null @@ -1,51 +0,0 @@ -# Code Archaeology (git + in-repo) - -## What this source contains - -- Commit history (messages, dates, authors, diffs) -- PR descriptions, review comments, and discussion threads (via `gh`) -- Inline code comments, TODOs, FIXMEs, deprecation notes -- ADRs (architectural decision records) if the repo keeps them -- Tests, whose names and assertions often encode the edge cases that motivated a change -- Related files modified in the same commits (co-change signal) -- CHANGELOG entries and release notes in the repo -- Issue/ticket IDs in commit messages and PR bodies - -The most trustworthy source, tied directly to the code, and the most complete. Everything that went through the repo should be here. - -## How to search it - -Expand the seed commit list: - -```bash -# History through renames -git log --follow --oneline -- - -# Pickaxe: commits that added or removed this exact text -git log -S '' -- - -# Or for patterns: -git log -G '' -- - -# Who wrote each line and when -git blame -L , - -# One commit's full diff -git show - -# Commits between two points affecting this file -git log .. -p -- -``` - -Look for out-of-band docs: - -```bash -# ADRs often live in docs/adr/ or similar -rg -l -i 'architecture.decision' --glob '*.md' - -# TODOs and FIXMEs near the target -rg -n -C2 '(TODO|FIXME|HACK|XXX|NOTE)' - -# Related tests -rg -l '' --glob '*test*' -``` diff --git a/skills/why/references/sources/databricks.md b/skills/why/references/sources/databricks.md deleted file mode 100644 index 2770763..0000000 --- a/skills/why/references/sources/databricks.md +++ /dev/null @@ -1,70 +0,0 @@ -# Databricks Analytics & System Tables - -## What this source contains - -Databricks is the product-analytics, data-pipeline, and warehouse-telemetry layer. It complements Datadog. Datadog is the *infra/runtime* view, Databricks is the *product/data* view (what users did, which experiments ran, how feature usage evolved, where a threshold constant came from). - -- **Product analytics events.** `your_warehouse.events.analytics_track_event` (raw) and typed, deduplicated per-event dbt models in `..`. User behavior: feature invocations, clicks, accepts/rejects, submissions, client-reported errors. -- **Usage & billing events.** `your_warehouse.events.usage_event` / `..stg_usage_events`, `your_warehouse.events.raw_model_event` / `..stg_raw_model_events`. For cost- or volume-driven decisions. -- **Experiment / feature-flag data.** Exposure and outcome tables. **Schema is company-specific.** Probe with `SHOW TABLES` before assuming names. -- **System tables.** `system.query.history`, `system.compute.warehouses`, `system.billing.*`, `system.access.audit`. Answer "was this query expensive?", "how often did anyone run this?", "when did warehouse load spike?" -- **dbt lineage.** Models in `.` reveal what pipelines depend on a table/field. Upstream changes frequently motivate consumer-code changes. -- **Databricks notebooks.** Exploratory analyses engineers wrote before code changes. **Not queryable via the SQL MCP.** If you suspect the rationale lives in a notebook, name it as a gap. - -## How to search it - -Use the Databricks SQL MCP. Primary tool: `execute_sql_read_only`. If it returns a `statement_id`, poll with `poll_sql_result` rather than re-running. - -**Orient before querying.** Schemas are company-specific. Probe before trusting a table name: - -```sql -SHOW TABLES IN . LIKE '**'; -DESCRIBE TABLE ..stg_; -``` - -**Time-bound every query.** These tables are huge and unconstrained scans time out. Filter on `_timestamp` (events) or `start_time` (`system.query.history`) with a window bracketing the ship date, typically ~30 days before and after, wider only for strong reason. - -**Prefer typed dbt models over the raw table.** `..
` is deduplicated, typed, and liquid-clustered. `your_warehouse.events.analytics_track_event` has duplicates and untyped `properties_json`. Model-name pattern: `stg__`, where `` is `app`, `backend`, `website`, or `cli`. Confirm the exact model name with `SHOW TABLES` when the pattern alone doesn't resolve it. Drop to the raw table only when there's no dbt model yet, or you need events from inside the dbt refresh lag. - -**Column conventions on the typed dbt models** (knowing these avoids a `DESCRIBE` round-trip): - -- `_timestamp`, `_id`, `_auth_id`, `_request_id`, `event_name`. Standard on every model -- `properties_`. Typed, underscore-cased event properties (`properties_entrypoint`, `properties_size_bytes`, …) -- `context_team_id`, `context_client_version`, `context_country`, `context_client_os`. Pre-extracted client context - -### Investigation patterns that tend to pay off - -Pick the table + column combination that matches the target: - -1. **Event usage trajectory.** Daily counts on the relevant `stg_*` model across a ±30d window around the PR merge. A step function from zero to steady volume within a day or two of the merge is strong circumstantial evidence the PR launched the feature. A decay to zero suggests a deprecation or deletion. -2. **Guard-rail / defensive-check origin.** Distribution (median / p99 / max) of the relevant `properties_` column in the 14 days *before* the PR. A p99 that matches the target's threshold constant suggests the number was chosen from data. -3. **Experiment / feature-flag lookup.** `SHOW TABLES ... LIKE '*experiment*'` to find the exposure table, then pull exposure counts by variant for the relevant flag key near the PR date. -4. **Query-history evidence for migrations, backfills, or perf rewrites.** `system.query.history` filtered by `statement_text ILIKE '%%'` with a tight `start_time` window surfaces the expensive queries that likely motivated the change (sort by `total_duration_ms` or aggregate `SUM(read_bytes)`, `COUNT(*)`). -5. **dbt lineage.** If the target reads from or writes into a `.` model, the model's own git history (in this repo) often carries the rationale. Hand that lead back to the git investigator rather than chasing it yourself. - -## What good evidence looks like here - -Beyond the pattern shapes above: - -- An error-classifying event's count drops to near zero in the days after a defensive-code PR. Suggests the PR resolved that error class -- An exposure table row names the target's feature-flag key with a "shipped" / "concluded" decision around the PR ship date - -## Common pitfalls - -- **Instrumented ≠ caused.** An event's existence means someone cared enough to log it, not that the target code exists *because* of it. Pair with a PR/commit citation from the git investigator before claiming causation. -- **Silent instrumentation changes.** A step function in event volume may mean a new event started being logged, not that user behavior changed. Check for instrumentation PRs in the same window before reading the ramp as a feature-launch signal. -- **Schema drift.** Event properties evolve. A column on the typed dbt model today may not have existed when the target was written. Older data may carry the property only inside raw `properties_json`. -- **dbt refresh lag.** `..*` is rebuilt on a schedule (often hourly/daily). For events from the last few hours, fall back to `your_warehouse.events.*` and deduplicate by `_id`. -- **Company-specific tables.** Experiment, feature-flag, billing, and usage tables vary. Reporting a result from a table whose existence you never confirmed is a classic failure mode. Probe with `SHOW TABLES` / `DESCRIBE TABLE` first. -- **Retention cliff.** If the relevant window predates the table's retention or the dbt model's creation date, that's a *gap*, not a null result. Name it explicitly so the synthesizer doesn't read "no results" as "no activity." -- **Notebooks aren't queryable.** The SQL MCP can't see Databricks notebooks. If you suspect the rationale lives in one, return a gap. - -## What to return - -For each relevant finding: -- Type (product event / experiment exposure / usage or billing event / system-table row / dbt model) -- Fully-qualified table name and the exact query you ran -- Time window queried -- Compact numeric summary (counts, percentiles, first/last-seen timestamps). **Don't dump raw rows.** -- Temporal correlation with the target's ship date (e.g., "first row 2024-08-15, PR #49074 merged 2024-08-14") -- Relevance + strength: direct / circumstantial / weak diff --git a/skills/why/references/sources/datadog.md b/skills/why/references/sources/datadog.md deleted file mode 100644 index 536466d..0000000 --- a/skills/why/references/sources/datadog.md +++ /dev/null @@ -1,97 +0,0 @@ -# Datadog Telemetry - -## What this source contains - -Datadog holds the runtime record, what actually happened in production, as opposed to what was planned or discussed. - -- **Metrics.** Counters, gauges, histograms instrumented by the team. A metric's *presence* is itself evidence that someone thought the number worth watching. -- **Monitors & alerts.** Conditions the team decided warranted waking someone up. A monitor firing on `rate_limit_hit > 10/min` is direct evidence the team worried about that threshold. -- **Dashboards.** Curated views of what the team considers important for a subsystem. -- **APM traces & spans.** Request-level runtime data, for "why is this slow" / "why is there a timeout here" questions. -- **Logs.** High-volume event records, often holding the error conditions that motivated defensive code. -- **Incidents.** Formal incident records with timelines and linked postmortems. -- **Notebooks.** The team's exploratory investigations, often with hypotheses and analyses. - -## How to search it - -Use the Datadog MCP. Start broad, then narrow. - -1. **Identify the owning service(s).** - - ``` - search_datadog_services (filter by name or team) - search_datadog_service_dependencies (see upstream/downstream) - ``` - -2. **Dashboards and monitors first.** - - ``` - search_datadog_dashboards (query: feature name, service name, symbol) - search_datadog_monitors (same queries) - ``` - - When a dashboard or monitor covers the target, note its queries and watched thresholds. The threshold is frequently the answer to "why is this clamped at N?" - -3. **Metrics around the target.** - - ``` - search_datadog_metrics (by name pattern, e.g., the feature or symbol) - get_datadog_metric_context (metadata: description, units, tags) - get_datadog_metric (timeseries; "was there a spike around the PR date?") - ``` - - Correlating a metric's trajectory with the target's add/change date is strong supporting evidence: "the `payment_timeout` metric spiked 2023-11-03, and the retry logic merged 2023-11-06." - -4. **Logs. Narrow, don't dump.** - - ``` - search_datadog_logs (raw log patterns near the target, set use_log_patterns=true) - analyze_datadog_logs (SQL-style aggregations, only when you need counts) - ``` - - Search with symbols, error strings, or feature names. **Strongly prefer time-bounded queries** (e.g., 30 days before/after the change). - -5. **APM spans and traces.** - - ``` - aggregate_spans (stats: "how often does this endpoint fail?") - search_datadog_spans (inspect individual spans) - get_datadog_trace (a specific trace ID) - ``` - - Useful for timeouts, retries, slow paths, and cross-service behavior. - -6. **Incidents.** - - ``` - search_datadog_incidents (by title, team, date range) - get_datadog_incident (full detail for a specific incident) - ``` - - If the target looks defensive, search for incidents around the time it was added. An incident whose timeline includes "added defensive check for X" is near-direct evidence. - -## What good evidence looks like here - -- A monitor whose query and threshold match the constraint the code enforces (code clamps to 100, monitor alerts when requests exceed 100/min) -- A dashboard created by the target's author, with widgets that correspond to what the code measures or guards against -- A metric showing a production spike immediately before the code was merged, and stable values after -- An incident record referencing the target code, the same symbols, or the same error strings -- Logs showing a specific error pattern the defensive code would prevent, timestamped in the window before the change - -## Common pitfalls - -- **Correlation is not causation.** A spike before a PR and stabilization after is suggestive, not definitive, since other changes may have landed in the same window. Check neighboring PRs. -- **Overfitting to the chart you found.** A chart reflects its maker's framing. A chart named "retry success rate" is evidence the team cared about retry success, not that it's why a specific line of code exists. -- **Vanished telemetry.** Metrics can be renamed, deleted, or have short retention. If you can't find data from the relevant window, that's a gap, not a null result. -- **Noise at scale.** Narrow log searches by service, tag, and time window aggressively. Use `analyze_datadog_logs` to aggregate rather than dumping raw logs. -- **Instrumented != caused.** A metric shows someone cared enough to measure something, not that the code was added *because* of it. Cross-reference with commit/PR dates. - -## What to return - -For each relevant item: -- Type (dashboard / monitor / metric / log pattern / trace / incident / notebook) -- Title or name -- Link or identifier (dashboard ID, monitor ID, metric name, incident ID) -- Owner/author and created/modified date -- The specific condition, query, or quote that bears on the question (verbatim where possible) -- Relevance: what this suggests about the target code, and how strong the connection is diff --git a/skills/why/references/sources/incident-postmortem.md b/skills/why/references/sources/incident-postmortem.md deleted file mode 100644 index e7397e7..0000000 --- a/skills/why/references/sources/incident-postmortem.md +++ /dev/null @@ -1,5 +0,0 @@ -# Incident & Postmortem Context - -- **Linear**: look for tickets labeled `incident`, `sev-*`, `postmortem-action-item`, `reliability` -- **Slack**: search `#sev-*` and `#incident-*` channels around the dates the target code was added -- **Git**: commits with messages like "fix for incident", "add defensive check", "revert" followed by "re-apply with..." are strong signals diff --git a/skills/why/references/sources/linear.md b/skills/why/references/sources/linear.md deleted file mode 100644 index 899c643..0000000 --- a/skills/why/references/sources/linear.md +++ /dev/null @@ -1,48 +0,0 @@ -# Linear Tickets - -## What this source contains - -- Issues describing features, bugs, and their motivation -- Project docs attached to issues (often PRDs or specs) -- Parent/sub-issue relationships (broader initiative → specific tickets) -- Comments on issues (clarifications, scope changes, "why we're doing this" rationale) -- Labels (e.g., `compliance`, `customer-request`, `perf`) that signal the type of motivation -- Status updates that explain scope changes -- Attachments and linked GitHub PRs - -Linear is where the product/business context often lives: the "we're doing this because customer X asked" or "this is for the Q3 compliance initiative" layer. - -## How to search it - -Use the Linear MCP. - -1. **Start with linked tickets.** If the seed commits or PRs reference ticket IDs (e.g., `ENG-1234`, `[BUG-567]`), fetch those first with `get_issue`. Read the full issue including comments. -2. **List related issues by keyword.** Use `list_issues` with text search for the feature name, key symbol, or business term. Try multiple phrasings. -3. **Walk the issue tree.** If you land on a sub-issue, fetch its parent. Sub-issues are tactical. Parents often carry the "why." -4. **Read project docs.** If the issue belongs to a project, use `get_project` and check attached docs. Project-level documents are where specs and rationale are most often captured. -5. **Check labels and milestones.** Labels hint at the category of motivation (customer-request, incident-followup, compliance). Milestones tie work to deadlines, which often reveal motivation. - -## What good evidence looks like here - -- An issue description stating the business problem: "Customer Acme needs X because of their SOC2 audit" -- A comment recording a decision: "We decided to go with approach B because approach A would require touching the billing service" -- A parent issue titled like an initiative: "Q3 Enterprise Readiness" or "Reduce Payment Failures" -- An attached PRD or spec -- Labels like `customer:acme`, `incident-followup`, `compliance`, `perf-regression` - -## Common pitfalls - -- **Scope drift.** The ticket the PR references may have been closed and reopened with a different scope. Read the whole history. -- **Mechanical templates.** Some teams require "Why" sections but fill them with boilerplate. Generic text ("improve user experience") is probably not a real answer. -- **Stale tickets.** Old tickets often reflect a version of the plan that changed. Check dates and cross-reference with the code's ship date. -- **Closed-as-duplicate chains.** Follow the duplicate-of relationships back to the canonical ticket. -- **Private workspace content.** If you can't access an issue, note that as a gap rather than guessing. - -## What to return - -For each relevant ticket: -- Ticket ID and title -- The problem/motivation quoted from the description or comments (not paraphrased. The synthesizer needs the exact text to cite) -- Labels, parent issue, project -- Author, created date, closed date -- Link to the ticket if available diff --git a/skills/why/references/sources/notion.md b/skills/why/references/sources/notion.md deleted file mode 100644 index d16230a..0000000 --- a/skills/why/references/sources/notion.md +++ /dev/null @@ -1,55 +0,0 @@ -# Notion Docs - -## What this source contains - -- PRDs (product requirement documents) -- Technical specs and RFCs -- Architectural decision records (ADRs) -- Meeting notes from design reviews -- Team pages with domain context -- Postmortems from incidents -- Runbooks that may explain defensive code -- Strategy documents that set priorities - -Notion is where "why" often lives in long-form before it becomes code. A significant feature usually has a doc. - -## How to search it - -Use the Notion MCP. - -1. **Keyword searches with `notion-search`.** Try: - - The feature name - - Key symbols / class names from the target code - - Author handles (design docs are often authored before the code lands) - - Error strings or user-visible terms - - Time-bounded queries if you know when the code shipped -2. **Fetch candidate pages with `notion-fetch`.** Read the full content, not the preview. Rationale is often buried mid-document. -3. **Follow backlinks and child pages.** Design docs often have sub-pages for alternatives considered, appendices, or implementation notes. -4. **Check related databases.** `notion-query-data-sources` and `notion-query-meeting-notes` can surface meeting notes that discussed the decision. -5. **Search author-specific spaces.** If the PR author has a personal notebook (common at some companies), it may hold exploratory thinking that preceded the code. - -## What good evidence looks like here - -- A PRD with a "Problem statement" or "Motivation" section that matches the target code's purpose -- An "Alternatives considered" or "Rejected approaches" section -- A postmortem that names the target code as the fix for a specific incident -- Meeting notes that record "we decided X because Y" and tie to the same author/date range as the PR -- An ADR template filled out non-trivially (status, context, decision, consequences) - -## Common pitfalls - -- **Outdated docs.** Specs are often written before implementation and not updated. The doc may describe a plan that changed. Cross-check against the actual PR. -- **Doc vs. reality drift.** A spec may say "we'll do X" but the code actually does Y. Flag the divergence. The synthesizer will surface the contradiction. -- **Boilerplate templates.** Some orgs require a "Why" section that gets filled with fluff. Look for specificity. -- **Unlinked docs.** The most relevant doc may not be linked from anywhere. Broad keyword searches help. -- **Multiple drafts.** If a topic has multiple docs, find the one that was finalized or most recently updated. Check dates. -- **Access-restricted pages.** If you can't access a page, note it as a gap. - -## What to return - -For each relevant doc: -- Title and URL -- Authors and last-updated date -- The motivation text (verbatim quote), with page/section location -- Relevant linked pages (so the synthesizer can cite them) -- Whether the doc was finalized or draft diff --git a/skills/why/references/sources/sentry.md b/skills/why/references/sources/sentry.md deleted file mode 100644 index 8200fd9..0000000 --- a/skills/why/references/sources/sentry.md +++ /dev/null @@ -1,66 +0,0 @@ -# Sentry Error History - -## How to search it - -Use the Sentry MCP. - -1. **Orient.** If you don't know the project slug and organization: - - ``` - find_organizations - find_projects - ``` - -2. **Search for issues related to the target.** - - ``` - search_issues (natural language, e.g., "errors in PaymentService timeout", "unhandled exceptions in uploadFile") - ``` - - Build queries from the exception class names the target handles, its function or class name, the error message strings it checks for, and its file path. - -3. **Narrow by release and time window.** - - ``` - search_issue_events (filter by release, time, environment, trace ID, tags) - get_issue_tag_values (for an issue, see distribution across versions, users, environments) - ``` - - For a suspected issue, check **first seen** and **last seen** (does the stop line up with the target's ship date?), the **affected releases** (which saw it, and which was the fix?), and the **frequency trajectory** (did it spike, then get resolved?). - -4. **Pull the full event for context.** - - ``` - get_sentry_resource (pass a Sentry URL or type+ID) - ``` - - Does the stack trace pass through the target code? Do the tags and breadcrumbs match the conditions the target defends against? - -5. **Check releases that landed near the target.** - - ``` - find_releases (around the commit date of the target) - ``` - - Cross-reference release version with the PR's merge date. - -6. **Use Seer sparingly.** - - ``` - analyze_issue_with_seer - ``` - - Seer's AI root-cause analyses are a hypothesis generator. Treat them as inference, not authoritative. The actual events and stack traces are the primary evidence. - -## What to return - -For each relevant issue: -- Issue ID and title -- Project and organization -- First seen / last seen timestamps -- Event count (and sampling rate if known) -- Affected releases -- A representative stack trace snippet showing relevance to the target (verbatim excerpt, not summary) -- First/last-seen correlation with the target's ship date -- Link to the issue -- Any author comments or resolution notes diff --git a/skills/why/references/sources/slack.md b/skills/why/references/sources/slack.md deleted file mode 100644 index cadd561..0000000 --- a/skills/why/references/sources/slack.md +++ /dev/null @@ -1,17 +0,0 @@ -# Slack Conversations - -## How to search it - -Slack MCP tools vary. Check which Slack MCP is available and inspect its tool schema first. It may require `mcp_auth`. If authentication fails, stop and report the gap. - -1. **Author-bounded search.** Messages from the PR author around the PR merge date. Limits scope dramatically and often hits gold. -3. **PR URL search.** Slack often links PRs when they're reviewed or discussed. Search for the PR URL (or just `/pull/`). -4. **Error string search.** If the code handles a specific error, search for the error string. Incident threads often surface. - -## Common pitfalls - -- **Channel archaeology limits.** Very old messages may be gone due to retention policies. If you can't find anything before a certain date, note the retention cliff. -- **Unsearched DMs.** Many decisions happen in DMs that aren't searchable. You'll miss them. That's a known limitation. -- **Speculative jokes as "decisions."** Slack is casual. "Lol just do the thing" isn't a decision, even if it preceded the commit. Look for considered discussion. -- **Context collapse in single messages.** Without the thread, a single message often reads differently than in context. Always fetch threads. -- **Auth failures.** If the MCP isn't authenticated, stop. Don't make up findings. Report that Slack wasn't searchable. diff --git a/skills/why/references/synthesizer-prompt.md b/skills/why/references/synthesizer-prompt.md deleted file mode 100644 index 287a350..0000000 --- a/skills/why/references/synthesizer-prompt.md +++ /dev/null @@ -1,129 +0,0 @@ -# Synthesizer Prompt Template - -Fill in the placeholders. - ---- - -You are answering a "why" question about a piece of code by synthesizing findings from investigators who searched different historical sources (source control, issue / ticket tracker, long-form documents, real-time team chat, infrastructure observability, error / exception tracking, product analytics warehouse, and code comments). Produce a confidence-weighted, evidence-cited narrative that says honestly what the evidence supports, and just as honestly what it doesn't. - -## The Question - -> {QUESTION} - -## The Code Anchor - -**Target files:** {FILES_WITH_LINE_RANGES} - -**Key symbols:** {SYMBOLS} - -## Investigator Findings - -{ALL_INVESTIGATOR_FINDINGS} - -## Sources That Weren't Searched - -{SKIPPED_SOURCES_WITH_REASONS} - -## Epistemics Framework - -You MUST follow `references/epistemics.md`. Read it in full before writing. The key rules: - -1. Every claim must sit in one tier: **Direct**, **Supported**, **Inferred**, **Speculative**, **Unknown**. The tier sets its section and its phrasing. -2. Every Direct/Supported claim must have a citation (PR #, ticket ID, doc URL, chat permalink, commit hash, or file:line). -3. Inferred and Speculative claims must use hedged language ("appears to", "likely", "suggests", "one possibility is"). -4. Never cite code as evidence for its own intent. -5. Document gaps. Don't fill them with plausible-sounding guesses. -6. Treat a hypothesis embedded in the user's question as a candidate, not a conclusion. Check it independently. - -## Instructions - -1. **Read all investigator findings** and weigh the evidence yourself. Investigators gathered raw evidence, not conclusions. -2. **Merge overlaps.** When several investigators cite the same PR, ticket, or doc, give it one authoritative reference. -3. **Surface contradictions.** When two items disagree, show both. Don't pick one. -4. **Calibrate each claim.** Find its evidence and tier. Direct: cite it and state it plainly. Inferred: hedge it and show the inference. Speculative: mark it. No evidence: put it in the gaps. -5. **Verify citations by spot-checking.** If you're uncertain a cited item exists or says what the investigator claims, check it by reading the codebase or calling MCP tools. Don't propagate errors. Do not write files, commit, or modify external state. -6. **Don't overreach.** The user will act on this. Leave an open question open rather than fill it with a confident guess. - -## Output Format - -Write for the user, in this exact structure: - ---- - -### The Question - -Restate the user's question in one or two sentences. - -### The Code in Question - -File paths, line ranges, key symbols. Two or three lines to orient a cold reader. - -### What We Found - -Claims with textual evidence, each quoted or paraphrased and cited precisely: - -- **[Direct]** {Claim}. Source: [PR #123](url) / ticket ID / file:line. {Brief quote or paraphrase.} -- **[Supported]** {Claim}. Evidence: {list of items and what each contributes}. - -`[Direct]` is single-source, explicit evidence. `[Supported]` is multiple indirect items converging on a conclusion. - -### What We Can Reasonably Infer - -Claims stated nowhere but well-supported by indirect evidence. Each bullet must make the inference chain visible ("Given A and B, it's likely that C") and must use hedged language ("appears to", "likely", "suggests", "is consistent with"): - -- **[Inferred]** {Hedged claim}. Reasoning: {the specific evidence and the inference step}. - -Skip this section if there's nothing to infer. - -### Competing Hypotheses - -If the evidence fits multiple stories, present each. Don't force a winner the record doesn't support. For each hypothesis: - -- **Hypothesis:** {one-sentence statement} -- **Evidence for:** {specific items} -- **Evidence against or missing:** {what would need to be true but isn't, or what counter-signals exist} - -Skip this section if there's a single clear answer. - -### What We Don't Know - -Specific gaps: "We searched the issue tracker for [query1], [query2], [query3] and found no issue discussing the rate-limit threshold", not "We don't know why." Include: - -- Questions that went unanswered -- Searches that returned nothing -- Sources that were unavailable, and why (such as a missing real-time team chat MCP) -- People who would likely know but whom you can't ask - -### Sources Consulted - -What was actually searched, so the user can judge coverage and redirect: - -- **Source control history**: {file paths}, {number of commits reviewed}, PRs #{numbers}, and code comments searched. Or "Not searched. This should not happen because git and `gh` are always expected." -- **Issue / ticket tracker**: {ticket IDs and keyword searches}. Or "Not searched. No matching MCP available in this environment." -- **Long-form documents**: {page titles and search queries}. Or "Not searched. No matching MCP available in this environment." -- **Real-time team chat**: {channels searched, date ranges, queries}. Or "Not searched. No matching MCP available in this environment." -- **Infrastructure observability**: {dashboards, monitors, metrics, logs, traces, or incidents searched}. Or "Not searched. No matching MCP available in this environment." -- **Error / exception tracking**: {issues, events, or releases searched}. Or "Not searched. No matching MCP available in this environment." -- **Product analytics warehouse**: {fully-qualified tables queried, the time windows, and the numeric summaries (counts, percentiles, first/last-seen timestamps) that bore on the question}. Or "Not searched. No matching MCP available in this environment." - -### Confidence Summary - -One or two sentences on overall confidence, e.g.: - -> "The core rationale (A) is well-supported by direct PR and ticket evidence. The specific threshold value (100) is inferred from the surrounding context but not explicitly documented. The question of whether this was driven by a customer request could not be answered. No relevant issue tracker or long-form doc content surfaced, and real-time team chat search was unavailable." - ---- - -## Quality Check Before Returning - -Revise if any item fails: - -1. Does every claim in "What We Found" have a citation? If not, add one or move it to "Inferred" or "Hypotheses." -2. Is the phrasing tier-appropriate? (Direct claims can use "because". Inferred claims cannot.) -3. Did you surface every contradiction you noticed, or quietly pick one? -4. Does "What We Don't Know" name specific gaps? If it's empty or missing, be suspicious. Historical investigations almost always have gaps. -5. Did you check any hypothesis embedded in the question against the evidence rather than rubber-stamp it? -6. Did you cite code as evidence for its own intent? Remove it. Code is mechanics, not motivation. -7. Is the tone calibrated? A confident-sounding answer on weak evidence is the exact failure this skill exists to prevent. - -The value of this output is its honesty, not its authority. A reader who takes it to the original author, an engineering lead, or a product manager should know what's known, what's inferred, and what's missing, so they can ask the right follow-up questions. Optimize for being useful, not for looking decisive.