agentleFS
G1JoshiG1Joshi/Agent-Skills/skills/frameworks/htmx/SKILL.md

htmx

Skill15 starsChanged 2 months agoMITView on GitHub

Expert htmx assistance covering hypermedia-driven UIs, AJAX swaps, out-of-band updates, and SSE/WebSockets. Use when building dynamic web interfaces without writing complex client JavaScript.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use declarative htmx attributes on standard HTML input:

    line 96
  2. Very specific:

    Use hx-indicator to provide visual loading indicators and spinners for every network interaction.

    line 118

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

htmx

High power tools for HTML. Allows you to build modern user interfaces with the simplicity of hypertext.

When to Use

  • Hypermedia-Driven Web Architectures: Building dynamic user interfaces using server-rendered HTML over the wire without heavy SPA frameworks.
  • CRUD Backends with Existing Templating: Django, Rails, Laravel, Go templates, or Spring Boot apps wanting SPA-like responsiveness.
  • Instant Search, Inline Editing, and Polling: Enhancing HTML forms and tables with declarative AJAX attributes.
  • Low-JavaScript Minimal Bundles: Drastically reducing client bundle sizes and eliminating frontend state management complexity.

Quick Start

<script src="https://unpkg.com/htmx.org@1.9.10"></script>

<!-- When clicked, issue GET to /clicked, swap outerHTML with response -->
<button hx-get="/clicked" hx-swap="outerHTML">Click Me</button>

Core Concepts

Declarative AJAX with Trigger & Swap Directives

Making async requests and swapping server HTML directly into DOM targets:

<!-- Instant search input with debouncing -->
<div class="search-widget">
  <input
    type="text"
    name="q"
    placeholder="Search users..."
    hx-post="/api/users/search"
    hx-trigger="keyup changed delay:300ms, search"
    hx-target="#search-results"
    hx-indicator="#loading-spinner"
    class="form-control"
  />
  <div id="loading-spinner" class="htmx-indicator">Searching...</div>
  <div id="search-results">
    <!-- Server returns <ul> list HTML here -->
  </div>
</div>

Inline Editing with Target Swapping

Updating tabular records in-place without page reloads:

<!-- Table Row Component -->
<tr id="user-row-42">
  <td>Alice Johnson</td>
  <td>alice@example.com</td>
  <td>
    <button
      class="btn btn-sm btn-primary"
      hx-get="/users/42/edit"
      hx-target="#user-row-42"
      hx-swap="outerHTML"
    >
      Edit
    </button>
  </td>
</tr>

Out-of-Band (OOB) Updates & Server-Sent Events

Updating multiple disconnected DOM regions from a single response:

<!-- Server response contains main payload and an OOB notification badge -->
<div id="order-details">
  <h4>Order #1029 Confirmed</h4>
  <p>Status: Processing</p>
</div>

<!-- Out-of-band swap updates the navbar cart badge automatically -->
<span id="cart-counter" hx-swap-oob="true" class="badge bg-danger"> 3 </span>

Common Patterns

Inline Search with Debounced Active Search

Problem: Building responsive autocomplete search typically requires heavy React/Vue state machines.

Solution: Use declarative htmx attributes on standard HTML input:

<input
  type="search"
  name="q"
  placeholder="Search users..."
  hx-post="/api/users/search"
  hx-trigger="keyup changed delay:300ms, search"
  hx-target="#search-results"
  hx-indicator="#loading-spinner"
/>

<div id="loading-spinner" class="htmx-indicator">Searching...</div>
<div id="search-results"></div>

Best Practices

Do:

  • Return clean HTML partials/fragments from the server instead of entire HTML document trees for htmx endpoints.
  • Use hx-indicator to provide visual loading indicators and spinners for every network interaction.
  • Leverage hx-boost="true" on root layout links and forms for instant progressive enhancement.
  • Validate and sanitize all server-rendered HTML to neutralize Cross-Site Scripting (XSS).

Don't:

  • Return JSON from htmx endpoints; htmx is fundamentally designed for server-rendered HTML.
  • Neglect accessibility; announce dynamic swaps to screen readers using aria-live="polite".
  • Overuse client-side scripting when declarative htmx attributes can achieve the desired interaction.

Troubleshooting

ErrorCauseSolution
htmx:targetError: Target element does not existElement specified in hx-target ID selector is missing from DOM.Verify ID in DOM: #search-results must exist before request triggers.
Response received but nothing swappedServer returned empty response or non-200 HTTP code.Verify server returns HTML with HTTP 200, or configure hx-swap response codes.
Infinite request loophx-trigger="load" placed inside swapped HTML fragment.Move load trigger to outer persistent container or remove trigger on swap.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.