Index of every page on this site: llms.txt
All skills
corey-alix avatar

/dom-utilities-assistant

@e4fbc1d
Run it yourself

Specialized assistant for implementing robust DOM manipulation patterns using the bespoke DOM utility library for type-safe element queries.

  • 1 file
  • 3.6 KB
  • Updated 9 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/corey-alix/dwp-hours/dom-utilities-assistant

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈41 tokens for metadata: the name and description. ≈883 when used: this file.

Description uses 2.1% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈166 characters, or 2.1%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

DOM Utilities Assistant

Description

Specialized assistant for implementing robust DOM manipulation patterns in the DWP Hours Tracker frontend. Provides guidance on using the bespoke DOM utility library (client/components/test-utils.ts) for type-safe element queries, consistent error handling, and enhanced debugging capabilities.

DOM Utilities System

The DWP Hours Tracker uses a lightweight bespoke DOM utility library to facilitate robust DOM manipulation with enhanced error logging and debugging capabilities. Direct use of native DOM APIs like document.getElementById(), document.querySelector(), etc. is discouraged in favor of utility functions.

Core Principles

  • Type-Safe Queries: Use TypeScript generics for compile-time type checking
  • Automatic Error Logging: Descriptive errors when elements are not found
  • Consistent Error Handling: Standardized error patterns across the application
  • Debug-Friendly Output: Enhanced console logging for development
  • Reliable Interactions: Ensures DOM operations are predictable and testable

Key Utility Functions

Element Queries
  • querySingle<T>(selector: string): T - Finds a single element by selector, throws descriptive error if not found
  • queryMultiple<T>(selector: string): T[] - Finds multiple elements by selector, throws error if none found
  • getElementById<T>(id: string): T - Finds element by ID with error logging
Event Management
  • addEventListener(element, event, handler, options?) - Safely adds event listeners with error handling
Element Creation
  • createElement<T>(tagName, attributes?) - Creates elements with optional attributes

Usage Patterns

❌ Avoid Direct DOM APIs

const button = document.getElementById("my-button") as HTMLButtonElement;
if (!button) {
  console.error("Button not found");
  throw new Error("Button not found");
}
button.addEventListener("click", handler);

✅ Use DOM Utilities

import { getElementById, addEventListener } from "./components/test-utils.js";
const button = getElementById<HTMLButtonElement>("my-button");
addEventListener(button, "click", handler);

Trigger

Activate this skill when users ask about:

  • DOM element queries and manipulation
  • Type-safe element access patterns
  • Event listener management
  • Element creation utilities
  • DOM error handling and debugging
  • Web component DOM interactions
  • Shadow DOM element queries

Response Pattern

When activated, follow this structured approach:

  1. Identify DOM Operation: Determine if query involves element access, event handling, or creation
  2. Reference Utility Functions: Show appropriate functions from test-utils.ts
  3. Provide Type-Safe Examples: Demonstrate TypeScript generic usage
  4. Address Error Scenarios: Explain error handling and debugging benefits
  5. Ensure Shadow DOM Compatibility: Consider web component encapsulation needs

Examples

  • "How do I safely query DOM elements?"
  • "What's the best way to add event listeners?"
  • "How do I handle missing elements gracefully?"
  • "How do I create elements with proper typing?"
  • "How do I query elements within web components?"

Additional Context

This skill integrates with the web components architecture and ensures all DOM interactions follow the project's patterns for reliability and testability. The utilities are located in client/components/test-utils.ts and should be imported for all DOM operations.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at e4fbc1d. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Dormantupdated 9 months ago

README badge

README badge for corey-alix/dwp-hours/dom-utilities-assistant