Saltar al contenido principal

Agent Skills

Abrir en ChatGPT

Agent skills teach AI coding assistants how to build webforJ applications using the correct APIs, design tokens, and component patterns. Instead of guessing at framework conventions, an AI assistant loads a skill and follows its structured workflow to produce code that compiles and follows best practices on the first attempt.

Skills follow the open Agent Skills specification and work across multiple AI assistants, including Claude Code, GitHub Copilot in VS Code, and Cursor. Each skill is a single directory with a SKILL.md file describing the skill's purpose and workflow, along with references/ and scripts/ directories for supporting documentation and helper scripts.

Agent skills for webforJ are available in the GitHub repository webforj/webforj-agent-skills. With these skills installed, an AI will load these files automatically when it detects a relevant task. For example, asking an AI to "theme this app with a blue palette" triggers the styling-apps skill, which walks the AI through looking up valid DWC tokens, writing scoped CSS, and validating every variable name before producing output.

Why use skills?

Without skills, AI assistants often produce webforJ code that looks plausible but fails in practice. Common problems include:

  • Inventing --dwc-* token names that don't exist (CSS compiles but has no effect)
  • Using the wrong base class for component wrappers (Composite instead of ElementComposite, or vice versa)
  • Missing PropertyDescriptor patterns, event annotations, or concern interfaces
  • Hardcoding colors that break dark mode
  • Skipping validation steps that catch silent failures

Skills eliminate these issues by giving the AI exact decision tables, lookup scripts, and validation checklists for each task type.

How skills differ from MCP

Skills and the webforJ MCP server serve complementary roles. MCP provides live tools the AI can call at runtime to search documentation or generate projects. Skills provide static knowledge and step-by-step workflows that guide how the AI approaches a task.

MCP serverAgent skills
What it providesLive tools: documentation search, project scaffolding, theme generationStatic knowledge: workflows, decision tables, reference docs, helper scripts
When it actsOn demand, when the AI calls a toolAutomatically, when the AI detects a matching task
Best forLooking up specific APIs, generating starter projects, creating theme palettesEnd-to-end tasks that require following framework conventions and multi-step workflows

In practice, the two work well together. The MCP server's webforj-create-theme tool generates a valid palette from a single color, and the styling-apps skill then guides the AI through component-level styling and dark mode validation using that palette.

Skills are static files read from disk—they don't add runtime overhead or make external API calls. The AI loads a skill's reference material into its context window when relevant, which uses some context tokens, but the resulting output quality for framework-specific work is significantly higher.

Installation

Clone the webforJ agent skills repository, then copy the skill folders into the location your AI tool expects. Each tool supports two scopes:

  • Project scope: the skill is available only in that project
  • User scope: the skill is available across all your projects
git clone https://github.com/webforj/webforJ-agent-skills.git
cd webforJ-agent-skills

# Project scope
cp -r creating-components /path/to/your/project/.claude/skills/
cp -r styling-apps /path/to/your/project/.claude/skills/

# User scope
cp -r creating-components ~/.claude/skills/
cp -r styling-apps ~/.claude/skills/
Which scope to use

Use project scope when collaborating with a team so everyone on the project benefits from the same skills. Use user scope when you work on multiple webforJ projects and want the skills available everywhere without copying them into each repository.

Available skills

This skill guides an AI assistant through building reusable Java components from any source, whether that's an existing web component library, a plain JavaScript library, or a composition of existing webforJ components.

What it covers

The skill defines five paths for creating components, and teaches the AI to select the right one based on the task:

PathWhen to useBase class
Wrap an existing Custom Element libraryLibrary ships Custom Elements (<x-button>, <x-dialog>)ElementComposite / ElementCompositeContainer
Build a Custom Element, then wrap itNew visual component or wrapping a plain JS libraryElementComposite / ElementCompositeContainer
Compose webforJ componentsCombining existing webforJ components into a reusable unitComposite<T>
Extend an HTML elementLightweight one-off integration with no Shadow DOMDiv, Span, etc.
Page-level utilityBrowser API or global feature with no DOM widgetPlain Java class + EventDispatcher

Workflow

For Custom Element wrapping (the most common path), the skill walks the AI through a structured workflow:

  1. Setup: download third-party JS/CSS into the project's src/main/resources/static/libs/ directory. The skill instructs the AI to prefer local resources over CDN links for offline reliability.
  2. Extract component data: use the included extract_components.mjs script to parse a Custom Elements Manifest and produce a structured specification of each component's properties, events, slots, and CSS custom properties.
  3. Write Java wrappers: create ElementComposite or ElementCompositeContainer classes with PropertyDescriptor fields, event classes, slot methods, and concern interfaces, all following webforJ conventions.
  4. Write tests: generate JUnit 5 tests using PropertyDescriptorTester and structured test patterns for properties, slots, and events.

Reference material

The skill includes eight reference documents covering ElementComposite patterns, component composition, property descriptors, event handling, JavaScript interop, testing patterns, and common anti-patterns.

This skill teaches an AI assistant how to style webforJ applications using the DWC design-token system. The core principle is that all visual values use --dwc-* CSS custom properties. The skill enforces this by providing validation steps and lookup scripts that prevent the AI from inventing token names or hardcoding colors.

What it covers

TaskApproach the skill teaches
Color reskinOverride palette hue, saturation, and contrast tokens at :root
Component stylingLook up the component's CSS variables first, fall back to ::part() only when needed
Layout and spacingUse --dwc-space-* and --dwc-size-* tokens
TypographyUse --dwc-font-* tokens
Full themePalette configuration with semantic token remapping
Table styling::part() selectors only (tables expose no CSS variables)
Google ChartsJSON theme file loaded via Assets.contentOf() and Gson

Workflow

The skill enforces a strict lookup-before-write discipline:

  1. Classify the task: determine whether this is a palette reskin, component styling, layout work, or a full theme.
  2. Scan the app: read the Java source to find every component, theme variant, and expanse in use.
  3. Look up every component: run the included component_styles.py script to retrieve the exact CSS variables, ::part() names, and reflected attributes each component supports. The AI writes no CSS until this step is complete.
  4. Write CSS: produce nested, compact CSS that follows DWC conventions: global tokens first, then component CSS variables, then ::part() overrides as a last resort.
  5. Validate: re-run the lookup script and verify that every token, part name, and selector in the output actually exists. Fix anything that fails.

Key rules the skill enforces

  • Seven palettes only: primary, success, warning, danger, info, default, and gray. Names like secondary or accent don't exist in DWC and silently fail.
  • No hardcoded colors: every color value must be a var() reference, including inside box-shadow and border. Hardcoded values break dark mode.
  • CSS variables over ::part(): component CSS variables are the intended styling API. ::part() is the escape hatch for cases where no variable exists.
  • Scoped selectors: bare tag selectors on components with theme or expanse attributes override all variants. The skill requires :not([theme]) or [theme~="value"] scoping.