Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Design and review htmx endpoint contracts for server-rendered HTML fragments. Use when adding or debugging hx-get, hx-post, hx-put, hx-patch, hx-delete, hx-target, hx-swap, hx-select, out-of-band swaps, HX-Trigger events, partial template responses, redirects, retargeting, or response headers.
.claude/skills/hashgraph-online-htmx-endpoint-design/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 11% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 13% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 39% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 124% | 0% |
| case-23 | ✗→✓ | ▲ Improved | 25% | 0% |
Use this skill when the hard part is the server/browser contract: which element makes the request, which endpoint handles it, what HTML comes back, and where that HTML lands.
Define the endpoint contract before writing attributes:
GET for safe reads; POST, PUT, PATCH, or DELETE for mutations when the server/framework supports them.hx-target when using outerHTML.hx-include when one control must submit data from a nearby form or filter panel.hx-vals only for small explicit values. Avoid secrets and avoid executable js: values; prefer form fields, hidden inputs, or URL parameters instead.keyup, input, and polling.Choose the smallest response that keeps the UI honest:
| Situation | Response | | --- | --- | | Replace one component | Return that component fragment | | Update several unrelated components | Return primary fragment plus hx-swap-oob fragments | | Mutation succeeds and another element should refresh | Return 204 plus an event/header when supported | | Validation fails | Return the bound form fragment with errors | | Browser should navigate | Return a normal redirect for non-htmx, and an htmx redirect/location response for htmx | | Server needs a different target/swap | Use framework helpers or htmx response headers where available |
hx-target="this" for self-contained components.outerHTML when replacing the target element itself.innerHTML when preserving the target shell and replacing only its contents.beforeend for appending rows, log entries, or feed items.hx-select when the server returns a larger document but the client should extract one fragment.Use out-of-band swaps for shared chrome and secondary facts:
Keep out-of-band fragments small and predictable. If many out-of-band updates are required for one action, consider returning the larger owner component instead.
Use events to decouple server results from browser-local behavior:
_hyperscript.invoice:saved or filters:changed.200 for normal fragment replacement, including many invalid form responses.204 when no visible fragment should be swapped.Other measured skills in the registry, with their headline benchmark lift.