Agent skill
storybook
Script Kit GPUI design explorer (storybook) system. Use when adding stories, footer/input variations, working with the StoryBrowser, design adoption, chrome audits, or the storybook CLI binary. Covers story registration, variant compare mode, selection persistence, and live adoption wiring.
Install this agent skill to your Project
npx add-skill https://github.com/johnlindquist/script-kit-next/tree/main/.claude/skills/storybook
SKILL.md
Storybook / Design Explorer
In-app design explorer for comparing, selecting, and adopting UI variations across prompt surfaces. Stories render real components — footer, input, header, action dialog variants — in a browsable, comparable format with persistent selection.
Key Concepts
| Concept | What it means |
|---|---|
| Story | A trait impl that renders one or more variants of a UI surface |
| StoryBrowser | The GPUI entity that hosts browsing, compare mode, and adoption |
| Variation | A declarative spec (e.g., FooterVariationSpec) defining a design option |
| Adoption | Persisting a selected variant so live prompt surfaces use it at runtime |
| Chrome Audit | Structured log that validates minimal chrome compliance per surface |
File Map
| Path | Role |
|---|---|
src/storybook/mod.rs |
Module root; re-exports; JSON error payloads |
src/storybook/story.rs |
Story trait, StorySurface enum, StoryVariant |
src/storybook/registry.rs |
Lookup, filtering, first_story_with_multiple_variants() |
src/storybook/browser.rs |
StoryBrowser entity (~1400 lines) |
src/storybook/selection.rs |
StorySelectionStore, atomic persistence |
src/storybook/diagnostics.rs |
StoryCatalogSnapshot for machine-readable catalog |
src/storybook/footer_variations/ |
5 footer specs + rendering + adoption resolution |
src/storybook/input_variations/ |
5 input specs + rendering + adoption resolution |
src/storybook/layout.rs |
UI helpers (story_container, story_section, etc.) |
src/stories/mod.rs |
Story registration (ALL_STORIES LazyLock) |
src/bin/storybook.rs |
Standalone binary with CLI flags |
Adding a New Story
- Create struct implementing
Storytrait insrc/stories/ - Return stable
id(), descriptivename(),category(), andsurface() - Implement
variants()returningVec<StoryVariant>with stable IDs - Implement
render_variant(&self, variant)to render each variant - Register in
ALL_STORIESinsrc/stories/mod.rs
pub struct MyStory;
impl Story for MyStory {
fn id(&self) -> &'static str { "my-component-variations" }
fn name(&self) -> &'static str { "My Component Variations" }
fn category(&self) -> &'static str { "Components" }
fn surface(&self) -> StorySurface { StorySurface::Component }
fn variants(&self) -> Vec<StoryVariant> {
vec![
StoryVariant::default_named("variant-a", "Variant A"),
StoryVariant::default_named("variant-b", "Variant B"),
]
}
fn render_variant(&self, variant: &StoryVariant) -> AnyElement {
match variant.stable_id() {
"variant-a" => /* render A */,
"variant-b" => /* render B */,
_ => self.render(),
}
}
}
Adding a New Variation System (Footer/Input Pattern)
Follow the footer_variations or input_variations pattern:
- Define an ID enum with
stable_id() -> &'static strandfrom_stable_id() - Define a declarative spec struct with design properties
- Create a const array of specs
- Implement
story_variants()converting specs toStoryVariant - Implement
render_preview(stable_id)rendering real components - Implement
adopted_*_variation()reading fromStorySelectionStore - Add tests for unique IDs, round-trip, and resolution
CLI Usage
# Interactive browser
cargo run --bin storybook
# Pre-select story + compare mode
cargo run --bin storybook -- --story footer-layout-variations --compare
# Non-interactive adoption (JSON output, exit code 0/2)
cargo run --bin storybook -- --adopt --story footer-layout-variations --variant minimal
# Machine-readable catalog
cargo run --bin storybook -- --catalog-json
# Screenshot capture
cargo run --bin storybook -- --story footer-layout-variations --screenshot
Selection Persistence
- File:
~/.kit/design-explorer-selections.json - Format:
{ "selections": { "<story_id>": "<variant_id>" } } - Atomic writes via temp file + rename
StorySelectionStoreinselection.rshandles load/savesave_selected_story_variant()returnsStorySelectionWriteResultwith previous value
Live Adoption Wiring
Footer adoption: config_from_storybook_footer_selection() reads persisted selection, resolves via resolve_footer_selection_spec(), falls back to RaycastExact.
Input adoption: adopted_input_variation() reads persisted selection, falls back to Bare.
Both are called at render time in live prompt surfaces.
Chrome Audit System
PromptChromeAudit in prompt_layout_shell.rs validates minimal chrome compliance:
PromptChromeAudit::minimal(...)for standard surfacesPromptChromeAudit::exception(surface, reason)for rich-chrome exceptionsemit_prompt_chrome_audit()logs once per unique audit (deduped via HashSet)- Warns if a non-exception surface uses
prompt_footermode
Testing
cargo test footer # Footer adoption + resolution
cargo test storybook # Browser, catalog, errors
cargo test chrome_audit # Audit dedup + emission
cargo test source_audit # Minimal chrome compliance
cargo test input_variation # Input adoption + resolution
References
references/architecture.md— Detailed type definitions, browser state, rendering pipeline, keyboard shortcuts
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
Generate Component Documentation
Based on existing docs styles and specific API implementations, and referencing same name stories, generate comprehensive documentation for the new component.
Generate Component Story
Generate a comprehensive story for a new component for as example.
new-component
How to write a new component of GPUI Component.
troubleshooting
Diagnose and fix common Script Kit issues. Use when the user reports bugs, crashes, missing features, or unexpected behavior in Script Kit GPUI.
script-authoring
Create and manage TypeScript scripts for Script Kit. Use when the user wants to write a new script, edit an existing script, or understand Script Kit's SDK and metadata system.
agents
Create mdflow-backed agent files for Script Kit. Use when the user wants to create AI agents, configure agent backends (Claude, Gemini, Codex), or manage agent metadata.
Didn't find tool you were looking for?