From aa87f2a65f1a1c0cd1cb5850d6050a6060bdfe56 Mon Sep 17 00:00:00 2001 From: mathias Date: Tue, 12 May 2026 15:22:31 +0000 Subject: [PATCH] feat: add htmx-patterns skill --- .skills/htmx-patterns/SKILL.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .skills/htmx-patterns/SKILL.md diff --git a/.skills/htmx-patterns/SKILL.md b/.skills/htmx-patterns/SKILL.md new file mode 100644 index 0000000..3c28a68 --- /dev/null +++ b/.skills/htmx-patterns/SKILL.md @@ -0,0 +1,31 @@ +--- +name: htmx-patterns +description: HTMX conventions — default attributes, form patterns, validation errors, hypermedia-first API design. Use when writing HTMX templates or Go handlers that return HTML fragments. +--- + +# HTMX patterns + +## Default attributes +Always include on interactive elements: +- `hx-indicator` for loading states +- `hx-swap="innerHTML"` as default (explicit over implicit) +- `hx-target` pointing to a specific ID, never `this` in production + +## Form pattern +```html +
+ + + ... +
+``` + +## Server-sent validation errors +Return 422 with the error fragment, swap into the form's error container: +```html +hx-target-422="#form-errors" +``` + +## Prefer hypermedia over JSON +If the endpoint returns data for display, return an HTML fragment. +Only use JSON for machine-to-machine APIs or when a non-browser client needs it.