agentleFS
EndavaEndava/BEEQ/.agents/skills/write-stories/SKILL.md

write-stories

Skill162 starsChanged 13 days agoApache-2.0View on GitHub

Write Storybook stories and MDX for a `bq-*` component: argTypes, controls and variants for every state. Use when adding or updating a component''s stories. Files live in the component''s `__storybook__/` folder.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Always import from @storybook/web-components-vite (not @storybook/web-components):

    line 28
  2. Very specific:

    Use lit-html tagged template literals.

    line 75
  3. Very specific:

    Keep story-only styles inline in the story template.

    line 99
  4. Distinctive:

    Add a BEM-style class when a selector needs to target a specific element, or when styling is reused.

    line 118

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Write BEEQ Storybook Stories

When to Use

  • Adding stories for a new bq-* component
  • Adding missing story variants for component states
  • Updating stories after a component API change
  • Writing or updating the MDX documentation page

File Locations

packages/beeq/src/components/<name>/__storybook__/
├── bq-<name>.stories.tsx   # Story definitions
└── bq-<name>.mdx           # Documentation page

Stories File Structure

Always import from @storybook/web-components-vite (not @storybook/web-components):

import type { Args, Meta, StoryObj } from '@storybook/web-components-vite';
import { html, nothing } from 'lit-html';
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js'; // only if dynamic HTML needed
import { fn } from 'storybook/test';

import { isChromatic, skipSnapshotParameters } from '../../../../.storybook/chromatic-parameters';
import { BQ_COMPONENT_PROP_CONST } from '../bq-<name>.types';
import mdx from './bq-<name>.mdx';

const meta: Meta = {
  title: 'Components/<ComponentName>',
  component: 'bq-<name>',
  parameters: {
    docs: { page: mdx },
  },
  argTypes: {
    // @Prop() controls — use const arrays from types file for selects
    size: { control: 'select', options: [...BQ_COMPONENT_SIZE] },
    disabled: { control: 'boolean' },
    value: { control: 'text' },
    // Slot / story-only controls (hide from docs table)
    slotContent: { control: 'text', table: { disable: true } },
  },
  args: {
    size: 'medium',
    disabled: false,
    value: undefined,
    // @Event() handlers: use fn(), never `argTypes: { bqX: { action: 'bqX' } }`
    bqChange: fn(),
    bqFocus: fn(),
    bqBlur: fn(),
  },
};
export default meta;

type Story = StoryObj;

Event Actions

Declare every @Event() as args: { bqX: fn() } (from storybook/test) and bind it with @bqX=${args.bqX}. Do not use argTypes: { bqX: { action: 'bqX' } }: Storybook wraps those actions in mocks, so the Actions panel logs every event twice after a control change.

Template Pattern

Use lit-html tagged template literals. Handle boolean attributes with ?:

const Template = (args: Args) => html`
  <bq-<name>
    size=${args.size}
    ?disabled=${args.disabled}
    value=${args.value ?? nothing}
    @bqChange=${args.bqChange}
    @bqFocus=${args.bqFocus}
    @bqBlur=${args.bqBlur}
  >
    ${args.slotContent}
  </bq-<name>>
`;

export const Default: Story = {
  render: Template,
  args: {},
};

Story Styling

Keep story-only styles inline in the story template. Use a <style> block and semantic markup instead of utility classes:

const Template = () => html`
  <style>
    main {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: var(--bq-spacing-m);
      padding: var(--bq-spacing-m);
    }
  </style>
  <main>
    <section>...</section>
    <section>...</section>
  </main>
`;

Add a BEM-style class when a selector needs to target a specific element, or when styling is reused. Do not add a separate stylesheet for a story.

Required Story Variants

At minimum, provide stories for:

StoryPurpose
DefaultComponent in its default state
Disableddisabled prop set
WithPrefix / WithSuffixSlot usage where applicable
One story per primary variant/appearancee.g. Primary, Secondary, Ghost

Chromatic / Snapshot Handling

For animated or stateful components, opt out of Chromatic snapshots:

import { skipSnapshotParameters } from '../../../../.storybook/chromatic-parameters';

export const WithAnimation: Story = {
  render: Template,
  parameters: { ...skipSnapshotParameters },
};

For loading states, guard against Chromatic environment:

const Template = (args: Args) => {
  const loading = isChromatic() ? false : args.loading;
  return html`<bq-button ?loading=${loading}>...</bq-button>`;
};

MDX Documentation Page

The .mdx file should import and use <Stories /> and <ArgTypes /> from @storybook/blocks. Reference the component's design documentation link if available from https://www.beeq.design/.

Running Storybook

pnpm start             # run locally
pnpm build:storybook   # production build

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.