@babylonjs-toolkit/agent 1.1.10 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/package.json +1 -1
- package/skills/bt-plan/SKILL.md +168 -41
package/README.md
CHANGED
|
@@ -124,7 +124,7 @@ happens to be named `bt-something` is safe.
|
|
|
124
124
|
| Skill | Command | What it does |
|
|
125
125
|
|-------|---------|--------------|
|
|
126
126
|
| [`bt-spec`](skills/bt-spec/SKILL.md) | `/bt-spec` | Turn a short idea into a feature spec file on a new git branch. |
|
|
127
|
-
| [`bt-plan`](skills/bt-plan/SKILL.md) | `/bt-plan` | Produce a
|
|
127
|
+
| [`bt-plan`](skills/bt-plan/SKILL.md) | `/bt-plan` | Produce a decision-complete, task-checklist technical plan from a spec — the plan is the shared memory that keeps a long, fresh-context-per-task run cohesive. |
|
|
128
128
|
| [`bt-execute`](skills/bt-execute/SKILL.md) | `/bt-execute` | Implement one task (or all remaining tasks) from a plan/spec. |
|
|
129
129
|
| [`bt-convert`](skills/bt-convert/SKILL.md) | `/bt-convert` | Convert source code to Babylon Toolkit TypeScript. |
|
|
130
130
|
| [`bt-copycat`](skills/bt-copycat/SKILL.md) | `/bt-copycat` | Re-create the specified website adapted to specified genre. |
|
|
@@ -140,6 +140,18 @@ the frontmatter `name` + `description` to decide when the skill applies. The `al
|
|
|
140
140
|
line is honored by Claude Code (auto-approves those tools) and safely ignored by Codex and
|
|
141
141
|
Copilot.
|
|
142
142
|
|
|
143
|
+
### Why plans are heavy
|
|
144
|
+
|
|
145
|
+
A plan can hold 50+ tasks and run for days, with each task executed by `bt-execute` in a fresh
|
|
146
|
+
context. The only thing that survives between tasks is the plan file, so `bt-plan` writes it as
|
|
147
|
+
the feature's shared memory: a numbered `## Decisions` log (every choice, its rationale, what was
|
|
148
|
+
rejected, which tasks it binds), a `## Design Reference` (file map, interfaces written as code,
|
|
149
|
+
data shapes, algorithms with their constants, edge-case policy, verbatim conventions to mirror,
|
|
150
|
+
exact API usage, test strategy), and self-contained tasks that cite those sections by name
|
|
151
|
+
instead of relying on memory of earlier tasks. Before the plan is final, a fresh read-only
|
|
152
|
+
subagent audits it as a cold executor and every gap it finds is fixed. The result is that task 40
|
|
153
|
+
uses the same names, shapes and patterns as task 3 — whichever session, day, or model runs it.
|
|
154
|
+
|
|
143
155
|
## Universal Installations
|
|
144
156
|
|
|
145
157
|
Where each tool looks for GLOBAL skills (**Default Installation** — `~` = your home directory):
|
package/package.json
CHANGED
package/skills/bt-plan/SKILL.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bt-plan
|
|
3
|
-
description: "The Babylon Toolkit Plan Skill creates the detailed technical plan for the specified feature spec file. Use when asked to plan or produce implementation tasks for an existing spec. Also supports a Quick Plan mode: when given only a brief (no spec file), it interviews the user to build a mini-spec and plans from that. Always planning-only — it writes the plan file and stops; execution is the separate bt-execute skill."
|
|
3
|
+
description: "The Babylon Toolkit Plan Skill creates the detailed technical plan for the specified feature spec file. Use when asked to plan or produce implementation tasks for an existing spec. Also supports a Quick Plan mode: when given only a brief (no spec file), it interviews the user to build a mini-spec and plans from that. The plan is written to be decision-complete — a numbered Decisions log, a Design Reference with the real interfaces, names, values and patterns, and self-contained tasks — so that a long run of tasks, each executed in a fresh context days apart, stays cohesive and resumable. Always planning-only — it writes the plan file and stops; execution is the separate bt-execute skill."
|
|
4
4
|
allowed-tools: Read, Grep, Glob, Write, WebFetch(domain:raw.githubusercontent.com), Agent, Task
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Create a detailed technical
|
|
7
|
+
Create a detailed technical implementation plan for the specified feature spec and save it in the `_specs` folder as `<feature-name>_plan.md`. Always generate implementation tasks or steps (prefer to call them tasks).
|
|
8
8
|
|
|
9
|
-
Use the user
|
|
9
|
+
Use the user's message after the skill name as the `arguments`.
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
@@ -31,10 +31,38 @@ Example:
|
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
34
|
+
## ⚠️ The plan is the memory — write it for a fresh context, forty tasks later
|
|
35
|
+
|
|
36
|
+
A plan from this skill is not executed in one sitting. It can hold **fifty or more tasks**, run over **several days**, and each task is typically executed by **bt-execute in a fresh context** (`/clear` between tasks, new sessions, resumed runs). The only thing that survives from one task to the next is the plan file. Whatever is not written in it is gone: the executor of task 40 has never seen task 3, does not know what it decided, and will re-derive conventions from the codebase — possibly differently. Across a long run, that is how features drift: two naming styles, two error-handling patterns, a helper written twice, an interface that changed shape halfway through.
|
|
37
|
+
|
|
38
|
+
So the plan must be the **complete, shared memory** of the feature: every decision, every name, every signature, every pattern to mirror, written once, in one place, and cited from every task that depends on it. **The test:** could an engineer with a fresh context, who has never seen this repo or the earlier tasks, open task 40 and produce code that is consistent with tasks 1–39 — same names, same shapes, same conventions — using only the plan? If they would have to look at what earlier tasks produced and infer the pattern, the plan is not carrying the memory.
|
|
39
|
+
|
|
40
|
+
**What must be decided in the plan, not left to be re-derived per task:**
|
|
41
|
+
|
|
42
|
+
| Class | What the plan must record |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| Architecture | module boundaries, which layer owns what, dependency direction, where state lives, sync vs async, event vs call |
|
|
45
|
+
| File layout | every file created / modified / deleted, by exact path; each new file's responsibility; where in an existing file new code goes (an anchor: "after `foo()`", "inside the `switch` at `:412`") |
|
|
46
|
+
| Interfaces & contracts | full signatures of every new/changed function, class, type, interface, event name, message shape, config key, CLI flag, route — written as code, not prose, so every task types the same thing |
|
|
47
|
+
| Data shapes & state | schemas, field names + types, defaults, invariants, persistence format, migration behaviour |
|
|
48
|
+
| Algorithms & formulas | pseudocode or real code for anything non-obvious: math, ordering, caching, retry, timing, physics tuning values |
|
|
49
|
+
| Naming | the actual names of the new things (classes, functions, fields, files, CSS classes, events, test names) — chosen once, following the repo's conventions |
|
|
50
|
+
| Error & edge-case policy | for every edge case the spec lists (and every one the analysis found): the decided behaviour, written as "when X → do Y" |
|
|
51
|
+
| Dependencies | exactly which packages/versions are added, or an explicit "no new dependencies" |
|
|
52
|
+
| Sibling-skill behavioural config | every option of a sibling-skill pattern (e.g. 3D-Hero-Scroll `sweep`) with its value, not just its name |
|
|
53
|
+
| Test design | the test file(s), the harness/pattern to copy, the named cases with expected outcomes, and the exact command to run |
|
|
54
|
+
| Ordering & dependencies | which tasks depend on which; what must keep working between tasks (temporary shims, feature flags) and which later task removes them |
|
|
55
|
+
|
|
56
|
+
**Corollary — write the code when the code IS the decision.** This skill never edits source files, but it may (and should) put code *inside the plan*: full signatures, type definitions, data schemas, the tricky 20-line algorithm, a config block, a test skeleton. When the shape of the code is the decision, prose is a lossy encoding of it — write the code once here, and every task that needs it copies the same thing. Leave to prose only the mechanical glue ("wire `X` into `Y`'s constructor the same way `Z` is at `:88`").
|
|
57
|
+
|
|
58
|
+
**Corollary — many small, self-contained tasks beat few large ones.** A task should fit in one fresh context: a handful of files, one clear outcome, everything it needs either in its own block or cited by name from the Decisions and Design Reference. Split a task whenever it grows past roughly ten steps, two hundred lines of new code, or four files.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
34
62
|
## Quick Plan mode (no feature spec file)
|
|
35
63
|
|
|
36
64
|
> 🛑 **"Quick" refers ONLY to skipping the spec file — never to skipping steps, and NEVER to executing the plan.**
|
|
37
|
-
> Quick Plan is still **PLANNING MODE**. It ends the moment `_specs/<feature-name>_plan.md` is
|
|
65
|
+
> Quick Plan is still **PLANNING MODE**. It ends the moment `_specs/<feature-name>_plan.md` is finalized. Do **NOT** implement any task, do **NOT** edit application/source files, do **NOT** run builds or tests, and do **NOT** continue into the tasks you just wrote — not even the first one, not even if the tasks look small, obvious, or trivially automatable. The user executes tasks separately with the **bt-execute** skill, deliberately, with a clean context between steps. Auto-executing destroys that workflow.
|
|
38
66
|
|
|
39
67
|
When invoked with a brief but **no feature spec file**, produce a plan from the brief. Do not stop to ask *for a spec file* — instead **interview the user** to build a **mini-spec** from their answers, then plan from that mini-spec exactly as you would from a real spec file. A spec is largely the product of that Q&A; skipping the file must not mean skipping the questions. Everything the skill would normally read from the feature spec is supplied by sensible defaults only as a **last-resort fallback** for anything left unanswered:
|
|
40
68
|
|
|
@@ -44,8 +72,9 @@ When invoked with a brief but **no feature spec file**, produce a plan from the
|
|
|
44
72
|
| Full feature requirements | Use the brief itself as the requirements, expanded by the Step 1 codebase analysis. |
|
|
45
73
|
| `spec_impact: yes/no` | **Infer** it from the Step 1 analysis: `yes` if the feature adds/changes a system, convention, dependency, or architectural decision; otherwise `no`. |
|
|
46
74
|
| `Project Spec Alignment` section | Derive alignment directly from root `SPEC.md` + the analysis. |
|
|
75
|
+
| `Decisions` section | Start empty; every interview answer and every choice you make becomes a plan `## Decisions` entry. |
|
|
47
76
|
|
|
48
|
-
**The one and only difference in Quick Plan mode is operating without a spec file** — the interview produces a mini-spec that stands in for it. Everything else is identical to a normal run: Step 1's comprehensive codebase analysis (including reading root `SPEC.md`) runs in full, the plan document has the same structure, the SPEC.md write-back task is still appended when the inferred `spec_impact` is `yes`, and the run still **STOPS after writing the plan file**. Nothing about Quick Plan grants permission to implement.
|
|
77
|
+
**The one and only difference in Quick Plan mode is operating without a spec file** — the interview produces a mini-spec that stands in for it. Everything else is identical to a normal run: Step 1's comprehensive codebase analysis (including reading root `SPEC.md`) runs in full, the plan document has the same structure and the same decision-completeness bar, the cold-context audit in Step 3 still runs, the SPEC.md write-back task is still appended when the inferred `spec_impact` is `yes`, and the run still **STOPS after writing the plan file**. Nothing about Quick Plan grants permission to implement.
|
|
49
78
|
|
|
50
79
|
Emit one visible status line when this path is taken: `⚡ [bt-plan] Quick Plan mode — no feature spec file; interviewing, then planning from the brief`.
|
|
51
80
|
|
|
@@ -65,7 +94,7 @@ Because there is no spec, the clarifying questions the spec process would have a
|
|
|
65
94
|
- Ask the user a focused round of clarifying questions covering the things that most change the plan: scope and non-goals, target UX/behavior, edge cases, which existing systems/files it should integrate with, constraints, and — critically — anything ambiguous in the brief or where the codebase suggests more than one reasonable approach.
|
|
66
95
|
- Prefer a small number of high-leverage questions (grouped, easy to answer) over interrogating the user. Do not ask about things the brief or codebase already make clear.
|
|
67
96
|
- Only fall back to the defaults table for items the user leaves unanswered or explicitly says "you decide". Never silently pick a default when a quick question would materially improve the plan.
|
|
68
|
-
- If the user declines to answer or says "just make the plan", proceed with the defaults and state which assumptions you made in the plan's Codebase Analysis section.
|
|
97
|
+
- If the user declines to answer or says "just make the plan", proceed with the defaults and state which assumptions you made in the plan's Codebase Analysis section **and** record each one as a `## Decisions` entry, so every later task sees the same assumption.
|
|
69
98
|
|
|
70
99
|
The goal is the same as a spec: a plan optimized to what the user actually wants — reached by asking, not by guessing.
|
|
71
100
|
|
|
@@ -75,7 +104,7 @@ The goal is the same as a spec: a plan optimized to what the user actually wants
|
|
|
75
104
|
|
|
76
105
|
This skill's workflow depends on subagents. **Invoking it is the user's explicit request to use them**, so any host default of the form *"do not spawn subagents / do not call the agent tool unless the user asks for it"* is **ALREADY SATISFIED** — the user asked by running this command. Never silently downgrade to the inline path on that basis, and never stop to ask permission for it first.
|
|
77
106
|
|
|
78
|
-
Downgrading is not a neutral choice. It removes the one property that makes the step worth running: independence.
|
|
107
|
+
Downgrading is not a neutral choice. It removes the one property that makes the step worth running: independence. An auditor that is the same context which just wrote the plan cannot adversarially check it — it re-confirms its own reasoning and reports "no gaps".
|
|
79
108
|
|
|
80
109
|
The ONE legitimate reason to run inline is that you genuinely have **no** subagent-spawning tool. Check the tools you actually have — Claude Code exposes it as **`Agent`** (older builds name it `Task`); other hosts have their own equivalent. Never call a subagent tool you do not have. Use the exact fan-out / inline status strings this skill specifies for the *path-chosen* line (the progress-narration lines below carry a fixed prefix but free wording), and if you do run inline, state plainly that no subagent tool was available, never a policy.
|
|
81
110
|
|
|
@@ -85,15 +114,15 @@ The user is watching a terminal, not your reasoning. Research and analysis in th
|
|
|
85
114
|
|
|
86
115
|
**Hard rules:**
|
|
87
116
|
|
|
88
|
-
1. **Announce before every long action.** Before any tool call that can take more than a few seconds — fetching the Agent Reference, reading `SPEC.md` / `DESIGN.md` / a sibling skill, launching subagents, a broad search — emit one visible line saying what you are about to do and why. Example: `🔎 [bt-plan] Reading SPEC.md and DESIGN.md to find the sections this feature must conform to …`
|
|
117
|
+
1. **Announce before every long action.** Before any tool call that can take more than a few seconds — fetching the Agent Reference, reading `SPEC.md` / `DESIGN.md` / a sibling skill, launching subagents, a broad search, writing a large plan — emit one visible line saying what you are about to do and why. Example: `🔎 [bt-plan] Reading SPEC.md and DESIGN.md to find the sections this feature must conform to …`
|
|
89
118
|
2. **Report after every result.** After each tool result, emit one line stating what you learned and what comes next, *before* the next tool call. The text between tool calls IS the progress display; a run of back-to-back tool calls with no text between them is a silent run.
|
|
90
119
|
3. **Subagents get a line each, going out and coming back.** When fanning out, print one line per subagent naming what it is investigating (`🚀 [bt-plan] Subagent 1/3 → mapping project structure, build + dependencies`). Prefer the host's background / non-blocking launch mode where it exists (Claude Code's `Agent` with `run_in_background: true`), so each completion returns control to you and you can report it: `✅ [bt-plan] Subagent 1/3 done — <one-line finding>`. Never block on all subagents in silence and then report them together.
|
|
91
120
|
4. **Waiting is also something to say.** If you are waiting on subagents with nothing else to do, say so once, naming what is still outstanding: `⏳ [bt-plan] Waiting on 2/3 research subagents (conventions to mirror, integration points) — typically 1–3 minutes …`. One line per wait, not repeated spam.
|
|
92
|
-
5. **Mark the phase transitions.** Emit a line when research starts, when it completes,
|
|
121
|
+
5. **Mark the phase transitions.** Emit a line when research starts, when it completes, when drafting begins, when the cold-context audit starts and what it found, and when the final write happens — e.g. `🧩 [bt-plan] Research complete — <n> findings synthesized` followed by a **3–6 bullet research summary** (the key findings, with file paths) so the user can see what the run is based on, then `✍️ [bt-plan] Drafting the document …`.
|
|
93
122
|
6. **Keep the lines short and uniform.** Format: `<emoji> [bt-plan] <what> — <detail>`. One line each. The prefix and emoji are fixed; the `<what>` / `<detail>` wording is yours. Do not dump findings, file contents, or tool output as progress — a status line says what happened, the document holds the detail.
|
|
94
|
-
7. **A silent gap may never span more than a single tool call.** If one tool call is itself long (a subagent, a large fetch), the line *preceding* it must say what it is and roughly how long it is expected to take.
|
|
123
|
+
7. **A silent gap may never span more than a single tool call.** If one tool call is itself long (a subagent, a large fetch, a large write), the line *preceding* it must say what it is and roughly how long it is expected to take. A plan with 50 tasks is a large write — say so before writing it, and consider writing it in two or three appends with a status line between them.
|
|
95
124
|
|
|
96
|
-
This applies to every phase of this skill — the Agent Reference fetch, `SPEC.md`/`DESIGN.md` reads, the fan-out research, sibling-skill reads, interviewing, and
|
|
125
|
+
This applies to every phase of this skill — the Agent Reference fetch, `SPEC.md`/`DESIGN.md` reads, the fan-out research, sibling-skill reads, interviewing, drafting, and the audit. When in doubt, say what you are doing.
|
|
97
126
|
|
|
98
127
|
## ⚠️ Required Reading Before Any Babylon Work
|
|
99
128
|
|
|
@@ -107,15 +136,17 @@ Do not refetch the Agent Reference repeatedly during the same remembered session
|
|
|
107
136
|
|
|
108
137
|
Treat the Agent Reference as the authority for conventions, API, and patterns. It routes to deeper docs. Fetch linked subpages only when they are relevant to the task, and do not refetch a subpage in the same remembered session/context unless you no longer remember it.
|
|
109
138
|
|
|
139
|
+
**Do the API homework once, here.** When a task uses a Babylon Toolkit component or BabylonJS API, the plan should name the exact class/method/property and show the call the way the Agent Reference (or its sub-document) shows it, in the Design Reference › *API usage* section — so every task across the run uses the same API the same way instead of each fresh context rediscovering it. Fetch the relevant sub-documents *now* and copy the correct usage into the plan.
|
|
140
|
+
|
|
110
141
|
If a required fetch fails, STOP and tell me. Do not guess at the API.
|
|
111
142
|
|
|
112
143
|
---
|
|
113
144
|
|
|
114
145
|
## Planning mode — do not implement
|
|
115
146
|
|
|
116
|
-
This command runs in PLANNING MODE. Research read-only and produce ONLY the technical plan document. Do NOT implement the feature, edit any existing application/source files, or run build, test, or other shell commands. The only file you may create is the plan markdown in `_specs/`, named `<feature-name>_plan.md`.
|
|
147
|
+
This command runs in PLANNING MODE. Research read-only and produce ONLY the technical plan document. Do NOT implement the feature, edit any existing application/source files, or run build, test, or other shell commands. The only file you may create or edit is the plan markdown in `_specs/`, named `<feature-name>_plan.md`. (You may write it more than once — a draft, then the audited final version — but nothing else.)
|
|
117
148
|
|
|
118
|
-
**This applies identically in Quick Plan mode.** Planning and execution are deliberately separate skills: `bt-plan` writes the plan, `bt-execute` runs it — one task at a time, with a clean context between tasks, at the user's discretion. Rolling straight from planning into implementation defeats the entire purpose of that split.
|
|
149
|
+
**This applies identically in Quick Plan mode.** Planning and execution are deliberately separate skills: `bt-plan` writes the plan, `bt-execute` runs it — one task at a time, with a clean context between tasks, at the user's discretion. Rolling straight from planning into implementation defeats the entire purpose of that split. Finalizing the plan file is the LAST action of this skill in every mode.
|
|
119
150
|
|
|
120
151
|
## Step 0. Confirm planning mode
|
|
121
152
|
|
|
@@ -126,65 +157,136 @@ A trustworthy plan requires a thorough, read-only investigation of the codebase
|
|
|
126
157
|
|
|
127
158
|
## Step 1. Comprehensive project analysis (REQUIRED before any plan)
|
|
128
159
|
|
|
129
|
-
This analysis can be **fanned out**. First check whether you actually have a subagent-spawning tool, and **emit one visible status line** so the user can see the path chosen — either `🔀 [bt-plan] subagent tool detected — fanning out analysis to N read-only subagents` or `➡️ [bt-plan] no subagent tool — analyzing sequentially`. If a subagent-spawning tool is available to you (e.g. Claude Code's `Agent`, Lovable's subagent tool, or your host's equivalent — check the tools you actually have; if there is none, or you are unsure, do the analysis yourself sequentially), launch up to 3 parallel **read-only** exploration subagents and divide the
|
|
160
|
+
This analysis can be **fanned out**. First check whether you actually have a subagent-spawning tool, and **emit one visible status line** so the user can see the path chosen — either `🔀 [bt-plan] subagent tool detected — fanning out analysis to N read-only subagents` or `➡️ [bt-plan] no subagent tool — analyzing sequentially`. If a subagent-spawning tool is available to you (e.g. Claude Code's `Agent`, Lovable's subagent tool, or your host's equivalent — check the tools you actually have; if there is none, or you are unsure, do the analysis yourself sequentially), launch up to 3 parallel **read-only** exploration subagents and divide the investigation points below among them (for example: one maps structure/build and dependencies; one extracts the real conventions and the closest existing feature to mirror; one lists integration points and constraints). Each subagent returns concise conclusions — findings and file paths, not file dumps — which you synthesize into the `## Codebase Analysis` section. Exploration subagents need not re-read the Agent Reference. Never call a subagent tool you do not actually have.
|
|
161
|
+
|
|
162
|
+
**Ask the subagents for plan-grade detail.** Because the plan must carry exact anchors and patterns, they should return `file:line` references, the real signatures of the functions the feature will call or change, and verbatim snippets of the conventions to mirror (the actual pattern, ten to thirty lines, with its location) — not summaries like "uses a manager pattern". You will paste these into the Design Reference.
|
|
130
163
|
|
|
131
164
|
**Narrate the whole step** (see *Progress narration — NEVER go silent* above). This is the step that most often runs for minutes, so it is where the rule matters most. The required cadence:
|
|
132
165
|
|
|
133
166
|
- One `🚀 [bt-plan] Subagent i/N → <what it investigates>` line per subagent as it is launched, and prefer the background / non-blocking launch mode so completions return to you one at a time.
|
|
134
167
|
- One `✅ [bt-plan] Subagent i/N done — <one-line finding>` line as each returns; a `⏳ [bt-plan] Waiting on …` line if you are idle with subagents still outstanding.
|
|
135
|
-
- On the sequential path, one `🔎 [bt-plan] …` line before each read/search (each of the
|
|
168
|
+
- On the sequential path, one `🔎 [bt-plan] …` line before each read/search (each of the investigation points below) and one result line after it.
|
|
136
169
|
- When everything is in: `🧩 [bt-plan] Analysis complete — <n> findings synthesized`, followed by a 3–6 bullet analysis summary (key findings with file paths), before moving on to the interview (Quick Plan) or Step 2.
|
|
137
170
|
|
|
138
|
-
Before writing a single
|
|
171
|
+
Before writing a single task, investigate the actual codebase read-only. This is mandatory — do NOT generate any plan content until this analysis is complete. Read and search the repo to discover, not assume:
|
|
139
172
|
|
|
140
|
-
1. Read the referenced feature spec in full (from `_specs/` or the file named in `arguments`), **and read the project `SPEC.md` at the repository root in full.** SPEC.md is the source of truth for the durable architecture, systems, conventions, and decisions — the plan MUST conform to it. Note the feature spec's `spec_impact` field
|
|
141
|
-
2. Map the project: top-level structure, entry points, how the app is built and run (build scripts, test runner, package manifests).
|
|
142
|
-
3. Identify the conventions actually used in this repo: naming, file/folder organization, state management, styling, error handling, testing patterns.
|
|
143
|
-
4. Find the closest existing feature(s) or modules to the one being planned and study how they are implemented — the plan should follow these patterns.
|
|
144
|
-
5. List the concrete integration points the feature will touch: files, modules, APIs, data models, routes, config.
|
|
173
|
+
1. Read the referenced feature spec in full (from `_specs/` or the file named in `arguments`), **and read the project `SPEC.md` at the repository root in full.** SPEC.md is the source of truth for the durable architecture, systems, conventions, and decisions — the plan MUST conform to it. Note the feature spec's `spec_impact` field, its `Project Spec Alignment` section, its `Decisions` section (carry every entry forward into the plan's `## Decisions`), and its `Open Questions` (each must be **resolved** in the plan — see Step 2). **In Quick Plan mode there is no feature spec file** — treat the brief as the feature request, still read root `SPEC.md` in full, and *infer* the `spec_impact` and Project Spec Alignment from the analysis per the Quick Plan defaults table. If the plan you are about to write would conflict with SPEC.md (contradict a decision, cross a system boundary, break a convention), STOP and flag the conflict to the user before writing the plan; do not silently override the project spec.
|
|
174
|
+
2. Map the project: top-level structure, entry points, how the app is built and run (build scripts, test runner, package manifests). Record the exact build and test commands — the plan's tasks will quote them.
|
|
175
|
+
3. Identify the conventions actually used in this repo: naming, file/folder organization, state management, styling, error handling, testing patterns. Capture each as a verbatim snippet with its `file:line`, not a description.
|
|
176
|
+
4. Find the closest existing feature(s) or modules to the one being planned and study how they are implemented — the plan should follow these patterns, and its tasks should point at the exact functions to mirror.
|
|
177
|
+
5. List the concrete integration points the feature will touch: files, modules, APIs, data models, routes, config — with the real signatures at each point and the line where new code will be inserted.
|
|
145
178
|
6. Note relevant dependencies already available (and their versions) versus anything new that would be required.
|
|
146
179
|
7. Capture any constraints from the project's agent instructions (AGENTS.md / CLAUDE.md / .github/copilot-instructions.md) and the feature spec.
|
|
147
|
-
8.
|
|
180
|
+
8. Establish the test baseline: how tests are run, which tests cover the code being touched, and whether the suite is currently green (record the failing set if not, so a task run days later can tell new failures from old ones).
|
|
181
|
+
9. If the feature builds on a **sibling-skill pattern** (e.g. bt-design's 3D-Hero-Scroll), read that sub-skill's reference **and its templates**. *(How to read one: where skills are loaded with a tool — the Babylon Toolkit App Builder platform — call `load_skill('<name>')`, then fetch its references and templates with `read_skill_resource` using the paths the load returns, never a guessed path. Where skills are files on disk — Claude Code — read them from the same skills directory, `~/.claude/skills/` or the project's `.claude/skills/`. Skip the load for anything already in your context.)* The plan MUST **copy and configure the sub-skill's template engine — never re-implement it from memory**; re-implementation is exactly how documented behaviors (`sweep`, veiled cuts, the preload gate, HUD auto-hide, graceful degradation) silently get dropped. Turn every behavioral-config requirement the spec records (e.g. `sweep: page`) into a concrete task whose Acceptance asserts that behavior in observable terms, and write the exact config values into the Design Reference.
|
|
148
182
|
|
|
149
|
-
If the spec or codebase is too ambiguous to analyze responsibly, stop and ask the user rather than guessing.
|
|
183
|
+
If the spec or codebase is too ambiguous to analyze responsibly, stop and ask the user rather than guessing. **Ask now, while the whole feature is in view** — a question deferred to execution gets answered by whichever task happens to hit it, in isolation, without the context to answer it consistently.
|
|
150
184
|
|
|
151
185
|
## Step 2. Write the plan
|
|
152
186
|
|
|
153
|
-
Emit `✍️ [bt-plan] Writing _specs/<feature-name>_plan.md …` before writing, and `💾 [bt-plan]
|
|
187
|
+
Emit `✍️ [bt-plan] Writing draft _specs/<feature-name>_plan.md …` before writing, and `💾 [bt-plan] Draft written — _specs/<feature-name>_plan.md (<n> tasks)` once the file is saved.
|
|
188
|
+
|
|
189
|
+
Only after Step 1 is complete, write the plan markdown to `_specs/` as `<feature-name>_plan.md`. The document has **five required sections, in this order**. A plan missing any of them is invalid; do not produce one.
|
|
190
|
+
|
|
191
|
+
### 2.1 `## Codebase Analysis`
|
|
192
|
+
|
|
193
|
+
Summarize the findings from Step 1 (cite the real files/modules you inspected, with `file:line`) — this is the evidence that the analysis happened. Include:
|
|
194
|
+
|
|
195
|
+
- a short **SPEC.md alignment** note: which SPEC.md sections the plan conforms to, and whether the feature is spec-impacting (carry over the feature spec's `spec_impact`, or in Quick Plan mode the value you inferred, and say it was inferred);
|
|
196
|
+
- the **test baseline** (command, current pass/fail state, which failures are pre-existing);
|
|
197
|
+
- in Quick Plan mode, the **interview answers** that stand in for the spec.
|
|
198
|
+
|
|
199
|
+
### 2.2 `## Decisions`
|
|
200
|
+
|
|
201
|
+
The feature-scoped decision log — the part of the plan that keeps task 40 consistent with task 3. One entry per decision, numbered `D1`, `D2`, … so tasks can cite them. Carry every entry from the feature spec's `Decisions` section forward (keep its wording, add the D-number), then add every decision *you* made while planning — architecture, layout, naming, algorithms, error policy, test strategy — using the table in *The plan is the memory* above as the checklist. Every entry has the same shape:
|
|
202
|
+
|
|
203
|
+
```markdown
|
|
204
|
+
- **D3 — <decision, stated as a fact>.** <why: the deciding constraint, or the precedent in the codebase with file:line>
|
|
205
|
+
Rejected: <alternative> (<why not>). Binds: T4, T7.
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Resolve every `Open Question` from the spec here.** An open question that survives into execution gets answered by one task in isolation and, days later, differently by another. If you genuinely cannot resolve one without the user, ask the user now, then record the answer. "TBD", "to be decided during implementation", "the implementer may choose" and similar phrases are forbidden anywhere in the plan.
|
|
154
209
|
|
|
155
|
-
|
|
210
|
+
### 2.3 `## Design Reference`
|
|
156
211
|
|
|
157
|
-
|
|
212
|
+
The blueprint every task cites. This is where the shared names, shapes and code live, so that each task copies from one source instead of inventing its own. Use the sub-headings below (omit one only if it truly does not apply, and say so in one line):
|
|
213
|
+
|
|
214
|
+
- **File map** — a table of every file the feature creates, modifies, or deletes: `path | create/modify/delete | responsibility | touched by tasks`.
|
|
215
|
+
- **Module boundaries** — what owns what, which direction dependencies point, where state lives. A short ASCII diagram is welcome where it clarifies flow.
|
|
216
|
+
- **Interfaces & contracts** — every new or changed function, class, type, interface, event, message, config key, or route, **written as code in the project's language** with full signatures, parameter types, return types and a one-line doc comment. These are the exact names every task will type.
|
|
217
|
+
- **Data shapes & state** — schemas / type definitions, defaults, invariants, persistence format.
|
|
218
|
+
- **Control flow** — the key sequences, numbered ("1. `onPointerDown` → 2. `#pick()` → 3. …"), including what happens on the failure branches.
|
|
219
|
+
- **Algorithms & formulas** — pseudocode or real code for anything non-obvious, with the constants and tuning values decided (`offset = max(halfWidth + 4, 18)`, not "a sensible offset").
|
|
220
|
+
- **Error & edge-case policy** — one line per edge case: `when <X> → <Y>`.
|
|
221
|
+
- **Conventions to mirror** — verbatim snippets of the repo's existing pattern with `file:line`, one per convention the feature must copy (component registration, debug-drawing pattern, test harness, styling tokens from `DESIGN.md`, …).
|
|
222
|
+
- **API usage** — for every Babylon Toolkit / BabylonJS / third-party API the feature calls, the exact call as the Agent Reference (or the library docs) shows it.
|
|
223
|
+
- **Test strategy** — the test file(s) to create or extend, the harness/pattern to copy (with `file:line`), how to run them, and the baseline to compare against.
|
|
224
|
+
|
|
225
|
+
### 2.4 `## Tasks`
|
|
226
|
+
|
|
227
|
+
The ordered checklist. Use GitHub-style checkboxes so progress can be tracked directly in the file — one task per checkbox, numbered `T1`, `T2`, `T3` … in dependency order, each small enough to be implemented and verified on its own in a fresh context (see *many small, self-contained tasks* above). Every task uses this block. The fields marked **required** must be present on every task; the others are omitted only when they genuinely have nothing to say.
|
|
158
228
|
|
|
159
229
|
```markdown
|
|
160
230
|
## Tasks
|
|
161
231
|
|
|
162
|
-
- [ ] **
|
|
163
|
-
-
|
|
164
|
-
-
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
232
|
+
- [ ] **T7** — <short imperative title>
|
|
233
|
+
- Depends on: T3, T5 # required (write "none" for the first task)
|
|
234
|
+
- Files: `src/foo.ts` (create), `src/bar.ts` (modify — `Bar.init()`), `src/old.ts` (delete) # required
|
|
235
|
+
- Applies: D2, D5 · Design Reference › Interfaces › `FooService` · Conventions to mirror › debug drawing # required — what this task must stay consistent with
|
|
236
|
+
- Steps: # required — numbered, concrete, one action each
|
|
237
|
+
1. In `src/bar.ts`, directly after the `import` block, add `import { FooService } from "./foo";`.
|
|
238
|
+
2. In `Bar.init()` (currently `src/bar.ts:41-58`), after the line `this.scene = scene;`, add `this.foo = new FooService(scene, { mode: "page" });`.
|
|
239
|
+
3. Create `src/foo.ts` with the code in **Code** below.
|
|
240
|
+
4. …
|
|
241
|
+
- Code: # when the code is the decision: full or skeleton code, in the project's language
|
|
242
|
+
```ts
|
|
243
|
+
export class FooService { … }
|
|
244
|
+
```
|
|
245
|
+
- Do not: … # the tempting wrong turns: "do not add a second guard in pull()", "do not touch the metadata override"
|
|
246
|
+
- Tests: `tests/foo.test.ts` (create, copy harness from `tests/bar.test.ts:1-30`) — # required unless the task has no testable surface, in which case say so
|
|
247
|
+
- `constructs with page mode by default` → `service.mode === "page"`
|
|
248
|
+
- `throws on a null scene` → rejects with `TypeError`
|
|
249
|
+
- run: `npm test -- tests/foo.test.ts`
|
|
250
|
+
- Acceptance: <observable, checkable statements — what is true when this task is done> # required
|
|
251
|
+
- Verify: `npm test -- tests/foo.test.ts` → 2 passing · `npx tsc --noEmit` → no errors · `grep -n "new FooService" src/bar.ts` → 1 hit # required — commands + expected output
|
|
170
252
|
```
|
|
171
253
|
|
|
172
|
-
|
|
254
|
+
Rules for the task blocks:
|
|
173
255
|
|
|
174
|
-
|
|
256
|
+
- **Every task is self-contained.** Its Steps plus the Decisions and Design Reference sections it cites on **Applies** are everything needed to do it. A task must never say "follow the pattern from T3" — T3's context is gone by then; say "follow Design Reference › Conventions to mirror › <name>" and put the pattern there, once.
|
|
257
|
+
- **Steps are instructions, not goals.** "Add validation" is a goal; "In `submit()` at `:120`, before the `fetch` call, add `if (!form.name) { setError('name', 'Required'); return; }`" is a step. Every step names the file, the anchor, and the change.
|
|
258
|
+
- **Anchors are real.** Every `file:line` and "after `<code>`" anchor comes from Step 1's reading of the actual file. Prefer code anchors ("after the line `this.scene = scene;`") to bare line numbers where lines are likely to shift during a long run — or give both.
|
|
259
|
+
- **Names, signatures and values come from the Design Reference.** If a step introduces a name that is not in the Design Reference, add it there first. That is what keeps the fortieth task's naming identical to the third's.
|
|
260
|
+
- **Acceptance is observable.** Something a verifier can check by running a command or inspecting a file: a test count, a grep result, a rendered behaviour ("PLAY auto-scrolls to the document bottom"), never "works correctly".
|
|
261
|
+
- **Verify gives the command and the expected output**, so a fresh context compares against a stated value rather than judging.
|
|
262
|
+
- **Keep the system working between tasks.** When a change spans tasks, say what temporary shim, flag, or compatibility write keeps the app running after each one, and which later task removes it — a resumed run may pause for days between them.
|
|
263
|
+
- When a task implements a **sibling-skill pattern**, its **Acceptance** must assert the skill-defined behavior in observable terms — e.g. for `sweep: page`, "PLAY auto-scrolls through to the document bottom and END jumps there", not merely "the hero renders". A plausible-looking result that dropped a documented behavior must fail acceptance. Prefer copying the sub-skill's template files as an early task (e.g. "T1 — copy + wire the 3D-Hero-Scroll engine") so later tasks only configure it, and put the exact config values in the Steps.
|
|
175
264
|
|
|
176
|
-
|
|
265
|
+
#### SPEC.md write-back task (required when the feature is spec-impacting)
|
|
266
|
+
|
|
267
|
+
If the feature is spec-impacting (`spec_impact: yes`, or your analysis found it adds/changes a system, convention, dependency, or architectural decision), the plan MUST end with an explicit final task that updates the project spec, so the write-back is tracked and independently verified like any other task — never left as a soft afterthought. **Write the SPEC.md content in the task** — the exact paragraphs to merge into each current-state section and the exact Decisions entries to append (they are your `## Decisions` entries, promoted to project scope) — so the write-back records what was planned, not what one fresh context remembers at the end:
|
|
177
268
|
|
|
178
269
|
```markdown
|
|
179
270
|
- [ ] **T<n>** — Update SPEC.md to match what was built
|
|
180
|
-
-
|
|
181
|
-
-
|
|
182
|
-
-
|
|
271
|
+
- Depends on: T<n-1>
|
|
272
|
+
- Files: `SPEC.md` (modify)
|
|
273
|
+
- Applies: D1–D<k>
|
|
274
|
+
- Steps:
|
|
275
|
+
1. Under `## Game Systems` › `<System>`, replace the paragraph beginning "<first words>" with the text in **Code** › *Game Systems*.
|
|
276
|
+
2. Under `## Conventions`, append the bullet(s) in **Code** › *Conventions*.
|
|
277
|
+
3. Under `## Decisions`, append (never edit or delete) the entries in **Code** › *Decisions*, newest last.
|
|
278
|
+
4. Under `## Dependencies`, add <dependency + version + why> — or, if none was added, make no change.
|
|
279
|
+
- Code:
|
|
280
|
+
<the exact markdown for each section>
|
|
281
|
+
- Acceptance: SPEC.md accurately describes the architecture/systems/conventions/dependencies as actually implemented by the tasks above; no section contradicts the shipped code; the Decisions entries are appended, nothing deleted; new dependencies are listed. Follow SPEC.md's "How to update this spec" contract: **replace/merge** current-state sections (removing seed placeholders on first real content), **append** to the Decisions log.
|
|
282
|
+
- Verify: `grep -n "<a distinctive phrase from each inserted paragraph>" SPEC.md` → one hit each.
|
|
183
283
|
```
|
|
184
284
|
|
|
185
285
|
Make this the LAST task so it captures the true final state. If the feature is genuinely not spec-impacting (`spec_impact: no`), omit this task, but state in the Codebase Analysis that no SPEC.md change is required.
|
|
186
286
|
|
|
187
|
-
|
|
287
|
+
### 2.5 `## How to execute this plan`
|
|
288
|
+
|
|
289
|
+
Include this exact section verbatim in the document so the plan is self-describing no matter how it is later run:
|
|
188
290
|
|
|
189
291
|
```markdown
|
|
190
292
|
## How to execute this plan
|
|
@@ -195,3 +297,28 @@ Each task above is a checkbox. To implement:
|
|
|
195
297
|
- When a task is fully implemented and its **Acceptance** criteria are met, mark it complete by editing this file and changing that task's `- [ ]` to `- [x]`.
|
|
196
298
|
- Stop and report if a task cannot be completed. Do NOT check a box for partial, skipped, or unverified work.
|
|
197
299
|
```
|
|
300
|
+
|
|
301
|
+
## Step 3. Cold-context audit (REQUIRED before the plan is final)
|
|
302
|
+
|
|
303
|
+
The draft is not the plan. A plan written in one pass by the same mind that holds all the context always leaves gaps that mind cannot see — the "obvious" choice that was never written down, the name that was in your head but not on the page, the task that quietly assumes you remember an earlier one. Those gaps are exactly what a fresh context at task 40 will fill in differently. The audit finds them now.
|
|
304
|
+
|
|
305
|
+
Emit `🕵️ [bt-plan] Cold-context audit — reading the draft as a fresh executor …`. Then, if a subagent-spawning tool is available, launch **one read-only audit subagent** with a fresh context (it must NOT see your reasoning, only the files), and give it: the path of the draft plan, the repository root, and these instructions verbatim:
|
|
306
|
+
|
|
307
|
+
> You are a competent engineer with a fresh context. You have never seen this repository or this feature before, and you will execute one task at a time with no memory of the others. Read the plan at `<path>` in full. Then, for **every** task, check the plan against the actual codebase (read the files and anchors it names) and list every point where you would be **forced to decide, guess, look up, or infer** something the plan should have given you: a missing signature, name, value, file location or anchor; an anchor that does not match the real file; a step that states a goal instead of an instruction; a step that depends on knowing what an earlier task did rather than on the Design Reference; a name used in a task that is not defined in the Design Reference; a test case without an expected outcome; a Verify without an expected output; an edge case with no decided behaviour; an API call whose exact usage is not shown; any use of "TBD", "appropriate", "suitable", "as needed", "etc." or "the implementer may". Also flag any task that would not fit in one sitting or touches more than four files. Report as a list: `T<n> · step <k> · <what is missing> · <what you would have had to decide>`. Do not fix anything, do not write files, do not run builds or tests. Report "NO GAPS" only if you found none.
|
|
308
|
+
|
|
309
|
+
If no subagent tool is available, emit `➡️ [bt-plan] no subagent tool — self-auditing the draft` and perform the same read yourself, deliberately re-reading the plan top to bottom against the real files with the checklist above, one task at a time.
|
|
310
|
+
|
|
311
|
+
Emit `🧾 [bt-plan] Audit found <n> gaps across <m> tasks` (or `… found NO GAPS`). Then **resolve every reported gap by editing the plan** — add the missing decision to `## Decisions`, the missing code/signature/name to `## Design Reference`, the missing instruction to the task — and emit `🔧 [bt-plan] Resolved <n>/<n> gaps`. If the audit found more than a handful of gaps, run it **once more** on the revised plan (`🕵️ [bt-plan] Second audit pass …`); stop after the second pass regardless, and list any gap you chose not to resolve, with why, in the plan's Codebase Analysis. A gap the audit reports that you cannot resolve without the user is a question for the user — ask it now.
|
|
312
|
+
|
|
313
|
+
## Step 4. Finalize and stop
|
|
314
|
+
|
|
315
|
+
Emit `💾 [bt-plan] Plan finalized — _specs/<feature-name>_plan.md (<n> tasks, <k> decisions)`.
|
|
316
|
+
|
|
317
|
+
Your final response is a short summary: the number of tasks and decisions, the two or three most consequential decisions (with their D-numbers), anything you were unable to resolve, and the exact next-step hint:
|
|
318
|
+
|
|
319
|
+
```
|
|
320
|
+
Plan written to _specs/<feature-name>_plan.md
|
|
321
|
+
Run a single task with `bt-execute _specs/<feature-name>_plan.md T1`, or every task with `bt-execute _specs/<feature-name>_plan.md ALL`.
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Then **STOP**. Do not begin T1. Do not offer to start.
|