bitovi/ai-enablement-prompts/discover-visual-states
Claude Code and agent skill by bitovi/ai-enablement-prompts
- community
Checking that the SKILL.md file is still in the repository.
Discover all visual states of a component by interactively exploring the production baseline page — not by reading story files. Finds every interactive element (nav items, dropdowns, toggles, buttons) that produces a distinct visual state, records the interactions needed to reach each one, and saves a pixel-perfect.config.json that the pixel-perfect skill uses to replay those same interactions on both production and Storybook. Run this once per component; re-run when the production page changes.
Install
npx vskill@latest install bitovi/ai-enablement-prompts/discover-visual-statesSKILL.md
Skill: Discover Visual States
Explore the production page to discover every distinct visual state a component can be in. Save the interactions needed to reach each state to pixel-perfect.config.json. The pixel-perfect skill then replays those same interactions on both production and Storybook — no separate story per state required.
When to Use
- Before running
pixel-perfecton a component for the first time - When the production page has gained new interactive states
- When
pixel-perfect.config.jsondoes not exist yet for a component
When NOT to Use
- When
pixel-perfect.config.jsonalready exists and is up to date (pixel-perfect will tell you) - For components with no interactive states (config will just have the default state)
Inputs
| Input | Required | Example | |
|---|---|---|---|
| Baseline URL | Yes | https://www.bitovi.com | |
| Component scope hint | Yes | navbar, header nav, [aria-label="Main navigation"] — narrows which part of the page to inspect | |
| Storybook default story URL | Yes | http://localhost:6007/iframe.html?id=components-meganavbar--default&viewMode=story | |
| Config output path | Auto-derived | temp/MegaNavBar/pixel-perfect.config.json — always temp/{ComponentName}/pixel-perfect.config.json |
Output: pixel-perfect.config.json
Workflow
Step 1: Check for existing config
Derive the config path from the component name: temp/{ComponentName}/pixel-perfect.config.json (e.g. MegaNavBar → temp/MegaNavBar/pixel-perfect.config.json). Create the directory if it does not exist.
Look for pixel-perfect.config.json at that path.
- If it exists: read it, show the user the current states, ask whether to re-discover or use as-is.
- If it does not exist: proceed to Step 2.
Step 2: Navigate to baseline and scope the component
- Navigate to the baseline URL with Playwright
- Dismiss any cookie banners or overlays
- Resize viewport to 1280x720
- Wait for the page to fully load (2 seconds)
- Use
mcp_playwright_browser_evaluateto find the component root element using the scope hint:
Step 3: Discover interactive elements
Within the scoped component, find all elements that can produce a distinct visual state. Run this evaluation:
Deduplicate by text. This gives a raw list of interactive elements.
Step 4: Probe each element to confirm it produces a distinct visual state
For each candidate, probe it by hovering and clicking to see if the page changes:
- Reset: reload the baseline URL (fresh state)
- Apply interaction (
hoverfirst, thenclickif hover produces nothing):
- Use
mcp_playwright_browser_snapshotto find the element ref by its text - Use
mcp_playwright_browser_hoverormcp_playwright_browser_click - Wait 500ms
- Check if state changed: look for newly visible elements (dropdowns, panels, overlays) using:
- If new content appeared: take a screenshot, record this as a distinct state with the interaction that triggered it
- If nothing changed: skip this element — it doesn't produce a distinct visual state in the component's scope
Step 5: Determine interaction type (hover vs click)
For nav items and dropdowns, prefer hover if it opens the state — it more accurately reflects the production behavior. Use click for toggles (contact forms, mobile menus, accordions).
Heuristic:
- If the element has
aria-expandedthat changes on hover → usehover - If clicking is required to toggle → use
click - If both work → prefer
hoverfor dropdowns,clickfor forms/panels
Step 6: Build and confirm the config
Assemble the states list:
- Always include
{ label: "default", interactions: [] }as the first state - Add one entry per probed interaction that produced a distinct visual state
- Use kebab-case for
labelderived from the element text (e.g. "Services" → "services-dropdown", "Contact Us" → "contact-form")
Show the proposed config to the user in a formatted block:
Wait for user confirmation before saving.
Step 7: Verify interactions work on Storybook too
Navigate to the storybookUrl. For each state (except default), attempt the interaction on the Storybook component using the same text/role target.
- If the element is found and the interaction works → mark ✅
- If the element is not found or produces no visible change → mark ⚠️ and note it in the config with
"storybookWarning": "element not found"
This catches mismatches early — e.g. if the Storybook component uses different text for a button.
Step 8: Save config
Write pixel-perfect.config.json to the specified output path. Confirm the saved path to the user.
Interaction Object Reference
Target format:
text:X— find the first visible element whose trimmed text content isXrole:button:X— find<button>orrole="button"with accessible nameXlabel:X— find an input associated with label textXselector:X— useXdirectly as a CSS selector (last resort)
When replaying interactions in pixel-perfect, translate targets to Playwright MCP calls:
mcp_playwright_browser_snapshot→ find the ref matching the target descriptionmcp_playwright_browser_hover/mcp_playwright_browser_clickwith that ref
Example Output
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/playwright/skills/discover-visual-states/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/bitovi/ai-enablement-prompts/discover-visual-states)