web-components-architecture

Enforce attribute-driven state and zero DOM queries in Custom Elements v1.

3|Updated Nov 16, 2025
One-click install
npx skills add https://github.com/matthewharwood/engmanager.xyz --skill web-components-architecture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: web-components-architecture
Source: https://github.com/matthewharwood/engmanager.xyz/tree/main/.claude/skills/web-components-architecture
Command: npx skills add https://github.com/matthewharwood/engmanager.xyz --skill web-components-architecture

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enforces a strict architecture for Web Components: zero DOM selection, attribute-driven state, event-based output, handleEvent pattern, and Declarative Shadow DOM for server-renderable components.

Core Features & Use Cases

  • Zero DOM selection and no innerHTML
  • Attribute-driven state and data flow through attributes
  • Event-based output via CustomEvents
  • HandleEvent pattern for memory-efficient delegation
  • Declarative Shadow DOM for instant rendering
  • Progressive enhancement with degraded behavior when JS is unavailable

Quick Start

Define a custom element using the web-components-architecture patterns and register it with a hyphenated name; wrap internal content in a Declarative Shadow DOM template.

Frequently Asked Questions about web-components-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build web components without DOM queries?

Zero-DOM selection web components use attributes to drive state and CustomEvents for output instead of querying the DOM. This eliminates imperative selection, enforces declarative patterns, and ensures components remain portable and testable across rendering contexts.

What is Declarative Shadow DOM and why use it for web components?

Declarative Shadow DOM is a template-based approach to encapsulation that renders instantly on the server without requiring JavaScript execution. It enables progressive enhancement, faster first paint, and server-renderable custom elements without client-side setup overhead.

How do I implement the handleEvent pattern in custom elements?

The handleEvent pattern delegates all events through a single method on the element itself, reducing memory overhead and simplifying listener management. Bind the element as the event listener and route events through a switch statement or dispatcher in the handleEvent method.

Can I build forms, modals, and carousels as custom elements without external dependencies?

Yes. Standard Web Platform APIs—Custom Elements v1, Shadow DOM, and CustomEvents—provide all primitives needed to build complex widgets like forms, modals, tabs, and carousels with zero external dependencies and full architectural control.

What happens to custom elements when JavaScript fails or is unavailable?

Progressive enhancement ensures degraded behavior: Declarative Shadow DOM content renders as plain HTML, attribute-driven markup displays without interactivity, and semantic fallbacks work in no-JS contexts. Components remain partially functional instead of completely broken.

How do attribute-driven custom elements differ from prop-based approaches?

Attribute-driven state flows through HTML attributes, making components serializable, server-renderable, and URL-reproducible. Prop-based approaches store state in JavaScript memory, complicating server rendering, persistence, and cross-frame communication.