Agents start here (webcomponents monorepo)
- Read
llms.txtin this folder, then thehax-webcomponent-devskill: https://github.com/haxtheweb/create/blob/main/src/skills/hax-webcomponent-dev/SKILL.md.- Before writing a new element, search the existing ones:
hax wc --search <words>orelements-catalog.json(tag, title, description, package, import path, HAX type, tags). Prefer composing existing elements.- Create new elements only with
hax webcomponent <name> --y --no-i(the globalhax, nevernpx hax), and runhax auditin the element folder before you finish. Never pass--no-docshere: every element's build must end withnode ../../scripts/extract-element-docs.mjs --write .so itslib/<tag>.docs.jsonships for<documentation-player>. After changing an element's properties, HAX settings, slots or events, runyarn run buildin its folder and commit the refreshed docs data.- Never run the ubiquity script and never run a build at the top of this monorepo.
This file provides comprehensive instructions for AI coding agents working within the HAX ecosystem. HAX (Headless Authoring eXperience) is a comprehensive web development ecosystem that enables rapid creation of accessible, performant web components and static sites. Follow these guidelines to set up, develop, test, and contribute effectively to HAX projects.
Shared HAX ecosystem guidance (repo map, pillars, rules, scoped rules, skills) lives in one place, https://github.com/haxtheweb/praw, and is read from there instead of being copied into each repo:
- Always-on rules and ecosystem index: https://github.com/haxtheweb/praw/blob/main/WARP.md
- Rule registry, by Rule ID: https://github.com/haxtheweb/praw/blob/main/RULES.md
- Scoped rules: webcomponents, HAXcms backends, DDD design system
- What HAX is, pillars, and the repo map: https://github.com/haxtheweb/praw/blob/main/what-is-hax.md
- Workflow skills: https://github.com/haxtheweb/praw/tree/main/skills; interface skills: https://github.com/haxtheweb/create/tree/main/src/skills
- Machine-readable index: https://raw.githubusercontent.com/haxtheweb/praw/main/llms.txt
- Work queue: https://github.com/haxtheweb/issues (
gh issue list --repo haxtheweb/issues) - CLI options:
hax help,hax <command> --help, orman hax
Before starting any work, check the unified issue queue:
- All HAX ecosystem issues are tracked at
haxtheweb/issues - Use GitHub CLI to check issues:
gh issue list - Reference existing issues when making contributions
- Install HAX CLI globally:
npm install @haxtheweb/create --global
- Install project dependencies (run from the project root):
npm install
- Start interactive CLI (for web components or HAXsites):
hax start
- Launches an interactive CLI with ASCII art (via Clack).
- Start development server (for HAXsites):
hax serve
- Launches the site in development mode at
http://localhost.
- Launches the site in development mode at
- Create a new web component:
hax webcomponent my-element --y
- Creates a LitElement-based web component with DDD design system and i18n support.
- In a monorepo, places the component in the correct location and inherits settings.
- Create a new HAXsite:
hax site mysite --y
- Generates a HAXcms-based static site with templated files.
- Update HAX CLI:
hax update
- Alternative usage (one-time execution without global install):
or
npx @haxtheweb/create
npm init @haxtheweb
- Windows-specific setup:
- If issues occur, set a custom npm cache path:
npm config set cache C:\tmp\nodejs\npm-cache --global
- For PowerShell, check execution policy to allow scripts:
Adjust if needed using
Get-ExecutionPolicy
Set-ExecutionPolicy(see Microsoft documentation).
- If issues occur, set a custom npm cache path:
- Language: Pure JavaScript with LitElement for web components
- NO TypeScript: HAX strictly avoids TypeScript to eliminate compilation requirements
- Unbundled Approach: Components ship as native JS/HTML/CSS for maximum compatibility
- Third-party Libraries: When using libraries written in TypeScript, always import the pre-compiled JavaScript distribution
- Global References: Use
globalThisinstead ofwindowfor consistency across environments - Formatting:
- Use single quotes (
') - Avoid semicolons where possible
- Prefer functional programming patterns
- Use Prettier for consistent formatting
- Use single quotes (
- ES Modules: Use standard ES6 import/export syntax
- Modern JavaScript: Leverage ES2018+ features while maintaining browser compatibility
- CSS template literals: Never write a backtick (
`) character inside acsscomment block (or anywhere else in a LitElementcss\...`` tagged template), including in prose like "don't" or "it's". A stray backtick terminates the template literal early and breaks the build/parse.
- DDD System: All components MUST adhere to the DDD (Design, Develop, Destroy) design system
- Location:
elements/d-d-din the webcomponents repository - Use DDD for fonts, colors, padding, spacing, margins, and other design tokens
- Inherit from
DDDSuperclass for automatic DDD integration - Reference
.dddignorefile to exclude irrelevant files during audits
- Location:
- HAX Properties: Include
haxPropertiesin web components for HAX compatibility (use--writeHaxPropertiesflag) - Theme Development: HAXcms themes should extend
HAXCMSLitElementclass - File Structure:
- Web components: Place source files in
src/orlib/directories - HAXsites: Pages in
pages/, themes intheme/, assets inassets/ - Monorepo: Each component gets its own directory in
elements/
- Web components: Place source files in
- Web Components: Use hyphenated names (e.g.,
my-element) - Package Names: Match component/site name in
package.json - CSS Classes: Follow BEM methodology when not using DDD tokens
- Use provided i18n wiring for web components (automatically included with
hax webcomponent) - Support multiple languages from the start
The HAX ecosystem uses a sophisticated build pipeline optimized for unbundled JavaScript delivery:
- Gulp: Handles asset compilation and processing
- Prettier: Ensures consistent code formatting
- CEM (Custom Elements Manifest): Generates
custom-elements.jsonfor component metadata - Lerna: Manages monorepo dependencies and publishing
- No TypeScript Compilation: Pure JavaScript workflow eliminates build complexity
-
Standard build (from component root):
yarn run build
- Compiles assets, formats code, generates custom-elements.json
- CRITICAL: Always run this after changes to HAXCMSLitElement themes
- Do NOT manually edit
custom-elements.json- it's auto-generated
-
Development build with watching:
yarn run dev
-
Run tests (from project or component root):
npm test -
Monorepo testing:
npm run test --filter <component_name>
- Tests specific component in monorepo
- Use Lerna for more complex filtering
- Audit web components for DDD compliance:
hax audit
- Checks CSS and structure against DDD design system standards
- Ignores files listed in
.dddignore - Run from component root for accurate results
- Required before submitting theme components
-
Linting:
npm run lint
- Ensures code style compliance before committing
- Uses ESLint, Prettier, and Stylelint
-
Fix issues automatically:
npm run lint:fix
/node_modules
/dist
/build
/public
/test
/.github
/.vscode
/.idea
/locales
LICENSE
.dddignore
.editorconfig
.gitignore
.npmignore
*.md
*.yml
*.json
*.png
*.svg
- PR Title Format:
[<project_name>] <Descriptive Title>- Example:
[my-element] Add dynamic property binding
- Example:
- Pre-commit checks:
- Run
yarn precheckbefore every push or PR. It runs the Prettier, Stylelint, ESLint and DDD token checks CI runs, plus a CodeQL security scan, on the files you changed. Fix everything it reports and re-run until it passes (yarn precheck:fixauto-fixes formatting and fixable lint). A Claude Code hook in.claude/blocksgit pushandgh pr createuntil it passes. - CodeQL must pass on the first push. Install the CodeQL CLI once with
yarn codeql:install(agents: do this at the start of any session that will push).yarn codeqlscans the element folders you changed with the same query suite andpaths-ignoreas the CodeQL PR check, in about a minute, and reports only alerts in files you changed. Fix every alert it reports by changing the code, not by suppressing it; never useMath.random()for ids or anything a rule treats as security-sensitive, and use linear-time regexes and full (not single-pass) sanitization. CI still scans the whole repo and is the source of truth. - Run
npm testto ensure all tests pass. - Run
npm run lintto verify code style. - Run
hax auditfor web components to confirm DDD compliance.
- Run
- Commit Guidelines:
- Use clear, descriptive commit messages (e.g., "Add i18n support to my-element").
- Include relevant changes to tests or documentation.
- HAXsite PRs:
- Test locally with
hax serveto verify page rendering. - Ensure new pages or content updates align with
site.jsonand JSON Outline Schema.
- Test locally with
- Security Audits: For recurring security audits of this repo, start with
SECURITY-AUDIT.md— it defines the read order, scope, commands, regression guards, and reporting convention - Dependencies: Keep dependencies updated before running
npm install - Sensitive Data: Avoid committing API keys or sensitive data to
package.json,site.json, or public files - Site Imports: Validate source URLs when using
--import-siteto prevent malicious content - File Permissions: Ensure scripts have correct execution permissions (
chmod +x script.sh) - Component Security: Sanitize user inputs in custom components
- Schema Validation: Validate against JSON schemas before processing content
- Library Security: Only import from trusted, well-maintained JavaScript distributions
- Missing custom-elements.json: Run
yarn run buildfrom component root - DDD Audit Failures: Check
.dddignoreand fix CSS token usage - Lerna Issues: Run
lerna clean && lerna bootstrap
- CLI Not Found: Ensure
@haxtheweb/createis globally installed - Permission Errors: Check file permissions and ownership
- Theme Not Loading: Verify HAXCMSLitElement inheritance and build process
- DDD Tokens Missing: Import DDD properly and use CSS custom properties
- HAX Integration: Ensure
haxPropertiesare defined correctly - Library Import Errors: Verify you're importing JavaScript distributions, not TypeScript sources
- Slow Loading: Check for unnecessary dependencies or large imports
- Bundle Size: HAX's unbundled approach should keep individual files small
- Memory Usage: Monitor component lifecycle and cleanup
This AGENTS.md file is maintained across all HAX ecosystem repositories to ensure consistent development experience regardless of entry point.
# Run command across all components
lerna run build
# Publish components (maintainers only)
lerna publish
# Add dependency to specific component
lerna add package-name --scope=@haxtheweb/component-name- HAX Community: Run
hax partyfor involvement opportunities - Discord: https://discord.gg/aCGxmRHEJP
- Issue Reporting: Use
haxtheweb/issuesor GitHub interface - Merlin Integration: Use "Issue" command in HAX spaces for automated reporting
- Documentation: Run
man hax(Linux/macOS) for comprehensive CLI docs - Educational Resources: Complete documentation at https://haxtheweb.org/