htmx
БесплатноБез исполняемых скриптовНе проверенhtmx for Go/templ apps: hx-* attributes, swap strategies, triggers, OOB updates, SSE, WebSockets, forms, redirects, debounce, server integration. Trigger when…
от gopherguides★ 21 звезда на GitHubОб этом скилле
htmx Best Practices & Go/Templ Integration
Apply correct htmx patterns when building hypermedia-driven web applications, especially with Go and templ.
Core Principles
- Return HTML fragments, not JSON — htmx is designed for hypermedia; the server returns rendered HTML
- Use HTML attributes, not JavaScript — prefer
hx-*attributes overhtmx.ajax()orfetch()calls - Server controls behavior — use response headers (
HX-Retarget,HX-Reswap,HX-Redirect) for control flow - Check
HX-Requestheader — return fragments for htmx requests, full pages for normal requests - Don't mix paradigms — avoid using
fetch()alongside htmx in the same page; pick one approach
Reference Files
Read the relevant file for detailed patterns, code examples, and best practices:
templ-integration.md — Templ + htmx
- CRITICAL: Templ interpolation rules (dynamic attributes,
{ }vs quoted strings) - Dynamic JSON in
hx-vals— usejson.Marshal, notfmt.Sprintf - URL construction patterns (fmt.Sprintf, concatenation, templ.URL)
- Templ component patterns (spread attributes, conditional attributes, full page vs partial)
- JavaScript and
hx-onevents in templ (JSFuncCall, OnceHandle, event name syntax) - Embedding Go data in script tags
- Alpine.js listening to htmx events from templ
go-handlers.md — Go Server Patterns
- Fragment vs full page response (
isHTMXRequesthelper) - Separate routes for partials vs full pages
- Multi-target OOB responses (writing multiple components)
- htmx-aware redirects (
HX-Redirectinstead of HTTP 302) - Event-driven list reloads with
HX-Triggerheader - Delete with empty response
- Validation error re-rendering with error state
attributes-reference.md — Swap, Triggers & Headers
- Swap strategies table (innerHTML, outerHTML, delete, morph, etc.) and modifiers
- Trigger patterns (events, special triggers, modifiers, filters, multiple triggers)
- Self-terminating polling pattern
- Request headers (sent automatically) and response headers (server control)
- Out-of-Band (OOB) swap patterns and gotchas
patterns-and-extensions.md — Advanced Patterns
- Error handling (4xx/5xx don't swap by default — 4 solutions)
- Filter state preservation with
hx-includeandhx-push-url - Forms and file uploads (auto-submit, progress, external values, radio/checkbox)
- Inline editing pattern (read-only row ↔ edit form)
- Alpine.js + htmx integration (separation of concerns, event listening,
htmx.process()) - Loading indicators and disabled elements
- Sync strategies (
hx-sync: replace, abort, queue) - Target selectors (this, closest, next, previous, find)
- Extensions (json-enc, SSE, WebSockets, head-support, preload)
- JavaScript event patterns (delegation, afterSwap vs afterSettle,
htmx.onLoad) - Common anti-patterns table
- CSRF protection pattern
- Configuration via meta tag
- Useful Go libraries (htmx-go, go-htmx, typed-htmx-go)
Установить htmx в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл htmx?
htmx for Go/templ apps: hx-* attributes, swap strategies, triggers, OOB updates, SSE, WebSockets, forms, redirects, debounce, server integration. Trigger when user writes or pastes templates containing hx-* attributes, asks about HTMX swaps/triggers/OOB updates, or wires HTMX to a Go handler. SKIP generic web, fetch/AJAX, or templUI questions with no htmx context.
Как установить скилл htmx?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл htmx запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic