Generate a series of social/marketing image React components in the same theme.
| Term | What it is | Scope |
|---|---|---|
| ------ | ----------- | ------- |
| Viewport | Shared outer frame component. Safe-area padding, content alignment, root container, optional branding. Written once, reused by every image in the set. | Per set |
| Stylesheet | Shared CSS file. Starts from default-styles.css, adds preset-specific overrides. Styles all typography, cards, grids, and layout via token CSS vars. Written once, imported by every image. | Per set |
| Brief | Per-image content instructions written by the orchestrator. Includes exact text strings, layout description, creative direction, metadata. Writers implement the brief — they do not make content decisions. | Per image |
| Layout | Content arrangement description inside the Viewport. Written by the orchestrator per image (e.g., "split — title left, 2x2 cards right"). The shared agent creates CSS classes to support all layouts in the set. | Per image |
| File | Purpose | When to use |
|---|---|---|
| ------ | --------- | ------------- |
scripts/init.sh | Bootstrap workspace (tokens, deps, --preset or --tokens required) | After intake: if .token-image/ workspace missing |
assets/ | Token set for the chosen design system | Selected during intake; copied to .token-image/tokens/ by init.sh |
assets/ | Design principles and stylesheet overrides for the chosen token set | Read during intake after preset selection; injected into agent prompts |
.token-image/src/token.active.json | Project's active token file | Read in full during intake; passed to every agent |
references/default-styles.css | Base stylesheet with typography, card, grid, and layout styles | Read by shared-files agent in Phase 2 Step 2 |
references/viewports.md | Viewport examples (2-3 variants) | Read by shared-files agent in Phase 2 Step 2 |
references/components.md | Component snippets (Card, Grid, decoration patterns) | Read by Writer agents in Phase 2 Step 3 |
prompts/shared.md | Shared files agent prompt (Viewport + Stylesheet) | Read by agent in Phase 2 Step 2 |
prompts/writer.md | Writer agent prompt | Read by Writer agents in Phase 2 Step 3 |
prompts/reviewer.md | Reviewer agent prompt | Read by Reviewer agents in Phase 2 Step 3 |
Announce: "I'm using the token-image skill."
Check for .token-image/ workspace directory in the project root.
.token-image/src/token.active.json for reference.Ensure Playwright browsers are installed:
npx playwright install chromium
This is idempotent — if already installed, it's a no-op.
Before generating anything, ask the user these questions. Skip any that were already answered in the initial prompt.
/assets/ }tokens.json (with optional design-guide.md alongside it). This will be passed as --tokens to init.sh.(e.g. "4 banners: Hooks, Context, Suspense, Server Components")
twitter-card 1200×600instagram-square 1080×1080og-image 1200×630custom — User specify width and heightWhat goes where? (e.g., "title top-left, 2x2 card grid on right",
"full-canvas hero with oversized title", "numbered steps down the left side")
You can describe one layout for all images or a different one per image.
If you're not sure, say "auto" and I'll pick based on content.
(e.g., "logo bottom-right", "series label 'REACT SERIES · PART N' in footer",
"no branding", "subtle watermark center-bottom")
This becomes part of the shared Viewport that wraps every image.
If none, say "none" and I'll keep the viewport clean.
Wait for the user's answers before proceeding. If the user says "auto" or leaves something blank, make a reasonable choice and state it.
After the user selects a preset or provides a custom token file:
```bash
# For a built-in preset:
bash
# For a custom token file:
bash
```
```bash
cp .token-image/tokens/
```
/assets//tokens.json into context as {token_json} and /assets//design-guide.md into context as {design_guide}tokens.json and optionally design-guide.md if it exists alongside itOnce you have all answers, confirm the plan:
Got it. Here's what I'll generate:
- Format: {format} ({width}×{height})
- Theme: {token_file}
- Branding: {user's branding spec from Q5}
- Images:
1. {title 1} — {subtitle 1}
- Layout: {layout description 1}
2. {title 2} — {subtitle 2}
- Layout: {layout description 2}
...
I'll plan content, create shared Viewport + Stylesheet, then one component per image.
Proceed?
Only proceed after the user confirms.
Do NOT delegate this step. The orchestrator (you) writes a content brief for every image in the set.
Based on the user's intake answers, produce two things:
A. Shared element inventory — decide what's shared across the whole set, informed by the user's branding answer (Q5):
B. Per-image brief — for each image, describe what goes inside the Viewport. Include:
Example output for a 4-image set:
SHARED:
- Viewport: hero variant (Image 1), standard variant centered (Images 2-4)
- Stylesheet: Nothing preset, no overrides needed
- Metadata format: "REACT SERIES · PART N" for all images, bottom
- No branding
Image 1 — hero, full canvas:
Layout: hero — oversized display title pushed to bottom-right, tagline below
Creative direction: "Poster-style, 70% whitespace above, oversized display text, bottom-right anchored"
Image 2 — split, text left + decoration right:
Layout: split — title and body left panel, dot-grid background pattern right panel
Title: "useState". Subtitle: "Managing local component state".
Body: short paragraph about useState and when to reach for it.
Image 3 — split, swapped:
Layout: split — dot-grid background pattern left panel, title and body right panel
Title: "useEffect". Subtitle: "Handling side effects in function components".
Image 4 — title above grid:
Layout: title spanning full width, 2×2 card grid below
Title: "Hook Patterns". Cards:
- STATE: "Manage local state with useState"
- EFFECT: "Handle side effects with useEffect"
- CONTEXT: "Share data across the component tree"
- CUSTOM: "Build reusable logic abstractions"
Consistency rules (enforced by the orchestrator when writing briefs):
Dispatch one agent to create the Viewport component and the complete stylesheet. This agent is the layout architect — it reads the full content plan and creates CSS classes for every layout the images need.
Tell the agent:
/prompts/shared.md for full instructions.token-image/src/token.active.json for tokens/references/viewports.md for viewport examples/references/default-styles.css for the base stylesheet/references/components.md for layout pattern reference (CSS + TSX pairs)/assets//design-guide.md for the design guideThe agent writes directly to .token-image/src/viewport.tsx and .token-image/src/styles.css.
The stylesheet must include an "available classes" comment block listing all layout CSS classes, so writers know what's available.
Do NOT run the Reviewer on shared files — they are structural, not design-heavy.
This step runs in rounds. Each round: all Writers in parallel → batch render → all Reviewers in parallel. Max 3 rounds per image.
Round N:
Tell each Writer agent:
Layout: field), the creative direction, and the file index/prompts/writer.md for full instructions.token-image/src/token.active.json for tokens.token-image/src/viewport.tsx for the Viewport component.token-image/src/styles.css for available CSS classes (the "available classes" comment block at the top lists all layout classes)/references/components.md for component patterns/assets//design-guide.md for the design guide The Writer writes the component directly to .token-image/src/.
```bash
cd .token-image && npm run render
```
This renders every .tsx → .png in one pass (single Playwright session). The PNGs are saved to .token-image/src/.
Tell each Reviewer agent:
/prompts/reviewer.md for full instructions.token-image/src/viewport.tsx for the Viewport component.token-image/src/styles.css for the shared stylesheet.token-image/src/token.active.json for tokens.token-image/src/-.tsx for the component to review.token-image/src/-.png for the rendered image (already rendered by the orchestrator — reviewer does NOT run render)For re-renders of individual components in subsequent rounds:
```bash
cd .token-image && npm run render --
```
Run max 3 rounds total. After 3 rounds, accept whatever state the remaining images are in.
Save files to .token-image/src/:
| File | Purpose |
|---|---|
| ------ | --------- |
viewport.tsx | Shared Viewport component |
styles.css | Shared stylesheet (default + preset overrides) |
| Per-image components |
Create the .token-image/src/ directory if it doesn't exist.
After all images are written and reviewed, summarize:
.token-image/src/cd .token-image && npm run render [component] to re-render if neededThen automatically launch the visual editor:
cd .token-image && npm run editor
This opens the editor in the user's browser so they can visually inspect and tweak tokens immediately.
After generating all components, tell the user:
"Done. The visual editor should be open in your browser. Useful commands:
npm run render # re-render all .tsx → .png
npm run render -- square-1 # render one by name
npm run render:2x -- square-1 # render one at 2x dimensions
npm run editor # re-launch visual token editor (if closed)"
共 1 个版本