Source profileQuality 86/100

commontoolsinc/labs/skills/lit-component/SKILL.md

lit-component

Guide for developing Lit web components in the Common UI v2 system (@commonfabric/ui). Use when creating or modifying cf- prefixed components, implementing theme integration, working with Cell abstractions, or building reactive UI components that integrate with the Common Fabric runtime.

Source repository stars
37
Declared platforms
0
Static risk flags
1
Last source update
2026-08-05
Source checked
2026-08-05

Decision brief

What it does—and where it fits

This skill provides guidance for developing Lit web components within the Common UI v2 component library (packages/ui/src/v2).

Best for

  • Creating new cf- prefixed components in the UI package
  • Modifying existing Common UI v2 components
  • Implementing theme-aware components

Not for

  • ❌ Forgetting to clean up Cell subscriptions (causes memory leaks)
  • ❌ Mutating Cells without transactions (breaks reactivity)

Compatibility matrix

Platform support, with evidence labels

PlatformStatusEvidenceWhat to check
CodexNot declaredNo explicit evidencePortability before use
Claude CodeNot declaredNo explicit evidencePortability before use
CursorNot declaredNo explicit evidencePortability before use
Gemini CLINot declaredNo explicit evidencePortability before use
Open the compatibility checker

Installation

Inspect first. Install second.

The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

Source-detected install commandSource
npx skills add https://github.com/commontoolsinc/labs --skill "skills/lit-component"
Safe inspection promptEditorial

Inspect the Agent Skill "lit-component" from https://github.com/commontoolsinc/labs/blob/b0ff67d2dde1812680849aa2373df1f49b6faa2f/skills/lit-component/SKILL.md at commit b0ff67d2dde1812680849aa2373df1f49b6faa2f. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

Workflow

What the source asks the agent to do

  1. 01

    Quick Start Pattern

    Identify which category the component falls into:

    Layout: Arranges other components (vstack, hstack, screen)Visual: Displays styled content (separator, skeleton, label)Input: Captures user interaction (button, input, checkbox)
  2. 02

    When to Use This Skill

    Do NOT use this skill when authoring or styling pattern UIs that consume cf- components — that's pattern-ui's job. Patterns must never touch component internals, and pattern JSX uses theme={...}, not Lit's .theme=${...}.

    Creating new cf- prefixed components in the UI packageModifying existing Common UI v2 componentsImplementing theme-aware components
  3. 03

    Core Philosophy

    Common UI is inspired by SwiftUI and emphasizes:

    Default Configuration Works: Components should work together with minimalComposition Over Control: Emphasize composing components rather thanAdaptive to User Preferences: Respect system preferences and theme
  4. 04

    1. Choose Component Category

    Identify which category the component falls into:

    Layout: Arranges other components (vstack, hstack, screen)Visual: Displays styled content (separator, skeleton, label)Input: Captures user interaction (button, input, checkbox)
  5. 05

    2. Create Component Files

    Create the component directory structure:

    Create the component directory structure:

Permission review

Static risk signals and limitations

Writes files

medium · line 60

The documentation asks the agent to create, modify, or delete local files.

Create the component directory structure:

Writes files

medium · line 113

The documentation asks the agent to create, modify, or delete local files.

### 4. Create Index File

Evidence record

Why each signal appears

EvidenceSourceComputedTestedEditorial
SignalValueEvidence typeMeaning
Quality score86/100ComputedDocumentation, specificity, maintenance, and trust rules
Repository stars37SourceRepository attention, not individual Skill quality
Compatibility0 platformsSourceDeclared in the catalog source record
Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

Pinned source

Provenance and original SKILL.md

Repository
commontoolsinc/labs
Skill path
skills/lit-component/SKILL.md
Commit
b0ff67d2dde1812680849aa2373df1f49b6faa2f
License
0BSD
Collected
2026-08-05
Default branch
main
View the original SKILL.md

Lit Component Development for Common UI

This skill provides guidance for developing Lit web components within the Common UI v2 component library (packages/ui/src/v2).

When to Use This Skill

Use this skill when:

  • Creating new cf- prefixed components in the UI package
  • Modifying existing Common UI v2 components
  • Implementing theme-aware components
  • Integrating components with Cell abstractions from the runtime
  • Building reactive components for pattern UIs
  • Debugging component lifecycle or reactivity issues

Do NOT use this skill when authoring or styling pattern UIs that consume cf- components — that's pattern-ui's job. Patterns must never touch component internals, and pattern JSX uses theme={...}, not Lit's .theme=${...}.

Core Philosophy

Common UI is inspired by SwiftUI and emphasizes:

  1. Default Configuration Works: Components should work together with minimal configuration
  2. Composition Over Control: Emphasize composing components rather than granular styling
  3. Adaptive to User Preferences: Respect system preferences and theme settings (theme is ambient context, not explicit props)
  4. Reactive Binding Model: Integration with FRP-style Cell abstractions from the runtime
  5. Progressive Enhancement: Components work with plain values but enhance with Cells for reactivity
  6. Separation of Concerns: Presentation components, theme-aware inputs, Cell-aware state, runtime-integrated operations

Quick Start Pattern

1. Choose Component Category

Identify which category the component falls into:

  • Layout: Arranges other components (vstack, hstack, screen)
  • Visual: Displays styled content (separator, skeleton, label)
  • Input: Captures user interaction (button, input, checkbox)
  • Complex/Integrated: Deep runtime integration with Cells (render, code-editor, outliner)

Complexity spectrum: Components range from pure presentation (no runtime) to deeply integrated (Cell operations, pattern execution, backlink resolution). Choose the simplest pattern that meets requirements.

See references/component-patterns.md for detailed patterns for each category and references/advanced-patterns.md for complex integration patterns.

2. Create Component Files

Create the component directory structure:

packages/ui/src/v2/components/cf-component-name/
├── cf-component-name.ts    # Component implementation
├── index.ts                # Export and registration
└── styles.ts               # Optional: for complex components

3. Implement Component

Basic template:

import { css, html } from "lit";
import { BaseElement } from "../../core/base-element.ts";

export class CFComponentName extends BaseElement {
  static override styles = [
    BaseElement.baseStyles,
    css`
      :host {
        display: block;
        box-sizing: border-box;
      }

      *,
      *::before,
      *::after {
        box-sizing: inherit;
      }
    `,
  ];

  static override properties = {
    // Define reactive properties
  };

  constructor() {
    super();
    // Set defaults
  }

  override render() {
    return html`
      <!-- component template -->
    `;
  }
}

globalThis.customElements.define("cf-component-name", CFComponentName);

4. Create Index File

import { CFComponentName } from "./cf-component-name.ts";

if (!customElements.get("cf-component-name")) {
  customElements.define("cf-component-name", CFComponentName);
}

export { CFComponentName };
export type {}; /* exported types */

Both registrations are the codebase convention, not a contradiction: the component file registers unconditionally when it is imported, and the index file's guarded define is a safe no-op in that case — it only registers when the component module didn't (and prevents duplicate-registration errors during hot module replacement). Keep both.

Theme Integration

Most components should use var(--cf-theme-*) CSS variables with fallbacks (--cf-theme-* first, then --cf-* base token, then a literal). Consume cfThemeContext (with applyThemeToElement) only when JavaScript needs the theme object for runtime logic, derived values, or applying theme variables to dynamically created elements.

Theme consumption code and complete reference: See references/theme-system.md for the @consume boilerplate, all available CSS variables, and helper functions.

Cell Integration

For components that work with reactive runtime data, declare the cell as @property({ attribute: false }), subscribe with cell.sink(() => this.requestUpdate()) when the cell property changes, and read with cell.get() in render() (guarding the no-cell case). The pitfalls that matter:

  • Clean up the previous subscription before subscribing to a new cell, and unsubscribe in disconnectedCallback() (memory leaks)
  • Check isCell(this.cell) before subscribing
  • Mutate cells through transactions, never directly

Subscription boilerplate and complete Cell patterns: See references/cell-integration.md for subscription management, nested property access with .key(), array cell manipulation, transaction-based mutations, and finding cells by equality.

Reactive Controllers

For reusable component behaviors, use reactive controllers. Example: InputTimingController for debouncing/throttling:

import { InputTimingController } from "../../core/input-timing-controller.ts";

export class CFInput extends BaseElement {
  @property()
  timingStrategy: "immediate" | "debounce" | "throttle" | "blur" = "debounce";

  @property()
  timingDelay: number = 500;

  private inputTiming = new InputTimingController(this, {
    strategy: this.timingStrategy,
    delay: this.timingDelay,
  });

  private handleInput(event: Event) {
    const value = (event.target as HTMLInputElement).value;

    this.inputTiming.schedule(() => {
      this.emit("cf-change", { value });
    });
  }
}

Common Patterns

Event Emission

Use the emit() helper from BaseElement:

private handleChange(newValue: string) {
  this.emit("cf-change", { value: newValue });
}

Events are automatically bubbles: true and composed: true.

Dynamic Classes

Use classMap for conditional classes:

import { classMap } from "lit/directives/class-map.js";

const classes = {
  button: true,
  [this.variant]: true,
  disabled: this.disabled,
};

return html`
  <button class="${classMap(classes)}">...</button>
`;

List Rendering

Use repeat directive with stable keys:

import { repeat } from "lit/directives/repeat.js";

return html`
  ${repeat(
    items,
    (item) => item.id, // stable key
    (item) =>
      html`
        <div>${item.title}</div>
      `,
  )}
`;

Testing

Colocate tests with components:

// cf-button.test.ts
import { describe, it } from "@std/testing/bdd";
import { expect } from "@std/expect";
import { CFButton } from "./cf-button.ts";

describe("CFButton", () => {
  it("should be defined", () => {
    expect(CFButton).toBeDefined();
  });

  it("should have default properties", () => {
    const element = new CFButton();
    expect(element.variant).toBe("primary");
  });
});

Run with: deno task test (includes required flags)

Package Structure

Each component is declared in its own directory under packages/ui/src/v2/components/. packages/ui/src/v2/index.ts re-exports every component, and the package root re-exports that in turn, so consumers import them from @commonfabric/ui:

// packages/ui/src/v2/index.ts
export * from "./components/cf-button/index.ts";

Reference Documentation

Load these references as needed for detailed guidance:

  • references/component-patterns.md - Detailed patterns for each component category, file structure, type safety, styling conventions, event handling, and lifecycle methods
  • references/theme-system.md - Theme philosophy, cf-theme provider, CFTheme interface, CSS variables, and theming patterns
  • references/cell-integration.md - Comprehensive Cell integration patterns including subscriptions, mutations, array handling, and common pitfalls
  • references/advanced-patterns.md - Advanced architectural patterns revealed by complex components: context provision, third-party integration, reactive controllers, path-based operations, diff-based rendering, and progressive enhancement

Key Conventions

  1. Always extend BaseElement - Provides emit() helper and base CSS variables
  2. Include box-sizing reset - Ensures consistent layout behavior
  3. Use attribute: false for objects/arrays/Cells - Prevents serialization errors
  4. Prefix custom events with cf- - Namespace convention
  5. Export types separately - Use export type { ... }
  6. Clean up subscriptions - Always unsubscribe in disconnectedCallback()
  7. Use transactions for Cell mutations - Never mutate cells directly
  8. Provide CSS variable fallbacks - Components should work without theme context
  9. Document with JSDoc - Include @element, @attr, @fires, @example
  10. Run tests with deno task test - Not plain deno test

Common Pitfalls to Avoid

  • ❌ Forgetting to clean up Cell subscriptions (causes memory leaks)
  • ❌ Mutating Cells without transactions (breaks reactivity)
  • ❌ Using array index as key in repeat() (breaks reactivity)
  • ❌ Missing box-sizing reset (causes layout issues)
  • ❌ Not providing CSS variable fallbacks (breaks without theme)
  • ❌ Using attribute: true for objects/arrays (serialization errors)
  • ❌ Skipping super calls in lifecycle methods (breaks base functionality)

Architecture Patterns to Study

Study these components to understand architectural patterns:

Basic patterns:

  • Simple visual: cf-separator - Minimal component, CSS parts, ARIA
  • Layout: cf-vstack - Flexbox abstraction, utility classes with classMap
  • Themed input: cf-button - Theme consumption, event emission, variants

Advanced patterns:

  • Context provider: cf-theme - Ambient configuration with @provide, display: contents, reactive Cell subscriptions
  • Runtime rendering: cf-render - Pattern loading, UI extraction, lifecycle management
  • Third-party integration: cf-code-editor - CodeMirror lifecycle, Compartments, bidirectional sync, CellController
  • Legacy tree editor patterns: historical outliner implementation - Path-based operations, diff-based rendering, keyboard commands, MentionController

Each component reveals deeper patterns - study them not just for API but for architectural principles.

Alternatives

Compare before choosing

Computed 10043,034

coreyhaines31/marketingskills

ab-testing

When the user wants to plan, design, or implement an A/B test or experiment, or build a growth experimentation program. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "should I test this," "which version is better," "test two versions," "statistical significance," "how long should I run this test," "growth experiments," "experiment velocity," "experiment backlog," "ICE score," "experimentation program

Computed 10043,034

coreyhaines31/marketingskills

churn-prevention

When the user wants to reduce churn, build cancellation flows, set up save offers, recover failed payments, or implement retention strategies. Also use when the user mentions 'churn,' 'cancel flow,' 'offboarding,' 'save offer,' 'dunning,' 'failed payment recovery,' 'win-back,' 'retention,' 'exit survey,' 'pause subscription,' 'involuntary churn,' 'people keep canceling,' 'churn rate is too high,' 'how do I keep users,' or 'customers are leaving.' Use this whenever someone is losing subscribers o

Computed 10014,533

prowler-cloud/prowler

postgresql-indexing

PostgreSQL indexing best practices for Prowler: index design, partial indexes, partitioned table indexing, EXPLAIN ANALYZE validation, concurrent operations, monitoring, and maintenance. Trigger: When creating or modifying PostgreSQL indexes, analyzing query performance with EXPLAIN, debugging slow queries, reviewing index usage statistics, reindexing, dropping indexes, or working with partitioned table indexes. Also trigger when discussing index strategies, partial indexes, or index maintenance

Computed 100165

JasonColapietro/suede-creator-skills

suede-ab-testing

Suede-owned experimentation discipline for hypotheses, sample sizing, test duration, significance, and repeatable experiment programs. Use when comparing variants, deciding whether a result is reliable, or building an experiment backlog and cadence. NOT FOR: analytics instrumentation (use suede-analytics), post-click conversion diagnosis (use suede-site-alchemy), or writing the variant copy itself (use suede-copy).