Skip to content

Commit f93b30e

Browse files
gold-ak47claude
andcommitted
fix: add visual pipeline preflight and stronger mission to dev prompt
The /treble:dev command now: - States 95-99% visual accuracy as the explicit goal - Runs silent preflight checks before any code: 1. Figma data exists 2. Chrome DevTools MCP works (real test, not just a check) 3. Dev server starts with hot-reload 4. Git repo exists - Hard-stops if Chrome DevTools MCP is unavailable - Names the exact subagents used for visual comparison - Removes bloat (testing setup, database, duplicated project structure) - Promotes resume path to a prominent section Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 26ff00b commit f93b30e

1 file changed

Lines changed: 106 additions & 173 deletions

File tree

  • .claude-plugin/ui/commands

.claude-plugin/ui/commands/dev.md

Lines changed: 106 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -8,134 +8,146 @@ arguments:
88

99
# /treble:dev — Build Loop
1010

11-
You are Treble's build router. Your job is to triage the design, choose the right deployment target, set up a solid project foundation, and hand off to the correct build skill.
11+
You are Treble's build router. Your mission is to translate a Figma design into code that is **95-99% visually identical** to the original. Not "close enough." Not "looks similar." Pixel-level fidelity.
1212

13-
## Guard Rails (ENFORCE BEFORE ANYTHING ELSE)
13+
## The Core Loop
1414

15-
### 1. CMS is out of scope
15+
Everything in this command exists to serve ONE pipeline:
1616

17-
`/treble:dev` is **only** concerned with translating Figma designs into code. If the user mentions CMS, content management, WordPress editing, ACF fields, or anything related to making content editable — **stop and explain:**
17+
```
18+
[Code] → [Screenshot] → [Compare to Figma] → [Fix or Commit]
19+
```
1820

19-
> CMS integration is a separate step that happens **after** the build is complete. `/treble:dev` translates your Figma design into code — that's it. Once the build is done, you can run `/treble:cms` to wire up editability.
21+
If you cannot execute every step of this pipeline, you cannot do your job. The preflight checks below verify this BEFORE any code is written.
2022

21-
Do NOT attempt any CMS work during the dev phase. Do NOT install CMS plugins, create custom post types, or set up content fields. Refuse politely and redirect to `/treble:cms`.
23+
The visual comparison uses two subagents:
24+
1. **`chrome-devtools-tester`** — navigates to the running dev server, takes a full-page screenshot at 1440px width
25+
2. **`general-purpose`** — reads both the Figma reference PNG and the implementation screenshot, does a harsh section-by-section comparison, returns a JSON verdict (MATCH / CLOSE / WRONG per section)
2226

23-
### 2. WordPress requires Docker — no exceptions
27+
The build skills (`treble:dev-shadcn` and `treble:dev-basecoat-wp`) execute this loop for every component. Your job here is to make sure the environment is ready for them.
2428

25-
If the user selects **WordPress** as the deployment target, immediately check that Docker is running:
29+
---
2630

27-
```bash
28-
docker info > /dev/null 2>&1
29-
```
31+
## Preflight (SILENT — run before anything else)
3032

31-
If Docker is **not running**, refuse to proceed:
33+
Run these checks silently. Do not ask the user for input. If any check fails, stop and explain what's wrong.
3234

33-
> WordPress builds require a running Docker environment. Please start Docker Desktop (or your Docker daemon) and try again. I cannot proceed without it — there is no alternative setup that will work.
35+
### Check 1: Figma data exists
3436

35-
**NEVER** attempt to work around a missing Docker environment. Do not suggest MAMP, XAMPP, Local by Flywheel, manual PHP installs, or any other mechanism. The WordPress build skill depends on a Dockerized WordPress stack. Without it, stop completely.
37+
`.treble/analysis.json` and `.treble/figma/manifest.json` must exist.
3638

37-
### 3. One page at a time
39+
If missing → stop:
40+
> No Figma data found. Run `/treble:sync` then `/treble:plan` first.
3841
39-
`/treble:dev` builds **one page per run**. Before starting, check how many pages/frames are available in `.treble/figma/manifest.json`.
42+
### Check 2: Chrome DevTools MCP is available
4043

41-
- If there is **exactly one page** — proceed automatically.
42-
- If there are **multiple pages** — ask the user which one to build. List the available pages and let them choose.
43-
- If the user asks to build **multiple pages at once** — explain the constraint:
44+
The visual review pipeline requires the Chrome DevTools MCP server. Test it by spawning a `chrome-devtools-tester` subagent:
4445

45-
> Treble builds one page at a time to ensure quality and allow you to review each one. Which page would you like to start with?
46+
```
47+
Open a new browser page and navigate to "about:blank".
48+
Take a screenshot.
49+
Close the page.
50+
Report success or failure.
51+
```
4652

47-
List the available pages from the manifest and wait for the user to pick one.
53+
If the subagent fails, errors, or the `mcp__chrome-devtools__*` tools are unavailable → **STOP. Do not proceed. Do not offer workarounds.**
4854

49-
---
55+
> Treble requires the Chrome DevTools MCP server for visual review, but it's not available in your environment.
56+
>
57+
> Without it, I cannot screenshot your running code, compare it to the Figma reference, or verify visual accuracy. This is not optional — the entire build loop depends on it.
58+
>
59+
> **Setup:** Add a Chrome DevTools MCP server to your Claude Code configuration. See: https://github.com/anthropics/claude-code/blob/main/docs/mcp.md
60+
>
61+
> Once configured, run `/treble:dev` again.
5062
51-
## Step 0: Triage & Project Setup (FIRST PRIORITY)
63+
**WHY THIS IS NON-NEGOTIABLE:** Without Chrome DevTools, you can only write code and hope it looks right. Treble's value is the verified visual feedback loop. Shipping unverified code defeats the purpose. Do not attempt to build without it.
5264

53-
Before writing any components, classify the design, pick a deployment target, and ensure the project is a well-organized, **runnable** repository.
65+
### Check 3: Dev server works with hot-reload
5466

55-
If `package.json` already exists, the dev server starts, AND `.treble/build-state.json` has a `buildConfig` section, skip to "Hand off".
67+
If `package.json` exists, start the dev server (`npm run dev` or equivalent) and verify:
68+
1. It starts without errors
69+
2. It serves a page on localhost
70+
3. Use the `chrome-devtools-tester` subagent to navigate to it and take a screenshot
5671

57-
### 0a. Classify the design
72+
If the dev server doesn't start → fix it before proceeding.
5873

59-
Read `.treble/analysis.json` and classify by the section/component signals present:
74+
This also validates that the Chrome DevTools → dev server pipeline works end-to-end. If you can screenshot `localhost:{port}`, the build loop will work.
6075

61-
| Signals in analysis.json | Classification |
62-
|--------------------------|---------------|
63-
| Hero, testimonials, feature grids, CTA buttons, pricing cards | **marketing-website** |
64-
| Sidebar nav, data tables, forms, modals, tabs, breadcrumbs, user avatars | **web-app** |
65-
| Product cards, cart, checkout flows, pricing tables | **ecommerce** |
66-
| Article layout, author cards, tag lists, pagination | **blog** |
67-
| Gallery grids, case studies, project cards | **portfolio** |
76+
**IMPORTANT:** The dev server must support hot-reload (HMR). When the build skill writes code, the page must update automatically so the next screenshot reflects the change. Next.js, Astro, and Vite all do this by default. If you're resuming a project with a custom setup, verify HMR works.
6877

69-
Look at sections, component names, and page structure. If multiple categories fit, pick the dominant one.
78+
### Check 4: Git repo exists
7079

71-
Tell the user what you found:
80+
The project directory must be a git repository. If not → `git init`.
7281

73-
> This looks like a **multi-page marketing website** with 5 pages.
82+
---
7483

75-
or
84+
## Resume Path
7685

77-
> This looks like a **web application** with dashboard, settings, and user management views.
86+
If `.treble/build-state.json` already has a `buildConfig` section AND the dev server is running → skip straight to **Hand Off**. Do not re-triage, re-scaffold, or re-ask questions.
7887

79-
### 0b. Present ranked deployment targets
88+
---
8089

81-
Based on the classification, present ranked options. **Always ask — never auto-select.**
90+
## Guard Rails
8291

83-
**Exclusion rules:**
84-
- **Exclude WordPress** if classification is `web-app` or `ecommerce` (no WP for SaaS UIs or custom storefronts)
85-
- **Rank Astro last** for `web-app` (shared state and auth are harder with islands architecture)
86-
- **Always include Next.js** — it works for everything
92+
### CMS is out of scope
8793

88-
For a **marketing-website**, **blog**, or **portfolio**:
89-
```
90-
Deployment options (ranked by fit):
94+
`/treble:dev` translates Figma designs into code. Period. If the user mentions CMS, content management, WordPress editing, ACF fields, or making content editable:
9195

92-
1. Next.js (Recommended) — SSR/SSG, best ecosystem, works with any CMS later
93-
2. Astro — static-first, faster for pure content sites
94-
3. WordPress — if you need WP hosting or existing WP infrastructure
95-
```
96+
> CMS integration happens **after** the build is complete. Run `/treble:cms` when you're ready.
9697
97-
For a **web-app**:
98-
```
99-
Deployment options (ranked by fit):
98+
Do NOT install CMS plugins, create custom post types, or set up content fields during dev.
10099

101-
1. Next.js (Recommended) — SSR/SSG, API routes, auth, shared state — built for this
102-
2. Astro — possible with React islands, but shared state and auth are harder than in Next.js
100+
### WordPress requires Docker
103101

104-
(WordPress is not appropriate for this type of design.)
105-
```
102+
If the user selects WordPress, check `docker info > /dev/null 2>&1`. If Docker is not running → refuse. No MAMP, XAMPP, or workarounds.
106103

107-
For **ecommerce**:
108-
```
109-
Deployment options (ranked by fit):
104+
### One page at a time
110105

111-
1. Next.js (Recommended) — SSR/SSG, API routes for cart/checkout, best ecosystem
112-
2. Astro — static catalog pages with islands for interactive cart
106+
Check `.treble/figma/manifest.json`:
107+
- **One page** → proceed automatically
108+
- **Multiple pages** → list them, ask which one to build
109+
- **User wants multiple at once** → explain: "Treble builds one page at a time for quality. Which one first?"
113110

114-
(WordPress is not appropriate for custom e-commerce UIs.)
115-
```
111+
---
116112

117-
Wait for the user to choose before continuing.
113+
## Step 0: Triage & Project Setup
118114

119-
### 0c. Ask where to place files (ALWAYS)
115+
### 0a. Classify the design
120116

121-
After the deployment target is chosen, ask where to set up the project:
117+
Read `.treble/analysis.json` and classify:
122118

123-
```
124-
Where should I set up the project?
119+
| Signals | Classification |
120+
|---------|---------------|
121+
| Hero, testimonials, feature grids, CTA, pricing cards | **marketing-website** |
122+
| Sidebar nav, data tables, forms, modals, tabs, breadcrumbs | **web-app** |
123+
| Product cards, cart, checkout flows | **ecommerce** |
124+
| Article layout, author cards, tag lists, pagination | **blog** |
125+
| Gallery grids, case studies, project cards | **portfolio** |
125126

126-
Suggested: ./ (current directory)
127-
Or specify a path:
128-
```
127+
Tell the user: "This looks like a **marketing website** with 3 pages."
128+
129+
### 0b. Present deployment targets
130+
131+
Always ask — never auto-select.
132+
133+
| Classification | Ranked Options |
134+
|---------------|----------------|
135+
| marketing-website, blog, portfolio | 1. Next.js (Recommended) 2. Astro 3. WordPress |
136+
| web-app | 1. Next.js (Recommended) 2. Astro — no WordPress |
137+
| ecommerce | 1. Next.js (Recommended) 2. Astro — no WordPress |
138+
139+
**Rules:** Always include Next.js. Exclude WordPress for web-app/ecommerce. Rank Astro last for web-app.
140+
141+
### 0c. Ask where to place files
129142

130-
If the current directory already has a `package.json`, note it and offer:
131-
1. Build inside this existing project
132-
2. Create a new subdirectory (suggest a name based on the design)
143+
If `package.json` exists → offer: build here, or create a subdirectory.
144+
If no `package.json` → suggest current directory.
133145

134-
Wait for the user to confirm before continuing.
146+
Wait for confirmation.
135147

136148
### 0d. Record build config
137149

138-
Write the triage decisions to `.treble/build-state.json` under a `buildConfig` key:
150+
Write to `.treble/build-state.json`:
139151

140152
```json
141153
{
@@ -149,17 +161,13 @@ Write the triage decisions to `.treble/build-state.json` under a `buildConfig` k
149161
}
150162
```
151163

152-
**Compatibility matrix:**
153-
154-
| Deployment Target | Compatible CMS | Build Skill |
155-
|-------------------|---------------|-------------|
164+
| Target | Compatible CMS | Build Skill |
165+
|--------|---------------|-------------|
156166
| Next.js | sanity, prismic | dev-shadcn |
157167
| Astro | sanity, prismic | dev-shadcn |
158168
| WordPress | wordpress | dev-basecoat-wp |
159169

160-
### 0e. Scaffold or verify the project
161-
162-
If starting fresh (no `package.json`):
170+
### 0e. Scaffold the project
163171

164172
**Next.js:**
165173
```bash
@@ -174,102 +182,27 @@ npx astro add react tailwind
174182
npx shadcn@latest init
175183
```
176184

177-
**WordPress:** existing theme root is fine, skip scaffold.
178-
179-
**Verify it runs**`npm run dev` must start without errors. Fix any issues before moving on.
180-
181-
If `package.json` exists, verify: `npm install && npm run dev` works. If it doesn't, fix it first.
182-
183-
### 0f. Project structure
184-
185-
Set up the feature-based directory structure (see `skills/dev-shadcn.md` for full rules):
186-
187-
```
188-
src/
189-
├── components/
190-
│ ├── ui/ # shadcn primitives ONLY (managed by shadcn CLI)
191-
│ ├── common/ # truly reusable across 2+ features (Logo, SocialLinks)
192-
│ └── layout/ # page shells (Header, Footer, PageLayout, SectionContainer)
193-
├── features/
194-
│ └── [feature-name]/ # one per page/domain area
195-
│ ├── components/ # feature-specific components
196-
│ └── feature.tsx # main export — mounted in pages/routes
197-
├── lib/ # utilities, helpers, cn()
198-
└── app/ or pages/ # thin route files that mount features
199-
public/
200-
├── images/ # extracted Figma images
201-
└── fonts/ # local font files (if any)
202-
```
203-
204-
**Rule:** If you're about to write a file to `src/components/`, stop and ask: "Is this used by 2+ features?" If not, it belongs in `src/features/{name}/components/`.
205-
206-
### 0g. Testing setup (if appropriate)
207-
208-
Add a basic test runner. Skip for simple landing pages — add for apps with logic, forms, or interactivity.
209-
210-
```bash
211-
npm install -D vitest @testing-library/react @testing-library/jest-dom jsdom
212-
```
213-
214-
Add to `vite.config.ts` (or `vitest.config.ts` for Next.js/Astro):
215-
```ts
216-
test: {
217-
environment: 'jsdom',
218-
setupFiles: './src/test/setup.ts',
219-
}
220-
```
221-
222-
Create `src/test/setup.ts`:
223-
```ts
224-
import '@testing-library/jest-dom'
225-
```
226-
227-
Add `"test": "vitest"` to `package.json` scripts. Run `npm test` to verify.
185+
**WordPress:** existing theme root, skip scaffold.
228186

229-
### 0h. Database / backend services (if needed)
187+
**Verify:** Start the dev server. It must run without errors. Use the `chrome-devtools-tester` subagent to navigate to localhost and take a screenshot — this confirms the full pipeline works before writing any components.
230188

231-
If the project needs a database (CMS, auth, etc.), use Docker so the repo is self-contained:
189+
### 0f. Git baseline
232190

233-
```yaml
234-
# docker-compose.yml
235-
services:
236-
db:
237-
image: postgres:16-alpine
238-
ports: ["5432:5432"]
239-
environment:
240-
POSTGRES_DB: app
241-
POSTGRES_USER: app
242-
POSTGRES_PASSWORD: app
243-
volumes:
244-
- pgdata:/var/lib/postgresql/data
245-
246-
volumes:
247-
pgdata:
248-
```
249-
250-
Add to `package.json` scripts: `"db:up": "docker compose up -d"`, `"db:down": "docker compose down"`.
251-
252-
For simpler needs (Payload CMS, small apps), prefer **SQLite** — no Docker required.
253-
254-
### 0i. Git hygiene
191+
Ensure `.gitignore` covers: `node_modules/`, `dist/`, `.env.local`, `.treble-tmp/`, `.next/`, `.astro/`.
255192

256193
```bash
257-
git init # if not already a repo
194+
git add -A && git commit -m "chore: initial project setup"
258195
```
259196

260-
Ensure `.gitignore` covers: `node_modules/`, `dist/`, `.env.local`, `.treble-tmp/`, `.next/` (Next.js), `.astro/` (Astro).
261-
262-
**Commit the scaffold:** `git add -A && git commit -m "chore: initial project setup"`
263-
264-
This is your clean baseline. Every component build after this gets its own commit.
265-
266197
---
267198

268-
## Hand off
199+
## Hand Off
200+
201+
Once preflight passes and the project is scaffolded:
269202

270-
Once the project is set up and runnable, hand off to the correct build skill using the `Skill` tool:
203+
- **Next.js or Astro**`Skill(skill: "treble:dev-shadcn")`
204+
- **WordPress**`Skill(skill: "treble:dev-basecoat-wp")`
271205

272-
- **shadcn** (Next.js or Astro) → `Skill(skill: "treble:dev-shadcn")`
273-
- **wordpress** → `Skill(skill: "treble:dev-basecoat-wp")`
206+
Pass through any component argument the user provided.
274207

275-
Pass through any arguments the user provided (e.g. component name).
208+
The build skill will execute the core loop: code → screenshot (via `chrome-devtools-tester` subagent) → compare (via `general-purpose` subagent reading both PNGs) → fix or commit. Every component, every time.

0 commit comments

Comments
 (0)