opencode-overclock 0.4.0 → 0.5.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 (50) hide show
  1. package/README.md +72 -17
  2. package/package.json +5 -3
  3. package/skills/codebase-design/DEEPENING.md +35 -0
  4. package/skills/codebase-design/DESIGN-IT-TWICE.md +34 -0
  5. package/skills/codebase-design/SKILL.md +93 -0
  6. package/skills/diagnosing-bugs/SKILL.md +123 -0
  7. package/skills/domain-modeling/ADR-FORMAT.md +55 -0
  8. package/skills/domain-modeling/CONTEXT-FORMAT.md +32 -0
  9. package/skills/domain-modeling/SKILL.md +102 -0
  10. package/skills/doubt/SKILL.md +80 -0
  11. package/skills/grilling/SKILL.md +96 -0
  12. package/skills/source-discipline/SKILL.md +78 -0
  13. package/skills/tdd/SKILL.md +87 -0
  14. package/skills/to-spec/SKILL.md +69 -0
  15. package/skills/to-spec/SPEC-TEMPLATE.md +50 -0
  16. package/skills/to-tickets/SKILL.md +74 -0
  17. package/skills/to-tickets/TICKET-TEMPLATE.md +41 -0
  18. package/src/core/lifecycle.ts +18 -4
  19. package/src/core/types.ts +29 -0
  20. package/src/features/guard.ts +258 -12
  21. package/src/features/index.ts +13 -1
  22. package/src/features/recovery.ts +13 -3
  23. package/src/features/safety.ts +147 -0
  24. package/src/features/sched.ts +46 -10
  25. package/src/features/tasks.ts +87 -20
  26. package/src/features/truncator.ts +26 -9
  27. package/src/features/usage.ts +20 -0
  28. package/src/features/workflow.ts +270 -0
  29. package/src/lib/exec.ts +7 -1
  30. package/src/platform/process/exec.ts +252 -11
  31. package/src/platform/session/inject.ts +8 -1
  32. package/src/platform/storage/state.ts +26 -4
  33. package/src/v2/host.ts +4 -1
  34. package/src/workflow/agents/codebase-researcher.ts +27 -0
  35. package/src/workflow/agents/craftsman.ts +26 -0
  36. package/src/workflow/agents/design-explorer.ts +33 -0
  37. package/src/workflow/agents/doc-writer.ts +24 -0
  38. package/src/workflow/agents/doubt-reviewer.ts +26 -0
  39. package/src/workflow/agents/engineering-coach.ts +23 -0
  40. package/src/workflow/agents/performance-auditor.ts +29 -0
  41. package/src/workflow/agents/security-auditor.ts +23 -0
  42. package/src/workflow/agents/spec-reviewer.ts +15 -0
  43. package/src/workflow/agents/standards-reviewer.ts +24 -0
  44. package/src/workflow/agents/test-engineer.ts +28 -0
  45. package/src/workflow/catalog.ts +210 -0
  46. package/src/workflow/templates/build.ts +47 -0
  47. package/src/workflow/templates/define.ts +45 -0
  48. package/src/workflow/templates/diagnose.ts +58 -0
  49. package/src/workflow/templates/plan.ts +52 -0
  50. package/src/workflow/templates/ship.ts +64 -0
package/README.md CHANGED
@@ -13,15 +13,17 @@ opencode plugin -g opencode-overclock # every project
13
13
 
14
14
  ## What you get
15
15
 
16
- | Module | What it does | Tools it adds |
17
- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
18
- | `tasks` | Run shell commands in the background. The agent gets the result posted back into the session when they finish, and a nudge if one blocks on a prompt. | `task_run` `task_status` `task_output` `task_kill` |
19
- | `sched` | Recurring prompts on a cron expression or an interval (`"5m"`). Survives restarts; an interval on the current session makes a loop. | `schedule_create` `schedule_list` `schedule_delete` |
20
- | `guard` | Your own quality gates: run a command after the agent edits files, and feed failures back to it once the session goes idle. Built-in recipes & edit recovery. | |
21
- | `recovery` | Automatically heal provider errors (missing tool results, thinking block sequencing, context limit) and auto-resume sessions. | |
22
- | `truncator` | Context-protecting smart output truncation for high-volume tools (`task_output`, `bash`, `grep`, `glob`, `webfetch`) preserving header & tail diagnostics. | — |
23
- | `usage` | Per-day and per-session cost and token totals, collected from the event bus (accessible via TUI `/oc-usage`). | — |
24
- | `buddy` | An ASCII pet next to the prompt that reacts to what the session is doing. Purely cosmetic. | — |
16
+ | Module | What it does | Tools it adds |
17
+ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
18
+ | `workflow` | 5 lifecycle commands (`/define`, `/plan`, `/build`, `/diagnose`, `/ship`), 11 agents (interactive & sandboxed subagents), and 9 bundled engineering skills (`tdd`, `grilling`, `doubt`, etc.). | — |
19
+ | `safety` | Blocks destructive git operations (`git reset --hard`, force-push, `clean -f`, `branch -D`, `stash drop`) in `bash` tool calls before they run. | |
20
+ | `tasks` | Run shell commands in the background. The agent gets the result posted back into the session when they finish, and a nudge if one blocks on a prompt. | `task_run` `task_status` `task_output` `task_kill` |
21
+ | `sched` | Recurring prompts on a cron expression or an interval (`"5m"`). Survives restarts; an interval on the current session makes a loop. | `schedule_create` `schedule_list` `schedule_delete` |
22
+ | `guard` | Your own quality gates: run a command after the agent edits files, feed failures back on idle, edit recovery hints, and `floorGuard` anti-bypass protection. | — |
23
+ | `recovery` | Automatically heal provider errors (missing tool results, thinking block sequencing, context limit) and auto-resume sessions. | — |
24
+ | `truncator` | Context-protecting smart output truncation for high-volume tools (`task_output`, `bash`, `grep`, `glob`, `webfetch`) preserving header & tail diagnostics. | — |
25
+ | `usage` | Per-day and per-session cost and token totals, collected from the event bus (accessible via TUI `/oc-usage`). | — |
26
+ | `buddy` | An ASCII pet next to the prompt that reacts to what the session is doing. Purely cosmetic. | — |
25
27
 
26
28
  On top of the tools, the TUI side adds desktop notifications when a turn finishes or the agent
27
29
  needs you, plus `/oc-tasks`, `/oc-usage`, `/oc-schedules`, `/oc-buddy` (pet), `/oc-buddy-switch` (choose species), and `/oc-buddy-cycle` (next species).
@@ -88,14 +90,67 @@ To turn an individual feature off:
88
90
  }
89
91
  ```
90
92
 
91
- | Module | Options |
92
- | ---------------- | ---------------------------------------------------------------------------------------------------------------- |
93
- | `tasks` | `killOnExit` bool · `stallDetection` bool · `stallThresholdMs` num · `stallCheckIntervalMs` num · `tmux` bool |
94
- | `sched` | `skipIfBusy` bool |
95
- | `guard` | `hooks` array · `recipes` array (`["tsc", "eslint", "cargo", "ruff", "go"]`) · `auto` bool · `editRecovery` bool |
96
- | `recovery` | `maxAttempts` num · `cooldownMs` num · `autoResume` bool |
97
- | `truncator` | `maxChars` num · `tools` array · `headLines` num · `tailLines` num |
98
- | `usage`, `buddy` | |
93
+ | Module | Options |
94
+ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
95
+ | `workflow` | `enabled` bool · `commands` bool · `subagents` bool · `skillsPath` string |
96
+ | `safety` | `blockDestructiveGit` bool · `allowForcePush` bool · `allowStashDrop` bool · `customPatterns` array |
97
+ | `guard` | `hooks` array · `recipes` array (`["tsc", "eslint", "cargo", "ruff", "go"]`) · `auto` bool · `editRecovery` bool · `floorGuard` bool / obj |
98
+ | `tasks` | `killOnExit` bool · `stallDetection` bool · `stallThresholdMs` num · `stallCheckIntervalMs` num · `tmux` bool |
99
+ | `sched` | `skipIfBusy` bool |
100
+ | `recovery` | `maxAttempts` num · `cooldownMs` num · `autoResume` bool |
101
+ | `truncator` | `maxChars` num · `tools` array · `headLines` num · `tailLines` num |
102
+ | `usage`, `buddy` | — |
103
+
104
+ ### Engineering harness & workflows (`workflow`)
105
+
106
+ Overclock bundles a structured software engineering harness that elevates opencode from a code generator into an elite engineering partner.
107
+
108
+ #### 1. Lifecycle Commands (The "When")
109
+
110
+ | Command | Purpose |
111
+ | :---------- | :--------------------------------------------------------------------------------------------------------------------------------- |
112
+ | `/define` | Structured inquiry via `grilling` and `domain-modeling`, or direct specification synthesis (`to-spec`) into `SPEC.md`. |
113
+ | `/plan` | Decomposes `SPEC.md` into vertical tracer bullets (`to-tickets`) with dependency DAGs and expand/contract migration branches. |
114
+ | `/build` | Autonomous TDD implementation (`tdd`) with stop-the-line tripwires (halts on 3 consecutive test failures or schema changes). |
115
+ | `/diagnose` | Disciplined 6-phase defect isolation loop with automated reproductions, tagged logging (`[DEBUG-xxxx]`), and regression tests. |
116
+ | `/ship` | Pre-launch gatekeeper running a parallel 4-way subagent audit across uncommitted, staged, and branch diffs with GO/NO-GO verdicts. |
117
+
118
+ #### 2. Bundled Engineering Skills (The "How")
119
+
120
+ Auto-discovered by opencode's `skill` tool when relevant:
121
+
122
+ - `tdd`: Test-driven development loop enforcing public seam tests before implementation and the Prove-It bug pattern.
123
+ - `grilling`: Requirements interrogation on the decision dependency frontier with opinionated defaults (`➡️ **Recommended:**`).
124
+ - `domain-modeling`: Ubiquitous language management (`CONTEXT.md`) and Architecture Decision Records (`ADR-FORMAT.md`).
125
+ - `to-spec`: Fast requirements synthesis into `SPEC.md` without reopening interview loops.
126
+ - `to-tickets`: Context-sized DAG task planning with expand-and-contract branches for wide refactors.
127
+ - `codebase-design`: Deep module architecture (Ousterhout), 4 dependency categories, and "Design It Twice" exploration.
128
+ - `diagnosing-bugs`: Systematic defect reproduction, ranked hypotheses, secret redaction, and tagged probes.
129
+ - `doubt`: Adversarial verification where artifacts are audited against contracts without author confirmation bias.
130
+ - `source-discipline`: Grounding framework code in official, version-matched documentation.
131
+
132
+ #### 3. Workflow Agents (The "Who")
133
+
134
+ Specialized agents available interactively in the TUI (`Tab`) and delegable via the `task` tool:
135
+
136
+ ##### Interactive & Subagent Agents (`mode: "all"`)
137
+
138
+ - `craftsman`: Disciplined implementation agent enforcing TDD (public seam first), minimal vertical slices, and zero compromises on code quality.
139
+ - `doc-writer`: Technical writer synthesizing accurate documentation, API references, ADRs, and user guides grounded directly in codebase evidence.
140
+ - `engineering-coach`: Elite staff mentor providing Socratic debugging guidance, mental models, and architectural critique (read-only sandboxed).
141
+ - `design-explorer`: Architect formulating contrasting minimalist vs extensible interface proposals ("Design It Twice", read-only sandboxed).
142
+ - `codebase-researcher`: Scout tracing call graphs, seams, and dependencies without cluttering context (read-only sandboxed).
143
+ - `doubt-reviewer`: Adversarial verifier probing race conditions, error bounds, and silent assumptions (read-only sandboxed).
144
+
145
+ ##### Sandboxed Audit Subagents (`mode: "subagent"`)
146
+
147
+ Leaf subagents invoked via the `task` tool with **enforced read-only tool sandboxing** (`tools: { write: false, edit: false }`, `permission: { edit: "deny" }`):
148
+
149
+ - `standards-reviewer`: Senior reviewer auditing code diffs against Martin Fowler's code smells and repo idioms.
150
+ - `spec-reviewer`: Product reviewer ensuring strict compliance with `SPEC.md` and zero unrequested scope creep.
151
+ - `security-auditor`: Adversarial security engineer auditing diffs for OWASP Top 10 flaws and secret hygiene.
152
+ - `test-engineer`: QA engineer assessing test coverage gaps, assertion quality, and mocking boundaries.
153
+ - `performance-auditor`: Performance engineer identifying N+1 queries, unbounded memory, and latency bottlenecks.
99
154
 
100
155
  ### Quality gates (`guard`)
101
156
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-overclock",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Power-ups for opencode: background tasks, cron scheduling, quality-gate hooks, usage telemetry, and companion. Modular, toggleable.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -16,7 +16,8 @@
16
16
  "./tui": "./src/tui.ts"
17
17
  },
18
18
  "files": [
19
- "src"
19
+ "src",
20
+ "skills"
20
21
  ],
21
22
  "keywords": [
22
23
  "opencode",
@@ -39,7 +40,8 @@
39
40
  },
40
41
  "dependencies": {
41
42
  "@opencode-ai/plugin": "1.18.9",
42
- "croner": "^10.0.1"
43
+ "croner": "^10.0.1",
44
+ "yaml": "^2.7.0"
43
45
  },
44
46
  "peerDependencies": {
45
47
  "@opentui/solid": ">=0.4.5"
@@ -0,0 +1,35 @@
1
+ # Deepening: Dependency Categories and Seam Discipline
2
+
3
+ How to deepen a cluster of shallow modules into high-leverage architectural components.
4
+
5
+ ## Dependency Categories
6
+
7
+ When assessing a module or candidate for deepening, classify its dependencies. The category dictates how the module is structured and tested across its seams:
8
+
9
+ ### 1. In-Process (Pure Computation)
10
+
11
+ - **Characteristics:** In-memory state, algorithms, data transformations, zero network/disk I/O.
12
+ - **Deepening Strategy:** Merge shallow helpers and test directly through the deep module interface. No adapters, mocks, or ports needed.
13
+
14
+ ### 2. Local-Substitutable
15
+
16
+ - **Characteristics:** Infrastructure dependencies with reliable in-memory or embedded substitutes (e.g. SQLite in `:memory:`, PGLite, in-memory filesystem, mock clock).
17
+ - **Deepening Strategy:** Deepen the module and run tests directly against the local substitute. The seam remains internal to the module; callers never configure or pass database handles.
18
+
19
+ ### 3. Remote but Owned (Ports & Adapters)
20
+
21
+ - **Characteristics:** Internal microservices, background job queues, or intra-company APIs deployed across network boundaries.
22
+ - **Deepening Strategy:** Define a clean **port** (interface) at the seam. The deep module owns domain orchestration; the transport is injected via an **adapter**. Tests supply a fast in-memory adapter; production supplies an HTTP/gRPC/queue adapter.
23
+
24
+ ### 4. True External (Third-Party Services)
25
+
26
+ - **Characteristics:** External vendors (Stripe, Twilio, SendGrid, AWS S3) outside your control.
27
+ - **Deepening Strategy:** The module defines a narrow domain port. Test suites supply a mock/stub adapter verifying request shapes; production supplies the vendor client adapter.
28
+
29
+ ---
30
+
31
+ ## Seam Discipline
32
+
33
+ - **The Two-Adapter Rule:** One adapter means a hypothetical seam; two adapters means a real one. Do NOT introduce an interface or port unless at least two implementations are justified (typically production + in-memory test). A single-implementation interface is unnecessary indirection.
34
+ - **Internal vs External Seams:** A deep module may have internal seams (private helpers, internal storage engines) for its own tests. Do not leak internal seams to external callers.
35
+ - **The Interface is the Test Surface:** Write unit tests against the deep module interface, not against internal private functions. Tests survive internal refactoring when they test behavior, not implementation mechanics.
@@ -0,0 +1,34 @@
1
+ # Design It Twice
2
+
3
+ When architecting a critical module, interface, or subsystem boundary, your first idea is almost never your best idea. First ideas are typically shallow adaptations of existing local constraints.
4
+
5
+ ## The Exploration Protocol
6
+
7
+ ### 1. Frame the Problem Space
8
+
9
+ Before generating interfaces, explicitly articulate:
10
+
11
+ - The caller goals and constraints the interface must satisfy.
12
+ - The dependency category (In-Process, Local-Substitutable, Remote-Owned, or True External) per [DEEPENING.md](DEEPENING.md).
13
+ - A concrete usage scenario with realistic inputs and outputs.
14
+
15
+ ### 2. Formulate Radically Differently Constrained Interfaces
16
+
17
+ Generate at least 2 (preferably 3) contrasting architectural designs:
18
+
19
+ - **Option A (Minimalist / High-Leverage):** Absolute minimum public surface (1-3 intuitive functions). Maximum internal power hidden behind simple calls. Optimizes for caller ergonomics.
20
+ - **Option B (Extensible / Composable):** Explicit ports and adapters, pluggable pipeline or middleware, highly configurable. Optimizes for future variance and third-party extensions.
21
+ - **Option C (Default-Optimized):** The common 90% use case requires zero configuration, while advanced capabilities are exposed through optional progressive disclosure.
22
+
23
+ ### 3. Compare Across Concrete Criteria
24
+
25
+ Evaluate the designs against:
26
+
27
+ 1. **Depth (Leverage):** Ratio of internal power provided to interface complexity imposed on callers.
28
+ 2. **Call-Site Simplicity:** How clean and readable is the calling code?
29
+ 3. **Information Hiding:** Does the interface leak internal details, vendor types, or database identifiers?
30
+ 4. **Blast Radius of Change:** If the internal implementation changes tomorrow, do callers need to change?
31
+
32
+ ### 4. Provide an Opinionated Recommendation
33
+
34
+ Do not present a bland menu of options without guidance. Recommend the best approach (or a synthesized hybrid), clearly stating the trade-offs and rationale.
@@ -0,0 +1,93 @@
1
+ ---
2
+ name: codebase-design
3
+ description: Principles for deep module architecture and high-leverage interface design. Use when creating new services or modules, untangling tightly coupled subsystems, designing APIs, or refactoring architecture.
4
+ pack: core
5
+ license: MIT
6
+ attribution: Adapted from mattpocock/skills (MIT License)
7
+ references:
8
+ - DEEPENING.md
9
+ - DESIGN-IT-TWICE.md
10
+ ---
11
+
12
+ # Codebase Design: Deep Modules & High-Leverage Architecture
13
+
14
+ Rooted in John Ousterhout's _A Philosophy of Software Design_ and domain-driven architectural patterns, this skill guides the creation of deep, high-leverage modules that make codebases simpler to understand, maintain, and evolve.
15
+
16
+ ## When to Use
17
+
18
+ - Designing a new service, package, module, or domain boundary.
19
+ - Decomposing a tangled god-object or sprawling utility library into cohesive components.
20
+ - Designing API contracts or SDK entry points for internal or external callers.
21
+ - Assessing architectural coupling and seam placement.
22
+
23
+ ## When NOT to Use
24
+
25
+ - Routine bug fixes or isolated one-line edits.
26
+ - Editing declarative configuration files.
27
+ - Mechanical script maintenance.
28
+
29
+ ---
30
+
31
+ ## Core Architectural Principles
32
+
33
+ ### 1. Deep Modules (Depth Over Shallowness)
34
+
35
+ - **Shallow Module (Anti-pattern):** A module whose public interface is complicated relative to the small amount of capability it provides. (e.g. A 40-line wrapper around `fetch` that requires callers to pass 6 configuration objects).
36
+ - **Deep Module (Ideal):** A module that provides a simple, intuitive interface while concealing substantial complexity and power behind it. (e.g. Unix file I/O: `open`, `read`, `write`, `close` concealing disk block caching, buffer pools, and kernel drivers).
37
+ - **Measure of Architectural Leverage:**
38
+ $$\text{Leverage} = \frac{\text{Internal Functionality Provided}}{\text{Interface Complexity Imposed on Callers}}$$
39
+
40
+ ### 2. Information Hiding vs Information Leakage
41
+
42
+ - **Information Hiding:** Knowledge of private algorithms, data representations, and third-party dependencies is strictly contained within the module.
43
+ - **Information Leakage:** Occurs when an internal change to a module forces ripple edits across caller code (e.g. exposing internal database IDs, ORM models, or vendor SDK types directly to consumers).
44
+ - **Hyrum's Law:** _"With a sufficient number of users of an API, all observable behaviors of your system will be depended on by somebody."_ Keep public surfaces strictly bounded.
45
+
46
+ ### 3. The Full Caller Contract
47
+
48
+ An interface is not just a function signature or type signature. The full contract comprises:
49
+
50
+ - **Ordering:** Must `init()` be called before `run()`?
51
+ - **Error Modes:** How are failures surfaced (exceptions, result tuples, status codes)?
52
+ - **Invariants:** What assumptions must callers hold true?
53
+ - **Configuration & Defaults:** Are sane defaults supplied so simple callers do not configure knobs?
54
+ - **Performance & Resource Cleanup:** Must callers explicitly close or release handles?
55
+
56
+ ### 4. Dependency Classification & Seams
57
+
58
+ Classify dependencies before introducing interfaces:
59
+
60
+ - See [DEEPENING.md](DEEPENING.md) for the 4 categories: In-Process, Local-Substitutable, Remote-Owned (Ports & Adapters), and True External.
61
+ - Observe the **Two-Adapter Rule**: Never create an interface or port unless at least two real adapters exist (typically production + in-memory test).
62
+
63
+ ### 5. Design It Twice
64
+
65
+ When designing a critical subsystem or boundary:
66
+
67
+ - Never settle on the first design that comes to mind.
68
+ - Explore at least 2 contrasting architectural designs (e.g. Minimalist vs Extensible).
69
+ - See [DESIGN-IT-TWICE.md](DESIGN-IT-TWICE.md) for the structured comparison protocol.
70
+
71
+ ### 6. Chesterton's Fence in Refactoring
72
+
73
+ Before modifying or deleting code that appears redundant, verbose, or unusual, you MUST discover and explain why it was originally written. If you cannot explain why it exists, you are not qualified to change it.
74
+
75
+ ---
76
+
77
+ ## Common Rationalizations
78
+
79
+ | Rationalization | Reality |
80
+ | :-------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------- |
81
+ | _"More small files and 5-line classes are always cleaner."_ | Fragmenting logic creates shallow modules and cognitive indirection. Colocate cohesive logic into deep modules. |
82
+ | _"Expose all knobs so callers have maximum flexibility."_ | Forcing callers to configure dozens of low-level options leaks complexity. Provide high-leverage defaults. |
83
+ | _"I will create an interface just in case we need another implementation later."_ | Speculative interfaces add indirection without value. Introduce ports when you have two concrete adapters. |
84
+
85
+ ---
86
+
87
+ ## Verification
88
+
89
+ Architectural design is complete when:
90
+
91
+ 1. Callers can achieve primary use cases using 1-2 intuitive entry points.
92
+ 2. Internal changes to storage, third-party libraries, or algorithms cause zero ripple effects on callers.
93
+ 3. Automated tests exercise the public interface rather than private internal implementation details.
@@ -0,0 +1,123 @@
1
+ ---
2
+ name: diagnosing-bugs
3
+ description: Disciplined root-cause investigation loop for bugs, flakes, and performance regressions. Use when investigating unexpected behavior, diagnosing error traces, resolving flaky tests, or fixing performance bottlenecks.
4
+ pack: core
5
+ license: MIT
6
+ attribution: Adapted from mattpocock/skills (MIT License)
7
+ ---
8
+
9
+ # Diagnosing Bugs: Disciplined Root-Cause Investigation
10
+
11
+ A systematic discipline for isolating, reproducing, and fixing elusive software defects. Skip phases only when explicitly justified.
12
+
13
+ ## Fast Explanation vs Full Investigation
14
+
15
+ - **Explanation Request:** If the user asks for a conceptual explanation of an error message ("what does this error mean?"), provide a direct explanation without launching a full diagnostic loop.
16
+ - **Defect Investigation:** When investigating an actual broken feature, unexpected output, crash, or performance regression, execute the structured loop below.
17
+
18
+ ---
19
+
20
+ ## 0. Redaction First
21
+
22
+ Before displaying commands, outputs, or captured logs:
23
+
24
+ - **Redact every credential or secret:** Replace tokens, API keys, passwords, and private identifiers with `<REDACTED>`.
25
+ - Use environment variables so sensitive credentials never leak into logs or command strings.
26
+
27
+ ---
28
+
29
+ ## The 6-Phase Diagnostic Loop
30
+
31
+ ### Phase 1: Build a Tight Feedback Loop
32
+
33
+ **This is the core of the skill.** If you have a fast, automated pass/fail signal that goes red on _this specific bug_, you will isolate the cause. If you do not have one, theorizing about code is speculation.
34
+
35
+ #### Ways to Construct the Loop (in order of preference):
36
+
37
+ 1. **Failing Unit / Integration Test:** At the seam reaching the bug.
38
+ 2. **Automated HTTP / Script Invocation:** `curl` or script against a local server.
39
+ 3. **CLI Invocation with Snapshot Diff:** Diffing output against known-good state.
40
+ 4. **Headless Browser Test:** Playwright or Puppeteer script asserting on DOM or network.
41
+ 5. **Replayed Trace / Fixture:** Load a captured production payload or event in isolation.
42
+ 6. **Throwaway Minimal Harness:** Isolated script calling the subsystem directly.
43
+
44
+ #### Non-Deterministic & Flaky Defects
45
+
46
+ For intermittent bugs, the goal is to **raise the reproduction rate**:
47
+
48
+ - Loop the trigger 50–100 times in a test harness.
49
+ - Parallelize requests, add concurrent load, or inject micro-delays around timing windows.
50
+ - A bug that reproduces 40% of the time under stress is debuggable; a 0.5% flake is not.
51
+
52
+ #### Inaccessible Environments & Missing Access
53
+
54
+ If a bug cannot be reproduced locally due to missing external credentials or environments:
55
+
56
+ - **Do not guess blindly.** State what you tried and what is missing.
57
+ - Ask the user for:
58
+ 1. Access or temporary environment credentials, OR
59
+ 2. A sanitized log dump, HAR recording, or telemetry trace, OR
60
+ 3. Permission to add temporary diagnostic instrumentation to staging.
61
+
62
+ **Completion Criterion:** You have an automated, red-capable command that you have executed and confirmed red on the reported defect.
63
+
64
+ ---
65
+
66
+ ### Phase 2: Reproduce & Minimise
67
+
68
+ Confirm the failure matches the **user's actual symptom**, not an unrelated error nearby.
69
+
70
+ #### Minimise the Scenario
71
+
72
+ Once red, shrink the reproduction to the absolute smallest scenario that still fails:
73
+
74
+ - Cut parameters, configurations, data fields, and unnecessary steps one at a time.
75
+ - Re-run the loop after each reduction.
76
+ - **Done when every remaining element is load-bearing:** removing any remaining line causes the loop to pass green.
77
+
78
+ ---
79
+
80
+ ### Phase 3: Formulate Ranked, Falsifiable Hypotheses
81
+
82
+ Formulate 3 to 5 distinct, ranked hypotheses explaining the failure. Generating multiple hypotheses prevents cognitive anchoring on the first plausible idea.
83
+
84
+ Every hypothesis must be **falsifiable**:
85
+
86
+ > _"If [Cause X] is the root cause, then [Changing Y] will resolve the failure, and [Changing Z] will exacerbate it."_
87
+
88
+ If a hypothesis cannot state a testable prediction, discard or sharpen it.
89
+
90
+ ---
91
+
92
+ ### Phase 4: Targeted Tagged Instrumentation
93
+
94
+ Test predictions one variable at a time:
95
+
96
+ - **Inspect with Debugger / REPL:** When available, inspecting state beats adding ten log statements.
97
+ - **Unique Hex Tags:** Tag every temporary diagnostic log with a unique searchable prefix:
98
+ ```ts
99
+ console.log("[DEBUG-f7a2] Parsed payload headers:", headers)
100
+ ```
101
+ Unique tags guarantee that all temporary probes can be identified and removed with a single pass.
102
+ - **Performance Regressions Branch:** Do not use `console.log` for performance bugs (logging distorts timings). Establish a stable baseline measurement (`performance.now()`, profiler, query plan), change one variable, and compare against the baseline.
103
+
104
+ ---
105
+
106
+ ### Phase 5: Fix & Regression Guard
107
+
108
+ 1. **Verify the Seam:** Write an automated regression test at the public seam **before** applying the fix.
109
+ - If the codebase architecture lacks a seam to test the defect cleanly, note this explicitly as an architectural gap.
110
+ 2. **Apply the Minimal Root-Cause Fix:** Never paper over symptoms, suppress errors, or catch-and-ignore. Fix the underlying invariant.
111
+ 3. **Assert Green:** Run the regression test and confirm it passes.
112
+ 4. **Re-run Full Scenario:** Re-run the Phase 1 loop against the original un-minimised scenario to ensure full resolution.
113
+
114
+ ---
115
+
116
+ ### Phase 6: Clean Up & Document
117
+
118
+ Before concluding:
119
+
120
+ - [ ] Remove all `[DEBUG-xxxx]` logging probes (`grep` for the tag).
121
+ - [ ] Delete or clean up throwaway reproduction scripts.
122
+ - [ ] Run full test suite and linters to verify zero side-effects.
123
+ - [ ] Document the verified root cause in the commit message or PR summary so future maintainers learn from the defect.
@@ -0,0 +1,55 @@
1
+ # Architecture Decision Record (ADR) Format
2
+
3
+ An ADR captures a consequential architectural decision, its context, trade-offs, and alternatives considered.
4
+
5
+ ## When to Write an ADR: The 3-Criteria Filter
6
+
7
+ An ADR MUST only be recorded if the decision meets ALL THREE criteria:
8
+
9
+ 1. **Hard to Reverse:** Changing it later would require significant refactoring, database migrations, or cross-system coordination.
10
+ 2. **Surprising Without Context:** A reasonable engineer might wonder why this path was chosen instead of a conventional alternative.
11
+ 3. **A Real Trade-off:** The choice involves clear disadvantages, constraints, or costs that were deliberately accepted in exchange for specific benefits.
12
+
13
+ If a decision does not meet all three (e.g. choosing a standard linter or routine naming convention), do NOT write an ADR. Record it as a standard or invariant in the project spec instead.
14
+
15
+ ---
16
+
17
+ ## ADR Template
18
+
19
+ \`\`\`markdown
20
+
21
+ # ADR-[NUMBER]: [Short Title in Imperative Mood, e.g. Use PostgreSQL for Outbox Queue]
22
+
23
+ - **Status:** [Proposed | Accepted | Superseded by ADR-xxx]
24
+ - **Date:** [YYYY-MM-DD]
25
+ - **Deciders:** [Names or Roles]
26
+
27
+ ## Context & Problem Statement
28
+
29
+ What problem are we trying to solve? What forces and constraints exist (performance, delivery deadline, team expertise, infrastructure)?
30
+
31
+ ## Considered Options
32
+
33
+ 1. **Option A:** [Description]
34
+ 2. **Option B:** [Description]
35
+ 3. **Option C:** [Description]
36
+
37
+ ## Decision Outcome
38
+
39
+ Chosen option: **Option [X]**, because [concise justification].
40
+
41
+ ### Positive Consequences
42
+
43
+ - [Benefit 1]
44
+ - [Benefit 2]
45
+
46
+ ### Negative Consequences & Accepted Costs
47
+
48
+ - [Accepted downside 1]
49
+ - [Accepted downside 2]
50
+
51
+ ## Compliance & Invariants
52
+
53
+ - [Invariant 1 that future maintainers must observe]
54
+ - [Verification rule or automated test asserting this decision]
55
+ \`\`\`
@@ -0,0 +1,32 @@
1
+ # CONTEXT.md Format
2
+
3
+ A project glossary establishing ubiquitous language for the bounded context.
4
+
5
+ ## Structure
6
+
7
+ ```markdown
8
+ # {Context Name}
9
+
10
+ {One or two sentence description of what this bounded context is and why it exists.}
11
+
12
+ ## Ubiquitous Language
13
+
14
+ **Order**:
15
+ A customer request to purchase goods, created at checkout and tracked through fulfillment.
16
+ _Avoid_: Purchase, Transaction, Cart.
17
+
18
+ **Invoice**:
19
+ A formal request for payment issued to a customer with payment terms and due dates.
20
+ _Avoid_: Bill, Receipt.
21
+
22
+ **Customer**:
23
+ A person or legal entity holding an active account that places orders.
24
+ _Avoid_: User, Client, Buyer.
25
+ ```
26
+
27
+ ## Rules
28
+
29
+ - **Be Opinionated:** When multiple words exist for the same concept, designate the canonical term and list confusing alternatives under `_Avoid_`.
30
+ - **Keep Definitions Tight:** 1 to 2 sentences max. Define what the concept IS, not how it is implemented in code.
31
+ - **Domain Concepts Only:** General programming concepts (buffers, queues, retries, JSON schemas) do NOT belong here unless they are domain entities within the system.
32
+ - **No Implementation Artifacts:** Do not put task lists, scratchpads, or pseudo-code in `CONTEXT.md`.
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: domain-modeling
3
+ description: Builds and sharpens a project's domain model and ubiquitous language. Use when establishing codebase terminology, writing or editing CONTEXT.md, defining entities, or recording Architecture Decision Records (ADRs).
4
+ pack: core
5
+ license: MIT
6
+ attribution: Adapted from mattpocock/skills (MIT License)
7
+ references:
8
+ - CONTEXT-FORMAT.md
9
+ - ADR-FORMAT.md
10
+ ---
11
+
12
+ # Domain Modeling
13
+
14
+ Actively build and sharpen the project's domain model as you design and implement. This is an active discipline: challenging ambiguous terms, discovering edge cases, and recording the glossary and decisions the moment they crystallize.
15
+
16
+ ## When to Use
17
+
18
+ - Defining new entities, services, APIs, or data models.
19
+ - Resolving ambiguous or conflicting terminology used by stakeholders or in code.
20
+ - Capturing ubiquitous language in `CONTEXT.md` (or existing project glossary).
21
+ - Making consequential, hard-to-reverse architectural decisions that warrant an ADR.
22
+
23
+ ## When NOT to Use
24
+
25
+ - Routine bug fixes or mechanical refactoring where domain concepts do not change.
26
+ - Storing task lists, implementation steps, or temporary notes (use specs and task plans instead).
27
+ - General programming concepts (e.g. timeouts, HTTP helpers, logger wrappers).
28
+
29
+ ---
30
+
31
+ ## File Structure
32
+
33
+ ### Single Context (Standard)
34
+
35
+ ```
36
+ /
37
+ ├── CONTEXT.md ← Ubiquitous language glossary
38
+ ├── docs/
39
+ │ └── adr/
40
+ │ ├── 0001-storage-engine.md
41
+ │ └── 0002-auth-tokens.md
42
+ └── src/
43
+ ```
44
+
45
+ ### Multi-Context Repositories
46
+
47
+ If different subsystems have distinct ubiquitous languages (e.g. `billing` vs `fulfillment`), a `CONTEXT-MAP.md` at root maps each bounded context:
48
+
49
+ ```
50
+ /
51
+ ├── CONTEXT-MAP.md ← Maps bounded contexts and relationships
52
+ ├── docs/adr/ ← System-wide ADRs
53
+ └── src/
54
+ ├── ordering/
55
+ │ └── CONTEXT.md
56
+ └── billing/
57
+ └── CONTEXT.md
58
+ ```
59
+
60
+ Create files lazily: only when the first term or ADR is resolved. Respect existing project document conventions if ADRs or glossaries are already placed elsewhere (e.g. `doc/adr/` or `wiki/`).
61
+
62
+ ---
63
+
64
+ ## The Active Modeling Protocol
65
+
66
+ ### 1. Challenge Against the Glossary
67
+
68
+ When the user or code uses a term conflicting with existing language, call it out immediately:
69
+
70
+ > _"The glossary defines 'Cancellation' as voiding an unfulfilled order, but you described 'Cancellation' of an already shipped package. Do you mean 'Return' or 'Recall'?"_
71
+
72
+ ### 2. Sharpen Fuzzy and Overloaded Terms
73
+
74
+ When terms are overloaded or vague, propose a precise canonical term:
75
+
76
+ > _"You mentioned 'User': in this context, do you mean 'Organization Admin', 'Member', or 'API Service Account'?"_
77
+
78
+ ### 3. Discuss Concrete Scenarios
79
+
80
+ Probe domain relationships with concrete boundary scenarios:
81
+
82
+ > _"What happens if an organization subscription expires while an asynchronous batch export is actively running?"_
83
+
84
+ ### 4. Cross-Reference with Code
85
+
86
+ Compare user descriptions with the existing codebase:
87
+
88
+ > _"The codebase requires a verified billing address before generating an invoice, but you stated invoices can be drafted without an address. Which is the intended invariant?"_
89
+
90
+ ### 5. Update CONTEXT.md Inline
91
+
92
+ Update `CONTEXT.md` immediately when a term is settled. Do not batch glossary updates until the end of the session. Keep definitions tight (1-2 sentences defining what the entity IS, not how it is implemented). See [CONTEXT-FORMAT.md](CONTEXT-FORMAT.md).
93
+
94
+ ### 6. Offer ADRs Sparingly: The 3-Criteria Filter
95
+
96
+ Only propose recording an ADR when ALL THREE criteria are satisfied:
97
+
98
+ 1. **Hard to Reverse:** Changing the decision later imposes high migration, refactoring, or coordination costs.
99
+ 2. **Surprising Without Context:** A reasonable future engineer might ask _"Why did they do it this way instead of the standard approach?"_
100
+ 3. **A Real Trade-off:** There were genuine alternative options, and one was chosen with deliberate acceptance of specific disadvantages.
101
+
102
+ If any criterion is missing, do NOT create an ADR. Record it as an invariant or decision in the specification instead. See [ADR-FORMAT.md](ADR-FORMAT.md).