---
title: "Component Skills"
description: "Component skill files are structured references that teach AI assistants and humans how to build each component's HTML correctly."
slug: "component-skills"
---

import { DocPage, PageHeader, SkillPanel, Example, ExampleLabel, ExampleHint, ExampleCode, SourceFiles, SourceNote, StatesSection, CodeBlock, Demo, DemoCode, ChangelogEntries, ArchBody, StatsClaim, StatsCards, PageOverlay, DocText, DocLink, H2, SkillField, SkillText, SkillRow, SkillGrid, Variant, ApiPill, Dim, CodeWindow, CodeCard, TableCard } from "../../lib/components/index";

<DocPage meta={meta}>

<PageHeader slug="component-skills" title="Component Skills" introStyle="max-width:38rem;">
  Every component includes a <code>component-skill.md</code> file - a structured reference that teaches both AI assistants and humans how to build that component's HTML correctly. And every skill is indexed in <code>dist/SKILL.md</code> - the single entry point an agent should read first.
</PageHeader>

<H2>What is a component skill?</H2>

<p class="text-sm text-muted-foreground mb-5">A component skill is a Markdown file that documents the <strong>HTML pattern</strong> for a component - what elements to use, which attributes to set, what variants and sizes are available, and the ARIA requirements. It's the single source of truth for how to write the markup.</p>

<p class="text-sm text-muted-foreground mb-5">Component skills don't contain CSS or JavaScript code - those live in their own files alongside the skill. The skill focuses purely on the HTML structure and its configuration options.</p>

<CodeWindow lang="text" title="file location" mb="2.5rem" code={"dist/components/{name}/\n├── component-skill.md   ← the skill file (HTML reference)\n├── {name}.css           ← component stylesheet\n└── {name}.js            ← interaction JS (if needed)"} />

<div class="sep" />

<H2>The SKILL.md index</H2>

<p class="text-sm text-muted-foreground mb-5"><code>dist/SKILL.md</code> is the generated entry point of the whole system - integration instructions, the library's philosophy, a map of the <code>dist/</code> layout, and one index entry per component (its taxonomy type, why to use it, when to reach for it, which files ship it, and which states it supports). It is built on every build from <code>SKILL\_tpl.md</code> plus each skill's frontmatter, so it can never drift from the skills it indexes.</p>

```diagram
{
  "type": "flow",
  "eyebrow": "How a component skill ships",
  "title": "Every build regenerates the indexes from the skills",
  "caption": "verify fails the build when a skill’s frontmatter is missing or an index lags behind it. Play it, or click a node to see what feeds it and what checks it.",
  "steps": true,
  "autoplay": true,
  "interactive": true,
  "cols": 3,
  "nodes": [
    {
      "id": "verify",
      "name": "verify.ts",
      "col": 1,
      "row": 1,
      "step": 4,
      "shape": "diamond",
      "tone": "warn"
    },
    {
      "id": "skill",
      "eyebrow": "Source",
      "name": "component-skill.md",
      "meta": "src/components/{name}/",
      "col": 1,
      "row": 2,
      "step": 1
    },
    {
      "id": "tpl",
      "eyebrow": "Source",
      "name": "SKILL_tpl.md",
      "meta": "src/",
      "col": 1,
      "row": 4,
      "step": 1
    },
    {
      "id": "build",
      "name": "scripts/build.ts",
      "meta": "every build",
      "col": 2,
      "row": 3,
      "step": 2,
      "shape": "pill",
      "tone": "accent"
    },
    {
      "id": "dist",
      "eyebrow": "Ships",
      "name": "component-skill.md",
      "meta": "dist/components/{name}/",
      "col": 3,
      "row": 2,
      "step": 3
    },
    {
      "id": "index",
      "eyebrow": "Generated",
      "name": "dist/SKILL.md",
      "meta": "one entry per component",
      "col": 3,
      "row": 3,
      "step": 3
    },
    {
      "id": "root",
      "eyebrow": "Generated",
      "name": "skills/…/SKILL.md",
      "meta": "the Agent Skill + references/",
      "col": 3,
      "row": 4,
      "step": 3
    }
  ],
  "edges": [
    {
      "from": "skill",
      "to": "build",
      "step": 2,
      "flow": true
    },
    {
      "from": "tpl",
      "to": "build",
      "step": 2,
      "flow": true
    },
    {
      "from": "build",
      "to": "dist",
      "step": 3,
      "flow": true
    },
    {
      "from": "build",
      "to": "index",
      "step": 3,
      "flow": true
    },
    {
      "from": "build",
      "to": "root",
      "step": 3,
      "flow": true
    },
    {
      "from": "verify",
      "to": "skill",
      "label": "frontmatter",
      "line": "dashed",
      "step": 4
    },
    {
      "from": "verify",
      "to": "index",
      "label": "index fresh",
      "line": "dashed",
      "curve": "around",
      "step": 4
    },
    {
      "from": "verify",
      "to": "root",
      "label": "sources fresh",
      "line": "dashed",
      "curve": "around",
      "step": 4
    }
  ]
}
```

<p class="text-sm text-muted-foreground mb-5"><strong>If you are an agent wiring this library into a project, point yourself at <a class="link" href="https://github.com/kyr0/defuss-shadcn/blob/main/dist/SKILL.md"><code>dist/SKILL.md</code></a> first</strong> - it tells you what to include, which skill to read next, and where the state screenshots live (<code>screenshots/\{light,dark\}/\{name\}-\{state\}.png</code> in the source repo), so you can look up exactly what an "open modal" or "collapsed sidebar" should look like before you build it.</p>

<div class="sep" />

<H2>Skill file structure</H2>

<p class="text-sm text-muted-foreground mb-5">Every component skill opens with a YAML frontmatter block and then follows a consistent template with these sections in order:</p>

<div style="display:grid;grid-template-columns:auto 1fr;gap:0.5rem 1rem;margin-bottom:2.5rem;align-items:baseline;">
  <span class="def-term">0. Frontmatter</span>
  <span class="text-sm text-muted-foreground">Machine-readable header (<code>name</code>, <code>type</code>, <code>why</code>, <code>when</code>, <code>where</code>, <code>supportedStates</code>) that <code>SKILL.md</code> is generated from - required on every skill and enforced by <code>verify</code>.</span>
  <span class="def-term">1. Native basis</span>
  <span class="text-sm text-muted-foreground">Which HTML element or browser API the component builds on. Every component starts from native semantics.</span>
  <span class="def-term">2. Native Web APIs</span>
  <span class="text-sm text-muted-foreground">Bulleted list of significant platform APIs used (Popover API, CSS Anchor Positioning, <code>&lt;dialog&gt;</code>, etc.) with MDN links.</span>
  <span class="def-term">3. Structure</span>
  <span class="text-sm text-muted-foreground">Complete HTML markup showing the component's element hierarchy, class names, and required attributes.</span>
  <span class="def-term">4. Variants</span>
  <span class="text-sm text-muted-foreground">Table of <code>data-variant</code> values with descriptions and example markup.</span>
  <span class="def-term">5. Sizes</span>
  <span class="text-sm text-muted-foreground">Table of <code>data-size</code> values (if the component supports them).</span>
  <span class="def-term">6. Accessibility</span>
  <span class="text-sm text-muted-foreground">Required ARIA attributes, keyboard interactions, and screen reader considerations.</span>
  <span class="def-term">7. Notes</span>
  <span class="text-sm text-muted-foreground">Edge cases, composition tips, caveats, and integration notes.</span>
</div>

<div class="sep" />

<h2 id="component-taxonomy" class="h2-display">Component taxonomy</h2>

<p class="text-sm text-muted-foreground mb-5">Every component is classified with exactly one type, expressed in three places that <code>verify</code> keeps in sync: the skill's <code>type:</code> frontmatter (source of truth), the sidebar badge, and the badge on the component's doc page. Classification never leaks into component names - <code>Button</code>, never <code>ButtonAtom</code>.</p>

<div style="display:grid;gap:0.5rem;margin-bottom:2.5rem;">
  <div class="flex items-center gap-2">
    <span class="type-badge" data-type="ATM" title="Atom">ATM</span>
    <span class="text-sm text-muted-foreground"><strong>Atom</strong> - contains no descendant components (any DOM inside, but no other component).</span>
  </div>
  <div class="flex items-center gap-2">
    <span class="type-badge" data-type="MOL" title="Molecule">MOL</span>
    <span class="text-sm text-muted-foreground"><strong>Molecule</strong> - ≥1 direct child component, all atoms.</span>
  </div>
  <div class="flex items-center gap-2">
    <span class="type-badge" data-type="ORG" title="Organism">ORG</span>
    <span class="text-sm text-muted-foreground"><strong>Organism</strong> - direct children are atoms and/or molecules, with ≥1 molecule.</span>
  </div>
  <div class="flex items-center gap-2">
    <span class="type-badge" data-type="BLK" title="Block">BLK</span>
    <span class="text-sm text-muted-foreground"><strong>Block</strong> - a self-contained sectional slice of a template (header, hero, pricing, footer...); arbitrary nesting inside.</span>
  </div>
  <div class="flex items-center gap-2">
    <span class="type-badge" data-type="TPL" title="Template">TPL</span>
    <span class="text-sm text-muted-foreground"><strong>Template</strong> - the whole page/UI composition of blocks and anything else.</span>
  </div>
</div>

<div class="sep" />

<H2>Example: Badge skill file</H2>

<p class="text-sm text-muted-foreground mb-5">Here's the complete skill file for the Badge component - one of the simplest components in the system.</p>

<CodeWindow lang="markdown" title="dist/components/badge/component-skill.md" mb="2.5rem" code={"---\nname: Badge\ntype: ATM\nwhy: Pure-CSS <span> chip with emphasis variants -\n     nothing to wire up.\nwhen: Short status, version, or count labels next to\n      content - not for actions.\nwhere: dist/components/badge/badge.css\nsupportedStates: default\n---\n\n# Pattern: Badge\n\n## Native basis\n`<span>` element. No interactivity required -\npure visual indicator.\n\n---\n\n## Native Web APIs\n- [`<span>`](https://developer.mozilla.org/...)\n  - inline container for phrasing content\n\n---\n\n## Structure\n\n```html\n<span class=\"badge\" data-variant=\"default\">\n  Badge\n</span>\n```\n\n---\n\n## Variants\n\n| `data-variant` | Purpose                    |\n|----------------|----------------------------|\n| `default`      | Primary bg, high emphasis  |\n| `secondary`    | Secondary bg, medium       |\n| `outline`      | Border only, low emphasis  |\n\n```html\n<span class=\"badge\" data-variant=\"default\">\n  New\n</span>\n<span class=\"badge\" data-variant=\"secondary\">\n  Draft\n</span>\n<span class=\"badge\" data-variant=\"outline\">\n  v0.1.0\n</span>\n```\n\n---\n\n## Accessibility\n\n- Use descriptive text content - badges are\n  read inline by screen readers.\n- If the badge is purely decorative, add\n  `aria-hidden=\"true\"`."} />

<div class="sep" />

<H2>Using skills with AI assistants</H2>

<p class="text-sm text-muted-foreground mb-5">Component skills are designed to give AI assistants everything they need to generate correct, accessible markup in a single reference. Here's how to use them:</p>

<div style="display:grid;grid-template-columns:auto 1fr;gap:0.75rem 1.5rem;margin-bottom:1.5rem;align-items:baseline;">
  <span class="def-term">Start at SKILL.md</span>
  <span class="text-sm text-muted-foreground">Give the agent <code>dist/SKILL.md</code> as its entry point: it explains integration and philosophy once, then points at the right component skill - the agent only reads the skills it actually needs.</span>
  <span class="def-term">Copy &amp; paste</span>
  <span class="text-sm text-muted-foreground">Copy the skill file content into your AI chat alongside your request. The AI will use it as context to generate correct markup.</span>
  <span class="def-term">File reference</span>
  <span class="text-sm text-muted-foreground">In tools that support file context (Copilot, Cursor, etc.), point the AI at <code>dist/components/\{name\}/component-skill.md</code>.</span>
  <span class="def-term">Multiple skills</span>
  <span class="text-sm text-muted-foreground">For pages with multiple components, provide all relevant skill files. The AI will compose them correctly.</span>
</div>

<CodeWindow lang="markdown" title="example AI prompt" mb="2.5rem" code={"Using the defuss-shadcn component system, build a\nsettings page with:\n- A card containing a form with two text inputs\n- A destructive button to delete the account\n- A toast notification on save\n\nHere are the component skills:\n[paste card, form, input, button, and toast skills]"} />

<div class="sep" />

<H2>Using skills as a human reference</H2>

<p class="text-sm text-muted-foreground mb-5">Even without AI, skill files serve as quick references. Need to know what variants a Badge supports? Open <code>component-skill.md</code> and check the variants table. Need the exact ARIA attributes for a Combobox? The accessibility section has them.</p>

<div style="display:grid;grid-template-columns:auto 1fr;gap:0.5rem 1rem;margin-bottom:2.5rem;align-items:baseline;">
  <span class="def-term">Quick lookup</span>
  <span class="text-sm text-muted-foreground">Skill files are faster than searching through CSS for which <code>data-variant</code> values exist or scanning JS for keyboard bindings.</span>
  <span class="def-term">Copy-paste HTML</span>
  <span class="text-sm text-muted-foreground">The Structure section gives you copy-paste-ready markup with all required attributes already in place.</span>
  <span class="def-term">ARIA checklist</span>
  <span class="text-sm text-muted-foreground">The Accessibility section doubles as a checklist to verify your implementation covers all accessibility requirements.</span>
</div>

<div class="sep" />

<H2>Available skills</H2>

<p class="text-sm text-muted-foreground mb-8">Every component in the library has a skill file at <code>dist/components/\{name\}/component-skill.md</code>, and all of them are listed with their why/when/where and supported states in <code>dist/SKILL.md</code>. Browse the component pages in the sidebar to see the full list. Each component's documentation page includes a link to view its skill file.</p>

</DocPage>
