agentleFS
MindrallyMindrally/skills/flask-python/SKILL.md

flask-python

Skill275 starsChanged 52 days agoApache-2.0View on GitHub

Guidelines for Flask Python development with best practices for blueprints, RESTful APIs, and application factories.

The file

Show its rules and text

We split this skill into the rules it gives an agent

26 rules. About 0 are common, 21 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈21

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write concise, technical responses with accurate Python examples

    line 15
  2. Distinctive:

    Use functional, declarative programming.

    line 16
  3. Distinctive:

    Prefer iteration and modularization over code duplication

    line 17
  4. Very specific:

    Use descriptive variable names with auxiliary verbs (e.g., is_active, has_permission)

    line 18
  5. Very specific:

    Use lowercase with underscores for directories and files (e.g., blueprints/user_routes.py)

    line 19
  6. Very specific:

    Use def for function definitions

    line 25
  7. Distinctive:

    Use concise one-line syntax for simple conditional statements

    line 29
  8. Distinctive:

    Use early returns for error conditions to prevent deep nesting

    line 34
  9. Distinctive:

    Place successful logic last in functions for improved readability

    line 35
  10. Very specific:

    Avoid unnecessary else statements.

    line 36
  11. Distinctive:

    Use custom error types or error factories for consistent handling

    line 39
  12. Distinctive:

    Use Flask application factories for modularity and testing

    line 52
  13. Very specific:

    Use Flask decorators: before_request, after_request, teardown_request

    line 56
  14. Distinctive:

    Use Flask-Caching for frequently accessed data

    line 64
  15. Distinctive:

    Use background tasks for time-consuming operations (e.g., Celery)

    line 68
  16. Distinctive:

    Use Flask's application context and request context appropriately

    line 72
  17. Distinctive:

    Use Flask-SQLAlchemy for ORM operations

    line 78
  18. Distinctive:

    Use Marshmallow for object serialization/deserialization and input validation

    line 84
  19. Distinctive:

    Create schema classes for each model for consistent handling

    line 85
  20. Distinctive:

    Use decorators for protecting routes requiring authentication

    line 90
  21. Distinctive:

    Write unit tests using pytest

    line 94
  22. Distinctive:

    Use Flask's test client for integration testing

    line 95
  23. Distinctive:

    Use Flask-RESTX or Flasgger for Swagger/OpenAPI documentation

    line 100
  24. Distinctive:

    Document all endpoints with request/response schemas

    line 101
  25. Distinctive:

    Use Gunicorn or uWSGI as WSGI HTTP Server

    line 105
  26. Distinctive:

    Use environment variables for sensitive information and configuration

    line 107

≈ “Common” is an estimate: at least 1 in 5 of the 383,637 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Flask Python Development

You are an expert in Flask and Python web development. Follow these guidelines when writing Flask code.

Key Principles

  • Write concise, technical responses with accurate Python examples
  • Use functional, declarative programming; avoid classes except for Flask views
  • Prefer iteration and modularization over code duplication
  • Use descriptive variable names with auxiliary verbs (e.g., is_active, has_permission)
  • Use lowercase with underscores for directories and files (e.g., blueprints/user_routes.py)
  • Favor named exports for routes and utility functions
  • Apply the Receive an Object, Return an Object (RORO) pattern where applicable

Python/Flask Standards

  • Use def for function definitions
  • Implement type hints for all function signatures where possible
  • Structure: Flask app initialization, blueprints, models, utilities, config
  • Omit unnecessary curly braces in conditionals
  • Use concise one-line syntax for simple conditional statements

Error Handling and Validation

  • Handle errors and edge cases at function entry points
  • Use early returns for error conditions to prevent deep nesting
  • Place successful logic last in functions for improved readability
  • Avoid unnecessary else statements; use if-return pattern instead
  • Employ guard clauses for preconditions and invalid states
  • Implement proper error logging with user-friendly messages
  • Use custom error types or error factories for consistent handling

Required Dependencies

  • Flask
  • Flask-RESTful (RESTful API development)
  • Flask-SQLAlchemy (ORM)
  • Flask-Migrate (database migrations)
  • Marshmallow (serialization/deserialization)
  • Flask-JWT-Extended (JWT authentication)

Flask-Specific Guidelines

  • Use Flask application factories for modularity and testing
  • Organize routes using Flask Blueprints
  • Leverage Flask-RESTful for class-based views
  • Implement custom error handlers for different exception types
  • Use Flask decorators: before_request, after_request, teardown_request
  • Utilize Flask extensions for common functionalities
  • Manage configurations via Flask's config object (development, testing, production)
  • Implement logging using Flask's app.logger
  • Handle authentication/authorization with Flask-JWT-Extended

Performance Optimization

  • Use Flask-Caching for frequently accessed data
  • Implement database query optimization (eager loading, indexing)
  • Apply connection pooling for database connections
  • Manage database sessions properly
  • Use background tasks for time-consuming operations (e.g., Celery)

Key Conventions

  1. Use Flask's application context and request context appropriately
  2. Prioritize API performance metrics (response time, latency, throughput)
  3. Structure application with blueprints, clear separation of concerns, and environment variables

Database Interaction

  • Use Flask-SQLAlchemy for ORM operations
  • Implement database migrations via Flask-Migrate
  • Properly manage SQLAlchemy sessions, ensuring closure after use

Serialization and Validation

  • Use Marshmallow for object serialization/deserialization and input validation
  • Create schema classes for each model for consistent handling

Authentication and Authorization

  • Implement JWT-based authentication using Flask-JWT-Extended
  • Use decorators for protecting routes requiring authentication

Testing

  • Write unit tests using pytest
  • Use Flask's test client for integration testing
  • Implement test fixtures for database and application setup

API Documentation

  • Use Flask-RESTX or Flasgger for Swagger/OpenAPI documentation
  • Document all endpoints with request/response schemas

Deployment

  • Use Gunicorn or uWSGI as WSGI HTTP Server
  • Implement proper logging and monitoring in production
  • Use environment variables for sensitive information and configuration

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.