Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

flask-expert

БесплатноБез исполняемых скриптовНе проверен

Builds, modernizes and audits Flask 3.x applications: application factories and blueprints, Flask-SQLAlchemy 3.1 with SQLAlchemy 2.x typed models and…

Jeffallanот Jeffallan★ 12 571 звезда на GitHub

Об этом скилле

Flask Expert

Senior Flask engineer for Flask 3.1 and SQLAlchemy 2.x on Python 3.11+: factory-built apps that start only with real configuration, typed models, JSON APIs that never answer in HTML, and tests that build a fresh app per test.

When to Use This Skill

  • Building a new Flask JSON API or server-rendered Flask app
  • Adding models, migrations, login, JWT auth, forms or validation to an existing Flask app
  • Writing pytest tests for a Flask app, or making an existing suite isolate its tests
  • Preparing a Flask app for production: gunicorn or waitress, reverse proxy, secure cookies, background jobs
  • Reviewing or modernizing legacy Flask code (module-level app, db.Column, Model.query, removed 2.x APIs)

Core Workflow

  1. Structure — Check the pinned Flask and Flask-SQLAlchemy versions and the existing layout; build new apps with create_app(test_config=None), unbound extensions and blueprints, settings from FLASK_* environment variables
  2. Data — Mapped/mapped_column models and select() queries with eager loading; schema changes go through Flask-Migrate
  3. Interface — JSON blueprints with schema validation (Pydantic, or the project's marshmallow) and an app-level JSON error handler, or Jinja templates with Flask-WTF forms and Post/Redirect/Get
  4. Secure — CSRFProtect for browser forms, Flask-Login sessions or Flask-JWT-Extended tokens, ownership checks on every row, production cookie flags
  5. Test & deploy — pytest fixtures that call the factory with a fresh database per test, or the project's existing fixtures (run them before calling the work done), then gunicorn behind ProxyFix (waitress on Windows) and jobs that run in an app context

Reference Guide

Topic Reference Load When
App structure references/app-structure.md Factory, config and secrets, extensions, blueprints, error handlers, CLI commands, Flask 3.x removals
Database references/database.md Models, queries, pagination, N+1, transactions, Flask-Migrate, projects pinned to Flask-SQLAlchemy 2.x
REST APIs references/rest-apis.md JSON responses, Pydantic validation, JSON errors, pagination envelope, CORS, async def views
Templates & forms references/templates-forms.md Jinja autoescaping, Flask-WTF forms, CSRF, flash messages, session cookie
Authentication references/authentication.md Password hashing, Flask-Login, Flask-JWT-Extended, cookie flags, ownership and roles
Testing references/testing.md pytest fixtures over the factory, per-test database, logged-in clients, CSRF-on tests, SQLite vs PostgreSQL
Deployment & jobs references/deployment.md gunicorn, waitress on Windows, ProxyFix, production config, Celery, RQ, scheduled jobs

Minimal Working Example

A factory, one blueprint and one typed model, configured from FLASK_SECRET_KEY and FLASK_SQLALCHEMY_DATABASE_URI:

# app.py: run with `flask --app app run --debug`
from flask import Blueprint, Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import String, select
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column


class Base(DeclarativeBase):
    pass


db = SQLAlchemy(model_class=Base)
bp = Blueprint("notes", __name__)


class Note(db.Model):
    id: Mapped[int] = mapped_column(primary_key=True)
    title: Mapped[str] = mapped_column(String(200))


@bp.get("/notes")
def list_notes() -> dict:
    notes = db.session.scalars(select(Note).order_by(Note.id)).all()
    return {"items": [{"id": n.id, "title": n.title} for n in notes]}


def create_app(test_config: dict | None = None) -> Flask:
    app = Flask(__name__)
    app.config.from_prefixed_env()  # FLASK_SECRET_KEY -> SECRET_KEY
    if test_config is not None:
        app.config.from_mapping(test_config)
    for key in ("SECRET_KEY", "SQLALCHEMY_DATABASE_URI"):
        if not app.config.get(key):
            raise RuntimeError(f"Set FLASK_{key}")
    db.init_app(app)
    app.register_blueprint(bp, url_prefix="/api")
    return app

Tables come from Flask-Migrate (flask db upgrade); only tests call db.create_all(). An API also needs the app-level HTTPException handler from app-structure.md.

Auditing an Existing Flask Project

First read the pins: on Flask-SQLAlchemy 2.x, items 1 and 3 do not apply (database.md). Run each command from the project root, adding --exclude-dir=.venv (your virtualenv); hits in test files are expected. Ordered by how often unaided code got it wrong:

  1. Models — grep -rnE 'db\.Column\(' --include='*.py' . → no hits; columns are Mapped[...] = mapped_column(...) (database.md).
  2. Factory — grep -rnE '^[a-z_]*app = (Flask|create_app)\(' --include='*.py' . → only entry points nothing imports (wsgi.py, Celery/RQ worker modules) (app-structure.md).
  3. Queries — grep -rnE '\b[A-Z]\w*\.query\b' --include='*.py' . → no hits; db.session.get, select(), db.get_or_404, `db.paginate(
Полный SKILL.md на GitHub

Установить flask-expert в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/app-structure.mdreferences/authentication.mdreferences/database.mdreferences/deployment.mdreferences/rest-apis.mdreferences/templates-forms.mdreferences/testing.md

FAQ

Что делает скилл flask-expert?

Builds, modernizes and audits Flask 3.x applications: application factories and blueprints, Flask-SQLAlchemy 3.1 with SQLAlchemy 2.x typed models and Flask-Migrate, JSON APIs validated with Pydantic or marshmallow and JSON errors, Jinja templates with Flask-WTF CSRF, Flask-Login and Flask-JWT-Extended auth, pytest fixtures over the factory, and gunicorn or waitress deployment with Celery, RQ or APScheduler jobs. Use when code imports from flask or flask_* extensions (create_app, Blueprint, app.route, flask_sqlalchemy, flask_login, flask_wtf), when adding login, an API endpoint, forms, tests, background jobs or production deployment to a Flask app, when reviewing or upgrading an existing Flask project, or when diagnosing Flask errors such as 'Working outside of application context' or a 500 that only appears under gunicorn. Not for Django or FastAPI projects.

Как установить скилл flask-expert?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл flask-expert запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить flask-expert с