htmx-universal-patterns

HTMX Universal Standards

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "htmx-universal-patterns" with this command: npx skills add ecelayes/roots-skills/ecelayes-roots-skills-htmx-universal-patterns

HTMX Universal Standards

Core Philosophy (HATEOAS)

  • HTML over JSON: The server MUST respond with HTML fragments (partials), not JSON.

  • Side Effects via HTML: Do not use client-side logic to update the DOM. Let the server response dictate changes via hx-swap .

Security & CSRF (Critical)

  • CSRF Protection: HTMX requests are non-idempotent (POST/PUT/DELETE) and require CSRF protection just like standard forms.

  • Header Method: Configure the global hx-headers to include the token: <body hx-headers='{"X-CSRF-Token": "{{ csrfToken }}"}'> .

  • Form Method: If headers aren't viable, ensure every <form> includes the hidden CSRF input.

  • XSS Prevention: Since we are injecting HTML, ensure all user content rendered on the server is strictly escaped before reaching the client.

Architectural Rules

  • The "Partial" Rule: Identify strictly which part of the UI needs updating. Create a server route that renders only that component.

  • Idempotency: GET requests should never change state. Use POST/PUT/PATCH/DELETE for actions.

  • Progressive Enhancement: Design the feature to work with standard HTML forms/links first where possible.

UX & Feedback Patterns

  • Request Indicators: ALWAYS use hx-indicator .

  • Pattern: <button hx-post="..." hx-indicator="#loading-spinner">Save</button>

  • Active States: Use the htmx-added class or hx-vals to manage active states via server rendering.

Error Handling Protocol

The backend must communicate status via HTTP Codes:

  • 200 OK: Swap content normally.

  • 204 No Content: Do nothing.

  • 422 Unprocessable Entity: Validation error. Swap the form with the HTML containing error messages.

  • HX-Retarget: Use this header if an error requires updating a global element (like a top-level alert) instead of the local target.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

handlebars-pure-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
General

koa-advanced-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
General

ll-feishu-audio

飞书语音交互技能。支持语音消息自动识别、AI 处理、语音回复全流程。需要配置 FEISHU_APP_ID 和 FEISHU_APP_SECRET 环境变量。使用 faster-whisper 进行语音识别,Edge TTS 进行语音合成,自动转换 OPUS 格式并通过飞书发送。适用于飞书平台的语音对话场景。

Archived SourceRecently Updated
General

test_skill

import json import tkinter as tk from tkinter import messagebox, simpledialog

Archived SourceRecently Updated