htmx

htmx is a cursor rule for Cursor from nedcodes-ok/cursorrules-collection. It costs 529 tokens per session, scanned A, original, MIT.

A set of coding rules for htmx, a web tool that lets HTML trigger server requests and update parts of a page. It keeps the server responsible for returning HTML rather than JSON data.

In plain words
What is it for?
Use it when building htmx pages or endpoints, especially forms, navigation, loading states, validation, and destructive actions.
Why use it?
It gives developers consistent rules for page updates, loading feedback, browser history, redirects, and form errors. This reduces scattered browser-side code and unclear request behavior.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: mentions Cursor.

Good fit Use it when building htmx pages or endpoints, especially forms, navigation, loading states, validation, and destructive actions.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/nedcodes-ok/cursorrules-collection/htmx
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collection

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for htmx

README.md
[![agentmods](https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/htmx/github.svg)](https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/htmx)
Your own site
<a href="https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/htmx"><img src="https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/htmx/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for htmx

Your own site · 80×15
<a href="https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/htmx"><img src="https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/htmx.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 529 This file is loaded in full into every session.
When invoked 529 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00529 $0.00529
Opus 5.5 $0.00212 $0.00212
Sonnet 5.5 $0.00106 $0.00106
Haiku 4.5 $0.00053 $0.00053

Measured 3mo ago against content hash eee419fb37ef, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

htmx scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules-mdc/frameworks/htmx.mdc · 47 lines

How it starts

The opening of the file, as written. The whole thing — 47 lines — stays where its author put it; the contents beside it link to each section on GitHub.

htmx Cursor Rules

You are an expert htmx developer. Follow these rules:

Core Principles

  • Server returns HTML fragments, not JSON. Every endpoint returns renderable markup
  • Progressive enhancement: pages work without JavaScript first, htmx enhances
  • Hypermedia as the engine of application state — URLs and links drive navigation
  • Prefer hx-get/hx-post over fetch/XMLHttpRequest. No client-side state management

Attributes

  • Always set hx-target to scope updates. Never rely on default (innerHTML of triggering element)
  • Use hx-swap="outerHTML" for replacing elements, "innerHTML" for updating contents
  • hx-indicator for loading states on every network request. Users need feedback
  • hx-push-url="true" on navigation requests to maintain browser history
  • hx-confirm for destructive actions (delete, reset)

Server Responses

  • Return 200 with HTML fragment for success. Use HX-Trigger response header for events
  • Return 422 with form HTML (including errors) for validation failures — htmx swaps it in
  • Use HX-Redirect header for server-side redirects, not 301/302
  • Return 204 No Content to do nothing. Return empty string with HX-Trigger for event-only responses
  • Use HX-Retarget and HX-Reswap headers to override client-side targeting from the server

Patterns

  • Inline editing: hx-get to fetch edit form, hx-put to save, swap back to display view
  • Infinite scroll: hx-get with hx-trigger="revealed" on sentinel element
  • Active search: hx-get with hx-trigger="input changed delay:300ms" and hx-indicator
  • Bulk operations: use hx-include to gather checkbox values, hx-vals for extra data

Forms

  • hx-post on forms, not buttons. Let the form handle submission semantics
  • Use name attributes on all inputs. Server reads standard form data, not JSON
  • Disable buttons during submission with htmx:beforeRequest/afterRequest events
  • Return the full form with errors on validation failure, not just error messages

Organization

  • Keep htmx attributes in HTML, not added via JavaScript
  • Server-side partials/fragments for reusable components
  • Use hx-boost="true" on body or nav for automatic AJAX navigation

Read the full file on GitHub · 47 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 47 lines · 529 tokens per session scan A eee419fb37ef

Subscribe to this mod's changes

htmx is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (38 stars, last pushed 9mo ago), licensed MIT. It adds 529 tokens to every session, about $0.0021 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

htmx compared with cursor rules from other repositories

htmx next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
htmxnedcodes-ok/cursorrules-collectionCursor rule389mo agoMITA529Cursor
23-app-startuporbitalsonic/AndroidPilotCursor rule11mo agononeA0Cursor
21-ads-billingorbitalsonic/AndroidPilotCursor rule11mo agononeA0Cursor
30-screen-languageorbitalsonic/AndroidPilotCursor rule11mo agononeA0Cursor
01-feature-checklistorbitalsonic/AndroidPilotCursor rule11mo agononeA36Cursor
06-coroutines-floworbitalsonic/AndroidPilotCursor rule11mo agononeA0Cursor
09-resources-xmlorbitalsonic/AndroidPilotCursor rule11mo agononeA0Cursor