@rune-kit/rune 2.2.1 → 2.2.3

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 (94) hide show
  1. package/README.md +39 -13
  2. package/compiler/__tests__/adapters.test.js +109 -0
  3. package/compiler/__tests__/openclaw-adapter.test.js +149 -140
  4. package/compiler/__tests__/pack-split.test.js +145 -145
  5. package/compiler/__tests__/parser.test.js +3 -3
  6. package/compiler/__tests__/pipeline.test.js +110 -0
  7. package/compiler/__tests__/skill-validation.test.js +148 -0
  8. package/compiler/__tests__/transformer.test.js +70 -0
  9. package/compiler/__tests__/transforms.test.js +92 -0
  10. package/compiler/adapters/antigravity.js +5 -6
  11. package/compiler/adapters/claude.js +1 -1
  12. package/compiler/adapters/codex.js +69 -77
  13. package/compiler/adapters/cursor.js +5 -6
  14. package/compiler/adapters/generic.js +5 -6
  15. package/compiler/adapters/index.js +3 -3
  16. package/compiler/adapters/openclaw.js +146 -150
  17. package/compiler/adapters/opencode.js +78 -86
  18. package/compiler/adapters/windsurf.js +5 -6
  19. package/compiler/bin/rune.js +52 -21
  20. package/compiler/doctor.js +19 -7
  21. package/compiler/emitter.js +11 -18
  22. package/compiler/parser.js +5 -5
  23. package/compiler/transformer.js +3 -5
  24. package/compiler/transforms/branding.js +5 -4
  25. package/compiler/transforms/compliance.js +40 -40
  26. package/compiler/transforms/frontmatter.js +1 -1
  27. package/compiler/transforms/hooks.js +12 -14
  28. package/compiler/transforms/subagents.js +1 -3
  29. package/compiler/transforms/tool-names.js +1 -1
  30. package/docs/ANTIGRAVITY-GAP-ANALYSIS.md +369 -0
  31. package/docs/ARCHITECTURE.md +332 -0
  32. package/docs/COMMUNITY-PACKS.md +109 -0
  33. package/docs/CONTRIBUTING-L4.md +215 -0
  34. package/docs/CROSS-IDE-ANALYSIS.md +164 -0
  35. package/docs/EXTENSION-TEMPLATE.md +108 -0
  36. package/docs/MESH-RULES.md +34 -0
  37. package/docs/MULTI-PLATFORM.md +804 -0
  38. package/docs/SKILL-DEPTH-AUDIT.md +191 -0
  39. package/docs/SKILL-TEMPLATE.md +72 -0
  40. package/docs/TRADE-MATRIX.md +327 -0
  41. package/docs/VERSIONING.md +91 -0
  42. package/docs/VISION.md +263 -0
  43. package/docs/assets/demo-subtitles.srt +215 -0
  44. package/docs/assets/end-card.html +276 -0
  45. package/docs/assets/mesh-diagram.html +654 -0
  46. package/docs/assets/thumbnail.html +295 -0
  47. package/docs/guides/cli.md +403 -0
  48. package/docs/guides/index.html +1387 -0
  49. package/docs/index.html +739 -0
  50. package/docs/references/claudekit-analysis.md +414 -0
  51. package/docs/references/voltagent-analysis.md +189 -0
  52. package/docs/script.js +277 -0
  53. package/docs/skills/index.html +832 -0
  54. package/docs/style.css +600 -0
  55. package/docs/video-demo-plan.md +172 -0
  56. package/extensions/security/PACK.md +4 -3
  57. package/extensions/security/skills/defense-in-depth.md +103 -0
  58. package/extensions/ui/PACK.md +2 -0
  59. package/extensions/ui/skills/design-decision.md +10 -0
  60. package/extensions/ui/skills/palette-picker.md +11 -0
  61. package/hooks/.gitkeep +0 -0
  62. package/hooks/auto-format/index.cjs +48 -0
  63. package/hooks/context-watch/index.cjs +68 -0
  64. package/hooks/hooks.json +99 -0
  65. package/hooks/metrics-collector/index.cjs +42 -0
  66. package/hooks/post-session-reflect/index.cjs +153 -0
  67. package/hooks/pre-compact/index.cjs +95 -0
  68. package/hooks/pre-tool-guard/index.cjs +68 -0
  69. package/hooks/run-hook +17 -0
  70. package/hooks/run-hook.cjs +16 -0
  71. package/hooks/run-hook.cmd +1 -0
  72. package/hooks/secrets-scan/index.cjs +100 -0
  73. package/hooks/session-start/index.cjs +65 -0
  74. package/hooks/typecheck/index.cjs +65 -0
  75. package/package.json +16 -4
  76. package/references/ui-pro-max-data/LICENSE-UI-PRO-MAX +21 -0
  77. package/references/ui-pro-max-data/charts.csv +26 -0
  78. package/references/ui-pro-max-data/colors.csv +162 -0
  79. package/references/ui-pro-max-data/styles.csv +85 -0
  80. package/references/ui-pro-max-data/typography.csv +74 -0
  81. package/references/ui-pro-max-data/ui-reasoning.csv +162 -0
  82. package/references/ui-pro-max-data/ux-guidelines.csv +100 -0
  83. package/skills/ba/SKILL.md +10 -0
  84. package/skills/completion-gate/SKILL.md +34 -1
  85. package/skills/context-engine/SKILL.md +13 -0
  86. package/skills/cook/SKILL.md +71 -0
  87. package/skills/debug/SKILL.md +71 -1
  88. package/skills/design/SKILL.md +11 -0
  89. package/skills/fix/SKILL.md +26 -1
  90. package/skills/plan/SKILL.md +23 -6
  91. package/skills/review/SKILL.md +2 -0
  92. package/skills/skill-forge/SKILL.md +94 -3
  93. package/skills/test/SKILL.md +44 -2
  94. package/skills/verification/SKILL.md +60 -2
@@ -233,6 +233,16 @@ US-1: As a [persona], I want to [action] so that [benefit]
233
233
  ## Risks
234
234
  - [risk]: [mitigation strategy]
235
235
 
236
+ ## Decision Classification
237
+
238
+ | Category | Meaning | Example |
239
+ |----------|---------|---------|
240
+ | **Decisions** (locked) | User confirmed — agent MUST follow | "Use PostgreSQL, not MongoDB" |
241
+ | **Discretion** (agent decides) | User trusts agent judgment | "Pick the best validation library" |
242
+ | **Deferred** (out of scope) | Explicitly NOT this task | "Mobile app — future phase" |
243
+
244
+ Plan gates on Decision compliance — Discretion items don't need approval.
245
+
236
246
  ## Next Step
237
247
  → Hand off to rune:plan for implementation planning
238
248
  ```
@@ -4,7 +4,7 @@ description: "Validates agent claims against evidence trail. Catches 'done' with
4
4
  user-invocable: false
5
5
  metadata:
6
6
  author: runedev
7
- version: "1.1.0"
7
+ version: "1.2.0"
8
8
  layer: L3
9
9
  model: haiku
10
10
  group: validation
@@ -58,6 +58,21 @@ CLAIM PATTERNS:
58
58
 
59
59
  Extract each claim as: `{ claim: string, source_skill: string }`
60
60
 
61
+ ### Step 1b — Stub Detection (Existence Theater Check)
62
+
63
+ Before checking claims, scan all files created/modified in this workflow for stubs:
64
+
65
+ ```
66
+ Grep for stub patterns in new/modified files:
67
+ - "Placeholder" | "TODO" | "Not implemented" | "NotImplementedError"
68
+ - Functions with body: only `return null` / `return {}` / `pass` / `throw`
69
+ - Components returning only a single div with no logic
70
+ ```
71
+
72
+ If ANY stub detected:
73
+ - Add synthetic claim: "implemented [filename]" → CONTRADICTED (file is a stub)
74
+ - This catches agents that create files but don't implement them
75
+
61
76
  ### Step 2 — Match Evidence
62
77
 
63
78
  For each claim, look for corresponding evidence in the conversation context:
@@ -108,6 +123,23 @@ IF no evidence found:
108
123
  UNCONFIRMED — 1 claim lacks evidence, 1 contradicted. Cannot proceed to commit.
109
124
  ```
110
125
 
126
+ ### Step 5 — Evidence Quality Gate
127
+
128
+ Before emitting verdict, verify evidence quality:
129
+
130
+ 1. **IDENTIFY** — list every claim the agent made (Step 1 output)
131
+ 2. **RUN** — confirm verification commands were actually executed (not just planned)
132
+ 3. **READ** — read every line of command output (not just exit code)
133
+ 4. **VERIFY** — match each claim to a specific evidence quote (file:line or output snippet)
134
+ 5. **CLAIM** — only mark CONFIRMED if evidence quote directly supports the claim
135
+
136
+ | Evidence Quality | Verdict |
137
+ |-----------------|---------|
138
+ | Exit code 0 only, no output read | INSUFFICIENT — re-run and read output |
139
+ | Output read but no quote matched to claim | UNCONFIRMED — cite specific evidence |
140
+ | Quote matches claim exactly | CONFIRMED |
141
+ | Quote contradicts claim | CONTRADICTED |
142
+
111
143
  ## Verdict Rules
112
144
 
113
145
  ```
@@ -137,6 +169,7 @@ Completion Gate Report with status (CONFIRMED/UNCONFIRMED/CONTRADICTED), claim v
137
169
  | Evidence from a DIFFERENT test run (stale) | HIGH | Check that evidence timestamp/context matches current changes |
138
170
  | Agent pre-generates evidence by running commands proactively | LOW | This is actually GOOD behavior — we want agents to provide evidence |
139
171
  | Completion-gate itself claims "all confirmed" without evidence | CRITICAL | Gate report MUST include the evidence table — no table = report is invalid |
172
+ | Existence Theater — agent creates files but they're stubs | HIGH | Step 1b stub detection: grep for Placeholder/TODO/NotImplementedError in new files |
140
173
 
141
174
  ## Done When
142
175
 
@@ -117,6 +117,19 @@ Block further tool calls until compaction is acknowledged.
117
117
 
118
118
  Emit the context health report to the calling skill.
119
119
 
120
+ ### Step 6b — Context Percentage Advisory
121
+
122
+ In addition to tool-call counting, monitor context window percentage when available:
123
+
124
+ | Remaining | Level | Action |
125
+ |-----------|-------|--------|
126
+ | >35% | SAFE | Continue normally |
127
+ | 25-35% | WARNING | Advise: "Context at ~[X]%. Consider /compact at next phase boundary" |
128
+ | <25% | CRITICAL | Save state via session-bridge → recommend immediate /compact |
129
+
130
+ Debounce: emit advisory max once per 5 tool calls to avoid noise.
131
+ Tool-call thresholds (Steps 1-2) remain the primary signal. Percentage advisory is supplementary — use when CLI status bar data is available.
132
+
120
133
  ## Context Health Levels
121
134
 
122
135
  ```
@@ -556,6 +556,27 @@ cook instance → commit → push → create PR → wait CI
556
556
  IF 3 retries fail → escalate to user with CI logs
557
557
  ```
558
558
 
559
+ ### Formal Pause/Resume (`.continue-here.md`)
560
+
561
+ When cook must pause mid-phase (context limit, user break, session end before phase completes):
562
+
563
+ 1. Create `.rune/.continue-here.md` with structured handoff:
564
+ ```markdown
565
+ ## Continue Here
566
+ - **Phase**: [current phase number and name]
567
+ - **Task**: [current task within phase — e.g., "Task 3 of 5"]
568
+ - **Completed**: [list of tasks done this session]
569
+ - **Remaining**: [list of tasks not yet started]
570
+ - **Decisions**: [any decisions made this session]
571
+ - **Blockers**: [if any — what's stuck and why]
572
+ - **WIP Files**: [files modified but not yet committed]
573
+ ```
574
+ 2. Create a WIP commit: `wip: cook phase N paused at task M`
575
+ 3. Phase 0 (RESUME CHECK) detects `.continue-here.md` → resumes from exact task position
576
+ 4. After successful resume and phase completion → delete `.continue-here.md`
577
+
578
+ This is more granular than Phase 0's plan-level resume — it resumes within a phase, not just between phases.
579
+
559
580
  ### Exit Conditions (Mandatory for Autonomous Runs)
560
581
 
561
582
  Every cook invocation inside `team` or autonomous workflows MUST have exit conditions:
@@ -592,6 +613,20 @@ When cook completes (whether standalone or invoked by `team`), it MUST return on
592
613
 
593
614
  **BLOCKED format**: Include the phase, the sub-skill that emitted BLOCKED, the specific blocker, and what was already attempted.
594
615
 
616
+ ## Deviation Rules
617
+
618
+ When implementation diverges from plan:
619
+
620
+ | Rule | Scope | Action | Example |
621
+ |------|-------|--------|---------|
622
+ | R1: Bug fix | Code doesn't work as planned | Auto-fix, continue | Test fails due to typo, missing import |
623
+ | R2: Security fix | Vulnerability discovered | Auto-fix, continue | SQL injection, XSS, hardcoded secret |
624
+ | R3: Blocking fix | Can't proceed without change | Auto-fix, continue | Missing dependency, wrong API signature |
625
+ | R4: Architectural change | Different approach than planned | **ASK user first** | New database table, changed API contract, different library |
626
+
627
+ R1-R3: security primitives and correctness fixes are NOT features — fix silently.
628
+ R4: if you catch yourself thinking "this is a better way" — STOP and ask. The plan was approved for a reason.
629
+
595
630
  ## Error Recovery
596
631
 
597
632
  | Phase | If this fails... | Do this... |
@@ -605,6 +640,23 @@ When cook completes (whether standalone or invoked by `team`), it MUST return on
605
640
  | 5c REVIEW | Code quality issues | Fix CRITICAL/HIGH → re-review (max 2 loops) |
606
641
  | 6 VERIFY | Build/lint/type fails | Fix → re-run verification |
607
642
 
643
+ ### Repair Operators (before escalation)
644
+
645
+ When a task fails during Phase 4 (IMPLEMENT):
646
+
647
+ | Operator | When | Action |
648
+ |----------|------|--------|
649
+ | **RETRY** | Transient failure (network, timeout, flaky test) | Re-run same approach, max 2 attempts |
650
+ | **DECOMPOSE** | Task too complex, partial progress | Split into 2-3 smaller tasks, continue |
651
+ | **PRUNE** | Approach fundamentally wrong | Remove failed code, try different approach from plan |
652
+
653
+ **Budget**: 2 repair attempts per task. After 2 failures → escalate:
654
+ - Same error both times → `debug` for root cause
655
+ - Different errors → `plan` to redesign the task
656
+ - All approaches exhausted → `brainstorm(rescue)` for alternative category
657
+
658
+ Do NOT ask user until repair budget is spent.
659
+
608
660
  ## Called By (inbound)
609
661
 
610
662
  - User: `/rune cook` direct invocation — primary entry point
@@ -641,6 +693,24 @@ When cook completes (whether standalone or invoked by `team`), it MUST return on
641
693
  - `worktree` (L3): Phase 4 — worktree isolation for parallel implementation
642
694
  - L4 extension packs: Phase 1.5 — domain-specific patterns when stack matches (see Phase 1.5 mapping table)
643
695
 
696
+ ## Analysis Paralysis Guard
697
+
698
+ <HARD-GATE>
699
+ 5+ consecutive read-only tool calls (Read, Grep, Glob) without a single write action (Edit, Write, Bash) = STUCK.
700
+
701
+ You MUST either:
702
+ 1. **Act** — write code, run a command, create a file
703
+ 2. **Report BLOCKED** — state the specific missing piece: "Cannot proceed because [X]"
704
+
705
+ Stuck patterns (all banned):
706
+ - Reading 10+ files to "fully understand" before acting
707
+ - Grepping every variation of a string across the entire repo
708
+ - Reading the same file twice in one investigation
709
+ - "Let me check one more thing" — repeated after 5 reads
710
+
711
+ A wrong first attempt that produces feedback beats perfect understanding that never ships.
712
+ </HARD-GATE>
713
+
644
714
  ## Constraints
645
715
 
646
716
  1. MUST run scout before planning — no plan based on assumptions alone
@@ -699,6 +769,7 @@ Known failure modes for this skill. Check these before declaring done.
699
769
  | Not escalating to sentinel:opus on security-sensitive tasks | MEDIUM | Auth, crypto, payment code → sentinel must run at opus, not sonnet |
700
770
  | Running Phase 5 checks sequentially instead of parallel | MEDIUM | Launch preflight+sentinel+review as parallel Task agents for speed |
701
771
  | Saying "done" without evidence trail | CRITICAL | completion-gate validates claims — UNCONFIRMED = BLOCK |
772
+ | Analysis paralysis — 5+ reads without writing | HIGH | Analysis Paralysis Guard: act on incomplete info or report BLOCKED with specific missing piece |
702
773
  | Fast mode on security-relevant code | HIGH | Fast mode auto-excludes auth/crypto/payments — never fast-track security code |
703
774
  | Loading all phase files at once into context | HIGH | Phase File Gate: load ONLY the active phase file — one phase per session |
704
775
  | Resuming without checking master plan | MEDIUM | Phase 0 (RESUME CHECK) runs before Phase 1 — detects existing plans |
@@ -3,7 +3,7 @@ name: debug
3
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
4
  metadata:
5
5
  author: runedev
6
- version: "0.3.0"
6
+ version: "0.5.0"
7
7
  layer: L2
8
8
  model: sonnet
9
9
  group: development
@@ -89,6 +89,21 @@ When the error appears deep in execution (wrong directory, wrong path, wrong val
89
89
 
90
90
  Rule: NEVER fix where the error appears. Trace back to where invalid data originated.
91
91
 
92
+ #### Instrumentation Tip: Use console.error, Not Loggers
93
+ When adding diagnostic instrumentation, use `console.error()` (stderr) — NOT application loggers. Loggers are configured to suppress output based on log level or environment (e.g., `LOG_LEVEL=warn` silences `logger.debug`). `console.error` bypasses all logger configuration and writes directly to stderr. This is counterintuitive but critical — the one time you NEED debug output is exactly when loggers are configured to hide it.
94
+
95
+ #### Defense-in-Depth (After Root Cause Found)
96
+ When the root cause is invalid data flowing through multiple layers, recommend fixing at ALL layers — not just the source:
97
+
98
+ | Layer | Purpose | Example |
99
+ |-------|---------|---------|
100
+ | Layer 1: Entry Point | Reject invalid input at API/CLI boundary | Validate not empty, exists, correct type |
101
+ | Layer 2: Business Logic | Ensure data makes sense for the operation | Validate required params before processing |
102
+ | Layer 3: Environment Guards | Prevent dangerous operations in specific contexts | Refuse destructive ops outside allowed dirs |
103
+ | Layer 4: Debug Instrumentation | Capture context for forensics | Stack trace logging before dangerous operations |
104
+
105
+ All four layers are necessary. During testing, each layer catches bugs the others miss — different code paths bypass single validation points. When recommending a fix via `rune:fix`, explicitly call out which layers need validation added.
106
+
92
107
  #### Multi-Component Instrumentation (for systems with 3+ layers)
93
108
 
94
109
  When the system has multiple components (CI → build → deploy, API → service → DB):
@@ -101,6 +116,49 @@ Before hypothesizing, add diagnostic logging at EACH component boundary:
101
116
 
102
117
  This reveals: "secrets reach workflow ✓, workflow reaches build ✗" — pinpoints the failing layer.
103
118
 
119
+ ### Step 2b: Instrument with Preserved Markers
120
+
121
+ When adding diagnostic logging or instrumentation during investigation, mark ALL additions with region markers:
122
+
123
+ ```
124
+ // #region agent-debug — [hypothesis being tested]
125
+ console.log('[DEBUG] value at boundary:', data);
126
+ // #endregion agent-debug
127
+ ```
128
+
129
+ Language-appropriate equivalents:
130
+ - Python: `# region agent-debug` / `# endregion agent-debug`
131
+ - Rust: `// region agent-debug` / `// endregion agent-debug`
132
+
133
+ **Why preserved markers matter:**
134
+ - `rune:fix` will preserve these markers until the bug is fully resolved and tests pass
135
+ - If the bug recurs, markers show exactly what was previously instrumented
136
+ - Cleaning up debug traces before the fix is verified prevents learning from failure history
137
+ - After fix is verified + tests pass → fix will clean up markers in a final pass
138
+
139
+ <HARD-GATE>
140
+ ALL diagnostic code added during debug MUST be wrapped in `#region agent-debug` markers.
141
+ Unmarked instrumentation will be treated as stray code and removed prematurely.
142
+ </HARD-GATE>
143
+
144
+ ### Step 2c: Check Debug Knowledge Base
145
+
146
+ Before forming hypotheses, check `.rune/debug/knowledge-base.md`:
147
+ - If file exists → search for matching symptoms/error messages
148
+ - If match found → try known fix FIRST, skip hypothesis cycle
149
+ - If no match → proceed to Step 3
150
+
151
+ After successful root cause identification (Step 5), append entry:
152
+ ```
153
+ ### [date] — [symptom summary]
154
+ - **Symptom**: [error message or behavior]
155
+ - **Root Cause**: [what was actually wrong]
156
+ - **Fix**: [what resolved it]
157
+ - **Files**: [affected files]
158
+ ```
159
+
160
+ This prevents re-debugging the same issue across sessions.
161
+
104
162
  ### Step 3: Form Hypotheses
105
163
 
106
164
  List exactly 2-3 possible root causes — no more, no fewer.
@@ -163,6 +221,16 @@ Produce structured output and hand off to rune:fix.
163
221
  - Call `rune:fix` with the full report if fix is needed
164
222
  - Do NOT apply any code changes — report only
165
223
 
224
+ ## Analysis Paralysis Guard
225
+
226
+ <HARD-GATE>
227
+ Debug is read-heavy by nature — but there are limits.
228
+
229
+ After Step 4 (Test Hypotheses): if NO hypothesis is confirmed after 3 cycles of Steps 2-4, you MUST stop and escalate. Do NOT start cycle 4. Report all evidence gathered and escalate to problem-solver or sequential-thinking.
230
+
231
+ Within any single step: 5+ consecutive Read/Grep calls without forming or testing a hypothesis = stuck. Stop reading, form a hypothesis from what you have, and test it. Incomplete hypotheses that get tested are better than perfect hypotheses that never form.
232
+ </HARD-GATE>
233
+
166
234
  ## Red Flags — STOP and Return to Step 2
167
235
 
168
236
  If you catch yourself thinking any of these, you are GUESSING, not debugging:
@@ -174,6 +242,7 @@ If you catch yourself thinking any of these, you are GUESSING, not debugging:
174
242
  - "Here are the main problems: [lists fixes without investigation]"
175
243
  - Proposing solutions before tracing data flow
176
244
  - "One more fix attempt" (when already tried 2+)
245
+ - "Let me read one more file before forming a hypothesis" (after 5+ reads)
177
246
 
178
247
  ALL of these mean: STOP. Return to Step 2 (Gather Evidence).
179
248
 
@@ -231,6 +300,7 @@ ALL of these mean: STOP. Return to Step 2 (Gather Evidence).
231
300
  | Same bug "fixed" 3+ times without questioning architecture | CRITICAL | 3-Fix Escalation Rule: classify failure → same blocker category = brainstorm(rescue), different bugs = plan redesign |
232
301
  | 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 |
233
302
  | Not tracking fix attempt number for recurring bugs | HIGH | Debug Report MUST include Fix Attempt counter — enables escalation gate |
303
+ | Adding instrumentation without region markers | MEDIUM | All debug logging MUST use `#region agent-debug` — unmarked code gets cleaned up prematurely by fix |
234
304
 
235
305
  ## Done When
236
306
 
@@ -57,6 +57,17 @@ Load the design knowledge base before reasoning:
57
57
 
58
58
  > **Why two layers**: The baseline ships "good enough" universal design knowledge. Users who care about aesthetics create their own `design-dna.md` with curated palettes, font pairings, and style preferences. The design skill works well with either — it just works _better_ with a curated reference.
59
59
 
60
+ ### External Data Source
61
+
62
+ Design intelligence data from [UI/UX Pro Max](https://github.com/nextlevelbuilder/ui-ux-pro-max-skill) (MIT, 42.8k★).
63
+ Located at `references/ui-pro-max-data/` — 161 palettes, 84 styles, 73 font pairings, 161 reasoning rules, 99 UX guidelines.
64
+
65
+ When `references/ui-pro-max-data/` is available:
66
+ - Step 2: query `styles.csv` for domain-matched visual styles (expands from 10 → 84)
67
+ - Step 3: query `ui-reasoning.csv` for industry-specific design rules (161 rules)
68
+ - Step 3: query `colors.csv` for palette alternatives (expands from 10 → 161)
69
+ - Step 6 (Anti-AI): cross-check proposed style against reasoning DB — if flagged as "AI-generic", suggest 3 alternatives
70
+
60
71
  ### Step 1 — Discover
61
72
 
62
73
  Invoke `scout` to detect:
@@ -3,7 +3,7 @@ name: fix
3
3
  description: Apply code changes and fixes. Writes implementation code, applies bug fixes, and verifies changes with tests. Core action hub in the development mesh.
4
4
  metadata:
5
5
  author: runedev
6
- version: "0.3.0"
6
+ version: "0.4.0"
7
7
  layer: L2
8
8
  model: sonnet
9
9
  group: development
@@ -112,6 +112,17 @@ Single validation at one point can be bypassed by different code paths, refactor
112
112
 
113
113
  Apply this when: the bug was caused by invalid data flowing through multiple layers. Skip for trivial one-liner fixes.
114
114
 
115
+ ### Step 5b: Preserve Debug Instrumentation
116
+
117
+ If `rune:debug` left `#region agent-debug` markers in the code:
118
+
119
+ 1. **During fix**: DO NOT remove these markers — they capture the investigation trail
120
+ 2. **After fix verified** (tests pass, lint pass): scan for `#region agent-debug` markers
121
+ 3. **Remove markers and their contents** in a final cleanup pass ONLY after full verification
122
+ 4. If the fix is partial or tests still fail → KEEP all markers for the next debug cycle
123
+
124
+ **Why:** Premature cleanup of debug instrumentation erases failure history. If the bug recurs after cleanup, the next debug session starts from zero. Keeping markers until verification means downstream skills can see what was already investigated.
125
+
115
126
  ### Step 6: Self-Review
116
127
 
117
128
  Verify correctness of the changes just made.
@@ -141,6 +152,19 @@ Produce a structured summary of all changes made.
141
152
  5. MUST follow project conventions found by scout — don't invent new patterns
142
153
  6. MUST NOT add unplanned features while fixing — fix only what was diagnosed
143
154
  7. MUST track fix attempt number — this feeds debug's 3-Fix Escalation classification
155
+ 8. MUST preserve `#region agent-debug` markers until fix is fully verified — cleanup only after tests pass
156
+
157
+ ## Scope Gate
158
+
159
+ | Change Type | Action |
160
+ |-------------|--------|
161
+ | Bug fix (diagnosed cause) | Fix it |
162
+ | Security fix (found during fix) | Fix it + flag to sentinel |
163
+ | Blocking issue (can't complete fix without) | Fix it + document in report |
164
+ | Unrelated improvement | **STOP — create separate task** |
165
+ | Architectural change | **STOP — escalate to cook/plan** |
166
+
167
+ If fix requires touching >3 files not in the diagnosis → re-diagnose. You're probably fixing a symptom.
144
168
 
145
169
  ## Mesh Gates
146
170
 
@@ -182,6 +206,7 @@ Known failure modes for this skill. Check these before declaring done.
182
206
  | Not running tests after each individual change | MEDIUM | Constraint 3: never batch untested changes — run tests after each edit |
183
207
  | Fixing at crash site without tracing data origin | HIGH | Defense-in-depth: trace where bad data ORIGINATES, add validation at every layer it passes through |
184
208
  | Single-point validation (fix one spot, hope it holds) | MEDIUM | Step 5: add entry + business logic + environment + debug layers for data-flow bugs |
209
+ | Removing debug instrumentation before fix is verified | MEDIUM | Step 5b: preserve `#region agent-debug` markers until all tests pass — premature cleanup erases failure history |
185
210
 
186
211
  ## Done When
187
212
 
@@ -171,6 +171,11 @@ Save to `.rune/plan-<feature>.md`:
171
171
  - <decision 1 — chosen approach and why>
172
172
  - <decision 2>
173
173
 
174
+ ## Decision Compliance
175
+ - Decisions (locked): [list from requirements.md — plan MUST honor these]
176
+ - Discretion (agent): [list — agent chose X because Y]
177
+ - Deferred: [list — explicitly excluded from this feature]
178
+
174
179
  ## Architecture
175
180
  <brief system diagram or component list — NOT implementation detail>
176
181
 
@@ -226,17 +231,27 @@ function validateInput(raw: unknown): TradeEntry[]; // throws ValidationError
226
231
  ```
227
232
 
228
233
  ## Tasks
234
+
235
+ Each task MUST include: **File** (exact path), **Test** (test file or N/A), **Verify** (shell command), **Commit** (semantic message). Granularity: 2-5 min per task. If >10min, decompose.
236
+
229
237
  - [ ] Task 1 — Create calculateProfit function
230
- - File: `src/foo/bar.ts`
231
- - Create: `function calculateProfit(entries: TradeEntry[]): ProfitResult`
238
+ - File: `src/foo/bar.ts` (new)
239
+ - Test: `tests/foo/bar.test.ts` (new)
240
+ - Verify: `npm test -- --grep "calculateProfit"`
241
+ - Commit: `feat(trading): add calculateProfit with fee calculation`
232
242
  - Logic: sum entries by side, apply fees (0.1% per trade), return net P&L
233
243
  - Edge: empty array → return { netPnL: 0, totalFees: 0, winRate: 0 }
234
244
  - [ ] Task 2 — Add input validation
235
- - File: `src/foo/baz.ts`
236
- - Modify: add `validateInput()` before processing
245
+ - File: `src/foo/baz.ts` (modify)
246
+ - Test: `tests/foo/baz.test.ts` (new)
247
+ - Verify: `npm test -- --grep "validateInput"`
248
+ - Commit: `feat(trading): add input validation for trade entries`
237
249
  - Logic: check side is 'long'|'short', prices > 0, quantity > 0
238
- - [ ] Task 3 — Write tests
239
- - File: `tests/foo/bar.test.ts`
250
+ - [ ] Task 3 — Write integration tests
251
+ - File: `tests/foo/bar.test.ts` (modify)
252
+ - Test: N/A — this IS the test task
253
+ - Verify: `npm test -- --grep "trading" && npx tsc --noEmit`
254
+ - Commit: `test(trading): add integration tests for edge cases`
240
255
  - Cases: happy path, empty input, negative values, overflow
241
256
 
242
257
  ## Failure Scenarios
@@ -503,6 +518,8 @@ Max 200 lines. Self-contained — coder needs ONLY this file.
503
518
  | Plan without scout context — invented file paths | CRITICAL | Step 1: scout first, always |
504
519
  | Phase with zero test tasks | CRITICAL | HARD-GATE rejects it |
505
520
  | 10+ phases overwhelming the master plan | MEDIUM | Max 8 phases — split into sub-projects if more |
521
+ | Task without File path or Verify command | HIGH | Every task MUST have File + Test + Verify + Commit fields — no vague "implement the feature" tasks |
522
+ | Plan ignores locked Decisions from BA | CRITICAL | Decision Compliance section cross-checks requirements.md — locked decisions are non-negotiable |
506
523
 
507
524
  ## Done When
508
525
 
@@ -378,6 +378,8 @@ LOW — style inconsistency, naming suggestion, minor refactor opportunity
378
378
  | Skipping UI anti-pattern checks for frontend changes | MEDIUM | Any .tsx/.jsx/.svelte/.vue in diff → MUST run UI/UX Anti-Pattern Checks section |
379
379
  | Skipping spec compliance check (Step 5.5 Stage 1) | HIGH | Code quality without spec check ships clean code that does the wrong thing — always load the plan/ticket before reviewing quality |
380
380
  | Treating purple/indigo accent as "just a color choice" | MEDIUM | It is a documented AI-generated UI signature — always flag for domain justification |
381
+ | Suggesting "add X" without checking if X is used | MEDIUM | YAGNI pushback: grep codebase for the suggested feature → if uncalled anywhere → respond "Not called anywhere. Remove? (YAGNI)". Valid pushback, not laziness |
382
+ | Adding abstractions "for future flexibility" | MEDIUM | Three similar lines > premature abstraction. Only abstract when there are 3+ concrete callers today |
381
383
 
382
384
  ## Done When
383
385
 
@@ -3,7 +3,7 @@ name: skill-forge
3
3
  description: Use when creating new Rune skills, editing existing skills, or verifying skill quality before deployment. Applies TDD discipline to skill authoring — test before write, verify before ship.
4
4
  metadata:
5
5
  author: runedev
6
- version: "1.0.0"
6
+ version: "1.2.0"
7
7
  layer: L2
8
8
  model: opus
9
9
  group: creation
@@ -106,6 +106,33 @@ Follow `docs/SKILL-TEMPLATE.md` format. Required sections:
106
106
  | Cost Profile | YES | Token estimate |
107
107
  | Mesh Gates | L1/L2 only | Progression guards |
108
108
 
109
+ #### SKILL.md Anatomy — WHY vs HOW Split
110
+
111
+ A skill file answers WHY and WHEN — not HOW. Code examples, syntax references, and implementation patterns belong in separate files:
112
+
113
+ ```
114
+ skills/[name]/
115
+ ├── SKILL.md ← WHY: purpose, triggers, constraints, sharp edges (~150-300 lines)
116
+ ├── references/ ← HOW: code patterns, syntax tables, API examples
117
+ │ ├── patterns.md ← Implementation patterns with code blocks
118
+ │ └── gotchas.md ← Language/framework-specific pitfalls
119
+ └── scripts/ ← WHAT: deterministic operations (shell, node)
120
+ ```
121
+
122
+ **Rules:**
123
+ 1. SKILL.md MUST NOT contain code blocks longer than 10 lines — move to `references/`
124
+ 2. One excellent inline example (≤10 lines) is OK for clarity — more than that is a smell
125
+ 3. Format templates (Output Format section) are NOT code — they stay in SKILL.md
126
+ 4. Pressure test scenarios (Phase 2) are NOT code — they stay in SKILL.md
127
+ 5. If a skill has >3 code blocks → create `references/` and extract them
128
+
129
+ **Why this matters:** Code blocks in SKILL.md inflate context tokens on EVERY invocation. References are loaded only when needed. A 500-line SKILL.md with 200 lines of code examples should be a 300-line SKILL.md + a 200-line references file.
130
+
131
+ <HARD-GATE>
132
+ Code blocks in SKILL.md > 10 lines = review failure.
133
+ Extract to references/ or scripts/. No exceptions.
134
+ </HARD-GATE>
135
+
109
136
  #### Frontmatter Rules
110
137
 
111
138
  ```yaml
@@ -119,11 +146,16 @@ metadata:
119
146
  ---
120
147
  ```
121
148
 
122
- **Description rules:**
149
+ **Description rules (CSO Discipline):**
123
150
  - MUST start with "Use when..."
124
151
  - MUST describe triggering conditions, NOT workflow
125
152
  - MUST be third person
126
153
  - MUST NOT summarize what the skill does internally
154
+ - AI reads description → decides whether to invoke → if description contains workflow summary, AI skips reading the full SKILL.md content (it thinks it already knows)
155
+ - Test: if you can execute the skill from the description alone, the description leaks too much
156
+
157
+ Bad: "Analyzes code quality through 6-step process: scan files, check patterns, run linters, compare metrics, generate report, suggest fixes"
158
+ Good: "Use when code changes need quality review before commit. Symptoms: PR ready, refactor complete, pre-release check."
127
159
 
128
160
  ```yaml
129
161
  # BAD: Summarizes workflow — agent reads description, skips full content
@@ -182,6 +214,62 @@ Run additional pressure scenarios with varied pressures. For each new failure:
182
214
 
183
215
  Repeat until no new failures emerge in 2 consecutive test runs.
184
216
 
217
+ #### Pressure Types for Test Scenarios
218
+
219
+ Best tests combine 3+ pressures simultaneously:
220
+
221
+ | Pressure | Example Scenario |
222
+ |----------|------------------|
223
+ | Time | "Emergency deployment, deadline in 30 min" |
224
+ | Sunk cost | "Already wrote 200 lines, can't restart" |
225
+ | Authority | "Senior dev says skip testing" |
226
+ | Economic | "Customer churning, ship now or lose $50k MRR" |
227
+ | Exhaustion | "50 tool calls deep, context filling up" |
228
+ | Social | "Looking dogmatic by insisting on process" |
229
+ | Pragmatic | "Being practical vs being pedantic" |
230
+
231
+ #### Scenario Quality Requirements
232
+
233
+ 1. **Concrete A/B/C options** — force explicit choice (no "I'd ask the user" escape hatch)
234
+ 2. **Real constraints** — specific times, actual consequences, named files
235
+ 3. **Real file paths** — `/tmp/payment-system` not "a project"
236
+ 4. **"Make agent ACT"** — "What do you do?" not "What should you do?"
237
+ 5. **No easy outs** — every option has a cost
238
+
239
+ #### Meta-Testing (When GREEN Isn't Working)
240
+
241
+ If the agent keeps failing even WITH the skill loaded, ask: "How could that skill have been written differently to make the correct option crystal clear?"
242
+
243
+ Three possible responses:
244
+ 1. "Skill was clear, I chose to ignore it" → foundational principle needed (stronger HARD-GATE)
245
+ 2. "Skill should have said X explicitly" → add that exact phrasing verbatim
246
+ 3. "I didn't see section Y" → reorganize for discoverability (move up, add header)
247
+
248
+ #### Bulletproof Criteria
249
+
250
+ A skill is bulletproof when:
251
+ - Agent chooses correct option under maximum pressure (3+ pressures combined)
252
+ - Agent CITES skill sections as justification for its choice
253
+ - Agent ACKNOWLEDGES the temptation but follows the rule anyway
254
+
255
+ #### Persuasion Principles for Skill Language
256
+
257
+ Research (Meincke et al., 2025, 28,000 conversations) shows 33% → 72% compliance with these techniques:
258
+
259
+ | Principle | Application | Use For |
260
+ |-----------|-------------|---------|
261
+ | Authority | "YOU MUST", imperative language | Eliminates decision fatigue, safety-critical rules |
262
+ | Commitment | Explicit announcements + tracked choices | Creates accountability trail |
263
+ | Scarcity | Time-bound requirements, "before proceeding" | Triggers immediate action |
264
+ | Social Proof | "Every time", universal statements | Documents what prevents failures |
265
+ | Unity | "We're building quality" language | Shared identity, quality goals |
266
+
267
+ **Prohibited in skills:**
268
+ - **Liking** ("Great job following the process!") → creates sycophancy
269
+ - **Reciprocity** ("I helped you, now follow the rules") → feels manipulative
270
+
271
+ **Ethical test**: Would this serve the user's genuine interests if they fully understood the technique?
272
+
185
273
  ### Phase 6 — INTEGRATE
186
274
 
187
275
  Wire the skill into the mesh:
@@ -302,10 +390,13 @@ Techniques:
302
390
  | Skill passes test but breaks mesh connections | MEDIUM | Phase 6 integration: verify output compatibility |
303
391
  | Editing skill without testing the edit | MEDIUM | Adapting section: same TDD cycle for edits |
304
392
  | Overly verbose skill burns context tokens | MEDIUM | Token efficiency guidelines: layer-based word targets |
393
+ | Code blocks in SKILL.md bloat every invocation | HIGH | WHY vs HOW split: SKILL.md ≤10-line code blocks, extract rest to references/ |
394
+ | Writing skill without TDD (no observed failures first) | CRITICAL | Skill TDD: RED (run scenario WITHOUT skill → document failures) → GREEN (write skill targeting failures) → REFACTOR (find bypasses → add blocks) |
395
+ | Description leaks workflow → agent skips full content | HIGH | CSO Discipline: description = triggers only. Test: can you execute from description alone? If yes, it leaks too much |
305
396
 
306
397
  ## Done When
307
398
 
308
- - Baseline test documented with observed failures
399
+ - Baseline test documented with observed failures (TDD RED phase)
309
400
  - SKILL.md follows template format completely
310
401
  - Skill passes pressure test (agent complies with skill loaded)
311
402
  - No new failures in 2 consecutive varied-pressure test runs