@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.
Files changed (128) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -0
  3. package/agents/comment-sicko.md +34 -0
  4. package/agents/poteto-agent.md +13 -0
  5. package/extensions/pstack/config.ts +228 -0
  6. package/extensions/pstack/index.ts +211 -0
  7. package/package.json +57 -0
  8. package/skills/architect/SKILL.md +82 -0
  9. package/skills/architect/references/design-red-flags.md +33 -0
  10. package/skills/architect/references/rationale-template.md +35 -0
  11. package/skills/architect/references/runner-prompt.md +20 -0
  12. package/skills/arena/SKILL.md +70 -0
  13. package/skills/automate-me/SKILL.md +114 -0
  14. package/skills/blast-radius/SKILL.md +49 -0
  15. package/skills/bro/SKILL.md +6 -0
  16. package/skills/create-verification-skill/SKILL.md +43 -0
  17. package/skills/create-verification-skill/references/feature-map-example/README.md +47 -0
  18. package/skills/create-verification-skill/references/feature-map-example/create-note.md +39 -0
  19. package/skills/create-verification-skill/references/feature-map-example/search.md +45 -0
  20. package/skills/figure-it-out/SKILL.md +54 -0
  21. package/skills/how/SKILL.md +134 -0
  22. package/skills/how/references/critic-prompt.md +59 -0
  23. package/skills/how/references/critique-rubric.md +58 -0
  24. package/skills/how/references/explainer-prompt.md +55 -0
  25. package/skills/how/references/explorer-prompt.md +52 -0
  26. package/skills/interrogate/SKILL.md +109 -0
  27. package/skills/interrogate/references/code-quality-review.md +47 -0
  28. package/skills/interrogate/references/lead-judgment.md +58 -0
  29. package/skills/interrogate/references/reviewer-prompt.md +72 -0
  30. package/skills/interrogate/references/rubric.md +77 -0
  31. package/skills/maintain-verification-skill/SKILL.md +38 -0
  32. package/skills/no-comments/SKILL.md +23 -0
  33. package/skills/poteto-mode/SKILL.md +140 -0
  34. package/skills/poteto-mode/playbooks/authoring-a-skill.md +12 -0
  35. package/skills/poteto-mode/playbooks/autonomous-run.md +13 -0
  36. package/skills/poteto-mode/playbooks/autopilot-full.md +13 -0
  37. package/skills/poteto-mode/playbooks/autopilot-stack.md +31 -0
  38. package/skills/poteto-mode/playbooks/babysit.md +27 -0
  39. package/skills/poteto-mode/playbooks/bug-fix.md +17 -0
  40. package/skills/poteto-mode/playbooks/eval.md +27 -0
  41. package/skills/poteto-mode/playbooks/feature.md +21 -0
  42. package/skills/poteto-mode/playbooks/hillclimb.md +21 -0
  43. package/skills/poteto-mode/playbooks/investigation.md +14 -0
  44. package/skills/poteto-mode/playbooks/multi-phase-plan.md +3 -0
  45. package/skills/poteto-mode/playbooks/opening-a-pr.md +35 -0
  46. package/skills/poteto-mode/playbooks/orchestrate.md +113 -0
  47. package/skills/poteto-mode/playbooks/pause-safely.md +10 -0
  48. package/skills/poteto-mode/playbooks/perf-issue.md +24 -0
  49. package/skills/poteto-mode/playbooks/prototype.md +14 -0
  50. package/skills/poteto-mode/playbooks/refactoring.md +16 -0
  51. package/skills/poteto-mode/playbooks/runtime-forensics.md +11 -0
  52. package/skills/poteto-mode/playbooks/session-pickup.md +13 -0
  53. package/skills/poteto-mode/playbooks/shipping.md +40 -0
  54. package/skills/poteto-mode/playbooks/trace-forensics.md +14 -0
  55. package/skills/poteto-mode/playbooks/visual-parity.md +11 -0
  56. package/skills/poteto-mode/playbooks/worktree-cleanup.md +14 -0
  57. package/skills/poteto-mode/references/bugbot-triage.md +142 -0
  58. package/skills/poteto-mode/references/plan.md +105 -0
  59. package/skills/poteto-mode/scripts/bootstrap.ts +62 -0
  60. package/skills/poteto-mode/scripts/bun.lock +67 -0
  61. package/skills/poteto-mode/scripts/orch/orch.test.ts +634 -0
  62. package/skills/poteto-mode/scripts/orch/orch.ts +578 -0
  63. package/skills/poteto-mode/scripts/orch/store.ts +1607 -0
  64. package/skills/poteto-mode/scripts/package.json +16 -0
  65. package/skills/poteto-mode/scripts/watch-pr/cli.test.ts +224 -0
  66. package/skills/poteto-mode/scripts/watch-pr/cli.ts +223 -0
  67. package/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +118 -0
  68. package/skills/poteto-mode/scripts/watch-pr/github.test.ts +306 -0
  69. package/skills/poteto-mode/scripts/watch-pr/github.ts +699 -0
  70. package/skills/poteto-mode/scripts/watch-pr/policy.test.ts +420 -0
  71. package/skills/poteto-mode/scripts/watch-pr/policy.ts +832 -0
  72. package/skills/poteto-mode/scripts/watch-pr/render.ts +169 -0
  73. package/skills/poteto-mode/scripts/watch-pr/tsconfig.json +13 -0
  74. package/skills/poteto-mode/scripts/watch-pr/types.compile.ts +93 -0
  75. package/skills/poteto-mode/scripts/watch-pr/types.ts +401 -0
  76. package/skills/poteto-mode/scripts/watch-pr/watch-pr +6 -0
  77. package/skills/poteto-mode/scripts/worktree-audit.sh +85 -0
  78. package/skills/principle-boundary-discipline/SKILL.md +33 -0
  79. package/skills/principle-build-the-lever/SKILL.md +22 -0
  80. package/skills/principle-encode-lessons-in-structure/SKILL.md +30 -0
  81. package/skills/principle-exhaust-the-design-space/SKILL.md +20 -0
  82. package/skills/principle-experience-first/SKILL.md +18 -0
  83. package/skills/principle-fix-root-causes/SKILL.md +22 -0
  84. package/skills/principle-foundational-thinking/SKILL.md +20 -0
  85. package/skills/principle-guard-the-context-window/SKILL.md +16 -0
  86. package/skills/principle-laziness-protocol/SKILL.md +17 -0
  87. package/skills/principle-make-operations-idempotent/SKILL.md +23 -0
  88. package/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +21 -0
  89. package/skills/principle-minimize-reader-load/SKILL.md +22 -0
  90. package/skills/principle-model-the-domain/SKILL.md +25 -0
  91. package/skills/principle-never-block-on-the-human/SKILL.md +22 -0
  92. package/skills/principle-outcome-oriented-execution/SKILL.md +21 -0
  93. package/skills/principle-prove-it-works/SKILL.md +32 -0
  94. package/skills/principle-redesign-from-first-principles/SKILL.md +15 -0
  95. package/skills/principle-separate-before-serializing-shared-state/SKILL.md +15 -0
  96. package/skills/principle-sequence-verifiable-units/SKILL.md +21 -0
  97. package/skills/principle-subtract-before-you-add/SKILL.md +21 -0
  98. package/skills/principle-type-system-discipline/SKILL.md +30 -0
  99. package/skills/recall/SKILL.md +40 -0
  100. package/skills/reflect/SKILL.md +77 -0
  101. package/skills/reflect/references/divergent-reviewer.md +43 -0
  102. package/skills/reflect/references/judgment-reviewer.md +42 -0
  103. package/skills/reflect/references/synthesizer.md +56 -0
  104. package/skills/reflect/references/tooling-reviewer.md +57 -0
  105. package/skills/setup-pstack/SKILL.md +28 -0
  106. package/skills/show-me-your-work/SKILL.md +89 -0
  107. package/skills/show-me-your-work/references/decision-log-template.tsv +1 -0
  108. package/skills/show-me-your-work/scripts/log.sh +40 -0
  109. package/skills/swarm/SKILL.md +45 -0
  110. package/skills/tdd/SKILL.md +43 -0
  111. package/skills/teach/SKILL.md +20 -0
  112. package/skills/technical-writing/SKILL.md +129 -0
  113. package/skills/typescript-best-practices/SKILL.md +28 -0
  114. package/skills/typescript-best-practices/references/patterns.md +292 -0
  115. package/skills/unslop/SKILL.md +80 -0
  116. package/skills/why/SKILL.md +229 -0
  117. package/skills/why/references/epistemics.md +144 -0
  118. package/skills/why/references/investigator-prompt.md +103 -0
  119. package/skills/why/references/source-playbook.md +17 -0
  120. package/skills/why/references/sources/code-archaeology.md +88 -0
  121. package/skills/why/references/sources/databricks.md +70 -0
  122. package/skills/why/references/sources/datadog.md +99 -0
  123. package/skills/why/references/sources/incident-postmortem.md +15 -0
  124. package/skills/why/references/sources/linear.md +48 -0
  125. package/skills/why/references/sources/notion.md +55 -0
  126. package/skills/why/references/sources/sentry.md +100 -0
  127. package/skills/why/references/sources/slack.md +54 -0
  128. package/skills/why/references/synthesizer-prompt.md +135 -0
@@ -0,0 +1,70 @@
1
+ # Databricks Analytics & System Tables
2
+
3
+ ## What this source contains
4
+
5
+ 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).
6
+
7
+ - **Product analytics events.** `your_warehouse.events.analytics_track_event` (raw) and typed, deduplicated per-event dbt models in `<your_analytics_db>.<schema>.<table>`. User behavior: feature invocations, clicks, accepts/rejects, submissions, client-reported errors.
8
+ - **Usage & billing events.** `your_warehouse.events.usage_event` / `<your_analytics_db>.<schema>.stg_usage_events`; `your_warehouse.events.raw_model_event` / `<your_analytics_db>.<schema>.stg_raw_model_events`. For cost- or volume-driven decisions.
9
+ - **Experiment / feature-flag data.** Exposure and outcome tables. **Schema is company-specific.** Probe with `SHOW TABLES` before assuming names.
10
+ - **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?"
11
+ - **dbt lineage.** Models in `<your_analytics_db>.<schema>` reveal what pipelines depend on a table/field; upstream changes frequently motivate consumer-code changes.
12
+ - **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.
13
+
14
+ ## How to search it
15
+
16
+ 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.
17
+
18
+ **Orient before querying.** Schemas are company-specific; probe before trusting a table name:
19
+
20
+ ```sql
21
+ SHOW TABLES IN <your_analytics_db>.<schema> LIKE '*<keyword>*';
22
+ DESCRIBE TABLE <your_analytics_db>.<schema>.stg_<event>;
23
+ ```
24
+
25
+ **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.
26
+
27
+ **Prefer typed dbt models over the raw table.** `<your_analytics_db>.<schema>.<table>` is deduplicated, typed, and liquid-clustered; `your_warehouse.events.analytics_track_event` has duplicates and untyped `properties_json`. Model-name pattern: `stg_<source>_<event_name_with_underscores>`, where `<source>` 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.
28
+
29
+ **Column conventions on the typed dbt models** (knowing these avoids a `DESCRIBE` round-trip):
30
+
31
+ - `_timestamp`, `_id`, `_auth_id`, `_request_id`, `event_name`. Standard on every model
32
+ - `properties_<name>`. Typed, underscore-cased event properties (`properties_entrypoint`, `properties_size_bytes`, …)
33
+ - `context_team_id`, `context_client_version`, `context_country`, `context_client_os`. Pre-extracted client context
34
+
35
+ ### Investigation patterns that tend to pay off
36
+
37
+ Pick the table + column combination that matches the target:
38
+
39
+ 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.
40
+ 2. **Guard-rail / defensive-check origin.** Distribution (median / p99 / max) of the relevant `properties_<name>` column in the 14 days *before* the PR. A p99 that matches the target's threshold constant suggests the number was chosen from data.
41
+ 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.
42
+ 4. **Query-history evidence for migrations, backfills, or perf rewrites.** `system.query.history` filtered by `statement_text ILIKE '%<table_or_symbol>%'` 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(*)`).
43
+ 5. **dbt lineage.** If the target reads from or writes into a `<your_analytics_db>.<schema>` 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.
44
+
45
+ ## What good evidence looks like here
46
+
47
+ Beyond the pattern shapes above:
48
+
49
+ - 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
50
+ - An exposure table row names the target's feature-flag key with a "shipped" / "concluded" decision around the PR ship date
51
+
52
+ ## Common pitfalls
53
+
54
+ - **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.
55
+ - **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.
56
+ - **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`.
57
+ - **dbt refresh lag.** `<your_analytics_db>.<schema>.*` 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`.
58
+ - **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.
59
+ - **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."
60
+ - **Notebooks aren't queryable.** The SQL MCP can't see Databricks notebooks. If you suspect the rationale lives in one, return a gap.
61
+
62
+ ## What to return
63
+
64
+ For each relevant finding:
65
+ - Type (product event / experiment exposure / usage or billing event / system-table row / dbt model)
66
+ - Fully-qualified table name and the exact query you ran
67
+ - Time window queried
68
+ - Compact numeric summary (counts, percentiles, first/last-seen timestamps). **Don't dump raw rows.**
69
+ - Temporal correlation with the target's ship date (e.g., "first row 2024-08-15; PR #49074 merged 2024-08-14")
70
+ - Relevance + strength: direct / circumstantial / weak
@@ -0,0 +1,99 @@
1
+ # Datadog Telemetry
2
+
3
+ ## What this source contains
4
+
5
+ Datadog holds the runtime record: what actually happened in production, as opposed to what was planned or discussed.
6
+
7
+ - **Metrics.** Counters, gauges, histograms instrumented by the team. A metric's *presence* is itself evidence: someone thought this number worth watching.
8
+ - **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.
9
+ - **Dashboards.** Curated views. The charts tell you what the team considers important for a subsystem.
10
+ - **APM traces & spans.** Request-level runtime data. Useful for "why is this slow" / "why is there a timeout here" questions.
11
+ - **Logs.** High-volume event records. Often contain the error conditions that motivated defensive code.
12
+ - **Incidents.** Formal incident records with timelines and linked postmortems.
13
+ - **Notebooks.** Exploratory investigations; often contain hypotheses and analyses.
14
+
15
+ Datadog answers "what was the production reality around the time this code was written?", which often explains the code's shape.
16
+
17
+ ## How to search it
18
+
19
+ Use the Datadog MCP. Start broad, then narrow.
20
+
21
+ 1. **Identify the owning service(s).**
22
+
23
+ ```
24
+ search_datadog_services (filter by name or team)
25
+ search_datadog_service_dependencies (see upstream/downstream)
26
+ ```
27
+
28
+ 2. **Dashboards and monitors first. They tell you what the team cares about.**
29
+
30
+ ```
31
+ search_datadog_dashboards (query: feature name, service name, symbol)
32
+ search_datadog_monitors (same queries)
33
+ ```
34
+
35
+ 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?"
36
+
37
+ 3. **Metrics around the target.**
38
+
39
+ ```
40
+ search_datadog_metrics (by name pattern, e.g., the feature or symbol)
41
+ get_datadog_metric_context (metadata: description, units, tags)
42
+ get_datadog_metric (timeseries; "was there a spike around the PR date?")
43
+ ```
44
+
45
+ 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."
46
+
47
+ 4. **Logs. Narrow, don't dump.**
48
+
49
+ ```
50
+ search_datadog_logs (raw log patterns near the target, set use_log_patterns=true)
51
+ analyze_datadog_logs (SQL-style aggregations, only when you need counts)
52
+ ```
53
+
54
+ Search with symbols, error strings, or feature names. **Strongly prefer time-bounded queries** (e.g., 30 days before/after the change). Log volume is huge; unconstrained searches waste time and may time out.
55
+
56
+ 5. **APM spans and traces.**
57
+
58
+ ```
59
+ aggregate_spans (stats: "how often does this endpoint fail?")
60
+ search_datadog_spans (inspect individual spans)
61
+ get_datadog_trace (a specific trace ID)
62
+ ```
63
+
64
+ Useful for timeouts, retries, slow paths, and cross-service behavior.
65
+
66
+ 6. **Incidents.**
67
+
68
+ ```
69
+ search_datadog_incidents (by title, team, date range)
70
+ get_datadog_incident (full detail for a specific incident)
71
+ ```
72
+
73
+ 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.
74
+
75
+ ## What good evidence looks like here
76
+
77
+ - A monitor whose query and threshold match the constraint the code enforces (code clamps to 100; monitor alerts when requests exceed 100/min)
78
+ - A dashboard created by the target's author, with widgets that correspond to what the code measures or guards against
79
+ - A metric showing a production spike immediately before the code was merged, and stable values after
80
+ - An incident record referencing the target code, the same symbols, or the same error strings
81
+ - Logs showing a specific error pattern the defensive code would prevent, timestamped in the window before the change
82
+
83
+ ## Common pitfalls
84
+
85
+ - **Correlation is not causation.** A spike before a PR and stabilization after is suggestive, not definitive. Other changes may have landed in the same window. Check neighboring PRs.
86
+ - **Overfitting to the chart you found.** Datadog visualizations are *made* by humans and reflect that human'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.
87
+ - **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.
88
+ - **Noise at scale.** Searching logs for a common string returns thousands of matches. Narrow by service, tag, and time aggressively. Use `analyze_datadog_logs` to aggregate rather than dumping raw logs.
89
+ - **Instrumented != caused.** A metric's existence tells you someone cared enough to measure something, not that the code was added *because* of it. Cross-reference with commit/PR dates.
90
+
91
+ ## What to return
92
+
93
+ For each relevant item:
94
+ - Type (dashboard / monitor / metric / log pattern / trace / incident / notebook)
95
+ - Title or name
96
+ - Link or identifier (dashboard ID, monitor ID, metric name, incident ID)
97
+ - Owner/author and created/modified date
98
+ - The specific condition, query, or quote that bears on the question (verbatim where possible)
99
+ - Relevance: what this suggests about the target code, and how strong the connection is
@@ -0,0 +1,15 @@
1
+ # Incident & Postmortem Context
2
+
3
+ Not a separate source, a **cross-cutting angle**. Incidents often motivate defensive code ("we added this check after the X outage"), so if the target looks defensive (null checks, retry logic, timeout handling, rate limiting, feature flags), specifically hunt for incident history across every available source:
4
+
5
+ - **Notion**: search for postmortems mentioning the target file, feature, or error string
6
+ - **Linear**: look for tickets labeled `incident`, `sev-*`, `postmortem-action-item`, `reliability`
7
+ - **Slack**: search `#sev-*` and `#incident-*` channels around the dates the target code was added
8
+ - **Git**: commits with messages like "fix for incident", "add defensive check", "revert" followed by "re-apply with..." are strong signals
9
+ - **Datadog**: `search_datadog_incidents` for formal incident records with timelines; dashboards and monitors created as postmortem action items
10
+ - **Sentry**: issues whose first-seen/last-seen window aligns with the target's PR ship date; stack traces through the target
11
+ - **Databricks**: product-analytics events that classify an error condition (client-reported failures, user-visible retry events, etc.) often spike during an incident window. A drop in that event count after the target PR ships is circumstantial support that the target code resolved the user-visible symptom, even when Datadog/Sentry signal is noisy.
12
+
13
+ If you find an incident link, fetch the full postmortem. Postmortems typically have an "Action Items" section that ties directly to code changes. When multiple sources corroborate (a Datadog incident ID appears in a Linear ticket, which appears in a Notion postmortem, which appears in a Slack thread that links to the target PR, and the Databricks error-event count drops after the fix), the evidence is especially strong.
14
+
15
+ Worth spending time on when the code's defensive character makes an incident-driven origin plausible. Skip it for code that doesn't look defensive.
@@ -0,0 +1,48 @@
1
+ # Linear Tickets
2
+
3
+ ## What this source contains
4
+
5
+ - Issues describing features, bugs, and their motivation
6
+ - Project docs attached to issues (often PRDs or specs)
7
+ - Parent/sub-issue relationships (broader initiative → specific tickets)
8
+ - Comments on issues (clarifications, scope changes, "why we're doing this" rationale)
9
+ - Labels (e.g., `compliance`, `customer-request`, `perf`) that signal the type of motivation
10
+ - Status updates that explain scope changes
11
+ - Attachments and linked GitHub PRs
12
+
13
+ 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.
14
+
15
+ ## How to search it
16
+
17
+ Use the Linear MCP.
18
+
19
+ 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.
20
+ 2. **List related issues by keyword.** Use `list_issues` with text search for the feature name, key symbol, or business term. Try multiple phrasings.
21
+ 3. **Walk the issue tree.** If you land on a sub-issue, fetch its parent. Sub-issues are tactical; parents often carry the "why."
22
+ 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.
23
+ 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.
24
+
25
+ ## What good evidence looks like here
26
+
27
+ - An issue description stating the business problem: "Customer Acme needs X because of their SOC2 audit"
28
+ - A comment recording a decision: "We decided to go with approach B because approach A would require touching the billing service"
29
+ - A parent issue titled like an initiative: "Q3 Enterprise Readiness" or "Reduce Payment Failures"
30
+ - An attached PRD or spec
31
+ - Labels like `customer:acme`, `incident-followup`, `compliance`, `perf-regression`
32
+
33
+ ## Common pitfalls
34
+
35
+ - **Scope drift.** The ticket the PR references may have been closed and reopened with a different scope. Read the whole history.
36
+ - **Mechanical templates.** Some teams require "Why" sections but fill them with boilerplate. Generic text ("improve user experience") is probably not a real answer.
37
+ - **Stale tickets.** Old tickets often reflect a version of the plan that changed. Check dates and cross-reference with the code's ship date.
38
+ - **Closed-as-duplicate chains.** Follow the duplicate-of relationships back to the canonical ticket.
39
+ - **Private workspace content.** If you can't access an issue, note that as a gap rather than guessing.
40
+
41
+ ## What to return
42
+
43
+ For each relevant ticket:
44
+ - Ticket ID and title
45
+ - The problem/motivation quoted from the description or comments (not paraphrased; the synthesizer needs the exact text to cite)
46
+ - Labels, parent issue, project
47
+ - Author, created date, closed date
48
+ - Link to the ticket if available
@@ -0,0 +1,55 @@
1
+ # Notion Docs
2
+
3
+ ## What this source contains
4
+
5
+ - PRDs (product requirement documents)
6
+ - Technical specs and RFCs
7
+ - Architectural decision records (ADRs)
8
+ - Meeting notes from design reviews
9
+ - Team pages with domain context
10
+ - Postmortems from incidents
11
+ - Runbooks that may explain defensive code
12
+ - Strategy documents that set priorities
13
+
14
+ Notion is where "why" often lives in long-form before it becomes code. A significant feature usually has a doc.
15
+
16
+ ## How to search it
17
+
18
+ Use the Notion MCP.
19
+
20
+ 1. **Keyword searches with `notion-search`.** Try:
21
+ - The feature name
22
+ - Key symbols / class names from the target code
23
+ - Author handles (design docs are often authored before the code lands)
24
+ - Error strings or user-visible terms
25
+ - Time-bounded queries if you know when the code shipped
26
+ 2. **Fetch candidate pages with `notion-fetch`.** Read the full content, not the preview; rationale is often buried mid-document.
27
+ 3. **Follow backlinks and child pages.** Design docs often have sub-pages for alternatives considered, appendices, or implementation notes.
28
+ 4. **Check related databases.** `notion-query-data-sources` and `notion-query-meeting-notes` can surface meeting notes that discussed the decision.
29
+ 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.
30
+
31
+ ## What good evidence looks like here
32
+
33
+ - A PRD with a "Problem statement" or "Motivation" section that matches the target code's purpose
34
+ - An "Alternatives considered" or "Rejected approaches" section
35
+ - A postmortem that names the target code as the fix for a specific incident
36
+ - Meeting notes that record "we decided X because Y" and tie to the same author/date range as the PR
37
+ - An ADR template filled out non-trivially (status, context, decision, consequences)
38
+
39
+ ## Common pitfalls
40
+
41
+ - **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.
42
+ - **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.
43
+ - **Boilerplate templates.** Some orgs require a "Why" section that gets filled with fluff. Look for specificity.
44
+ - **Unlinked docs.** The most relevant doc may not be linked from anywhere. Broad keyword searches help.
45
+ - **Multiple drafts.** If a topic has multiple docs, find the one that was finalized or most recently updated. Check dates.
46
+ - **Access-restricted pages.** If you can't access a page, note it as a gap.
47
+
48
+ ## What to return
49
+
50
+ For each relevant doc:
51
+ - Title and URL
52
+ - Authors and last-updated date
53
+ - The motivation text (verbatim quote), with page/section location
54
+ - Relevant linked pages (so the synthesizer can cite them)
55
+ - Whether the doc was finalized or draft
@@ -0,0 +1,100 @@
1
+ # Sentry Error History
2
+
3
+ ## What this source contains
4
+
5
+ Sentry is the archive of things that went wrong. For defensive, corrective, or error-handling code, it often holds the direct motivation: the specific exceptions, stack traces, and frequencies that pushed someone to add a check, catch, retry, or fallback.
6
+
7
+ - **Issues.** Grouped errors with counts, first/last seen timestamps, affected releases, and comments
8
+ - **Events.** Individual error instances within an issue (stack traces, tags, user context)
9
+ - **Releases.** Deployment records with associated issues (useful for "which version fixed this?")
10
+ - **Replays.** Session recordings of user-facing errors (if enabled)
11
+ - **Profiles.** Performance profiling data (less useful for "why"; more for "how slow")
12
+ - **Issue comments & assignments.** Sometimes contain engineer notes on root cause
13
+
14
+ The most valuable thing Sentry provides is **temporal correlation**: "issue X was created 2024-01-02, peaked at 500 events/day, stopped appearing after release v2.14.0 on 2024-01-15, the release that shipped the defensive check."
15
+
16
+ ## How to search it
17
+
18
+ Use the Sentry MCP.
19
+
20
+ 1. **Orient.** If you don't know the project slug and organization:
21
+
22
+ ```
23
+ find_organizations
24
+ find_projects
25
+ ```
26
+
27
+ 2. **Search for issues related to the target.**
28
+
29
+ ```
30
+ search_issues (natural language, e.g., "errors in PaymentService timeout", "unhandled exceptions in uploadFile")
31
+ ```
32
+
33
+ Good query components: exception class names the target handles, the function or class name of the target, error message strings the target checks for, the file path of the target.
34
+
35
+ 3. **Narrow by release and time window.**
36
+
37
+ ```
38
+ search_issue_events (filter by release, time, environment, trace ID, tags)
39
+ get_issue_tag_values (for an issue, see distribution across versions, users, environments)
40
+ ```
41
+
42
+ For a suspected issue, check:
43
+ - **First seen.** When did the error start appearing?
44
+ - **Last seen.** When did it stop? Does it line up with the target's ship date?
45
+ - **Affected releases.** Which versions saw it? Which was the fix?
46
+ - **Frequency trajectory.** Did it spike, then get resolved?
47
+
48
+ 4. **Pull the full event for context.**
49
+
50
+ ```
51
+ get_sentry_resource (pass a Sentry URL or type+ID)
52
+ ```
53
+
54
+ Does the stack trace pass through the target code? Do the tags and breadcrumbs match the conditions the target defends against?
55
+
56
+ 5. **Check releases that landed near the target.**
57
+
58
+ ```
59
+ find_releases (around the commit date of the target)
60
+ ```
61
+
62
+ Cross-reference release version with the PR's merge date.
63
+
64
+ 6. **Use Seer sparingly.**
65
+
66
+ ```
67
+ analyze_issue_with_seer
68
+ ```
69
+
70
+ Seer produces AI root-cause analyses. Useful as a hypothesis generator, but treat them as inference, not authoritative. The actual events and stack traces are the primary evidence; Seer's narrative is secondary.
71
+
72
+ ## What good evidence looks like here
73
+
74
+ - An issue whose **first seen** is shortly before the target's PR and **last seen** shortly after, suggesting the target addressed this error
75
+ - Stack traces that pass through or land on the target function, showing the exact failure mode being defended against
76
+ - A comment on the issue from the PR author describing the fix
77
+ - The target's PR description or commit message referencing a Sentry issue URL or ID
78
+ - An issue with high event counts that stops after the release containing the target
79
+
80
+ ## Common pitfalls
81
+
82
+ - **Grouping drift.** Sentry groups errors by fingerprint. Refactors or renames can track the "same" error under a new issue ID. If an issue ends abruptly, the error may have just been regrouped. Check for new issues immediately after.
83
+ - **Release correlation is noisy.** A release contains many commits. An issue stopping at v2.14.0 doesn't prove the target fixed it; another change in the same release might have. Cross-reference with the target's exact commit.
84
+ - **Silent fixes.** Sometimes the error stops because upstream changed, not because of the defensive code. The correlation suggests the fix; it doesn't prove authorship.
85
+ - **Resolved != fixed.** Issues can be marked "resolved" manually without any code change. Treat `resolved` as a human marker, not evidence that code fixed it.
86
+ - **Seer hallucinations.** Seer can generate confident-sounding explanations that aren't right. Fall back to the actual events, stack traces, and timestamps when making claims.
87
+ - **Sampling.** Some projects sample events aggressively. A low event count may just mean high sampling, not a rare error. If in doubt, note the gap.
88
+
89
+ ## What to return
90
+
91
+ For each relevant issue:
92
+ - Issue ID and title
93
+ - Project and organization
94
+ - First seen / last seen timestamps
95
+ - Event count (and sampling rate if known)
96
+ - Affected releases
97
+ - A representative stack trace snippet showing relevance to the target (verbatim excerpt, not summary)
98
+ - First/last-seen correlation with the target's ship date
99
+ - Link to the issue
100
+ - Any author comments or resolution notes
@@ -0,0 +1,54 @@
1
+ # Slack Conversations
2
+
3
+ ## What this source contains
4
+
5
+ - Real-time discussions of problems and decisions
6
+ - Incident channels where fire-drill decisions were made
7
+ - Design discussion threads where tradeoffs were debated
8
+ - Questions answered by senior engineers that didn't make it into docs
9
+ - Post-merge discussions that explain why something was revisited
10
+ - DMs (usually not searchable, scope accordingly)
11
+
12
+ Slack is frequently where the *real* decisions got made, especially for smaller changes that didn't warrant a doc. It's also the most ephemeral source: threads get deleted, channels get archived, and search quality degrades over time.
13
+
14
+ ## How to search it
15
+
16
+ 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.
17
+
18
+ 1. **Author-bounded search.** Messages from the PR author around the PR merge date. Limits scope dramatically and often hits gold.
19
+ 2. **Keyword search for the feature name and key symbols.** Include misspellings and casual phrasings.
20
+ 3. **PR URL search.** Slack often links PRs when they're reviewed or discussed. Search for the PR URL (or just `/pull/<number>`).
21
+ 4. **Error string search.** If the code handles a specific error, search for the error string. Incident threads often surface.
22
+ 5. **Channel-scoped search.** Narrow to likely channels:
23
+ - `#eng-*`. Engineering discussions
24
+ - `#proj-*`. Project channels
25
+ - `#incident-*` / `#sev-*`. Incident channels
26
+ - Team-specific channels for the owning team
27
+ - Design review channels
28
+ 6. **Thread traversal.** When you find a relevant message, fetch the whole thread. The decision often lives in the replies.
29
+
30
+ ## What good evidence looks like here
31
+
32
+ - A thread where tradeoffs were explicitly debated ("I was going to use A but B is better because...")
33
+ - An incident channel message describing the bug the code prevents
34
+ - A question from a reviewer and an authoritative answer from the author or lead
35
+ - A reference to a meeting where a decision was made
36
+ - A message from a product manager or customer-facing engineer explaining a customer ask
37
+
38
+ ## Common pitfalls
39
+
40
+ - **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.
41
+ - **Unsearched DMs.** Many decisions happen in DMs that aren't searchable. You'll miss them; that's a known limitation.
42
+ - **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.
43
+ - **Context collapse in single messages.** Without the thread, a single message often reads differently than in context. Always fetch threads.
44
+ - **Auth failures.** If the MCP isn't authenticated, stop. Don't make up findings. Report that Slack wasn't searchable.
45
+
46
+ ## What to return
47
+
48
+ For each relevant thread:
49
+ - Channel name
50
+ - Permalink or thread ID
51
+ - Participants
52
+ - Date range of the discussion
53
+ - The key quotes (verbatim) with attribution
54
+ - Context: what thread/incident/discussion this was part of
@@ -0,0 +1,135 @@
1
+ # Synthesizer Prompt Template
2
+
3
+ Build the synthesizer's prompt from this template; fill in the placeholders.
4
+
5
+ ---
6
+
7
+ You are answering a "why" question about a piece of code by synthesizing findings from multiple 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 honestly communicates what the evidence supports and what it doesn't.
8
+
9
+ ## The Question
10
+
11
+ > {QUESTION}
12
+
13
+ ## The Code Anchor
14
+
15
+ **Target files:** {FILES_WITH_LINE_RANGES}
16
+
17
+ **Key symbols:** {SYMBOLS}
18
+
19
+ ## Investigator Findings
20
+
21
+ {ALL_INVESTIGATOR_FINDINGS}
22
+
23
+ ## Sources That Weren't Searched
24
+
25
+ {SKIPPED_SOURCES_WITH_REASONS}
26
+
27
+ ## Epistemics Framework
28
+
29
+ You MUST follow the framework in `references/epistemics.md`. Read it in full before writing the output. The key rules:
30
+
31
+ 1. Every claim sits in one of these tiers: **Direct**, **Supported**, **Inferred**, **Speculative**, **Unknown**. The tier determines what section the claim goes in and how it's phrased.
32
+ 2. Every Direct/Supported claim must have a citation (PR #, ticket ID, doc URL, chat permalink, commit hash, or file:line).
33
+ 3. Inferred and Speculative claims must use hedged language ("appears to", "likely", "suggests", "one possibility is").
34
+ 4. Never cite code as evidence for its own intent.
35
+ 5. Gaps in the evidence must be documented. Don't fill them with plausible-sounding guesses.
36
+ 6. If the user's question embedded a hypothesis, treat it as a candidate, not a conclusion. Check the evidence independently.
37
+
38
+ ## Instructions
39
+
40
+ 1. **Read all investigator findings.** They gathered raw evidence, not conclusions. You weigh it.
41
+ 2. **Reconcile overlapping findings.** Multiple investigators may have cited the same PR, ticket, or doc. Merge into a single, authoritative reference.
42
+ 3. **Identify contradictions.** If two items of evidence disagree, don't pick one. Surface both.
43
+ 4. **Calibrate confidence.** For each claim, identify the evidence and the tier. State Direct claims plainly with a citation. Hedge Inferred claims and explain the inference. Mark Speculative claims explicitly. Put claims with no evidence in the gaps section.
44
+ 5. **Verify citations by spot-checking.** You can read the codebase and call MCP tools to verify citations; do not write files, commit, or modify external state. If you're uncertain a cited item exists or says what's claimed, check it. Don't propagate errors.
45
+ 6. **Don't overreach.** The user will act on your output. Better to leave an open question open than to fill it with a confident-sounding guess.
46
+
47
+ ## Output Format
48
+
49
+ Write the output for the user. Use this exact structure:
50
+
51
+ ---
52
+
53
+ ### The Question
54
+
55
+ Restate the user's question in one or two sentences so the answer is anchored.
56
+
57
+ ### The Code in Question
58
+
59
+ File paths, line ranges, key symbols. Two or three lines to orient a reader who lands here cold.
60
+
61
+ ### What We Found
62
+
63
+ **Claims with direct evidence**, one per bullet. Quote or paraphrase the source and cite precisely. Format each finding like:
64
+
65
+ - **[Direct]** {Claim}. Source: [PR #123](url) / ticket ID / file:line. {Brief quote or paraphrase.}
66
+ - **[Supported]** {Claim}. Evidence: {list of items and what each contributes}.
67
+
68
+ Use `[Direct]` for single-source, explicit evidence. Use `[Supported]` when multiple indirect items converge on a conclusion.
69
+
70
+ ### What We Can Reasonably Infer
71
+
72
+ **Claims that aren't explicitly stated anywhere but are well-supported by indirect evidence.** Make the inference chain visible: "Given A and B, it's likely that C." Use hedged language ("appears to", "likely", "suggests", "is consistent with"). Format:
73
+
74
+ - **[Inferred]** {Hedged claim}. Reasoning: {the specific evidence and the inference step}.
75
+
76
+ If there's nothing to infer, skip this section.
77
+
78
+ ### Competing Hypotheses
79
+
80
+ **If the evidence fits multiple stories, present them.** Don't force a winner when the record doesn't support one. For each hypothesis:
81
+
82
+ - **Hypothesis:** {one-sentence statement}
83
+ - **Evidence for:** {specific items}
84
+ - **Evidence against or missing:** {what would need to be true but isn't, or what counter-signals exist}
85
+
86
+ Skip this section if there's a single clear answer.
87
+
88
+ ### What We Don't Know
89
+
90
+ **Explicit gaps.** Things the user asked that the evidence didn't answer. Sources searched that came up empty. Sources that weren't searchable at all, such as a missing real-time team chat MCP.
91
+
92
+ Be specific. "We searched the issue tracker for [query1], [query2], [query3] and found no issue discussing the rate-limit threshold" is useful. "We don't know why" is not. Include:
93
+
94
+ - Specific questions that went unanswered
95
+ - Searches that returned nothing
96
+ - Sources that were unavailable (and why)
97
+ - People who would likely know but who you can't ask
98
+
99
+ ### Sources Consulted
100
+
101
+ Bulleted list of what was actually searched, so the user can judge coverage and redirect. Format:
102
+
103
+ - **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."
104
+ - **Issue / ticket tracker**: {ticket IDs and keyword searches}. Or "Not searched. No matching MCP available in this environment."
105
+ - **Long-form documents**: {page titles and search queries}. Or "Not searched. No matching MCP available in this environment."
106
+ - **Real-time team chat**: {channels searched, date ranges, queries}. Or "Not searched. No matching MCP available in this environment."
107
+ - **Infrastructure observability**: {dashboards, monitors, metrics, logs, traces, or incidents searched}. Or "Not searched. No matching MCP available in this environment."
108
+ - **Error / exception tracking**: {issues, events, or releases searched}. Or "Not searched. No matching MCP available in this environment."
109
+ - **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."
110
+
111
+ ### Confidence Summary
112
+
113
+ One or two sentences summarizing your overall confidence. E.g.:
114
+
115
+ > "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."
116
+
117
+ ---
118
+
119
+ ## Quality Check Before Returning
120
+
121
+ Before finalizing, review your output against this checklist:
122
+
123
+ 1. Does every claim in "What We Found" have a citation? If not, add one or move the claim to "Inferred" or "Hypotheses."
124
+ 2. Is the phrasing tier-appropriate? (Direct claims can use "because"; Inferred claims cannot.)
125
+ 3. Did you surface any contradictions you noticed, or did you quietly pick one?
126
+ 4. Does the "What We Don't Know" section exist and name specific gaps? If it's empty or missing, be suspicious. Historical investigations almost always have gaps.
127
+ 5. If the user embedded a hypothesis in their question, did you check it against the evidence rather than rubber-stamping it?
128
+ 6. Did you cite any code as evidence for its own intent? Remove those. Code is mechanics, not motivation.
129
+ 7. Is the overall tone calibrated? A confident-sounding answer with weak evidence is the exact failure mode this skill exists to prevent.
130
+
131
+ If any item fails, revise before returning.
132
+
133
+ ## A Final Note
134
+
135
+ The value of this output comes from its honesty, not its authority. A reader who takes your answer to the original author, an engineering lead, or a product manager should be well-positioned to ask the right follow-up questions. Be clear about what's known, what's inferred, and what's missing. Don't optimize for looking decisive. Optimize for being useful.