htmx-flask-cursorrules-prompt-file — Cursor rule
A Cursor rule for HTMX projects built with Flask. It sets guidance for templates, forms, routes, database access, and project layout.
.cursor/rules/htmx-flask-cursorrules-prompt-file.mdcWhat htmx-flask-cursorrules-prompt-file does
This rule guides work on HTMX and Flask applications. It recommends render_template for server-rendered pages, Flask-WTF for forms, url_for for links, jsonify for JSON responses, and Flask-SQLAlchemy for database access. It also calls for Blueprint when the application is split into modules.
The rule includes a layout with templates, static/css, static/js, models, and routes, plus __init__.py, config.py, and run.py. Its further guidance covers Jinja2 with HTMX attributes, CSRF protection, reading HTMX requests through request, Flask-Migrate, error handling, logging, the application factory pattern, and environment-based configuration. With alwaysApply: false, it is not applied on every Cursor interaction.
What it helps with
- build a Flask project layout
- connect Jinja2 templates to HTMX attributes
- handle forms with CSRF protection
- split routes with Flask
Blueprint - add database migrations and error handling
Example prompts for the agent
- Create a Flask app using the
templates,static,models, androuteslayout. - Add an HTMX form with
Flask-WTF, CSRF protection, and request handling throughrequest. - Move the routes into
Blueprintmodules and add migrations withFlask-Migrate.
How to install htmx-flask-cursorrules-prompt-file
Manually: put the files in place
.cursor/rules/htmx-flask-cursorrules-prompt-file.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/htmx-flask-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-flask-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-flask-cursorrules-prompt-file.mdManually: put the files in place
.clinerules/htmx-flask-cursorrules-prompt-file.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about htmx-flask-cursorrules-prompt-file
How do I install htmx-flask-cursorrules-prompt-file in Cursor?
Place the rule file at .cursor/rules/htmx-flask-cursorrules-prompt-file.mdc.
What does htmx-flask-cursorrules-prompt-file do?
It sets coding guidance for HTMX and Flask, covering server rendering, forms, URLs, JSON responses, database access, modular routes, and project structure.
Which Flask components does the rule cover?
It names Flask-WTF, Flask-SQLAlchemy, Flask-Migrate, Blueprint, request, jsonify, and render_template. The template guidance uses Jinja2 with HTMX attributes.
Source text
htmx-flask-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for HTMX development with Flask integration."
globs: **/*
alwaysApply: false
---
// HTMX with Flask .cursorrules
// HTMX and Flask best practices
const htmxFlaskBestPractices = [
"Use Flask's render_template for server-side rendering",
"Implement Flask-WTF for form handling",
"Utilize Flask's url_for for generating URLs",
"Use Flask's jsonify for JSON responses",
"Implement Flask-SQLAlchemy for database operations",
"Utilize Flask's Blueprint for modular applications",
];
// Folder structure
const folderStructure = `
app/
templates/
static/
css/
js/
models/
routes/
__init__.py
config.py
run.py
`;
// Additional instructions
const additionalInstructions = `
1. Use Jinja2 templating with HTMX attributes
2. Implement proper CSRF protection with Flask-WTF
3. Utilize Flask's request object for handling HTMX requests
4. Use Flask-Migrate for database migrations
5. Implement proper error handling and logging
6. Follow Flask's application factory pattern
7. Use environment variables for configuration
`;
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules