Skip to main content
rule

htmx-basic-cursorrules-prompt-file — Cursor rule: setup and use

Guides Cursor when building HTMX interfaces with server templates, clean folder layouts around app.py, and standard request attributes.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/htmx-basic-cursorrules-prompt-file.mdc
Open on GitHub

What htmx-basic-cursorrules-prompt-file does

This rule directs Cursor to write HTMX markup according to core patterns. It prompts the assistant to use attributes like hx-get, hx-post, and hx-trigger, while routing output via hx-target and controlling DOM replacement with hx-swap.

The configuration proposes a concrete project tree with src/templates/, static CSS and JS directories, and an app.py entry point. It also enforces server-side engines such as Jinja2 or Handlebars, semantic HTML5, and full navigation via hx-boost.

Security and resilience matter here: the rule mandates CSRF defense, proper error handling, and progressive enhancement. Because alwaysApply is set to false, Cursor does not attach these instructions automatically to every prompt.

What it helps with

  • configure hx-target and hx-swap for targeted DOM updates
  • organize template and asset folders for an app.py application
  • attach loading indicators to requests with hx-indicator
  • enable fast multi-page transitions using hx-boost

Example prompts for the agent

  • Create an item submission form using hx-post with a loading indicator
  • Update the notifications list with hx-swap into the target container
  • Set up navigation links across the template with hx-boost

How to install htmx-basic-cursorrules-prompt-file

Manually: put the files in place

.cursor/rules/htmx-basic-cursorrules-prompt-file.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about htmx-basic-cursorrules-prompt-file

How to install htmx-basic-cursorrules-prompt-file in Cursor?

Add the file .cursor/rules/htmx-basic-cursorrules-prompt-file.mdc in your project root and paste the rule contents into it.

What does htmx-basic-cursorrules-prompt-file do?

It provides guidelines for Cursor on writing HTMX attributes, structuring template directories, and handling CSRF protection.

Which templating engines does this rule mention?

The rule suggests server-side engines such as Jinja2 or Handlebars alongside a basic app.py backend structure.

Source text

htmx-basic-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for HTMX development with basic setup."
globs: **/*
alwaysApply: false
---
// HTMX Basic Setup .cursorrules

// HTMX best practices

const htmxBestPractices = [
  "Use hx-get for GET requests",
  "Implement hx-post for POST requests",
  "Utilize hx-trigger for custom events",
  "Use hx-swap to control how content is swapped",
  "Implement hx-target to specify where to swap content",
  "Utilize hx-indicator for loading indicators",
];

// Folder structure

const folderStructure = `
src/
  templates/
  static/
    css/
    js/
  app.py
`;

// Additional instructions

const additionalInstructions = `
1. Use semantic HTML5 elements
2. Implement proper CSRF protection
3. Utilize HTMX extensions when needed
4. Use hx-boost for full page navigation
5. Implement proper error handling
6. Follow progressive enhancement principles
7. Use server-side templating (e.g., Jinja2, Handlebars)
`;

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set210

htmx-go-fiber-cursorrules-prompt-file A Cursor rule for Go projects built on Fiber with HTMX: it pins down folder layout, routing and template rendering so the agent stops improvising. ★ 41,024repo stars htmx-go-basic-cursorrules-prompt-file Guides Cursor when building Go web apps with HTMX. Enforces standard project layout, html/template rendering, and idiomatic request handling. ★ 41,024repo stars htmx-flask-cursorrules-prompt-file A Cursor rule for HTMX projects built with Flask. It sets guidance for templates, forms, routes, database access, and project layout. ★ 41,024repo stars htmx-django-cursorrules-prompt-file A Cursor rule that keeps the agent on Django rails while it writes HTMX code: templates, forms, CSRF, class-based views. ★ 41,024repo stars html-tailwind-css-javascript-cursorrules-prompt-fi A Cursor rule for HTML, Tailwind CSS, and vanilla JavaScript work. Use it when an agent needs clear coding constraints for frontend files. ★ 41,024repo stars how-to-documentation-cursorrules-prompt-file A Cursor rule that turns technical steps, test scripts and screenshots into step-by-step guides for non-technical users. Useful when you write How To docs for a feature. ★ 41,024repo stars hol-hedera-typescript-cursorrules-prompt-file Cursor rules for building decentralized Hedera AI agents with Hashgraph Online SDK in TypeScript. Enforces strict typing and TDD workflow. ★ 41,024repo stars harmony-arkts A Cursor rule for HarmonyOS ArkTS code covering components, state, resources, layout, lifecycle, and accessibility. Useful for .ets projects. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor