From 04088b586fe6aee2c83602c01e06c9a62b5a6479 Mon Sep 17 00:00:00 2001 From: mathias Date: Tue, 12 May 2026 15:22:37 +0000 Subject: [PATCH] feat: add htmx-patterns context skill --- .context/skills/htmx-patterns.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .context/skills/htmx-patterns.md diff --git a/.context/skills/htmx-patterns.md b/.context/skills/htmx-patterns.md new file mode 100644 index 0000000..fe2f224 --- /dev/null +++ b/.context/skills/htmx-patterns.md @@ -0,0 +1,26 @@ +# Skill: 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.