home / skills / ampcode / amp-contrib / ui-preview

ui-preview skill

/.agents/skills/ui-preview

This skill lets you preview local web and server dev environments, capture screenshots of storybooks, and inspect UI components for quick validation.

npx playbooks add skill ampcode/amp-contrib --skill ui-preview

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
4.2 KB
---
name: ui-preview
description: 'Preview and screenshot local dev servers and storybooks. Use when asked to view UI components, take screenshots of storybooks, or inspect the web/server apps.'
metadata:
  version: '1'
---

# UI Preview Skill

Preview local dev servers and storybooks using Chrome DevTools.

## Available Tools

- `navigate_page` - Navigate to a URL
- `take_screenshot` - Capture a screenshot of the current page
- `new_page` - Open a new browser tab
- `press_key` - Press keyboard keys (e.g., scrolling with PageDown, End)
- `evaluate_script` - Run JavaScript on the page

## Workflow

1. **Navigate** to the target URL using `navigate_page`
2. **Screenshot** the page using `take_screenshot`
3. **Analyze** captured screenshots with `look_at` for visual analysis

## Local Dev URLs

Check `.amp/dev-environment.txt` for the running URLs (defaults: web=http://localhost:7001, server=https://localhost:7002).

| Service           | Path        |
| ----------------- | ----------- |
| Web dev server    | /           |
| Server dev server | /           |
| Webview storybook | /storybook  |
| Server storybook  | /storybook  |

## Storybooks

Access a specific story directly using the hash: `/storybook#${story-title}`

The story title is derived from the filename: `handoff-story.svelte` → `#handoff-tool`

### Webview Storybook (localhost:7001)

Components for the VS Code extension webview UI.

**Thread Components:**

- `#thread` - Full thread view
- `#streaming-thread` - Thread with streaming content
- `#scrollable-thread` - Thread with scroll behavior
- `#thread-reply-area` - Message input area
- `#thread-status` - Thread status indicators
- `#thread-summary` - Thread summary view
- `#thread-hints` - Thread hint suggestions
- `#thread-environment-input` - Environment input

**Tool Calls:**

- `#bash` - Bash tool output
- `#edit-file` - File edit diffs
- `#create-file` - File creation
- `#read` - File read output
- `#grep` - Search results
- `#glob` - File glob results
- `#handoff-tool` - Handoff tool states
- `#mermaid` - Diagram rendering
- `#oracle-tool` - Oracle tool output
- `#task-tool` - Task tool output
- `#web-search` - Web search results

**Editor & Input:**

- `#prompt-editor` - Message input editor
- `#mention-menu` - @mention autocomplete
- `#combobox` - Combobox component
- `#agent-mode-selector` - Agent mode picker

**Diff Viewer:**

- `#diff-viewer` - Side-by-side diff
- `#diff-display` - Inline diff display
- `#unified-diff` - Unified diff format

**Settings:**

- `#settings-page` - Settings page
- `#settings-error-modal` - Error modal
- `#sign-in-page` - Authentication page

**Layout:**

- `#layout-navbar` - Navigation bar
- `#current-thread-navbar-item` - Thread nav item

### Server Storybook (localhost:7002)

Components for the ampcode.com web app.

**Thread Management:**

- `#thread-feed` - Thread list feed
- `#thread-feed-item` - Individual thread item
- `#thread-feed-list` - Virtualized thread list
- `#thread-actions` - Thread action buttons
- `#thread-visibility` - Visibility settings
- `#thread-visibility-edit` - Edit visibility
- `#thread-page` - Full thread page
- `#thread-open-in-button` - Open in editor button
- `#pull-request-badge` - PR badge display

**Settings:**

- `#settings-access-token-section` - API tokens
- `#settings-advanced-section` - Advanced settings
- `#settings-client-section` - Client settings
- `#billing-section` - Billing info
- `#amp-free-section` - Free tier info
- `#code-host-connections-section` - GitHub/GitLab connections

**User & Profile:**

- `#avatar` - User avatar
- `#profile-card` - Profile card
- `#profile-dropdown` - Profile menu
- `#user-display` - User name display

**Dashboard:**

- `#welcome` - Welcome page
- `#usage-by-day` - Usage metrics

**UI Components:**

- `#amp-logo` - Logo variants
- `#badge-single` - Single badge
- `#badge-group` - Badge group
- `#copyable-text` - Copy-to-clipboard text
- `#colors` - Color palette
- `#icons` - Icon set

**OG Images:**

- `#og-images` - Social preview images

## Tips

- Story titles use kebab-case from filenames (remove `-story.svelte`)
- Reload the skill if MCP tools become unavailable
- Use `list_pages` to manage multiple browser tabs
- Use `press_key` with "End" or "PageDown" to scroll the page
- Use `evaluate_script` for custom page interactions

Overview

This skill previews and screenshots local development servers and Storybook instances using a headless Chrome DevTools workflow. It is designed to quickly open, inspect, and capture UI components running on localhost for both webview and server apps. Use it to verify component states, reproduce UI bugs, or generate visual references for reviews and documentation.

How this skill works

The skill navigates a browser tab to a target URL, runs optional page interactions or scripts, and captures screenshots of the rendered UI. It can open new tabs, press keys to scroll, and evaluate JavaScript for custom interactions before taking a capture. Storybook entries can be addressed directly via hash fragments to show specific stories.

When to use it

  • You need a screenshot of a local dev server UI (defaults: web http://localhost:7001, server https://localhost:7002).
  • You want to preview a specific Storybook component by its story hash (e.g., /storybook#component-name).
  • You need to inspect component behavior that requires scrolling or interactive script execution.
  • You want visual confirmation of UI changes during development or code review.
  • You need automated visual capture for documentation, bug reports, or handoff assets.

Best practices

  • Confirm the target dev server is running and note the URL in .amp/dev-environment.txt if available.
  • Address Storybook by the kebab-case story title derived from the filename (remove -story.svelte).
  • Use press_key with End or PageDown to reveal lazy content before screenshotting.
  • Use evaluate_script to set up component state or data fixtures when needed.
  • Open a new_page for each distinct capture to avoid tab state interference and use list_pages to manage tabs.

Example use cases

  • Capture the #thread or #thread-reply-area story from the webview Storybook to review messaging UI.
  • Open the server Storybook and screenshot #thread-feed-list to validate virtualized list rendering.
  • Run evaluate_script to populate a component with test data and then take a screenshot for a PR.
  • Scroll to the bottom of a long thread with press_key End and capture the final view for a bug report.
  • Programmatically capture OG image variants from the #og-images story for marketing previews.

FAQ

How do I target a specific Storybook story?

Append the kebab-case story title as a hash to /storybook, for example /storybook#handoff-tool.

What if the local tools become unavailable?

Reload the skill or restart the dev servers. Confirm URLs in .amp/dev-environment.txt and retry.