Skill Tracer
Skills › Superpowers › brainstorming › visual-companion.md

visual-companion.md

299 lines · skills/brainstorming/visual-companion.md at 2ce8aa1

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Visual Companion Guide
2
3Browser-based visual brainstorming companion for showing mockups, diagrams, and options.
4

Visual Companion Guide

Browser-based visual brainstorming companion for showing mockups, diagrams, and options.

Raw lines 1 to 4
5## When to Use
6
7Decide per-question, not per-session. The test: **would the user understand this better by seeing it than reading it?**
8
9**Use the browser** when the content itself is visual:
11- **UI mockups** — wireframes, layouts, navigation structures, component designs
12- **Architecture diagrams** — system components, data flow, relationship maps
13- **Side-by-side visual comparisons** — comparing two layouts, two color schemes, two design directions
14- **Design polish** — when the question is about look and feel, spacing, visual hierarchy
15- **Spatial relationships** — state machines, flowcharts, entity relationships rendered as diagrams
17**Use the terminal** when the content is text or tabular:
19- **Requirements and scope questions** — "what does X mean?", "which features are in scope?"
20- **Conceptual A/B/C choices** — picking between approaches described in words
21- **Tradeoff lists** — pros/cons, comparison tables
22- **Technical decisions** — API design, data modeling, architectural approach selection
23- **Clarifying questions** — anything where the answer is words, not a visual preference
25A question *about* a UI topic is not automatically a visual question. "What kind of wizard do you want?" is conceptual — use the terminal. "Which of these wizard layouts feels right?" is visual — use the browser.

When to Use

Decide per-question, not per-session. The test: would the user understand this better by seeing it than reading it?

Use the browser when the content itself is visual:

  • UI mockups — wireframes, layouts, navigation structures, component designs
  • Architecture diagrams — system components, data flow, relationship maps
  • Side-by-side visual comparisons — comparing two layouts, two color schemes, two design directions
  • Design polish — when the question is about look and feel, spacing, visual hierarchy
  • Spatial relationships — state machines, flowcharts, entity relationships rendered as diagrams

Use the terminal when the content is text or tabular:

  • Requirements and scope questions — "what does X mean?", "which features are in scope?"
  • Conceptual A/B/C choices — picking between approaches described in words
  • Tradeoff lists — pros/cons, comparison tables
  • Technical decisions — API design, data modeling, architectural approach selection
  • Clarifying questions — anything where the answer is words, not a visual preference

A question about a UI topic is not automatically a visual question. "What kind of wizard do you want?" is conceptual — use the terminal. "Which of these wizard layouts feels right?" is visual — use the browser.

Raw lines 5 to 26
27## How It Works
29The server watches a directory for HTML files and serves the newest one to the browser. You write HTML content to `screen_dir`, the user sees it in their browser and can click to select options. Selections are recorded to `state_dir/events` that you read on your next turn.
31**Content fragments vs full documents:** If your HTML file starts with `<!DOCTYPE` or `<html`, the server serves it as-is (just injects the helper script). Otherwise, the server automatically wraps your content in the frame template — adding the header, CSS theme, connection status, and all interactive infrastructure. **Write content fragments by default.** Only write full documents when you need complete control over the page.

How It Works

The server watches a directory for HTML files and serves the newest one to the browser. You write HTML content to screen_dir, the user sees it in their browser and can click to select options. Selections are recorded to state_dir/events that you read on your next turn.

Content fragments vs full documents: If your HTML file starts with <!DOCTYPE or <html, the server serves it as-is (just injects the helper script). Otherwise, the server automatically wraps your content in the frame template — adding the header, CSS theme, connection status, and all interactive infrastructure. Write content fragments by default. Only write full documents when you need complete control over the page.

Raw lines 27 to 32
33## Starting a Session
35```bash
36# Start AFTER the user approves the companion. --open auto-opens their browser on
37# the first screen; --project-dir persists mockups and enables same-port restart.
38bash scripts/start-server.sh --project-dir /path/to/project --open
40# Returns: {"type":"server-started","port":52341,
41# "url":"http://localhost:52341/?key=ab12…",
42# "screen_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000/content",
43# "state_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000/state"}
44```
46Save `screen_dir` and `state_dir` from the response. With `--open`, the browser opens itself when you push the first screen — you don't need to ask the user to open it, but still share the URL as a fallback (headless/remote setups won't auto-open).
48**The URL contains a session key (`?key=…`).** The server rejects any request
49without it, so always give the user the **complete** URL from the `url` field —
50never strip the query string, and never hand out a bare `http://host:port`. The
51key gates HTTP and WebSocket access so a stray browser tab or another machine on
52the network can't read the screens or inject events. After the first load the
53browser remembers the key via a cookie, so reloads and `/files/*` assets work
54without repeating it.
56**Finding connection info:** The server writes its startup JSON to `$STATE_DIR/server-info`. If you launched the server in the background and didn't capture stdout, read that file to get the URL and port. When using `--project-dir`, check `<project>/.superpowers/brainstorm/` for the session directory.
58**Note:** Pass the project root as `--project-dir` so mockups persist in `.superpowers/brainstorm/` and survive server restarts. Without it, files go to `/tmp` and get cleaned up. Remind the user to add `.superpowers/` to `.gitignore` if it's not already there.
60**Launching the server by platform:**
62**Claude Code:**
63```bash
64# Default mode works — the script backgrounds the server itself.
65bash scripts/start-server.sh --project-dir /path/to/project --open
66```
68On Windows, the script auto-detects and switches to foreground mode (which blocks the tool call). Use `run_in_background: true` on the Bash tool call so the server survives across conversation turns, then read `$STATE_DIR/server-info` on the next turn to get the URL and port.
70**Codex:**
71```bash
72# Codex reaps background processes. The script auto-detects CODEX_CI and
73# switches to foreground mode. Run it normally — no extra flags needed.
74bash scripts/start-server.sh --project-dir /path/to/project --open
75```
77**Gemini CLI:**
78```bash
79# Use --foreground and set is_background: true on your shell tool call
80# so the process survives across turns
81bash scripts/start-server.sh --project-dir /path/to/project --open --foreground
82```
84**Copilot CLI:**
85```bash
86# Start it with Copilot CLI's non-blocking/background shell mechanism so the
87# server survives across turns. Keep --foreground so the harness, not the
88# script, owns backgrounding. The launcher is a .sh, so invoke it via bash
89# (on Windows, call Git Bash's bash.exe from the PowerShell tool).
90bash scripts/start-server.sh --project-dir /path/to/project --open --foreground
91```
93**Other environments:** The server must keep running in the background across conversation turns. If your environment reaps detached processes, use `--foreground` and launch the command with your platform's background execution mechanism.
95If the URL is unreachable from your browser (common in remote/containerized setups), bind a non-loopback host:
97```bash
98bash scripts/start-server.sh \
99 --project-dir /path/to/project \
100 --host 0.0.0.0 \
101 --url-host localhost
102```
104Use `--url-host` to control what hostname is printed in the returned URL JSON.

Starting a Session

# Start AFTER the user approves the companion. --open auto-opens their browser on
# the first screen; --project-dir persists mockups and enables same-port restart.
bash scripts/start-server.sh --project-dir /path/to/project --open

# Returns: {"type":"server-started","port":52341,
#           "url":"http://localhost:52341/?key=ab12…",
#           "screen_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000/content",
#           "state_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000/state"}

Save screen_dir and state_dir from the response. With --open, the browser opens itself when you push the first screen — you don't need to ask the user to open it, but still share the URL as a fallback (headless/remote setups won't auto-open).

**The URL contains a session key (?key=…). The server rejects any request without it, so always give the user the complete** URL from the url field — never strip the query string, and never hand out a bare http://host:port. The key gates HTTP and WebSocket access so a stray browser tab or another machine on the network can't read the screens or inject events. After the first load the browser remembers the key via a cookie, so reloads and /files/* assets work without repeating it.

Finding connection info: The server writes its startup JSON to $STATE_DIR/server-info. If you launched the server in the background and didn't capture stdout, read that file to get the URL and port. When using --project-dir, check <project>/.superpowers/brainstorm/ for the session directory.

Note: Pass the project root as --project-dir so mockups persist in .superpowers/brainstorm/ and survive server restarts. Without it, files go to /tmp and get cleaned up. Remind the user to add .superpowers/ to .gitignore if it's not already there.

Launching the server by platform:

Claude Code:

# Default mode works — the script backgrounds the server itself.
bash scripts/start-server.sh --project-dir /path/to/project --open

On Windows, the script auto-detects and switches to foreground mode (which blocks the tool call). Use run_in_background: true on the Bash tool call so the server survives across conversation turns, then read $STATE_DIR/server-info on the next turn to get the URL and port.

Codex:

# Codex reaps background processes. The script auto-detects CODEX_CI and
# switches to foreground mode. Run it normally — no extra flags needed.
bash scripts/start-server.sh --project-dir /path/to/project --open

Gemini CLI:

# Use --foreground and set is_background: true on your shell tool call
# so the process survives across turns
bash scripts/start-server.sh --project-dir /path/to/project --open --foreground

Copilot CLI:

# Start it with Copilot CLI's non-blocking/background shell mechanism so the
# server survives across turns. Keep --foreground so the harness, not the
# script, owns backgrounding. The launcher is a .sh, so invoke it via bash
# (on Windows, call Git Bash's bash.exe from the PowerShell tool).
bash scripts/start-server.sh --project-dir /path/to/project --open --foreground

Other environments: The server must keep running in the background across conversation turns. If your environment reaps detached processes, use --foreground and launch the command with your platform's background execution mechanism.

If the URL is unreachable from your browser (common in remote/containerized setups), bind a non-loopback host:

bash scripts/start-server.sh \
  --project-dir /path/to/project \
  --host 0.0.0.0 \
  --url-host localhost

Use --url-host to control what hostname is printed in the returned URL JSON.

Raw lines 33 to 105
Runs code bash scripts/start-server.sh :38
Involves a person ask the user :46
106## The Loop
1081. **Check server is alive**, then **write HTML** to a new file in `screen_dir`:
109 - **Required: confirm the server is alive before referring to the URL or pushing a screen.** Check that `$STATE_DIR/server-info` exists and `$STATE_DIR/server-stopped` does not. If it has shut down, restart it with `start-server.sh` using the **same `--project-dir`** — it reuses the same port, so the user's open tab reconnects on its own (it shows a "paused" overlay while the server is down) and you don't need to send a new URL. The server auto-exits after 4 hours idle (configurable with `--idle-timeout-minutes`).
110 - Use semantic filenames: `platform.html`, `visual-style.html`, `layout.html`
111 - **Never reuse filenames** — each screen gets a fresh file
112 - Use your file-creation tool — **never use cat/heredoc** (dumps noise into terminal)
113 - Server automatically serves the newest file
1152. **Tell user what to expect and end your turn:**
116 - Remind them of the URL (every step, not just first)
117 - Give a brief text summary of what's on screen (e.g., "Showing 3 layout options for the homepage")
118 - Ask them to respond in the terminal: "Take a look and let me know what you think. Click to select an option if you'd like."
1203. **On your next turn** — after the user responds in the terminal:
121 - Read `$STATE_DIR/events` if it exists — this contains the user's browser interactions (clicks, selections) as JSON lines
122 - Merge with the user's terminal text to get the full picture
123 - The terminal message is the primary feedback; `state_dir/events` provides structured interaction data
1254. **Iterate or advance** — if feedback changes current screen, write a new file (e.g., `layout-v2.html`). Only move to the next question when the current step is validated.
1275. **Unload when returning to terminal** — when the next step doesn't need the browser (e.g., a clarifying question, a tradeoff discussion), push a waiting screen to clear the stale content:
129 ```html
130 <!-- filename: waiting.html (or waiting-2.html, etc.) -->
131 <div style="display:flex;align-items:center;justify-content:center;min-height:60vh">
132 <p class="subtitle">Continuing in terminal...</p>
133 </div>
134 ```
136 This prevents the user from staring at a resolved choice while the conversation has moved on. When the next visual question comes up, push a new content file as usual.
1386. Repeat until done.

The Loop

  1. Check server is alive, then write HTML to a new file in screen_dir:
  2. Required: confirm the server is alive before referring to the URL or pushing a screen. Check that $STATE_DIR/server-info exists and $STATE_DIR/server-stopped does not. If it has shut down, restart it with start-server.sh using the **same --project-dir** — it reuses the same port, so the user's open tab reconnects on its own (it shows a "paused" overlay while the server is down) and you don't need to send a new URL. The server auto-exits after 4 hours idle (configurable with --idle-timeout-minutes).
  3. Use semantic filenames: platform.html, visual-style.html, layout.html
  4. Never reuse filenames — each screen gets a fresh file
  5. Use your file-creation tool — never use cat/heredoc (dumps noise into terminal)
  6. Server automatically serves the newest file
  1. Tell user what to expect and end your turn:
  2. Remind them of the URL (every step, not just first)
  3. Give a brief text summary of what's on screen (e.g., "Showing 3 layout options for the homepage")
  4. Ask them to respond in the terminal: "Take a look and let me know what you think. Click to select an option if you'd like."
  1. On your next turn — after the user responds in the terminal:
  2. Read $STATE_DIR/events if it exists — this contains the user's browser interactions (clicks, selections) as JSON lines
  3. Merge with the user's terminal text to get the full picture
  4. The terminal message is the primary feedback; state_dir/events provides structured interaction data
  1. Iterate or advance — if feedback changes current screen, write a new file (e.g., layout-v2.html). Only move to the next question when the current step is validated.
  1. Unload when returning to terminal — when the next step doesn't need the browser (e.g., a clarifying question, a tradeoff discussion), push a waiting screen to clear the stale content:

html <!-- filename: waiting.html (or waiting-2.html, etc.) --> <div style="display:flex;align-items:center;justify-content:center;min-height:60vh"> <p class="subtitle">Continuing in terminal...</p> </div>

This prevents the user from staring at a resolved choice while the conversation has moved on. When the next visual question comes up, push a new content file as usual.

  1. Repeat until done.
Raw lines 106 to 139
140## Writing Content Fragments
142Write just the content that goes inside the page. The server wraps it in the frame template automatically (header, theme CSS, connection status, and all interactive infrastructure).
144**Minimal example:**
146```html
147<h2>Which layout works better?</h2>
148<p class="subtitle">Consider readability and visual hierarchy</p>
150<div class="options">
151 <div class="option" data-choice="a" onclick="toggleSelect(this)">
152 <div class="letter">A</div>
153 <div class="content">
154 <h3>Single Column</h3>
155 <p>Clean, focused reading experience</p>
156 </div>
157 </div>
158 <div class="option" data-choice="b" onclick="toggleSelect(this)">
159 <div class="letter">B</div>
160 <div class="content">
161 <h3>Two Column</h3>
162 <p>Sidebar navigation with main content</p>
163 </div>
164 </div>
165</div>
166```
168That's it. No `<html>`, no CSS, no `<script>` tags needed. The server provides all of that.

Writing Content Fragments

Write just the content that goes inside the page. The server wraps it in the frame template automatically (header, theme CSS, connection status, and all interactive infrastructure).

Minimal example:

<h2>Which layout works better?</h2>
<p class="subtitle">Consider readability and visual hierarchy</p>

<div class="options">
  <div class="option" data-choice="a" onclick="toggleSelect(this)">
    <div class="letter">A</div>
    <div class="content">
      <h3>Single Column</h3>
      <p>Clean, focused reading experience</p>
    </div>
  </div>
  <div class="option" data-choice="b" onclick="toggleSelect(this)">
    <div class="letter">B</div>
    <div class="content">
      <h3>Two Column</h3>
      <p>Sidebar navigation with main content</p>
    </div>
  </div>
</div>

That's it. No <html>, no CSS, no <script> tags needed. The server provides all of that.

Raw lines 140 to 169
170## CSS Classes Available
172The frame template provides these CSS classes for your content:

CSS Classes Available

The frame template provides these CSS classes for your content:

Raw lines 170 to 173
174### Options (A/B/C choices)
176```html
177<div class="options">
178 <div class="option" data-choice="a" onclick="toggleSelect(this)">
179 <div class="letter">A</div>
180 <div class="content">
181 <h3>Title</h3>
182 <p>Description</p>
183 </div>
184 </div>
185</div>
186```
188**Multi-select:** Add `data-multiselect` to the container to let users select multiple options. Each click toggles the item's selected styling.
190```html
191<div class="options" data-multiselect>
192 <!-- same option markup — users can select/deselect multiple -->
193</div>
194```

Options (A/B/C choices)

<div class="options">
  <div class="option" data-choice="a" onclick="toggleSelect(this)">
    <div class="letter">A</div>
    <div class="content">
      <h3>Title</h3>
      <p>Description</p>
    </div>
  </div>
</div>

Multi-select: Add data-multiselect to the container to let users select multiple options. Each click toggles the item's selected styling.

<div class="options" data-multiselect>
  <!-- same option markup — users can select/deselect multiple -->
</div>
Raw lines 174 to 195
196### Cards (visual designs)
198```html
199<div class="cards">
200 <div class="card" data-choice="design1" onclick="toggleSelect(this)">
201 <div class="card-image"><!-- mockup content --></div>
202 <div class="card-body">
203 <h3>Name</h3>
204 <p>Description</p>
205 </div>
206 </div>
207</div>
208```

Cards (visual designs)

<div class="cards">
  <div class="card" data-choice="design1" onclick="toggleSelect(this)">
    <div class="card-image"><!-- mockup content --></div>
    <div class="card-body">
      <h3>Name</h3>
      <p>Description</p>
    </div>
  </div>
</div>
Raw lines 196 to 209
210### Mockup container
212```html
213<div class="mockup">
214 <div class="mockup-header">Preview: Dashboard Layout</div>
215 <div class="mockup-body"><!-- your mockup HTML --></div>
216</div>
217```

Mockup container

<div class="mockup">
  <div class="mockup-header">Preview: Dashboard Layout</div>
  <div class="mockup-body"><!-- your mockup HTML --></div>
</div>
Raw lines 210 to 218
219### Split view (side-by-side)
221```html
222<div class="split">
223 <div class="mockup"><!-- left --></div>
224 <div class="mockup"><!-- right --></div>
225</div>
226```

Split view (side-by-side)

<div class="split">
  <div class="mockup"><!-- left --></div>
  <div class="mockup"><!-- right --></div>
</div>
Raw lines 219 to 227
228### Pros/Cons
230```html
231<div class="pros-cons">
232 <div class="pros"><h4>Pros</h4><ul><li>Benefit</li></ul></div>
233 <div class="cons"><h4>Cons</h4><ul><li>Drawback</li></ul></div>
234</div>
235```

Pros/Cons

<div class="pros-cons">
  <div class="pros"><h4>Pros</h4><ul><li>Benefit</li></ul></div>
  <div class="cons"><h4>Cons</h4><ul><li>Drawback</li></ul></div>
</div>
Raw lines 228 to 236
237### Mock elements (wireframe building blocks)
239```html
240<div class="mock-nav">Logo | Home | About | Contact</div>
241<div style="display: flex;">
242 <div class="mock-sidebar">Navigation</div>
243 <div class="mock-content">Main content area</div>
244</div>
245<button class="mock-button">Action Button</button>
246<input class="mock-input" placeholder="Input field">
247<div class="placeholder">Placeholder area</div>
248```

Mock elements (wireframe building blocks)

<div class="mock-nav">Logo | Home | About | Contact</div>
<div style="display: flex;">
  <div class="mock-sidebar">Navigation</div>
  <div class="mock-content">Main content area</div>
</div>
<button class="mock-button">Action Button</button>
<input class="mock-input" placeholder="Input field">
<div class="placeholder">Placeholder area</div>
Raw lines 237 to 249
250### Typography and sections
252- `h2` — page title
253- `h3` — section heading
254- `.subtitle` — secondary text below title
255- `.section` — content block with bottom margin
256- `.label` — small uppercase label text

Typography and sections

  • h2 — page title
  • h3 — section heading
  • .subtitle — secondary text below title
  • .section — content block with bottom margin
  • .label — small uppercase label text
Raw lines 250 to 257
258## Browser Events Format
260When the user clicks options in the browser, their interactions are recorded to `$STATE_DIR/events` (one JSON object per line). The file is cleared automatically when you push a new screen.
262```jsonl
263{"type":"click","choice":"a","text":"Option A - Simple Layout","timestamp":1706000101}
264{"type":"click","choice":"c","text":"Option C - Complex Grid","timestamp":1706000108}
265{"type":"click","choice":"b","text":"Option B - Hybrid","timestamp":1706000115}
266```
268The full event stream shows the user's exploration path — they may click multiple options before settling. The last `choice` event is typically the final selection, but the pattern of clicks can reveal hesitation or preferences worth asking about.
270If `$STATE_DIR/events` doesn't exist, the user didn't interact with the browser — use only their terminal text.

Browser Events Format

When the user clicks options in the browser, their interactions are recorded to $STATE_DIR/events (one JSON object per line). The file is cleared automatically when you push a new screen.

{"type":"click","choice":"a","text":"Option A - Simple Layout","timestamp":1706000101}
{"type":"click","choice":"c","text":"Option C - Complex Grid","timestamp":1706000108}
{"type":"click","choice":"b","text":"Option B - Hybrid","timestamp":1706000115}

The full event stream shows the user's exploration path — they may click multiple options before settling. The last choice event is typically the final selection, but the pattern of clicks can reveal hesitation or preferences worth asking about.

If $STATE_DIR/events doesn't exist, the user didn't interact with the browser — use only their terminal text.

Raw lines 258 to 271
272## Design Tips
274- **Scale fidelity to the question** — wireframes for layout, polish for polish questions
275- **Explain the question on each page** — "Which layout feels more professional?" not just "Pick one"
276- **Iterate before advancing** — if feedback changes current screen, write a new version
277- **2-4 options max** per screen
278- **Use real content when it matters** — for a photography portfolio, use actual images (Unsplash). Placeholder content obscures design issues.
279- **Keep mockups simple** — focus on layout and structure, not pixel-perfect design

Design Tips

  • Scale fidelity to the question — wireframes for layout, polish for polish questions
  • Explain the question on each page — "Which layout feels more professional?" not just "Pick one"
  • Iterate before advancing — if feedback changes current screen, write a new version
  • 2-4 options max per screen
  • Use real content when it matters — for a photography portfolio, use actual images (Unsplash). Placeholder content obscures design issues.
  • Keep mockups simple — focus on layout and structure, not pixel-perfect design
Raw lines 272 to 280
281## File Naming
283- Use semantic names: `platform.html`, `visual-style.html`, `layout.html`
284- Never reuse filenames — each screen must be a new file
285- For iterations: append version suffix like `layout-v2.html`, `layout-v3.html`
286- Server serves newest file by modification time

File Naming

  • Use semantic names: platform.html, visual-style.html, layout.html
  • Never reuse filenames — each screen must be a new file
  • For iterations: append version suffix like layout-v2.html, layout-v3.html
  • Server serves newest file by modification time
Raw lines 281 to 287
288## Cleaning Up
290```bash
291bash scripts/stop-server.sh $SESSION_DIR
292```
294If the session used `--project-dir`, mockup files persist in `.superpowers/brainstorm/` for later reference. Only `/tmp` sessions get deleted on stop.

Cleaning Up

bash scripts/stop-server.sh $SESSION_DIR

If the session used --project-dir, mockup files persist in .superpowers/brainstorm/ for later reference. Only /tmp sessions get deleted on stop.

Raw lines 288 to 295
Runs code bash scripts/stop-server.sh :291
296## Reference
298- Frame template (CSS reference): `scripts/frame-template.html`
299- Helper script (client-side): `scripts/helper.js`

Reference

  • Frame template (CSS reference): scripts/frame-template.html
  • Helper script (client-side): scripts/helper.js
Raw lines 296 to 299
Runs code scripts/frame-template.html :298
Runs code scripts/helper.js :299