@rune-kit/rune 2.1.1

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 (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +357 -0
  3. package/agents/.gitkeep +0 -0
  4. package/agents/architect.md +29 -0
  5. package/agents/asset-creator.md +11 -0
  6. package/agents/audit.md +11 -0
  7. package/agents/autopsy.md +11 -0
  8. package/agents/brainstorm.md +11 -0
  9. package/agents/browser-pilot.md +11 -0
  10. package/agents/coder.md +29 -0
  11. package/agents/completion-gate.md +11 -0
  12. package/agents/constraint-check.md +11 -0
  13. package/agents/context-engine.md +11 -0
  14. package/agents/cook.md +11 -0
  15. package/agents/db.md +11 -0
  16. package/agents/debug.md +11 -0
  17. package/agents/dependency-doctor.md +11 -0
  18. package/agents/deploy.md +11 -0
  19. package/agents/design.md +11 -0
  20. package/agents/docs-seeker.md +11 -0
  21. package/agents/fix.md +11 -0
  22. package/agents/hallucination-guard.md +11 -0
  23. package/agents/incident.md +11 -0
  24. package/agents/integrity-check.md +11 -0
  25. package/agents/journal.md +11 -0
  26. package/agents/launch.md +11 -0
  27. package/agents/logic-guardian.md +11 -0
  28. package/agents/marketing.md +11 -0
  29. package/agents/onboard.md +11 -0
  30. package/agents/perf.md +11 -0
  31. package/agents/plan.md +11 -0
  32. package/agents/preflight.md +11 -0
  33. package/agents/problem-solver.md +11 -0
  34. package/agents/rescue.md +11 -0
  35. package/agents/research.md +11 -0
  36. package/agents/researcher.md +29 -0
  37. package/agents/review-intake.md +11 -0
  38. package/agents/review.md +11 -0
  39. package/agents/reviewer.md +28 -0
  40. package/agents/safeguard.md +11 -0
  41. package/agents/sast.md +11 -0
  42. package/agents/scanner.md +28 -0
  43. package/agents/scope-guard.md +11 -0
  44. package/agents/scout.md +11 -0
  45. package/agents/sentinel.md +11 -0
  46. package/agents/sequential-thinking.md +11 -0
  47. package/agents/session-bridge.md +11 -0
  48. package/agents/skill-forge.md +11 -0
  49. package/agents/skill-router.md +11 -0
  50. package/agents/surgeon.md +11 -0
  51. package/agents/team.md +11 -0
  52. package/agents/test.md +11 -0
  53. package/agents/trend-scout.md +11 -0
  54. package/agents/verification.md +11 -0
  55. package/agents/video-creator.md +11 -0
  56. package/agents/watchdog.md +11 -0
  57. package/agents/worktree.md +11 -0
  58. package/commands/.gitkeep +0 -0
  59. package/commands/rune.md +168 -0
  60. package/compiler/__tests__/openclaw-adapter.test.js +140 -0
  61. package/compiler/__tests__/parser.test.js +55 -0
  62. package/compiler/adapters/antigravity.js +59 -0
  63. package/compiler/adapters/claude.js +37 -0
  64. package/compiler/adapters/cursor.js +67 -0
  65. package/compiler/adapters/generic.js +60 -0
  66. package/compiler/adapters/index.js +45 -0
  67. package/compiler/adapters/openclaw.js +150 -0
  68. package/compiler/adapters/windsurf.js +60 -0
  69. package/compiler/bin/rune.js +288 -0
  70. package/compiler/doctor.js +153 -0
  71. package/compiler/emitter.js +240 -0
  72. package/compiler/parser.js +208 -0
  73. package/compiler/transformer.js +69 -0
  74. package/compiler/transforms/branding.js +27 -0
  75. package/compiler/transforms/cross-references.js +29 -0
  76. package/compiler/transforms/frontmatter.js +38 -0
  77. package/compiler/transforms/hooks.js +68 -0
  78. package/compiler/transforms/subagents.js +36 -0
  79. package/compiler/transforms/tool-names.js +60 -0
  80. package/contexts/dev.md +34 -0
  81. package/contexts/research.md +43 -0
  82. package/contexts/review.md +55 -0
  83. package/extensions/ai-ml/PACK.md +517 -0
  84. package/extensions/analytics/PACK.md +557 -0
  85. package/extensions/backend/PACK.md +678 -0
  86. package/extensions/chrome-ext/PACK.md +995 -0
  87. package/extensions/content/PACK.md +381 -0
  88. package/extensions/devops/PACK.md +520 -0
  89. package/extensions/ecommerce/PACK.md +280 -0
  90. package/extensions/gamedev/PACK.md +393 -0
  91. package/extensions/mobile/PACK.md +273 -0
  92. package/extensions/saas/PACK.md +805 -0
  93. package/extensions/security/PACK.md +536 -0
  94. package/extensions/trading/PACK.md +597 -0
  95. package/extensions/ui/PACK.md +947 -0
  96. package/package.json +47 -0
  97. package/skills/.gitkeep +0 -0
  98. package/skills/adversary/SKILL.md +271 -0
  99. package/skills/asset-creator/SKILL.md +157 -0
  100. package/skills/audit/SKILL.md +466 -0
  101. package/skills/autopsy/SKILL.md +200 -0
  102. package/skills/ba/SKILL.md +279 -0
  103. package/skills/brainstorm/SKILL.md +266 -0
  104. package/skills/browser-pilot/SKILL.md +168 -0
  105. package/skills/completion-gate/SKILL.md +151 -0
  106. package/skills/constraint-check/SKILL.md +165 -0
  107. package/skills/context-engine/SKILL.md +176 -0
  108. package/skills/cook/SKILL.md +636 -0
  109. package/skills/db/SKILL.md +256 -0
  110. package/skills/debug/SKILL.md +240 -0
  111. package/skills/dependency-doctor/SKILL.md +235 -0
  112. package/skills/deploy/SKILL.md +174 -0
  113. package/skills/design/DESIGN-REFERENCE.md +365 -0
  114. package/skills/design/SKILL.md +462 -0
  115. package/skills/doc-processor/SKILL.md +254 -0
  116. package/skills/docs/SKILL.md +336 -0
  117. package/skills/docs-seeker/SKILL.md +166 -0
  118. package/skills/fix/SKILL.md +192 -0
  119. package/skills/git/SKILL.md +285 -0
  120. package/skills/hallucination-guard/SKILL.md +204 -0
  121. package/skills/incident/SKILL.md +241 -0
  122. package/skills/integrity-check/SKILL.md +169 -0
  123. package/skills/journal/SKILL.md +190 -0
  124. package/skills/launch/SKILL.md +330 -0
  125. package/skills/logic-guardian/SKILL.md +240 -0
  126. package/skills/marketing/SKILL.md +229 -0
  127. package/skills/mcp-builder/SKILL.md +311 -0
  128. package/skills/onboard/SKILL.md +298 -0
  129. package/skills/perf/SKILL.md +297 -0
  130. package/skills/plan/SKILL.md +520 -0
  131. package/skills/preflight/SKILL.md +231 -0
  132. package/skills/problem-solver/SKILL.md +284 -0
  133. package/skills/rescue/SKILL.md +434 -0
  134. package/skills/research/SKILL.md +122 -0
  135. package/skills/review/SKILL.md +354 -0
  136. package/skills/review-intake/SKILL.md +222 -0
  137. package/skills/safeguard/SKILL.md +188 -0
  138. package/skills/sast/SKILL.md +190 -0
  139. package/skills/scaffold/SKILL.md +276 -0
  140. package/skills/scope-guard/SKILL.md +150 -0
  141. package/skills/scout/SKILL.md +232 -0
  142. package/skills/sentinel/SKILL.md +320 -0
  143. package/skills/sentinel-env/SKILL.md +226 -0
  144. package/skills/sequential-thinking/SKILL.md +234 -0
  145. package/skills/session-bridge/SKILL.md +287 -0
  146. package/skills/skill-forge/SKILL.md +317 -0
  147. package/skills/skill-router/SKILL.md +267 -0
  148. package/skills/surgeon/SKILL.md +203 -0
  149. package/skills/team/SKILL.md +397 -0
  150. package/skills/test/SKILL.md +271 -0
  151. package/skills/trend-scout/SKILL.md +145 -0
  152. package/skills/verification/SKILL.md +201 -0
  153. package/skills/video-creator/SKILL.md +201 -0
  154. package/skills/watchdog/SKILL.md +166 -0
  155. package/skills/worktree/SKILL.md +140 -0
@@ -0,0 +1,256 @@
1
+ ---
2
+ name: db
3
+ description: Database workflow specialist. Generates migration files with rollback scripts, detects breaking schema changes, and validates query parameterization.
4
+ metadata:
5
+ author: runedev
6
+ version: "0.1.0"
7
+ layer: L2
8
+ model: sonnet
9
+ group: development
10
+ tools: "Read, Write, Edit, Bash, Glob, Grep"
11
+ ---
12
+
13
+ # db
14
+
15
+ ## Purpose
16
+
17
+ Database workflow specialist. Handles the parts of database work that cause production incidents — breaking schema changes, migrations without rollback, raw SQL injection vectors, and missing indexes on growing tables. Acts as a pre-deploy gate for any schema change, and generates correct migration files (up + down) for common ORMs.
18
+
19
+ ## Triggers
20
+
21
+ - `/rune db` — manual invocation when schema changes are planned
22
+ - Called by `cook` (L1): schema change detected in diff
23
+ - Called by `deploy` (L2): pre-deploy migration safety check
24
+ - Called by `audit` (L2): database health dimension
25
+
26
+ ## Calls (outbound)
27
+
28
+ - `scout` (L2): find schema files, migration files, ORM config
29
+ - `verification` (L3): run migration in test environment if configured
30
+ - `hallucination-guard` (L3): verify SQL syntax and ORM method names
31
+
32
+ ## Called By (inbound)
33
+
34
+ - `cook` (L1): schema change detected in diff
35
+ - `deploy` (L2): pre-deploy migration safety check
36
+ - `audit` (L2): database health dimension
37
+
38
+ ## Executable Steps
39
+
40
+ ### Step 1 — Discovery
41
+
42
+ Invoke `scout` to locate:
43
+ - Schema definition files: `*.sql`, `schema.prisma`, `models.py`, `*.migration.ts`, `db/migrate/*.rb`
44
+ - Migration directory and existing migration files (to determine next migration number)
45
+ - ORM in use: **Prisma** | **TypeORM** | **SQLAlchemy/Alembic** | **Django ORM** | **ActiveRecord** | **raw SQL** | **unknown**
46
+ - Database type: **PostgreSQL** | **MySQL** | **SQLite** | **MongoDB** | **unknown**
47
+
48
+ If ORM cannot be determined with confidence, fall back to generic SQL migration format.
49
+
50
+ ### Step 2 — Diff Analysis
51
+
52
+ Read current schema and compare against previous version (git diff if available):
53
+ - List all **added** columns, tables, indexes, constraints
54
+ - List all **removed** columns, tables, indexes
55
+ - List all **modified** columns (type changes, nullability changes, default changes)
56
+ - List all **renamed** columns or tables
57
+
58
+ ### Step 3 — Breaking Change Detection
59
+
60
+ Classify each change by impact:
61
+
62
+ | Change | Classification | Why |
63
+ |--------|---------------|-----|
64
+ | ADD COLUMN NOT NULL without DEFAULT | **BREAKING** | Fails on existing rows |
65
+ | DROP COLUMN | **BREAKING** | Irreversible data loss |
66
+ | RENAME COLUMN or TABLE | **BREAKING** | Breaks all existing queries |
67
+ | CHANGE column type (e.g. VARCHAR→INT) | **BREAKING** | Data truncation risk |
68
+ | ADD COLUMN nullable | SAFE | Existing rows get NULL |
69
+ | ADD TABLE | SAFE | No impact on existing data |
70
+ | ADD INDEX | SAFE (but may lock table) | Lock risk on large tables |
71
+ | DROP INDEX | SAFE | Slight query slowdown |
72
+ | DROP TABLE | **BREAKING** | Irreversible data loss |
73
+
74
+ For any **BREAKING** change: output `BREAKING: [change description]` and require explicit user confirmation before generating migration.
75
+
76
+ <HARD-GATE>
77
+ Migration adding NOT NULL column to existing table without DEFAULT value = BLOCK.
78
+ Column rename or type change on data-bearing table = BREAKING — emit warning and require confirmation before proceeding.
79
+ Empty downgrade/rollback function = BLOCK — every migration MUST have a working down/rollback path.
80
+ </HARD-GATE>
81
+
82
+ ### Step 4 — Migration Generation
83
+
84
+ For each schema change, generate a migration file with **up** (apply) and **down** (rollback) scripts.
85
+
86
+ **Prisma:**
87
+ ```typescript
88
+ // migrations/[timestamp]_[description]/migration.sql
89
+ -- Up
90
+ ALTER TABLE "users" ADD COLUMN "avatar_url" TEXT;
91
+
92
+ -- Down (in separate migration file or comment)
93
+ ALTER TABLE "users" DROP COLUMN "avatar_url";
94
+ ```
95
+
96
+ **Django / Alembic:**
97
+ ```python
98
+ def upgrade():
99
+ op.add_column('users', sa.Column('avatar_url', sa.Text(), nullable=True))
100
+
101
+ def downgrade():
102
+ op.drop_column('users', 'avatar_url')
103
+ # NEVER leave downgrade() empty — HARD-GATE blocks this
104
+ ```
105
+
106
+ **TypeORM:**
107
+ ```typescript
108
+ public async up(queryRunner: QueryRunner): Promise<void> {
109
+ await queryRunner.addColumn('users', new TableColumn({
110
+ name: 'avatar_url', type: 'text', isNullable: true
111
+ }));
112
+ }
113
+ public async down(queryRunner: QueryRunner): Promise<void> {
114
+ await queryRunner.dropColumn('users', 'avatar_url');
115
+ }
116
+ ```
117
+
118
+ **Raw SQL:**
119
+ ```sql
120
+ -- up.sql
121
+ ALTER TABLE users ADD COLUMN avatar_url TEXT;
122
+ -- down.sql
123
+ ALTER TABLE users DROP COLUMN avatar_url;
124
+ ```
125
+
126
+ Use `hallucination-guard` to verify syntax of generated SQL and ORM method names before writing.
127
+
128
+ ### Step 5 — Index Analysis
129
+
130
+ For every new table or column added, check:
131
+ - Foreign key columns without index → flag `MISSING_INDEX: [column] — add index for JOIN performance`
132
+ - High-cardinality columns used in WHERE clauses (email, user_id, status) without index → flag `CONSIDER_INDEX`
133
+ - Composite indexes: if queries filter on (A, B), index should be on (A, B) not just A
134
+
135
+ For existing tables with new query patterns:
136
+ - If query uses ORDER BY [column] on large table without index → flag `SORT_INDEX_MISSING`
137
+
138
+ ### Step 6 — Query Parameterization Scan
139
+
140
+ Scan migration files and any raw SQL files for injection vectors:
141
+
142
+ ```python
143
+ # BAD: string interpolation in SQL
144
+ query = f"SELECT * FROM users WHERE email = '{email}'"
145
+
146
+ # GOOD: parameterized
147
+ query = "SELECT * FROM users WHERE email = %s"
148
+ cursor.execute(query, (email,))
149
+ ```
150
+
151
+ Finding: `SQL_INJECTION_RISK — [file:line] — string interpolation in query — use parameterized query`
152
+
153
+ ### Step 7 — Schema Documentation
154
+
155
+ Update or create `.rune/schema-changelog.md` with a human-readable entry:
156
+
157
+ ```markdown
158
+ ## [date] — [migration name]
159
+ - Added: [column list]
160
+ - Removed: [column list — note if data was migrated]
161
+ - Breaking: [yes/no] — [details if yes]
162
+ - Rollback: [migration name or "manual"]
163
+ ```
164
+
165
+ ### Step 8 — Report
166
+
167
+ Emit structured report:
168
+
169
+ ```
170
+ ## DB Report: [scope]
171
+
172
+ ### Schema Changes
173
+ - [SAFE|BREAKING] [change description]
174
+
175
+ ### Breaking Changes Requiring Confirmation
176
+ - BREAKING: [description] — requires explicit approval before migration runs
177
+
178
+ ### Generated Files
179
+ - [migration file path] (up + down)
180
+
181
+ ### Index Recommendations
182
+ - MISSING_INDEX: [table.column] — [reason]
183
+
184
+ ### Query Safety
185
+ - SQL_INJECTION_RISK: [file:line] — [description]
186
+ - Clean: [list of checked files with no issues]
187
+
188
+ ### Verdict: PASS | WARN | BLOCK
189
+ ```
190
+
191
+ ## Output Format
192
+
193
+ ```
194
+ ## DB Report: schema.prisma diff
195
+
196
+ ### Schema Changes
197
+ - SAFE: Added users.avatar_url (TEXT, nullable)
198
+ - BREAKING: Renamed users.created → users.created_at
199
+
200
+ ### Breaking Changes Requiring Confirmation
201
+ - BREAKING: Column rename users.created → users.created_at
202
+ Impact: all queries referencing 'created' will break
203
+ Confirm before proceeding? [yes/no]
204
+
205
+ ### Generated Files
206
+ - migrations/20260224_add_avatar_url/migration.sql (up + down)
207
+
208
+ ### Index Recommendations
209
+ - MISSING_INDEX: users.email — high-cardinality FK, add for login query performance
210
+
211
+ ### Verdict: BLOCK (breaking change unconfirmed)
212
+ ```
213
+
214
+ ## Constraints
215
+
216
+ 1. MUST generate both up and down scripts for every migration — empty rollback = BLOCK
217
+ 2. MUST flag NOT NULL without DEFAULT as BLOCK — never silently generate broken migration
218
+ 3. MUST NOT run migration in production — only in test environment (via verification)
219
+ 4. MUST use hallucination-guard to verify SQL syntax before writing migration files
220
+ 5. MUST NOT rename columns silently — always present impact and require confirmation
221
+
222
+ ## Mesh Gates (L1/L2 only)
223
+
224
+ | Gate | Requires | If Missing |
225
+ |------|----------|------------|
226
+ | ORM Gate | ORM identified before migration generation | Fall back to raw SQL format + note |
227
+ | Breaking Gate | User confirmation before proceeding on BREAKING changes | BLOCK and await response |
228
+ | Rollback Gate | Working down() / rollback script before writing migration | BLOCK — prompt for rollback logic |
229
+ | Safety Gate | hallucination-guard verified SQL before Write | Re-verify or flag as unverified |
230
+
231
+ ## Sharp Edges
232
+
233
+ Known failure modes for this skill. Check these before declaring done.
234
+
235
+ | Failure Mode | Severity | Mitigation |
236
+ |---|---|---|
237
+ | Empty downgrade() written silently | CRITICAL | HARD-GATE: never write empty rollback — always prompt for rollback logic |
238
+ | NOT NULL column added without DEFAULT on existing table | CRITICAL | HARD-GATE: BLOCK and explain that this will fail on existing rows |
239
+ | Migration generated for wrong ORM (TypeORM syntax in Django project) | HIGH | hallucination-guard verifies method names match detected ORM |
240
+ | Index recommendations skipped on large tables | MEDIUM | Always run Step 5 — never skip index analysis |
241
+ | Schema changelog not updated after migration | LOW | Step 7 runs always — log INFO if skipped due to no .rune/ directory |
242
+
243
+ ## Done When
244
+
245
+ - All schema changes classified (SAFE vs BREAKING)
246
+ - Breaking changes surfaced and confirmed (or BLOCK issued)
247
+ - Migration files generated with working up + down scripts
248
+ - hallucination-guard verified SQL syntax
249
+ - Index recommendations listed
250
+ - Query parameterization scan complete
251
+ - Schema changelog updated in .rune/schema-changelog.md
252
+ - Structured DB Report emitted with PASS/WARN/BLOCK verdict
253
+
254
+ ## Cost Profile
255
+
256
+ ~2000-6000 tokens input, ~800-2000 tokens output. Sonnet for migration generation quality.
@@ -0,0 +1,240 @@
1
+ ---
2
+ name: debug
3
+ description: Root cause analysis for bugs and unexpected behavior. Traces errors through code, uses structured reasoning, and hands off to fix when cause is found. Core of the debug↔fix mesh.
4
+ metadata:
5
+ author: runedev
6
+ version: "0.3.0"
7
+ layer: L2
8
+ model: sonnet
9
+ group: development
10
+ tools: "Read, Bash, Glob, Grep"
11
+ ---
12
+
13
+ # debug
14
+
15
+ ## Purpose
16
+
17
+ Root cause analysis ONLY. Debug investigates — it does NOT fix. It traces errors through code, analyzes stack traces, forms and tests hypotheses, and identifies the exact cause before handing off to rune:fix.
18
+
19
+ <HARD-GATE>
20
+ Do NOT fix the code. Debug investigates only. Any code change is out of scope.
21
+ If root cause cannot be identified after 3 hypothesis cycles:
22
+ - Escalate to `rune:problem-solver` for structured 5-Whys or Fishbone analysis
23
+ - Or escalate to `rune:sequential-thinking` for multi-variable analysis
24
+ - Report escalation in the Debug Report with all evidence gathered so far
25
+ </HARD-GATE>
26
+
27
+ ## Triggers
28
+
29
+ - Called by `cook` when implementation hits unexpected errors
30
+ - Called by `test` when a test fails with unclear reason
31
+ - Called by `fix` when root cause is unclear before fixing
32
+ - `/rune debug <issue>` — manual debugging
33
+ - Auto-trigger: when error output contains stack trace or error code
34
+
35
+ ## Calls (outbound)
36
+
37
+ - `scout` (L2): find related code, trace imports, identify affected modules
38
+ - `fix` (L2): when root cause found, hand off with diagnosis for fix application
39
+ - `brainstorm` (L2): 3-Fix Escalation when root cause is "wrong approach" — invoke with mode="rescue" for category-diverse alternatives
40
+ - `plan` (L2): 3-Fix Escalation when root cause is "wrong module design" — invoke for redesign
41
+ - `docs-seeker` (L3): lookup API docs for unclear errors or deprecated APIs
42
+ - `problem-solver` (L3): structured reasoning (5 Whys, Fishbone) for complex bugs
43
+ - `browser-pilot` (L3): capture browser console errors, network failures, visual bugs
44
+ - `sequential-thinking` (L3): multi-variable root cause analysis
45
+
46
+ ## Called By (inbound)
47
+
48
+ - `cook` (L1): implementation hits bug during Phase 4
49
+ - `fix` (L2): root cause unclear, can't fix blindly — needs diagnosis first
50
+ - `test` (L2): test fails unexpectedly, unclear why
51
+ - `surgeon` (L2): diagnose issues in legacy modules
52
+
53
+ ## Cross-Hub Connections
54
+
55
+ - `debug` ↔ `fix` — bidirectional: debug finds cause → fix applies, fix can't determine cause → debug investigates
56
+ - `debug` ← `test` — test fails → debug investigates
57
+
58
+ ## Execution
59
+
60
+ ### Step 1: Reproduce
61
+
62
+ Understand and confirm the error described in the request.
63
+
64
+ - Read the error message, stack trace, and reproduction steps
65
+ - Identify which environment it occurs in (dev/prod, browser/server)
66
+ - Confirm the error is consistent and reproducible before proceeding
67
+ - If no reproduction steps provided, ask for them or attempt the most likely path
68
+
69
+ ### Step 2: Gather Evidence
70
+
71
+ Use tools to collect facts — do NOT guess yet.
72
+
73
+ - Use `Grep` to search codebase for the exact error string or related error codes
74
+ - Use `Read` to examine stack trace files, log files, or the specific file:line mentioned
75
+ - Use `Glob` to find related files (config, types, tests) that may be involved
76
+ - Use `rune:browser-pilot` if the issue is UI-related (console errors, network failures, visual bugs)
77
+ - Use `rune:scout` to trace imports and identify all modules touched by the affected code path
78
+
79
+ #### Backward Tracing (for deep stack errors)
80
+
81
+ When the error appears deep in execution (wrong directory, wrong path, wrong value):
82
+
83
+ 1. **Observe symptom** — what's the exact error and where does it appear?
84
+ 2. **Find immediate cause** — what code directly triggers this? Read that file:line
85
+ 3. **What called this?** — trace one level up. What value was passed? By whom?
86
+ 4. **Keep tracing up** — repeat until you find where the bad value ORIGINATES
87
+ 5. **Fix at source** — the root cause is where invalid data is CREATED, not where it CRASHES
88
+
89
+ Rule: NEVER fix where the error appears. Trace back to where invalid data originated.
90
+
91
+ #### Multi-Component Instrumentation (for systems with 3+ layers)
92
+
93
+ When the system has multiple components (CI → build → deploy, API → service → DB):
94
+
95
+ Before hypothesizing, add diagnostic logging at EACH component boundary:
96
+ - Log what data ENTERS each component
97
+ - Log what data EXITS each component
98
+ - Verify environment/config propagation across boundaries
99
+ - Run once → analyze logs → identify WHICH boundary fails → THEN hypothesize
100
+
101
+ This reveals: "secrets reach workflow ✓, workflow reaches build ✗" — pinpoints the failing layer.
102
+
103
+ ### Step 3: Form Hypotheses
104
+
105
+ List exactly 2-3 possible root causes — no more, no fewer.
106
+
107
+ - Each hypothesis must be specific (name the file, function, or line if possible)
108
+ - Order by likelihood (most likely first)
109
+ - Format:
110
+ - H1: [specific hypothesis — file/function/pattern]
111
+ - H2: [specific hypothesis]
112
+ - H3: [specific hypothesis]
113
+
114
+ ### Step 4: Test Hypotheses
115
+
116
+ Test each hypothesis systematically using tools.
117
+
118
+ - Use `Read` to inspect the suspected file/function for each hypothesis
119
+ - Use `Bash` to run targeted tests: a single failing test, a type check, a linter on the file
120
+ - Use `rune:browser-pilot` for UI hypotheses (inspect DOM, network, console)
121
+ - For each hypothesis: mark CONFIRMED / RULED OUT with evidence
122
+ - If all 3 hypotheses are ruled out → go back to Step 2 to gather more evidence
123
+ - Maximum 3 hypothesis cycles. If still unresolved after 3 cycles → escalate (see Hard-Gate)
124
+
125
+ ### Step 5: Identify Root Cause
126
+
127
+ Narrow to the single actual cause.
128
+
129
+ - State the confirmed hypothesis and the exact evidence that proves it
130
+ - Identify the specific file, line number, and code construct responsible
131
+ - Note any contributing factors (environment, data, timing, config)
132
+
133
+ ### Step 6: 3-Fix Escalation Rule
134
+
135
+ <HARD-GATE>
136
+ If the SAME bug has been "fixed" 3 times and keeps returning:
137
+ 1. STOP fixing. The bug is not the problem — the ARCHITECTURE is.
138
+ 2. **Classify the failure**:
139
+ - **Same category of blocker each time** (e.g., API doesn't support X, platform limitation) → the APPROACH is wrong, not just the code
140
+ - **Different bugs each time** (e.g., race condition, then null pointer, then type error) → the MODULE needs redesign
141
+ 3. **Route based on classification**:
142
+ - Approach is wrong → Escalate to `rune:brainstorm(mode="rescue")` for category-diverse alternatives
143
+ - Module needs redesign → Escalate to `rune:plan` for redesign of the affected module
144
+ 4. Report all 3 fix attempts and why each failed in the escalation.
145
+ "Try a 4th fix" is NOT acceptable. After 3 failures, question the design OR the approach.
146
+ </HARD-GATE>
147
+
148
+ Track fix attempts in the Debug Report. If this is attempt N>1 for the same symptom:
149
+ - Reference previous fix attempts and their outcomes
150
+ - Explain why the previous fix didn't hold
151
+ - If N=3: trigger the escalation gate above — classify and route accordingly
152
+
153
+ ### Step 7: Report
154
+
155
+ Produce structured output and hand off to rune:fix.
156
+
157
+ - Write the Debug Report (see Output Format below)
158
+ - Call `rune:fix` with the full report if fix is needed
159
+ - Do NOT apply any code changes — report only
160
+
161
+ ## Red Flags — STOP and Return to Step 2
162
+
163
+ If you catch yourself thinking any of these, you are GUESSING, not debugging:
164
+
165
+ - "Quick fix for now, investigate later"
166
+ - "Just try changing X and see if it works"
167
+ - "It's probably X, let me fix that"
168
+ - "I don't fully understand but this might work"
169
+ - "Here are the main problems: [lists fixes without investigation]"
170
+ - Proposing solutions before tracing data flow
171
+ - "One more fix attempt" (when already tried 2+)
172
+
173
+ ALL of these mean: STOP. Return to Step 2 (Gather Evidence).
174
+
175
+ ## Constraints
176
+
177
+ 1. MUST NOT apply any code changes — debug investigates only, fix applies
178
+ 2. MUST reproduce the error before forming hypotheses — no guessing from error messages alone
179
+ 3. MUST gather evidence (file reads, grep, stack traces) before hypothesizing
180
+ 4. MUST form exactly 2-3 hypotheses, ordered by likelihood — no more, no fewer
181
+ 5. MUST mark each hypothesis CONFIRMED or RULED OUT with specific evidence
182
+ 6. MUST NOT exceed 3 hypothesis cycles — escalate to problem-solver or sequential-thinking
183
+ 7. MUST NOT say "I know what's wrong" without citing file:line evidence
184
+ 8. For deep stack errors: MUST use backward tracing (Step 2) — never fix at the crash site
185
+ 9. For multi-component systems: MUST instrument boundaries before hypothesizing
186
+
187
+ ## Output Format
188
+
189
+ ```
190
+ ## Debug Report
191
+ - **Error**: [error message]
192
+ - **Severity**: critical | high | medium | low
193
+ - **Confidence**: high | medium | low
194
+ - **Fix Attempt**: [1/2/3 — track recurring bugs]
195
+
196
+ ### Root Cause
197
+ [Detailed explanation of what's causing the error]
198
+
199
+ ### Location
200
+ - `path/to/file.ts:42` — [description of the problematic code]
201
+
202
+ ### Evidence
203
+ 1. [observation supporting diagnosis]
204
+ 2. [observation supporting diagnosis]
205
+
206
+ ### Previous Fix Attempts (if any)
207
+ - Attempt 1: [what was tried] → [why it didn't hold]
208
+ - Attempt 2: [what was tried] → [why it didn't hold]
209
+
210
+ ### Suggested Fix
211
+ [Description of what needs to change — no code, just direction]
212
+ [If attempt 3: "ESCALATION: 3-fix rule triggered. Recommending redesign via rune:plan."]
213
+
214
+ ### Related Code
215
+ - `path/to/related.ts` — [why it's relevant]
216
+ ```
217
+
218
+ ## Sharp Edges
219
+
220
+ | Failure Mode | Severity | Mitigation |
221
+ |---|---|---|
222
+ | Forming hypothesis from error message alone without evidence | HIGH | Evidence-first rule: read files and grep logs BEFORE hypothesizing |
223
+ | Modifying code while "investigating" | CRITICAL | HARD-GATE: any code change during debug = out of scope — hand off to fix |
224
+ | Marking hypothesis CONFIRMED without file:line proof | HIGH | CONFIRMED requires specific evidence cited — "it makes sense" is not evidence |
225
+ | Exceeding 3 hypothesis cycles without escalation | MEDIUM | After 3 cycles: escalate to rune:problem-solver or rune:sequential-thinking |
226
+ | Same bug "fixed" 3+ times without questioning architecture | CRITICAL | 3-Fix Escalation Rule: classify failure → same blocker category = brainstorm(rescue), different bugs = plan redesign |
227
+ | Escalating to plan when the APPROACH is wrong (not the module) | HIGH | If all 3 fixes hit the same category of blocker (API limit, platform gap), the approach needs pivoting via brainstorm(rescue), not re-planning |
228
+ | Not tracking fix attempt number for recurring bugs | HIGH | Debug Report MUST include Fix Attempt counter — enables escalation gate |
229
+
230
+ ## Done When
231
+
232
+ - Error reproduced (not assumed) with specific reproduction steps documented
233
+ - 2-3 hypotheses formed, each marked CONFIRMED or RULED OUT with file:line evidence
234
+ - Root cause identified at specific file:line
235
+ - Structured Debug Report emitted
236
+ - No code changes made — rune:fix called with the report if fix is needed
237
+
238
+ ## Cost Profile
239
+
240
+ ~2000-5000 tokens input, ~500-1500 tokens output. Sonnet for code analysis quality. May escalate to opus for deeply complex bugs.