Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Turn ideas into validated designs and specs through collaborative dialogue before any code is written
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
visual-companion.md
1# Visual Companion Guide23Browser-based visual brainstorming companion for showing mockups, diagrams, and options.45## When to Use67Decide per-question, not per-session. The test: **would the user understand this better by seeing it than reading it?**89**Use the browser** when the content itself is visual:1011- **UI mockups** — wireframes, layouts, navigation structures, component designs12- **Architecture diagrams** — system components, data flow, relationship maps13- **Side-by-side visual comparisons** — comparing two layouts, two color schemes, two design directions14- **Design polish** — when the question is about look and feel, spacing, visual hierarchy15- **Spatial relationships** — state machines, flowcharts, entity relationships rendered as diagrams1617**Use the terminal** when the content is text or tabular:1819- **Requirements and scope questions** — "what does X mean?", "which features are in scope?"20- **Conceptual A/B/C choices** — picking between approaches described in words21- **Tradeoff lists** — pros/cons, comparison tables22- **Technical decisions** — API design, data modeling, architectural approach selection23- **Clarifying questions** — anything where the answer is words, not a visual preference2425A 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.2627## How It Works2829The 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.3031**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.3233## Starting a Session3435```bash36# Start AFTER the user approves the companion. --open auto-opens their browser on37# the first screen; --project-dir persists mockups and enables same-port restart.38scripts/start-server.sh --project-dir /path/to/project --open3940# 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```4546Save `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).4748**The URL contains a session key (`?key=…`).** The server rejects any request49without 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`. The51key gates HTTP and WebSocket access so a stray browser tab or another machine on52the network can't read the screens or inject events. After the first load the53browser remembers the key via a cookie, so reloads and `/files/*` assets work54without repeating it.5556**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.5758**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.5960**Launching the server by platform:**6162**Claude Code:**63```bash64# Default mode works — the script backgrounds the server itself.65scripts/start-server.sh --project-dir /path/to/project --open66```6768On 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.6970**Codex:**71```bash72# Codex reaps background processes. The script auto-detects CODEX_CI and73# switches to foreground mode. Run it normally — no extra flags needed.74scripts/start-server.sh --project-dir /path/to/project --open75```7677**Copilot CLI:**78```bash79# Use --foreground and start the server via the bash tool with mode: "async"80# so the process survives across turns. Capture the returned shellId for81# read_bash / stop_bash if you need to interact with it later.82scripts/start-server.sh --project-dir /path/to/project --open --foreground83```8485**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.8687If the URL is unreachable from your browser (common in remote/containerized setups), bind a non-loopback host:8889```bash90scripts/start-server.sh \91--project-dir /path/to/project \92--host 0.0.0.0 \93--url-host localhost94```9596Use `--url-host` to control what hostname is printed in the returned URL JSON.9798## The Loop991001. **Check server is alive**, then **write HTML** to a new file in `screen_dir`:101- **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`).102- Use semantic filenames: `platform.html`, `visual-style.html`, `layout.html`103- **Never reuse filenames** — each screen gets a fresh file104- Use your file-creation tool — **never use cat/heredoc** (dumps noise into terminal)105- Server automatically serves the newest file1061072. **Tell user what to expect and end your turn:**108- Remind them of the URL (every step, not just first)109- Give a brief text summary of what's on screen (e.g., "Showing 3 layout options for the homepage")110- 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."1111123. **On your next turn** — after the user responds in the terminal:113- Read `$STATE_DIR/events` if it exists — this contains the user's browser interactions (clicks, selections) as JSON lines114- Merge with the user's terminal text to get the full picture115- The terminal message is the primary feedback; `state_dir/events` provides structured interaction data1161174. **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.1181195. **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:120121```html122<!-- filename: waiting.html (or waiting-2.html, etc.) -->123<div style="display:flex;align-items:center;justify-content:center;min-height:60vh">124<p class="subtitle">Continuing in terminal...</p>125</div>126```127128This 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.1291306. Repeat until done.131132## Writing Content Fragments133134Write 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).135136**Minimal example:**137138```html139<h2>Which layout works better?</h2>140<p class="subtitle">Consider readability and visual hierarchy</p>141142<div class="options">143<div class="option" data-choice="a" onclick="toggleSelect(this)">144<div class="letter">A</div>145<div class="content">146<h3>Single Column</h3>147<p>Clean, focused reading experience</p>148</div>149</div>150<div class="option" data-choice="b" onclick="toggleSelect(this)">151<div class="letter">B</div>152<div class="content">153<h3>Two Column</h3>154<p>Sidebar navigation with main content</p>155</div>156</div>157</div>158```159160That's it. No `<html>`, no CSS, no `<script>` tags needed. The server provides all of that.161162## CSS Classes Available163164The frame template provides these CSS classes for your content:165166### Options (A/B/C choices)167168```html169<div class="options">170<div class="option" data-choice="a" onclick="toggleSelect(this)">171<div class="letter">A</div>172<div class="content">173<h3>Title</h3>174<p>Description</p>175</div>176</div>177</div>178```179180**Multi-select:** Add `data-multiselect` to the container to let users select multiple options. Each click toggles the item's selected styling.181182```html183<div class="options" data-multiselect>184<!-- same option markup — users can select/deselect multiple -->185</div>186```187188### Cards (visual designs)189190```html191<div class="cards">192<div class="card" data-choice="design1" onclick="toggleSelect(this)">193<div class="card-image"><!-- mockup content --></div>194<div class="card-body">195<h3>Name</h3>196<p>Description</p>197</div>198</div>199</div>200```201202### Mockup container203204```html205<div class="mockup">206<div class="mockup-header">Preview: Dashboard Layout</div>207<div class="mockup-body"><!-- your mockup HTML --></div>208</div>209```210211### Split view (side-by-side)212213```html214<div class="split">215<div class="mockup"><!-- left --></div>216<div class="mockup"><!-- right --></div>217</div>218```219220### Pros/Cons221222```html223<div class="pros-cons">224<div class="pros"><h4>Pros</h4><ul><li>Benefit</li></ul></div>225<div class="cons"><h4>Cons</h4><ul><li>Drawback</li></ul></div>226</div>227```228229### Mock elements (wireframe building blocks)230231```html232<div class="mock-nav">Logo | Home | About | Contact</div>233<div style="display: flex;">234<div class="mock-sidebar">Navigation</div>235<div class="mock-content">Main content area</div>236</div>237<button class="mock-button">Action Button</button>238<input class="mock-input" placeholder="Input field">239<div class="placeholder">Placeholder area</div>240```241242### Typography and sections243244- `h2` — page title245- `h3` — section heading246- `.subtitle` — secondary text below title247- `.section` — content block with bottom margin248- `.label` — small uppercase label text249250## Browser Events Format251252When 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.253254```jsonl255{"type":"click","choice":"a","text":"Option A - Simple Layout","timestamp":1706000101}256{"type":"click","choice":"c","text":"Option C - Complex Grid","timestamp":1706000108}257{"type":"click","choice":"b","text":"Option B - Hybrid","timestamp":1706000115}258```259260The 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.261262If `$STATE_DIR/events` doesn't exist, the user didn't interact with the browser — use only their terminal text.263264## Design Tips265266- **Scale fidelity to the question** — wireframes for layout, polish for polish questions267- **Explain the question on each page** — "Which layout feels more professional?" not just "Pick one"268- **Iterate before advancing** — if feedback changes current screen, write a new version269- **2-4 options max** per screen270- **Use real content when it matters** — for a photography portfolio, use actual images (Unsplash). Placeholder content obscures design issues.271- **Keep mockups simple** — focus on layout and structure, not pixel-perfect design272273## File Naming274275- Use semantic names: `platform.html`, `visual-style.html`, `layout.html`276- Never reuse filenames — each screen must be a new file277- For iterations: append version suffix like `layout-v2.html`, `layout-v3.html`278- Server serves newest file by modification time279280## Cleaning Up281282```bash283scripts/stop-server.sh $SESSION_DIR284```285286If the session used `--project-dir`, mockup files persist in `.superpowers/brainstorm/` for later reference. Only `/tmp` sessions get deleted on stop.287288## Reference289290- Frame template (CSS reference): `scripts/frame-template.html`291- Helper script (client-side): `scripts/helper.js`292