@zenspc/pi-pstack 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/agents/comment-sicko.md +34 -0
- package/agents/poteto-agent.md +13 -0
- package/extensions/pstack/config.ts +228 -0
- package/extensions/pstack/index.ts +211 -0
- package/package.json +57 -0
- package/skills/architect/SKILL.md +82 -0
- package/skills/architect/references/design-red-flags.md +33 -0
- package/skills/architect/references/rationale-template.md +35 -0
- package/skills/architect/references/runner-prompt.md +20 -0
- package/skills/arena/SKILL.md +70 -0
- package/skills/automate-me/SKILL.md +114 -0
- package/skills/blast-radius/SKILL.md +49 -0
- package/skills/bro/SKILL.md +6 -0
- package/skills/create-verification-skill/SKILL.md +43 -0
- package/skills/create-verification-skill/references/feature-map-example/README.md +47 -0
- package/skills/create-verification-skill/references/feature-map-example/create-note.md +39 -0
- package/skills/create-verification-skill/references/feature-map-example/search.md +45 -0
- package/skills/figure-it-out/SKILL.md +54 -0
- package/skills/how/SKILL.md +134 -0
- package/skills/how/references/critic-prompt.md +59 -0
- package/skills/how/references/critique-rubric.md +58 -0
- package/skills/how/references/explainer-prompt.md +55 -0
- package/skills/how/references/explorer-prompt.md +52 -0
- package/skills/interrogate/SKILL.md +109 -0
- package/skills/interrogate/references/code-quality-review.md +47 -0
- package/skills/interrogate/references/lead-judgment.md +58 -0
- package/skills/interrogate/references/reviewer-prompt.md +72 -0
- package/skills/interrogate/references/rubric.md +77 -0
- package/skills/maintain-verification-skill/SKILL.md +38 -0
- package/skills/no-comments/SKILL.md +23 -0
- package/skills/poteto-mode/SKILL.md +140 -0
- package/skills/poteto-mode/playbooks/authoring-a-skill.md +12 -0
- package/skills/poteto-mode/playbooks/autonomous-run.md +13 -0
- package/skills/poteto-mode/playbooks/autopilot-full.md +13 -0
- package/skills/poteto-mode/playbooks/autopilot-stack.md +31 -0
- package/skills/poteto-mode/playbooks/babysit.md +27 -0
- package/skills/poteto-mode/playbooks/bug-fix.md +17 -0
- package/skills/poteto-mode/playbooks/eval.md +27 -0
- package/skills/poteto-mode/playbooks/feature.md +21 -0
- package/skills/poteto-mode/playbooks/hillclimb.md +21 -0
- package/skills/poteto-mode/playbooks/investigation.md +14 -0
- package/skills/poteto-mode/playbooks/multi-phase-plan.md +3 -0
- package/skills/poteto-mode/playbooks/opening-a-pr.md +35 -0
- package/skills/poteto-mode/playbooks/orchestrate.md +113 -0
- package/skills/poteto-mode/playbooks/pause-safely.md +10 -0
- package/skills/poteto-mode/playbooks/perf-issue.md +24 -0
- package/skills/poteto-mode/playbooks/prototype.md +14 -0
- package/skills/poteto-mode/playbooks/refactoring.md +16 -0
- package/skills/poteto-mode/playbooks/runtime-forensics.md +11 -0
- package/skills/poteto-mode/playbooks/session-pickup.md +13 -0
- package/skills/poteto-mode/playbooks/shipping.md +40 -0
- package/skills/poteto-mode/playbooks/trace-forensics.md +14 -0
- package/skills/poteto-mode/playbooks/visual-parity.md +11 -0
- package/skills/poteto-mode/playbooks/worktree-cleanup.md +14 -0
- package/skills/poteto-mode/references/bugbot-triage.md +142 -0
- package/skills/poteto-mode/references/plan.md +105 -0
- package/skills/poteto-mode/scripts/bootstrap.ts +62 -0
- package/skills/poteto-mode/scripts/bun.lock +67 -0
- package/skills/poteto-mode/scripts/orch/orch.test.ts +634 -0
- package/skills/poteto-mode/scripts/orch/orch.ts +578 -0
- package/skills/poteto-mode/scripts/orch/store.ts +1607 -0
- package/skills/poteto-mode/scripts/package.json +16 -0
- package/skills/poteto-mode/scripts/watch-pr/cli.test.ts +224 -0
- package/skills/poteto-mode/scripts/watch-pr/cli.ts +223 -0
- package/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +118 -0
- package/skills/poteto-mode/scripts/watch-pr/github.test.ts +306 -0
- package/skills/poteto-mode/scripts/watch-pr/github.ts +699 -0
- package/skills/poteto-mode/scripts/watch-pr/policy.test.ts +420 -0
- package/skills/poteto-mode/scripts/watch-pr/policy.ts +832 -0
- package/skills/poteto-mode/scripts/watch-pr/render.ts +169 -0
- package/skills/poteto-mode/scripts/watch-pr/tsconfig.json +13 -0
- package/skills/poteto-mode/scripts/watch-pr/types.compile.ts +93 -0
- package/skills/poteto-mode/scripts/watch-pr/types.ts +401 -0
- package/skills/poteto-mode/scripts/watch-pr/watch-pr +6 -0
- package/skills/poteto-mode/scripts/worktree-audit.sh +85 -0
- package/skills/principle-boundary-discipline/SKILL.md +33 -0
- package/skills/principle-build-the-lever/SKILL.md +22 -0
- package/skills/principle-encode-lessons-in-structure/SKILL.md +30 -0
- package/skills/principle-exhaust-the-design-space/SKILL.md +20 -0
- package/skills/principle-experience-first/SKILL.md +18 -0
- package/skills/principle-fix-root-causes/SKILL.md +22 -0
- package/skills/principle-foundational-thinking/SKILL.md +20 -0
- package/skills/principle-guard-the-context-window/SKILL.md +16 -0
- package/skills/principle-laziness-protocol/SKILL.md +17 -0
- package/skills/principle-make-operations-idempotent/SKILL.md +23 -0
- package/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +21 -0
- package/skills/principle-minimize-reader-load/SKILL.md +22 -0
- package/skills/principle-model-the-domain/SKILL.md +25 -0
- package/skills/principle-never-block-on-the-human/SKILL.md +22 -0
- package/skills/principle-outcome-oriented-execution/SKILL.md +21 -0
- package/skills/principle-prove-it-works/SKILL.md +32 -0
- package/skills/principle-redesign-from-first-principles/SKILL.md +15 -0
- package/skills/principle-separate-before-serializing-shared-state/SKILL.md +15 -0
- package/skills/principle-sequence-verifiable-units/SKILL.md +21 -0
- package/skills/principle-subtract-before-you-add/SKILL.md +21 -0
- package/skills/principle-type-system-discipline/SKILL.md +30 -0
- package/skills/recall/SKILL.md +40 -0
- package/skills/reflect/SKILL.md +77 -0
- package/skills/reflect/references/divergent-reviewer.md +43 -0
- package/skills/reflect/references/judgment-reviewer.md +42 -0
- package/skills/reflect/references/synthesizer.md +56 -0
- package/skills/reflect/references/tooling-reviewer.md +57 -0
- package/skills/setup-pstack/SKILL.md +28 -0
- package/skills/show-me-your-work/SKILL.md +89 -0
- package/skills/show-me-your-work/references/decision-log-template.tsv +1 -0
- package/skills/show-me-your-work/scripts/log.sh +40 -0
- package/skills/swarm/SKILL.md +45 -0
- package/skills/tdd/SKILL.md +43 -0
- package/skills/teach/SKILL.md +20 -0
- package/skills/technical-writing/SKILL.md +129 -0
- package/skills/typescript-best-practices/SKILL.md +28 -0
- package/skills/typescript-best-practices/references/patterns.md +292 -0
- package/skills/unslop/SKILL.md +80 -0
- package/skills/why/SKILL.md +229 -0
- package/skills/why/references/epistemics.md +144 -0
- package/skills/why/references/investigator-prompt.md +103 -0
- package/skills/why/references/source-playbook.md +17 -0
- package/skills/why/references/sources/code-archaeology.md +88 -0
- package/skills/why/references/sources/databricks.md +70 -0
- package/skills/why/references/sources/datadog.md +99 -0
- package/skills/why/references/sources/incident-postmortem.md +15 -0
- package/skills/why/references/sources/linear.md +48 -0
- package/skills/why/references/sources/notion.md +55 -0
- package/skills/why/references/sources/sentry.md +100 -0
- package/skills/why/references/sources/slack.md +54 -0
- package/skills/why/references/synthesizer-prompt.md +135 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: why
|
|
3
|
+
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."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Why
|
|
7
|
+
|
|
8
|
+
Investigate the motivation and intent behind code. Why was it built this way? What edge cases were considered? What product, business, or operational constraints shaped the design? What alternatives were rejected, and why?
|
|
9
|
+
|
|
10
|
+
Companion to the `how` skill. `how` answers what the code does and how it works. `why` answers what forces led to its shape.
|
|
11
|
+
|
|
12
|
+
## How this skill works
|
|
13
|
+
|
|
14
|
+
Historical context spreads across seven evidence categories: source control history, issue or ticket tracking, long-form documents, real-time team chat, infrastructure observability, error or exception tracking, and product analytics warehouses. You cannot predict from the question alone which one holds the answer, so the skill enumerates available MCPs at run time, maps each to a category, queries all seven in parallel, then synthesizes with explicit confidence calibration. Null results from searched categories are first-class evidence about how the decision was made; report them alongside positive findings. The default is coverage, not minimalism.
|
|
15
|
+
|
|
16
|
+
## Operating Posture
|
|
17
|
+
|
|
18
|
+
Operate as a careful, cautious, precise investigator. Think like a detective piecing together a historical case from fragmentary records. When the record is thin, say so.
|
|
19
|
+
|
|
20
|
+
Concretely:
|
|
21
|
+
|
|
22
|
+
- **Evidence before narrative.** Collect the pieces first, then see what story they support. Never pick a story and recruit the evidence that fits it.
|
|
23
|
+
- **Precision over polish.** Prefer the exact quote and citation over a smooth paraphrase. A reader should be able to follow any claim back to its source and verify it in under a minute.
|
|
24
|
+
- **Consider what you haven't seen.** The evidence you find is a sample, not the whole truth. Before concluding, ask what you would expect to see if an alternative explanation were true, and whether you looked for it.
|
|
25
|
+
- **Name the gaps.** If a thread goes cold, a source isn't searchable, or a question has no answer, document the gap. Don't paper it over with an authoritative-sounding guess.
|
|
26
|
+
- **Hedge on purpose.** When evidence is indirect, your language should signal it ("appears to", "likely", "suggests"). Confidence-matching phrasing is a feature of the output, not a stylistic choice the synthesizer may override.
|
|
27
|
+
- **No shortcut by code-reading.** The code tells you what it does, rarely why it exists. Resist inferring intent from code shape.
|
|
28
|
+
|
|
29
|
+
This posture is the working method, not a disclaimer.
|
|
30
|
+
|
|
31
|
+
## Core Epistemics
|
|
32
|
+
|
|
33
|
+
This skill builds a **patchwork understanding** from fragmented historical evidence. Tickets go stale. Chat threads get deleted. Commit messages lie. People change their minds between the PR description and the implementation. The original author may have left the company.
|
|
34
|
+
|
|
35
|
+
Be ruthlessly honest about what you know versus what you're inferring. The goal is not a satisfying story; it is to surface evidence, calibrate confidence, and let the user decide.
|
|
36
|
+
|
|
37
|
+
Principles:
|
|
38
|
+
|
|
39
|
+
- **Cite everything.** Every claim about intent should reference a specific commit hash, PR number, ticket ID, doc URL, chat permalink, or code comment. If you can't cite it, it's inference, not fact, and must be labeled as such.
|
|
40
|
+
- **Prefer "appears to" over "because".** Hedge when evidence is indirect. Reserve confident language for direct, explicit evidence.
|
|
41
|
+
- **Surface contradictions.** If two sources disagree, show both. Don't quietly pick the one that fits your narrative.
|
|
42
|
+
- **Acknowledge gaps.** If a question has no answer in any source you searched, say so. An honest "we couldn't find out why" beats a confident guess.
|
|
43
|
+
- **Multiple hypotheses are valid.** When the evidence fits several stories, present them all with the evidence for each. Let the user triangulate.
|
|
44
|
+
- **Beware rationalization.** Code that makes sense today may have been written for reasons that no longer apply, or for no good reason at all. Don't retrofit intent.
|
|
45
|
+
|
|
46
|
+
Read `references/epistemics.md` for the full confidence framework and phrasing guide. The synthesizer must follow it.
|
|
47
|
+
|
|
48
|
+
## Step 1. Understand the Target and the Question
|
|
49
|
+
|
|
50
|
+
Parse what the user is asking. The **target** is usually a chunk of code, a pattern, a feature, or a named design decision. The **question** is usually one of:
|
|
51
|
+
|
|
52
|
+
- "Why was X designed this way?" Design rationale.
|
|
53
|
+
- "Why do we do X instead of Y?" Tradeoff or alternatives.
|
|
54
|
+
- "What edge cases motivated this?" Defensive reasoning.
|
|
55
|
+
- "What business or product constraint led to this?" External forcing function.
|
|
56
|
+
- "Why does this code still exist?" Dead-code territory.
|
|
57
|
+
- "What's the history of X?" Broad archaeological sweep.
|
|
58
|
+
|
|
59
|
+
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.
|
|
60
|
+
|
|
61
|
+
## Step 2. Establish the Code Anchor
|
|
62
|
+
|
|
63
|
+
Before spawning investigators, anchor the investigation in concrete code. You need:
|
|
64
|
+
|
|
65
|
+
- The relevant file path(s) and line range(s)
|
|
66
|
+
- The key symbols (function names, class names, constants)
|
|
67
|
+
- An initial commit list. The last few commits touching the target.
|
|
68
|
+
- PR numbers from merge commits (pattern `(#1234)` in the subject line)
|
|
69
|
+
|
|
70
|
+
Build this inline. It's cheap, and every investigator needs it.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Blame target lines for last-touch commits
|
|
74
|
+
git blame -L <start>,<end> <file>
|
|
75
|
+
|
|
76
|
+
# Full file history, with patches, through renames
|
|
77
|
+
git log --follow -p -- <file>
|
|
78
|
+
|
|
79
|
+
# Last N commits touching the file, PR numbers visible
|
|
80
|
+
git log --oneline -20 -- <file>
|
|
81
|
+
|
|
82
|
+
# Extract PR numbers from a commit message
|
|
83
|
+
git log -1 --format=%B <commit>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Pull PR bodies and discussion via `gh` for any substantive commits:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
gh pr view <number> --json title,body,author,createdAt,mergedAt,labels,closingIssuesReferences,comments,reviews
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Capture this as seed context (file paths, symbols, commits, PR numbers, linked ticket IDs). Pass it to the investigators so they don't rediscover it.
|
|
93
|
+
|
|
94
|
+
## Step 3. Spawn Parallel Investigators (default posture)
|
|
95
|
+
|
|
96
|
+
**Default to the full parallel investigation.** Each evidence category lives in a different kind of system, and you cannot tell from the question alone which one holds the answer without looking. So look across every available category, in parallel, by default.
|
|
97
|
+
|
|
98
|
+
### Discovery
|
|
99
|
+
|
|
100
|
+
Before spawning investigators, list the available MCP tools in this session. Use the available-tools map when present. Otherwise inspect the project's `.pi/mcp.json` and the user's `~/.pi/agent/mcp.json` for enabled MCP servers.
|
|
101
|
+
|
|
102
|
+
Map each available MCP to one evidence category:
|
|
103
|
+
|
|
104
|
+
1. Source control history
|
|
105
|
+
2. Issue / ticket tracker
|
|
106
|
+
3. Long-form documents
|
|
107
|
+
4. Real-time team chat
|
|
108
|
+
5. Infrastructure observability
|
|
109
|
+
6. Error / exception tracking
|
|
110
|
+
7. Product analytics warehouse
|
|
111
|
+
|
|
112
|
+
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.
|
|
113
|
+
|
|
114
|
+
Aim for a complete **coverage map**, not a minimal one. A null result from an issue tracker is evidence the decision was not ticketed, a useful fact in itself. Document the null, don't skip the search.
|
|
115
|
+
|
|
116
|
+
Launch all matching investigators in a single message so they run concurrently. One investigator per category lets each specialize in one tool's query vocabulary and result shape. Don't ask one agent to cover multiple MCPs.
|
|
117
|
+
|
|
118
|
+
Subagent config (each):
|
|
119
|
+
- agent: `worker`
|
|
120
|
+
- `model`: your configured why-investigators model (default `inherit-parent`)
|
|
121
|
+
- Full tools. Investigators need MCP access for tickets, chat, observability, and analytics lookups. They still shouldn't write anything. That's a posture, not a sandbox.
|
|
122
|
+
|
|
123
|
+
Each investigator gets:
|
|
124
|
+
1. The base prompt from `references/investigator-prompt.md`
|
|
125
|
+
2. The category playbook `references/sources/<source>.md` for the selected MCP, adapted from the examples in `references/source-playbook.md`
|
|
126
|
+
3. The cross-cutting `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)
|
|
127
|
+
4. The code anchor from Step 2 (file paths, symbols, commit hashes, PR numbers, ticket IDs)
|
|
128
|
+
5. The user's original question
|
|
129
|
+
|
|
130
|
+
### Investigator roster. One per available evidence category
|
|
131
|
+
|
|
132
|
+
Spawn one investigator per category that has a matching MCP. Each owns exactly one tool or MCP.
|
|
133
|
+
|
|
134
|
+
Each entry lists what the category physically contains and the kind of "why" it uniquely surfaces. Use it to know what to expect back, how to name a gap when a category returns empty, and (only in the rare provably-irrelevant case) to justify a skip. Every category overlaps, but each owns a kind of evidence the others cannot recover.
|
|
135
|
+
|
|
136
|
+
1. **Source control investigator**. Git history, `gh` for PRs, code comments, tests. Always spawn; the only guaranteed source. Best at surfacing *implementation-time rationale captured during review*. PR descriptions stating the problem, review threads debating alternatives, inline comments encoding non-obvious constraints, test names that encode motivating edge cases, and commit messages linking tickets or incidents. Most trustworthy because it ties directly to the diff that shipped.
|
|
137
|
+
|
|
138
|
+
2. **Issue / ticket tracker investigator** (e.g. Linear, Jira, GitHub Issues, Plane, Shortcut MCP). Tickets, project docs, status updates, spec attachments. Best at surfacing *the product or business forcing function*. Customer requests ("Acme needs X for their SOC2 audit"), compliance deadlines, parent-initiative framing ("Q3 enterprise readiness"), ticket-level scope changes, and labels that categorize the motivation (`customer:*`, `incident-followup`, `compliance`, `perf-regression`). Strongest when the why is external to engineering.
|
|
139
|
+
|
|
140
|
+
3. **Long-form documents investigator** (e.g. Notion, Confluence, Google Docs, Coda MCP). PRDs, specs, RFCs, design docs, ADRs, postmortems, team pages, meeting notes. Best at surfacing *long-form design rationale*. Problem statements, explicit "alternatives considered" and "rejected approaches" sections, strategy documents that set priorities, ADRs with finalized decisions, and postmortem action items that tie directly to code. Where the why is written out before it becomes code.
|
|
141
|
+
|
|
142
|
+
4. **Real-time team chat investigator** (e.g. Slack, Discord, Microsoft Teams, Mattermost MCP). Feature-name and symbol searches, PR URL mentions, incident channels (`#sev-*`, `#incident-*`), author-handle activity around the ship date. Best at surfacing *real-time deliberation that never reached a doc*. Fire-drill decisions during incidents, Q&A between the PR author and reviewers, casual "we decided X because Y" threads, and rationale for small changes that didn't warrant a PRD. Especially important when the source control, ticket, and doc paper trail is thin.
|
|
143
|
+
|
|
144
|
+
5. **Infrastructure observability investigator** (e.g. Datadog, New Relic, Honeycomb, Grafana, Splunk MCP). Metrics, monitors, dashboards, logs, APM traces, formal incidents. Infra/runtime view. Best at surfacing *infrastructure and runtime reality that motivated the code*. Monitor thresholds whose numbers match code constants, metric spikes in the window right before a PR merge, dashboards created as postmortem action items, incident timelines that reference the target. Strongest when the target reacts to an infra signal (timeouts, retries, rate limits, circuit breakers).
|
|
145
|
+
|
|
146
|
+
6. **Error / exception tracking investigator** (e.g. Sentry, Rollbar, Bugsnag, Airbrake MCP). Issues, events, stack traces, releases. Best at surfacing *the specific exceptions and error trajectories that motivated defensive or corrective code*. Stack traces that pass through the target function, issues whose first-seen/last-seen windows bracket the PR ship date, release correlations that show an error stopping at a specific version. Strongest for catch blocks, null guards, type checks, retries, and other defenses.
|
|
147
|
+
|
|
148
|
+
7. **Product analytics warehouse investigator** (e.g. Databricks, Snowflake, BigQuery, ClickHouse, dbt, Redshift MCP). Product-analytics events, experiment and feature-flag exposure tables, usage and billing events, query history, warehouse telemetry. Product/data view. Complements infrastructure observability by covering *user behavior and data reality* around the ship date rather than infra metrics. Best at surfacing *product and data reality that shaped the code*. Feature-usage trajectories (a step-function ramp from zero is strong evidence that this PR launched it), experiment/flag exposure data tied to ship decisions, pre-ship distributions that reveal where a threshold constant came from (e.g., `limit = 128 * 1024` matching the p99 of an upload-size column), and data-pipeline scale evidence for migrations/backfills. Strongest for flag-gated code, experiment-driven ships, data migrations, and "where did this number come from" questions.
|
|
149
|
+
|
|
150
|
+
### When to skip an investigator
|
|
151
|
+
|
|
152
|
+
Only skip with an **explicit, written justification** that goes in the final "Sources Consulted" section. Two valid reasons:
|
|
153
|
+
|
|
154
|
+
- **No MCP is available for that category** in this environment. Flag this as a gap, not a choice. Example: "Real-time team chat skipped. No matching MCP available, so the conversational record was not searchable."
|
|
155
|
+
- **The source is provably irrelevant**, not just "probably irrelevant." A high bar. Example: "Error / exception tracking skipped. Target is a build-time script with no runtime code path." Not "probably not in error tracking, it's a feature not an error."
|
|
156
|
+
|
|
157
|
+
"It's pure feature code, error tracking won't have anything" is **not** sufficient, and neither is "I doubt long-form docs would have this." Run the search; let the null result speak. The cost of an investigator returning empty is one subagent. The cost of missing a design doc that actually exists is a wrong answer.
|
|
158
|
+
|
|
159
|
+
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.
|
|
160
|
+
|
|
161
|
+
## Step 4. Synthesize
|
|
162
|
+
|
|
163
|
+
Spawn one synthesizer subagent:
|
|
164
|
+
|
|
165
|
+
- agent: `worker`
|
|
166
|
+
- `model`: your configured why-synthesizer model (default `inherit-parent`)
|
|
167
|
+
- Full tools. The synthesizer's quality check spot-verifies citations, which can require MCP access.
|
|
168
|
+
|
|
169
|
+
The synthesizer gets:
|
|
170
|
+
1. The investigator findings, including any null results and any categories skipped with justification
|
|
171
|
+
2. The code anchor from Step 2 (file paths, symbols, commit hashes, PR numbers, ticket IDs)
|
|
172
|
+
3. The user's original question
|
|
173
|
+
4. The epistemics framework from `references/epistemics.md`
|
|
174
|
+
5. The synthesizer prompt template from `references/synthesizer-prompt.md`
|
|
175
|
+
|
|
176
|
+
Its job is the final output: a confidence-weighted, evidence-cited narrative with clearly separated "what we know" and "what we're inferring" sections, plus honest acknowledgment of gaps and null-result sources.
|
|
177
|
+
|
|
178
|
+
## Step 5. Present
|
|
179
|
+
|
|
180
|
+
Take the synthesizer's output and present it to the user. You may lightly edit for clarity or add context from the conversation, but **do not rewrite the confidence language**. The epistemic framing is the product. Dropping the hedges to sound more authoritative is the exact failure mode this skill exists to prevent.
|
|
181
|
+
|
|
182
|
+
## Output Format
|
|
183
|
+
|
|
184
|
+
The final output uses this structure. Adapt as needed, but keep the confidence separation intact.
|
|
185
|
+
|
|
186
|
+
**The Question**. Restate what the user asked, concisely.
|
|
187
|
+
|
|
188
|
+
**The Code in Question**. File paths, line ranges, and key symbols. One or two lines so the reader is anchored.
|
|
189
|
+
|
|
190
|
+
**What We Found (direct evidence)**. Claims with explicit citations (PR #, ticket ID, doc URL, chat permalink, commit hash, code comment with file:line). Each bullet is a thing we have textual evidence for. Use present tense and quote or paraphrase the source.
|
|
191
|
+
|
|
192
|
+
**What We Can Reasonably Infer**. Claims well-supported by indirect evidence or combinations of signals, but not explicitly stated anywhere. Each bullet must explain the inference chain: "Given A and B, it's likely that C." Use hedged language ("appears to", "likely", "suggests").
|
|
193
|
+
|
|
194
|
+
**Competing Hypotheses**. If the evidence fits multiple stories, list them. For each, give the hypothesis, the evidence for it, and the evidence against it. Don't force a winner when the record doesn't support one. (Skip this section if there's a clear answer.)
|
|
195
|
+
|
|
196
|
+
**What We Don't Know**. Explicit gaps. Questions the user asked that the evidence didn't answer. Sources we searched and came up empty. Be specific. "We searched the issue tracker for 'rate limit' and found no ticket discussing this specific threshold" is more useful than "we don't know why."
|
|
197
|
+
|
|
198
|
+
**Sources Consulted**. One line per investigator, including the ones that returned nothing. The reader should see at a glance (a) which MCPs were queried, (b) which came back empty, and (c) which were skipped and why. This coverage map lets the user judge breadth and redirect if something obvious was missed.
|
|
199
|
+
|
|
200
|
+
Format each line as: `- <Source>: <what was searched>. <what was found, or "no relevant results," or "skipped. reason">.`
|
|
201
|
+
|
|
202
|
+
Example:
|
|
203
|
+
- Source control (git/gh): `git log --follow backend/retry.ts`, PRs #49074, #47812. Found PR #49074 introduced exponential backoff and linked ENG-4421.
|
|
204
|
+
- Issue tracker (Linear): searched for "retry" and ENG-4421. Found ENG-4421 parent issue but no discussion of backoff parameters.
|
|
205
|
+
- Long-form docs (Notion): searched for "retry policy," "backend retries," "ENG-4421." No relevant results.
|
|
206
|
+
- Real-time team chat (Slack): skipped. No matching MCP available in this environment. Gap: conversational record not searched.
|
|
207
|
+
- Infrastructure observability (Datadog): searched for `retry_count` metric and monitors around 2024-08-14. Found monitor "Upstream 5xx rate > 1%" created same day as PR #49074.
|
|
208
|
+
- Error / exception tracking (Sentry): searched for issues first-seen in Aug 2024 with stack through `retry.ts`. Found issue SENTRY-3821 spiking in the week before the PR.
|
|
209
|
+
- Product analytics warehouse (Databricks): queried `<your_analytics_db>.<schema>.stg_backend_upstream_retry` for the 30-day window around 2024-08-14. Daily failure-classified event count fell from ~1.2k/day pre-PR to <50/day post-PR. Also checked `system.query.history` for relevant migration queries. None found.
|
|
210
|
+
|
|
211
|
+
After the Sources Consulted block, if the user's `why` question is a precursor to actually changing this code, convert the lineage findings into a Preserve / Change / Avoid / Risk constraint set suitable for planning the change.
|
|
212
|
+
|
|
213
|
+
## Common Failure Modes to Avoid
|
|
214
|
+
|
|
215
|
+
- **Confident storytelling**. A plausible narrative built from thin evidence. A bullet with no citation goes in "inferred" or "hypotheses," not "what we found."
|
|
216
|
+
- **Citing the code as evidence for its own intent**. "Handles the null case because it checks for null" is mechanics, not motivation. Motivation comes from an external source (PR discussion, ticket, comment, conversation) or is labeled as inference.
|
|
217
|
+
- **Recency bias**. Assuming the most recent commit is authoritative. The current shape is often the accretion of many earlier decisions. Trace back.
|
|
218
|
+
- **Sycophantic agreement**. If the user suggests a reason ("I assume this is for performance?"), treat it as a hypothesis and check the evidence independently, don't just confirm it.
|
|
219
|
+
- **Skipping the gaps section**. An honest accounting of what you couldn't find out is part of the value.
|
|
220
|
+
- **Skipping investigators by anticipation**. Deciding up front that "long-form docs probably don't have this" or "this isn't an error tracking thing" without searching. The default-to-all-seven posture prevents this. A null result is a data point; a skipped search is a blind spot.
|
|
221
|
+
- **Collapsing investigators into one agent**. Each MCP has its own query vocabulary, result shape, and pitfalls; pooling them dilutes specialization and makes coverage harder to reason about. Always one investigator per category.
|
|
222
|
+
|
|
223
|
+
## Reference Files
|
|
224
|
+
|
|
225
|
+
- `references/epistemics.md`. Confidence tiers and phrasing guide. The synthesizer must follow it.
|
|
226
|
+
- `references/investigator-prompt.md`. Base prompt template for investigator subagents.
|
|
227
|
+
- `references/source-playbook.md`. Index pointing at the category playbooks below.
|
|
228
|
+
- `references/sources/*.md`. One self-contained example playbook per category, plus cross-cutting `incident-postmortem.md`. Give an investigator the single file that matches its category and adapt it to the available MCP.
|
|
229
|
+
- `references/synthesizer-prompt.md`. Prompt template for the synthesizer subagent, including the output format.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Epistemics
|
|
2
|
+
|
|
3
|
+
How to reason about confidence when evidence is historical, fragmentary, and sometimes contradictory, and how to communicate it without flattening it into false certainty.
|
|
4
|
+
|
|
5
|
+
Code doesn't carry its own motivation. You can read what code does; you can't read *why it exists*. That lives in commits, PRs, tickets, docs, and conversations, all incomplete, biased, and sometimes missing entirely. Pretending otherwise produces confident-sounding guesses that mislead the user.
|
|
6
|
+
|
|
7
|
+
## Confidence Tiers
|
|
8
|
+
|
|
9
|
+
Every claim in the final output must sit in one of these tiers. The tier determines which output section the claim goes in and how it's phrased.
|
|
10
|
+
|
|
11
|
+
### 1. Direct
|
|
12
|
+
|
|
13
|
+
An explicit, textual citation that answers the question. Not "the code does X so the author must have wanted X." Something an author actually *wrote* that says why.
|
|
14
|
+
|
|
15
|
+
Examples:
|
|
16
|
+
- A PR description that says "this fixes the bug where users with >1000 items couldn't paginate"
|
|
17
|
+
- A ticket that says "we're adding this because customer Acme requested it in their security review"
|
|
18
|
+
- A code comment that says "// clamp to 100 because the upstream API rejects larger values"
|
|
19
|
+
- A design doc that says "we chose option A over option B because we need persistence across restarts"
|
|
20
|
+
- A chat message from the author saying "switching to this approach since the old one was flaky in tests"
|
|
21
|
+
|
|
22
|
+
Phrasing: confident, present tense. "This exists because X." Cite the source.
|
|
23
|
+
|
|
24
|
+
### 2. Supported
|
|
25
|
+
|
|
26
|
+
Multiple pieces of indirect evidence converge. No single source states it explicitly, but the pattern across sources makes it likely.
|
|
27
|
+
|
|
28
|
+
Examples:
|
|
29
|
+
- The PR title says "improve performance," the ticket is labeled "perf," and the surrounding commits all touch the same hot path
|
|
30
|
+
- Multiple tests were added alongside the change, all exercising edge cases with very large inputs
|
|
31
|
+
- The author's other PRs from the same week all mention the same incident in their descriptions
|
|
32
|
+
|
|
33
|
+
Phrasing: confident but clearly derived. "The evidence points strongly to X: [the specific pieces]." Cite multiple sources.
|
|
34
|
+
|
|
35
|
+
### 3. Inferred
|
|
36
|
+
|
|
37
|
+
A reasonable reading of the context, but nothing explicitly supports it. The reader should understand this is *your interpretation*, not a fact from the record.
|
|
38
|
+
|
|
39
|
+
Examples:
|
|
40
|
+
- The PR doesn't say why, but given the error was happening in production (per the incident channel timing) and the fix was rushed (merged the same day), it was likely a hotfix.
|
|
41
|
+
- The function name suggests retry logic; the retry count is 3; this matches the team's general convention of "3 retries" seen elsewhere in the codebase.
|
|
42
|
+
|
|
43
|
+
Phrasing: hedged. "It appears", "likely", "suggests", "is consistent with", "one reading is". Make the inference chain explicit: "Given A and B, C seems likely because D."
|
|
44
|
+
|
|
45
|
+
### 4. Speculative
|
|
46
|
+
|
|
47
|
+
A plausible hypothesis, but the evidence is thin and other explanations fit equally well. Presenting these is valuable, but mark them clearly as guesses.
|
|
48
|
+
|
|
49
|
+
Examples:
|
|
50
|
+
- "This might be a workaround for a browser bug that's since been fixed, but we found no contemporary evidence of that."
|
|
51
|
+
- "It's possible this threshold was chosen to match an SLA commitment, but no SLA doc references it."
|
|
52
|
+
|
|
53
|
+
Phrasing: explicitly speculative. "One possibility is X, but we have no direct evidence." Usually lives in the "Competing Hypotheses" section alongside other possibilities.
|
|
54
|
+
|
|
55
|
+
### 5. Unknown
|
|
56
|
+
|
|
57
|
+
You looked and couldn't find out. A valid and important outcome. Document it.
|
|
58
|
+
|
|
59
|
+
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."
|
|
60
|
+
|
|
61
|
+
## Phrasing Guide
|
|
62
|
+
|
|
63
|
+
### Words that carry confidence. Use carefully
|
|
64
|
+
|
|
65
|
+
These imply **Direct** or **Supported** confidence. Don't use them for inferences.
|
|
66
|
+
|
|
67
|
+
- "because". Implies a causal claim with evidence
|
|
68
|
+
- "the reason is". Same
|
|
69
|
+
- "was designed to". Claims author intent
|
|
70
|
+
- "fixes", "addresses", "solves". Claims the change achieved its goal
|
|
71
|
+
- "the team decided". Claims a group decision happened
|
|
72
|
+
|
|
73
|
+
If you're using these, you should have a citation immediately adjacent.
|
|
74
|
+
|
|
75
|
+
### Words that hedge. Use for inferences
|
|
76
|
+
|
|
77
|
+
- "appears to"
|
|
78
|
+
- "seems to"
|
|
79
|
+
- "likely"
|
|
80
|
+
- "suggests"
|
|
81
|
+
- "is consistent with"
|
|
82
|
+
- "one reading is"
|
|
83
|
+
- "plausibly"
|
|
84
|
+
- "may have been"
|
|
85
|
+
- "the evidence points toward"
|
|
86
|
+
|
|
87
|
+
These signal that you're interpreting, not reporting. Use them liberally in the "What We Can Reasonably Infer" section.
|
|
88
|
+
|
|
89
|
+
### Words to avoid
|
|
90
|
+
|
|
91
|
+
- "obviously". If it were obvious, the user wouldn't be asking
|
|
92
|
+
- "clearly". Almost always precedes a claim that isn't clear
|
|
93
|
+
- "of course". Same
|
|
94
|
+
- "just" (as in "it's just X for performance"). Dismissive and usually hides uncertainty
|
|
95
|
+
- "I think" / "I believe". You're synthesizing evidence, not giving a personal opinion. Use "the evidence suggests" instead.
|
|
96
|
+
|
|
97
|
+
### Avoid rationalization
|
|
98
|
+
|
|
99
|
+
Code that "makes sense" today may have been written for reasons that no longer apply, or that were wrong when they were written. Don't retrofit a clean rationale onto messy history.
|
|
100
|
+
|
|
101
|
+
Resist the urge to:
|
|
102
|
+
- Assume the author did the "right" thing and work backward to justify it
|
|
103
|
+
- Assume a consistent pattern across the codebase was intentional when it might be copy-paste
|
|
104
|
+
- Turn an absence of evidence into evidence of absence ("no one mentioned security concerns, so it must not have been a concern")
|
|
105
|
+
|
|
106
|
+
## The Sycophancy Trap
|
|
107
|
+
|
|
108
|
+
Users often phrase `why` questions with an embedded hypothesis: "Why do we do it this way, I assume it's for performance?" Don't simply confirm it. 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.
|
|
109
|
+
|
|
110
|
+
The user's guess is a prompt for investigation, not a conclusion to validate.
|
|
111
|
+
|
|
112
|
+
## When Evidence Contradicts
|
|
113
|
+
|
|
114
|
+
If two sources disagree (the PR description says one thing, the ticket says another), surface both. Don't pick the one that fits a tidier narrative. A typical pattern:
|
|
115
|
+
|
|
116
|
+
- **The ticket says** "we need this for customer X's compliance requirement"
|
|
117
|
+
- **The PR says** "cleaning up tech debt in this area"
|
|
118
|
+
|
|
119
|
+
Both may be true (the ticket motivated the work, the PR is the author's framing of it), or one may be wrong. Present both with their citations and let the user make the call.
|
|
120
|
+
|
|
121
|
+
## When Evidence Is Missing
|
|
122
|
+
|
|
123
|
+
An honest "we don't know" is one of the most valuable outputs this skill can produce. The user now knows:
|
|
124
|
+
|
|
125
|
+
- The answer isn't in the obvious places
|
|
126
|
+
- They'll need to ask a human (the original author, the product owner, the team lead) to find out
|
|
127
|
+
- Or they can decide the question isn't worth pursuing further
|
|
128
|
+
|
|
129
|
+
Failing to mark a gap and filling it with a confident guess actively harms the user; they'll act on the guess.
|
|
130
|
+
|
|
131
|
+
When you hit a gap, name it concretely:
|
|
132
|
+
- What question you were trying to answer
|
|
133
|
+
- What sources you searched
|
|
134
|
+
- What you searched for in each
|
|
135
|
+
- What you found (nothing, or only tangentially related material)
|
|
136
|
+
|
|
137
|
+
## Calibration Check Before Finalizing
|
|
138
|
+
|
|
139
|
+
Before delivering the output, the synthesizer should review every claim in "What We Found" and "What We Can Reasonably Infer" and ask:
|
|
140
|
+
|
|
141
|
+
1. Does this claim have a citation? If not, either add one or move it to "Inferred" / "Hypotheses".
|
|
142
|
+
2. Is the phrasing calibrated to the tier? (A Direct claim can use "because"; an Inferred claim cannot.)
|
|
143
|
+
3. Am I treating the code itself as evidence for its own intent? If so, that's not evidence. Remove or reclassify.
|
|
144
|
+
4. Does the output include 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.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Investigator Prompt Template
|
|
2
|
+
|
|
3
|
+
Build each investigator's prompt from this template; fill in the placeholders. Append the single category playbook `sources/<source>.md` matching this investigator's evidence category (see `source-playbook.md` for the index). 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` for the incident-flavored queries to run inside its own source.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are investigating the historical context and motivation behind a piece of code. A separate synthesizer combines your findings with other investigators' into a final answer, so gather evidence accurately rather than writing prose.
|
|
8
|
+
|
|
9
|
+
Other investigators search different sources in parallel. Don't try to cover everything. Focus on your assigned source and go deep.
|
|
10
|
+
|
|
11
|
+
## Operating Posture
|
|
12
|
+
|
|
13
|
+
Work like a careful, cautious, precise investigator. Don't produce a narrative; surface evidence and describe it accurately, including the parts that don't fit a tidy story. The more boring and exact your output, the more useful it is. A single verbatim quote with a precise citation beats a paragraph of plausible-sounding summary.
|
|
14
|
+
|
|
15
|
+
- **Quote, don't paraphrase** when the exact wording matters. Citations should let the reader jump to the source and confirm the claim in seconds.
|
|
16
|
+
- **Go wide before going deep.** Cast a broad first net so you don't miss related context. Only then narrow in.
|
|
17
|
+
- **Track what you searched, not just what you found.** An absence is only useful if the reader knows what was looked for. Record queries verbatim.
|
|
18
|
+
- **Resist the story.** If three pieces of evidence line up neatly and a fourth contradicts them, the contradiction is the most interesting finding. Don't file it away.
|
|
19
|
+
- **Consider the counterfactual.** 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.
|
|
20
|
+
- **Never invent.** If you're tempted to round a partial finding up into a confident statement, stop and label it partial. The synthesizer is counting on your output being accurate.
|
|
21
|
+
|
|
22
|
+
## The Question
|
|
23
|
+
|
|
24
|
+
> {QUESTION}
|
|
25
|
+
|
|
26
|
+
## The Code Anchor
|
|
27
|
+
|
|
28
|
+
**Target files:** {FILES_WITH_LINE_RANGES}
|
|
29
|
+
|
|
30
|
+
**Key symbols:** {SYMBOLS}
|
|
31
|
+
|
|
32
|
+
**Initial commits touching this code (most recent first):**
|
|
33
|
+
{COMMIT_LIST}
|
|
34
|
+
|
|
35
|
+
**PR numbers extracted from commit messages:** {PR_NUMBERS}
|
|
36
|
+
|
|
37
|
+
**Ticket IDs mentioned in commits or PR bodies (if any):** {TICKET_IDS}
|
|
38
|
+
|
|
39
|
+
## Your Assigned Source
|
|
40
|
+
|
|
41
|
+
{SOURCE_NAME}
|
|
42
|
+
|
|
43
|
+
{SOURCE_PLAYBOOK_SECTION}
|
|
44
|
+
|
|
45
|
+
## Investigation Instructions
|
|
46
|
+
|
|
47
|
+
Gather **evidence**; don't answer the question directly. The synthesizer weighs the evidence and forms conclusions. Follow this loop:
|
|
48
|
+
|
|
49
|
+
1. **Cast a wide net first.** Start broad so you don't miss related context, then narrow in on specific items.
|
|
50
|
+
2. **Read the whole thing.** Read any PR, ticket, doc, or thread fully, not just the title or summary. The key evidence is often buried in a comment, a subtask, or a follow-up.
|
|
51
|
+
3. **Follow links within your assigned source.** If a PR references another PR or commit, pull it. If a ticket links a parent or sibling, pull it. If a doc links another doc, pull it. Stay inside your assigned source. When you spot a cross-source reference, do NOT chase it yourself. Record it under "Additional Leads" so the investigator assigned to that source can pick it up. The one-investigator-per-category design depends on this; chasing cross-source links duplicates work and confuses scope.
|
|
52
|
+
4. **Capture quotes verbatim** with their location (PR number, ticket ID, URL, commit hash, file:line). The synthesizer needs to cite this precisely.
|
|
53
|
+
5. **Note absences.** If you searched for something and came up empty, that's also a finding. Record what you searched for and what you didn't find.
|
|
54
|
+
6. **Watch for contradictions.** If two items in your source disagree, record both. Don't suppress the inconvenient one.
|
|
55
|
+
|
|
56
|
+
Don't synthesize or form a final opinion on "the why." Collect the raw material honestly and completely; the synthesizer does the reasoning.
|
|
57
|
+
|
|
58
|
+
## Epistemic Discipline
|
|
59
|
+
|
|
60
|
+
- **Don't confuse mechanics with motivation.** A commit changing `limit = 50` to `limit = 100` shows the change, not necessarily why. Look for the explanation in the commit message, PR description, linked ticket, or review comments.
|
|
61
|
+
- **Don't infer intent from code style.** "The author chose a functional approach" is an observation about code, not evidence of intent. Claim intent only when the author stated it.
|
|
62
|
+
- **Preserve uncertainty.** If the evidence is ambiguous, say so. If one reading is more plausible but not certain, say that. Don't collapse ambiguity to look decisive.
|
|
63
|
+
- **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.
|
|
64
|
+
|
|
65
|
+
## Output Format
|
|
66
|
+
|
|
67
|
+
Return your findings in this structure. The synthesizer will read it directly.
|
|
68
|
+
|
|
69
|
+
### Source
|
|
70
|
+
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.).
|
|
71
|
+
|
|
72
|
+
### What I Searched
|
|
73
|
+
The queries you ran, the items you opened, the places you looked. Be specific. This tells the synthesizer how thorough the investigation was and what might still be unsearched.
|
|
74
|
+
|
|
75
|
+
### Direct Evidence Found
|
|
76
|
+
For each piece that explicitly addresses the question:
|
|
77
|
+
- **What it says**: verbatim quote or accurate paraphrase
|
|
78
|
+
- **Where it's from**: PR #123, ticket ID, doc URL, chat permalink, commit hash, or file:line
|
|
79
|
+
- **Author and date** (if available)
|
|
80
|
+
- **Relevance**: one sentence on how it bears on the question
|
|
81
|
+
|
|
82
|
+
### Indirect / Circumstantial Evidence
|
|
83
|
+
Items that don't explicitly answer the question but bear on it. For each:
|
|
84
|
+
- **What it is**: brief description
|
|
85
|
+
- **Where it's from**: location
|
|
86
|
+
- **What it suggests**: what a careful reader might infer, and why. Name the inference chain.
|
|
87
|
+
- **Alternative readings**: if the same evidence could support a different interpretation, note it
|
|
88
|
+
|
|
89
|
+
### Contradictions
|
|
90
|
+
Two items that disagree with each other, with both citations.
|
|
91
|
+
|
|
92
|
+
### Gaps
|
|
93
|
+
What you searched for and didn't find. Be specific: "Searched the issue tracker for [query] across [time range]. No matching issues." These absences are valuable data.
|
|
94
|
+
|
|
95
|
+
### Additional Leads
|
|
96
|
+
Anything that suggests further investigation in a different source. For example, if a PR references a chat thread that wasn't in your source, note it so the real-time team chat investigator or a follow-up pass can pursue it.
|
|
97
|
+
|
|
98
|
+
## What You're Not Doing
|
|
99
|
+
|
|
100
|
+
- Writing the final answer. The synthesizer does that.
|
|
101
|
+
- Picking sides in contradictions. Surface them.
|
|
102
|
+
- Speculating beyond what the evidence supports. A hunch with no evidence isn't evidence.
|
|
103
|
+
- Reading the code itself to figure out intent. You may read the code to understand what the target *is*, but don't confuse "what the code does" with "why."
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Source playbooks
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
| Category | Playbook | Example MCP it documents |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| Source control history | [`code-archaeology.md`](./sources/code-archaeology.md) | git, `gh` |
|
|
8
|
+
| Issue / ticket tracker | [`linear.md`](./sources/linear.md) | Linear (adapt for Jira, GitHub Issues, Plane, Shortcut) |
|
|
9
|
+
| Long-form documents | [`notion.md`](./sources/notion.md) | Notion (adapt for Confluence, Google Docs, Coda) |
|
|
10
|
+
| Real-time team chat | [`slack.md`](./sources/slack.md) | Slack (adapt for Discord, Microsoft Teams, Mattermost) |
|
|
11
|
+
| Infrastructure observability | [`datadog.md`](./sources/datadog.md) | Datadog (adapt for New Relic, Honeycomb, Grafana, Splunk) |
|
|
12
|
+
| Error / exception tracking | [`sentry.md`](./sources/sentry.md) | Sentry (adapt for Rollbar, Bugsnag, Airbrake) |
|
|
13
|
+
| Product analytics warehouse | [`databricks.md`](./sources/databricks.md) | Databricks SQL (adapt for Snowflake, BigQuery, ClickHouse, dbt) |
|
|
14
|
+
|
|
15
|
+
Cross-cutting:
|
|
16
|
+
|
|
17
|
+
- [`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).
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Code Archaeology (git + in-repo)
|
|
2
|
+
|
|
3
|
+
## What this source contains
|
|
4
|
+
|
|
5
|
+
- Commit history (messages, dates, authors, diffs)
|
|
6
|
+
- PR descriptions, review comments, and discussion threads (via `gh`)
|
|
7
|
+
- Inline code comments, TODOs, FIXMEs, deprecation notes
|
|
8
|
+
- ADRs (architectural decision records) if the repo keeps them
|
|
9
|
+
- Tests. Names and assertions often encode the edge cases that motivated a change
|
|
10
|
+
- Related files modified in the same commits (co-change signal)
|
|
11
|
+
- CHANGELOG entries, release notes in the repo
|
|
12
|
+
- Issue/ticket IDs mentioned in commit messages and PR bodies
|
|
13
|
+
|
|
14
|
+
The most trustworthy source, tied directly to the code, and the most complete. Everything that went through the repo should be here.
|
|
15
|
+
|
|
16
|
+
## How to search it
|
|
17
|
+
|
|
18
|
+
Expand the seed commit list:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Full history of the file through renames
|
|
22
|
+
git log --follow --oneline -- <file>
|
|
23
|
+
|
|
24
|
+
# Pickaxe: commits that added or removed this exact text
|
|
25
|
+
git log -S '<exact_string_from_code>' -- <file>
|
|
26
|
+
|
|
27
|
+
# Or for patterns:
|
|
28
|
+
git log -G '<regex>' -- <file>
|
|
29
|
+
|
|
30
|
+
# Who wrote each line and when
|
|
31
|
+
git blame -L <start>,<end> <file>
|
|
32
|
+
|
|
33
|
+
# The full diff of a specific commit
|
|
34
|
+
git show <hash>
|
|
35
|
+
|
|
36
|
+
# Commits between two points affecting this file
|
|
37
|
+
git log <old>..<new> -p -- <file>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For each substantive commit, pull the PR context:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Find the PR number from the merge commit or branch
|
|
44
|
+
git log -1 --format=%B <hash>
|
|
45
|
+
|
|
46
|
+
# Full PR context: body, review comments, linked issues
|
|
47
|
+
gh pr view <number> --json title,body,author,createdAt,mergedAt,labels,closingIssuesReferences,comments,reviews,files
|
|
48
|
+
|
|
49
|
+
# The --json reviews and comments fields are where the real signal is
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Look for out-of-band docs:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# ADRs often live in docs/adr/ or similar
|
|
56
|
+
rg -l -i 'architecture.decision' --glob '*.md'
|
|
57
|
+
|
|
58
|
+
# TODOs and FIXMEs near the target
|
|
59
|
+
rg -n -C2 '(TODO|FIXME|HACK|XXX|NOTE)' <target_file>
|
|
60
|
+
|
|
61
|
+
# Related tests. Names often encode the "why"
|
|
62
|
+
rg -l '<symbol>' --glob '*test*'
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## What good evidence looks like here
|
|
66
|
+
|
|
67
|
+
- A PR description that explains the problem being solved, not just the change ("This fixes the pagination bug that caused X")
|
|
68
|
+
- A long review thread where alternatives were debated
|
|
69
|
+
- An inline comment near the target line that explains a non-obvious constraint
|
|
70
|
+
- A test named `test_handles_edge_case_when_X` that reveals an edge case motivating the code
|
|
71
|
+
- A commit message that references a ticket or incident ID
|
|
72
|
+
- A CHANGELOG entry that summarizes the user-visible rationale
|
|
73
|
+
|
|
74
|
+
## Common pitfalls
|
|
75
|
+
|
|
76
|
+
- **Squash-merge flatlands.** If the repo squashes PRs, individual commits in the branch history are lost. Fall back to PR body and comments.
|
|
77
|
+
- **Misleading commit messages.** "Small refactor" sometimes hides an intentional behavior change. Look at the diff, not the message.
|
|
78
|
+
- **Cargo-culted patterns.** The author may have copied a pattern without understanding why. Check if the pattern originated earlier in the codebase and investigate *that* commit.
|
|
79
|
+
- **Bot commits and auto-merges.** Dependabot, Renovate, and automated backports usually don't carry motivation. Skip them when trying to find intent.
|
|
80
|
+
- **Treating code as evidence of intent.** The code itself isn't evidence for why it exists. Evidence comes from commit messages, PRs, comments, tests, docs. Don't cite "the function is named X" as evidence of intent.
|
|
81
|
+
|
|
82
|
+
## What to return
|
|
83
|
+
|
|
84
|
+
Every commit/PR/comment that bears on the question, with:
|
|
85
|
+
- The exact text (quoted)
|
|
86
|
+
- The hash / PR number / file:line
|
|
87
|
+
- Author and date
|
|
88
|
+
- Whether it's direct (explicitly addresses the question) or circumstantial
|