Generate production-ready Flask Cursor rules for Project Rules (.mdc), AGENTS.md, or legacy .cursorrules. This template encodes stack-specific conventions for projects using Flask. Lightweight Python micro-framework with Jinja templates and Werkzeug routing.
The template focuses Cursor AI on concrete Flask practices instead of generic coding advice. Required sections are always included; optional sections can be enabled when they match your project.
Required guidance
- Application Factory
- Routes & Views
- Error Handling
- Database & ORM
Default style
- Indentation: 4 spaces
- Quotes: double
- Semicolons: disabled
- Naming: snake_case
Example Flask Rules
The generator turns these sections into Project Rules with frontmatter, AGENTS.md, or a single .cursorrules file depending on the output format you choose.
Application Factory
- Use the application factory pattern (create_app()).
- Use 4 spaces for indentation.
- Use snake_case for variables and functions.
- Use Blueprints for modular route organization.
- Register extensions in create_app() with init_app() pattern.
- Use app.config.from_object() and from_envvar() for configuration.
Routes & Views
- Use @bp.route() decorators within Blueprints.
- Use type hints for route parameters (<int:id>, <uuid:id>).
- Use request.get_json() for JSON request bodies.
- Return proper HTTP status codes for all responses.
- Use jsonify() or return dictionaries for JSON responses.
- Use url_for() for generating URLs — never hardcode paths.
Error Handling
- Use @bp.errorhandler() for route-level error handling.
- Use @app.errorhandler() for application-level error handlers.
- Define custom exception classes with appropriate HTTP status codes.
- Use abort() with status codes for expected error scenarios.
- Log errors with traceback information in production.
- Return structured JSON error responses for API endpoints.
What does the Flask Cursor rules template include?
It includes 4 rule sections covering application factory, routes & views, error handling and other Flask development conventions.
Can I generate Flask Project Rules and AGENTS.md from the same template?
Yes. The generator can export the same stack-specific guidance as modern Project Rules (.mdc), AGENTS.md, or a legacy .cursorrules file.
Should I combine Flask with other Cursor rules templates?
Yes. You can combine Flask with related templates such as TypeScript, Tailwind CSS, Docker, or backend frameworks when your project uses multiple technologies.