Command Palette

Search for a command to run...

Back to skills
skill № 03155

stencil

Use when the user asks about Stencil, @stencil/core, @Component/@Prop/@State/@Event decorators, a web component compiler, framework output targets or a…

FreeNo executable scripts
j4flmaoby j4flmao★ 47 GitHub stars

Install stencil in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

About this skill

Stencil

Purpose

Build reusable, framework-agnostic web components using Stencil's TypeScript-first compiler — optimized for design systems, component libraries, and performance-critical UIs.

Agent Protocol

Trigger

Exact user phrases: "Stencil setup", "Stencil component", "Stencil web component", "Stencil compiler", "Stencil design system", "Stencil project", "stencil component library".

Input Context

Before activating, verify:

  • @stencil/core is in devDependencies.
  • Whether building a standalone component library, a design system, or embedded in an app.
  • Target framework consumers (React, Vue, Angular, or vanilla).

Output Artifact

No file output. Produces code snippets and config examples as text.

Response Format

Component definition:

@Component({ tag: 'my-button', styleUrl: 'my-button.css' })
export class MyButton { ... }

No preamble. No postamble. No explanations. Compress output — why use many token when few do trick.

Completion Criteria

  • Components follow Stencil API: @Component, @Prop, @State, @Event, @Method.
  • Styles scoped with Shadow DOM or scoped CSS.
  • Reactive props with @Prop decorator (mutable or reflect).
  • Events emitted with @Event and EventEmitter.
  • Components tested with @stencil/jest or @stencil/playwright.
  • Library can be consumed as framework-agnostic or via framework bindings.
  • Build output includes lazy-loaded bundles.

Max Response Length

~4096 tokens.

Component Architecture / Decision Trees

Architecture Options

Approach Trade-off When to Use
Component with shadow DOM Style isolation Design system components
Component with scoped CSS Lighter, no shadow root App-specific components
Lazy-loaded (default) Loaded on demand Library distributed via CDN
Eager (customElementsExportBehavior) Available immediately Bundled library
dist output target Lazy loading + split Most use cases
dist-custom-elements Single bundle Bundler integration

Component Configuration Decision

Does the component need style isolation?
  Yes -> shadow: true (Shadow DOM, full isolation)
  No -> scoped: true (Scoped CSS, lighter, no shadow root)

Should the component be lazy-loaded?
  Yes (default) -> Stencil's output target handles this
  No (eager) -> Set customElementsExportBehavior

What output targets are needed?
  Reusable library -> dist (custom elements bundle)
  Framework integration -> dist-react, dist-vue, dist-angular
  Vanilla HTML usage -> www (full app with lazy loading)
  CDN distribution -> dist-custom-elements

Prop Design Decision

Should the prop be reflected to attribute?
  Yes -> reflect: true (useful for CSS selectors, framework bindings)
  No -> reflect: false (default, better performance)

Can the component mutate the prop internally?
  Yes -> mutable: true (component can change its own prop value)
  No -> mutable: false (default, prop is read-only)

What type is the prop?
  Primitive (string, number, boolean) -> Auto attribute serialization
  Complex (object, array) -> Pass via JS property (not HTML attr)

Component Design Patterns

Basic Component with Props

import { Component, Prop, h } from '@stencil/core'

@Component({ tag: 'my-button', styleUrl: 'my-button.css', shadow: true })
export class MyButton {
  @Prop({ reflect: true }) variant: 'primary' | 'secondary' = 'primary'
  @Prop({ reflect: true }) disabled = false

  render() {
    return (
      <button class={`btn btn--${this.variant}`} disabled={this.disabled}>
        <slot />
      </button>
    )
  }
}

Component with State and Events

import { Component, State, Event, EventEmitter, h } from '@stencil/core'

@Component({ tag: 'my-counter', shadow: true })
export class MyCounter {
  @Prop({ mutable: true }) value = 0
  @State() private internalValue = 0
  @Event() valueChange: EventEmitter<number>

  componentWillLoad() {
    this.internalValue = this.value
  }

  @Watch('value')
  watchValue(newValue: number) {
    this.internalValue = newValue
  }

  private increment() {
    this.internalValue++
    this.valueChange.emit(this.internalValue)
  }

  render() {
    return (
      <div>
        <p>Value: {this.internalValue}</p>
        <button onClick={() => this.increment()}>+</button>
      </div>
    )
  }
}

Form-Associated Component

@Component({ tag: 'my-input', formAssociated: true, shadow: true })
export class MyInput {
  @Prop() value = ''
  @Event() valueChange: EventEmitter<string>

  private handleInput(e: InputEvent) {
    const target = e.target as HTMLInputElement
    this.value = target.value
    this.valueChange.emit(this.value)
  }

  render() {
    return <input value={this.value} onInput={(e) => this.handleInput(e)} />
  }
}

State Management Patterns

Local State with @State

@State() private isOpen = false
@State() private items: Item[] =
Full SKILL.md on GitHub

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

  • references/stencil-advanced.md
  • references/stencil-architecture.md
  • references/stencil-components.md
  • references/stencil-deployment.md
  • references/stencil-fundamentals.md
  • references/stencil-setup.md

FAQ

What does the stencil skill do?

Use when the user asks about Stencil, @stencil/core, @Component/@Prop/@State/@Event decorators, a web component compiler, framework output targets or a Stencil design system. Produces lazy-loaded, framework-agnostic Stencil components and build config. Not for Lit (use frontend-lit) or hand-written custom elements (use frontend-web-components).

How do I install the stencil skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the stencil skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare stencil with