Skip to main content
rule

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.

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

What 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, and routes layout.
  • Add an HTMX form with Flask-WTF, CSRF protection, and request handling through request.
  • Move the routes into Blueprint modules and add migrations with Flask-Migrate.

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

Manually: put the files in place

.cursor/rules/htmx-flask-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-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

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set210

javascript-astro-tailwind-css-cursorrules-prompt-f Cursor rule for Astro and Tailwind CSS projects. Enforces clean component composition, static page generation, and disciplined island hydration. ★ 41,024repo stars java-springboot-jpa-cursorrules-prompt-file This rule guides Cursor when building Java Spring Boot projects with JPA, DTOs, and layered APIs. Use it when generated code should follow a fixed structure. ★ 41,024repo stars 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-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 htmx-basic-cursorrules-prompt-file Guides Cursor when building HTMX interfaces with server templates, clean folder layouts around app.py, and standard request attributes. ★ 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

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