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.
.cursor/rules/htmx-basic-cursorrules-prompt-file.mdcWhat 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-targetandhx-swapfor targeted DOM updates - organize template and asset folders for an
app.pyapplication - 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-postwith a loading indicator - Update the notifications list with
hx-swapinto 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.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/htmx-basic-cursorrules-prompt-file.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/htmx-basic-cursorrules-prompt-file.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/htmx-basic-cursorrules-prompt-file.mdManually: put the files in place
.clinerules/htmx-basic-cursorrules-prompt-file.mdStep 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