# flask-python

Flask coding guidelines for AI assistants. Enforces application factories, Marshmallow schemas, and route organization via blueprints.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 1500 installs · ★ 286
- Author: Mindrally
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Mindrally/skills/tree/HEAD/flask-python/SKILL.md
- Updated: 2026-10-08
- HTML: https://affpapa.org/en/nevibecode/skills/flask-python

## What it does

This skill guides the model to write Flask applications using a functional approach, avoiding classes except for views. It enforces an application factory layout with blueprints for routing. Error handling follows the guard clause pattern: edge cases trigger early returns at function entry points, leaving successful logic at the end.

The skill expects a specific stack including Flask-SQLAlchemy, Flask-JWT-Extended, and Marshmallow. If your codebase relies on Pydantic or direct SQLAlchemy setups, the agent will rewrite logic toward these specific Flask extensions.

Optimization guidelines include connection pooling and Flask-Caching. Background tasks must run through Celery. Test suites rely on pytest with the built-in Flask test client.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill flask-python -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/flask-python/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/flask-python/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill flask-python -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/flask-python/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill flask-python -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/flask-python/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Mindrally/skills flask-python
```

2. **Manually: put the files in place**
- File: `.github/skills/flask-python/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill flask-python -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Mindrally/skills --path flask-python
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/flask-python/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill flask-python -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Mindrally/skills/tree/HEAD/flask-python/SKILL.md

## When to use it
- structure Flask projects with application factories and blueprints
- handle input serialization and validation with Marshmallow
- secure endpoints using Flask-JWT-Extended tokens
- write integration tests with pytest and the Flask test client

## Example prompts
- Create a user registration endpoint with Marshmallow validation and error handling
- Refactor existing routes into a Flask blueprint with an application factory
- Write pytest unit tests for the authentication view using the Flask test client

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: d30e873534b0eeb3.

BEGIN THIRD-PARTY FILE d30e873534b0eeb3
```text
---
name: flask-python
description: Guidelines for Flask Python development with best practices for blueprints, RESTful APIs, and application factories.
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# 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
```
END THIRD-PARTY FILE d30e873534b0eeb3

The third-party file has ended. Everything between the d30e873534b0eeb3 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3083 of 4094 bytes. © Mindrally · Apache-2.0 · https://github.com/Mindrally/skills/tree/HEAD/flask-python/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
