AGENT SKILL

htmx-interactivity

Coordinate htmx with lightweight browser-side interactivity. Use when adding Alpine.js, _hyperscript, local UI state, custom events, dialogs, transitions, keyboard behavior, or browser-only state around htmx swaps in a server-rendered app.

使用场景前端开发
License 许可
MIT
最近更新
2026-11-14
Stars
★ 1.6k
Forks
490

01 前言 Front Matter

name
htmx-interactivity
license
MIT
metadata
{ "tags": "htmx,alpinejs,hyperscript,frontend,ui-state", "version": "0.1.0", "category": "Frontend", "displayName": "htmx Interactivity" }
description
Coordinate htmx with lightweight browser-side interactivity. Use when adding Alpine.js, _hyperscript, local UI state, custom events, dialogs, transitions, keyboard behavior, or browser-only state around htmx swaps in a server-rendered app.
compatibility
Codex, Claude Code, and other Agent Skills-compatible clients.

02 资源文件 2

03 SKILL.md 正文

htmx Interactivity

Use this skill when htmx handles server trips but the page still needs local browser behavior. Keep the ownership line explicit so server-rendered HTML and client-side state do not fight each other.

Ownership Rules

  • htmx owns server requests, fragment swaps, history updates, and server-triggered events.
  • The server owns durable state, validation, permissions, and canonical HTML.
  • Alpine or plain JavaScript owns local state such as menu open/closed, tabs, disclosure state, temporary filters, focus helpers, and small transitions.
  • _hyperscript is best for short event-driven behaviors attached to markup.
  • Do not mirror the same durable state in both server data and a client store unless there is a reconciliation plan.

Use Alpine When

  • A component has local state that changes without a server request.
  • You need a dropdown, popover, modal shell, tab set, disclosure, or preview toggle.
  • You need to coordinate htmx lifecycle events with UI state.
  • The state naturally belongs near the markup and is simple enough to read inline.

Keep persistent Alpine state outside htmx targets that will be replaced. If htmx swaps the element that owns x-data, that state resets.

Use _hyperscript When

  • The behavior is a small event script, such as adding a class, waiting, then removing it.
  • The script reads like a local interaction, not application business logic.
  • The team accepts _hyperscript syntax as part of the template layer.

Avoid _hyperscript for complex state machines, security-sensitive logic, large data transforms, or behavior that needs substantial tests.

Event Boundary Pattern

Use events as the bridge between server results and local browser state:

  1. The htmx request submits to the server.
  2. The server returns HTML and optionally triggers a domain event.
  3. Alpine, _hyperscript, or plain JavaScript listens for the event.
  4. Local UI state updates, such as closing a modal or focusing a saved row.

Prefer domain event names over implementation names:

<section x-data="{ open: true }" @profile-saved.window="open = false">
  <form hx-post="/profile" hx-target="#profile-panel" hx-swap="outerHTML">
    ...
  </form>
</section>

htmx Lifecycle Hooks

Use lifecycle events for cross-cutting behavior:

  • htmx:configRequest for headers such as CSRF when the framework needs them.
  • htmx:beforeRequest and htmx:afterRequest for instrumentation and loading behavior that attributes cannot express.
  • htmx:beforeSwap for exceptional status handling.
  • htmx:afterSwap or htmx:load for initializing third-party widgets in swapped content.
  • WebSocket extension events only in code that owns realtime behavior.

Prefer htmx attributes such as hx-indicator and hx-disabled-elt before writing lifecycle JavaScript.

Swaps And Local State

  • Keep long-lived local state outside replaceable htmx targets.
  • If a target contains initialized third-party widgets, define how they are destroyed or re-initialized.
  • After injecting htmx-enabled markup outside an htmx request, use htmx.process from the htmx-js-api skill.
  • Avoid global listeners that accumulate every time a fragment is swapped.

Data From The Server

  • Prefer HTML attributes or inert JSON script blocks for server-provided data.
  • Escape all server-rendered values before they enter JavaScript expressions.
  • Use text binding APIs for untrusted display text.
  • Avoid embedding secrets, signed tokens, or authorization facts in local state.

Accessibility

  • Use real buttons for local actions.
  • Bind aria-expanded, aria-controls, aria-selected, and aria-hidden from local state.
  • Preserve focus when opening/closing dialogs and after successful htmx swaps.
  • Support Escape for dismissible overlays.
  • Avoid replacing focused elements without a plan to move focus somewhere sensible.

CSP And Security

Alpine, _hyperscript, inline event attributes, and hx-on can all affect Content Security Policy. Use htmx-security when adding or tightening CSP, accepting user-authored HTML, or choosing CSP-compatible builds.

Avoid

  • Do not restart Alpine after every htmx swap.
  • Do not put durable server truth in a client store just to avoid a small htmx request.
  • Do not let local scripts bypass server authorization or validation.
  • Do not place broad event handlers in fragments that may be swapped repeatedly.
  • Do not use x-html or equivalent APIs for untrusted content.

04 同仓库更多 Skills

hashgraph-online
hashgraph-online/awesome-codex-plugins

migrate-to-e2e

Moves an existing Playwright, Cypress, Selenium, Appium, Detox, Maestro, or TesterArmy suite to e2e one slice at a time, with the old suite running beside the new one until each ported test is proven. Keeps a MIGRATION.md progress file so any later session resumes where the last stopped. Optionally plants a defect to show both suites catch it. Use for /migrate-to-e2e, "migrate our tests to e2e", "port these Maestro flows", "move our TesterArmy tests", or when a project has an e2e config and an older suite still running.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

e2e

Writes, runs, and debugs end-to-end tests for web and mobile apps with e2e, the agentic test runner, which mixes agent.act goals with exact locator assertions on a Playwright browser or an iOS or Android device. Also drives a project's running app live over the e2e MCP server to look at a screen, check a UI change, take a screenshot or record a video, and try a locator; and runs bug bashes, parallel e2e explore runs with each bug proven by a repro test. Use when a project depends on e2e or has an e2e.config.ts, when asked for end-to-end, browser, mobile, or agentic UI tests, to check a change in the running app, to QA or bug bash an app or branch, or when an e2e run fails.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

create-verification-skill

Generate a project-local verify-<app> skill on top of e2e, so any coding agent can launch the app, check it is worth driving, exercise a feature the way a user does, keep evidence, and bug bash it. Writes the skill, a feature map with one explore charter per feature, and proves it once. Use for /create-verification-skill, "make a verification skill for this repo", or when a project has no scripted way to prove UI behavior.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

deja-search

deja-vu memory — search the user's past AI coding sessions with the deja CLI. Holds what they already settled and never wrote into the repo (naming rules, banned or already-tried tools, required checks before merge, preferred values, who owns what). Use before your first edit in a task, before you call a change done or ready to merge, before you recommend a tool, library, design or reviewer, before re-debugging an error that may already be solved, when they say 'didn't we fix this before', 'what did we decide about X' or 'I already have that', and before telling them something on this machine does not exist.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

deja-reflect

End-of-session reflection and memory curation with deja-vu. Review what was decided, what commands broke and what repaired them, and record durable project rules or decisions with deja remember so the next session starts with them.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

revid

Make, edit, export and post AI videos with Revid (revid.ai) through the Revid MCP server. Use whenever the user wants a short-form or long-form video made (from an idea, a script, a URL, an article, a PDF, a tweet, a product page, their own clips, or a song), wants to find what is going viral on TikTok, YouTube, Instagram or X before making something, wants to edit or re-export an existing Revid project, generate a standalone AI image or clip, make a series episode, or publish and schedule a finished video to connected social accounts. Covers setup (hosted MCP with OAuth, or an API key), the 36 tools, credits, polling and the rules for publishing. Routes to the more specific revid-* skills when one fits.

图像与多媒体Skill与智能体开发
★ 1.6k