SkillAgentSearch skills...

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-Extend…

Install / Use

npx skills add Jeffallan/claude-skills --skill flask-expert

Installs into whichever agent you are using.

About this skill
πŸ“„

SKILL.md

Installable skill definition

Quality Score

89/100

Category

Operations

Supported Platforms

Universal

Our assessment of flask-expert

flask-expert scores 89/100 on our quality scale, 312th of 751 Operations skills we index (top 42%).

Its SKILL.md is 11 KB long, well organised into 13 sections with 1 code example: a thorough specification that gives an agent plenty to work with.

With 12,509 GitHub stars, it is one of the more widely adopted skills in the catalogue.

Substance
29/30
Structure
17/20
Description
15/15
Adoption
17/20
Freshness
15/15

Maintenance, license and trust

  • The repository was last updated yesterday, so flask-expert is actively maintained.
  • It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
  • Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit β€” read the skill file before letting an agent act on it.

flask-expert compared with similar skills

All 4 of these similar skills score higher than flask-expert; compare them before choosing.

SkillScoreStarsUpdatedFormat
flask-expert (this skill)by Jeffallan8912.5k1d agoSKILL.md
claude-memby thedotmack100119.6ktodayCLAUDE.md
Agent-Reachby Panniantong100114.5ktodayCLAUDE.md
headroomby headroomlabs-ai10080.8ktodayCLAUDE.md
Scraplingby D4Vinci100105.5ktodayMCP Server

Frequently asked questions

How do I install flask-expert?
Run npx skills add Jeffallan/claude-skills --skill flask-expert. The install tabs above show the steps for each supported agent.
Which AI agents does flask-expert work with?
It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
Is flask-expert safe to use?
It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
Is flask-expert still maintained?
The repository was last updated yesterday, so flask-expert is actively maintained.

name: flask-expert description: "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." license: MIT metadata: author: https://github.com/Saifullah1999Pk version: "1.0.0" domain: backend triggers: Flask, Flask app, Flask API, create_app, Blueprint, Flask-SQLAlchemy, Flask-Migrate, Flask-Login, Flask-WTF, Flask-JWT-Extended, Jinja2, Werkzeug, gunicorn, application context role: expert scope: implementation output-format: code related-skills: django-expert, fastapi-expert

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(max_per_page=...) (database.md).
  4. Secrets β€” grep -rnE 'SECRET_KEY["'\'']*\]? *= *["'\'']|SECRET_KEY.*(get(env)?\([^)]*,|\) or |token_(hex|urlsafe|bytes))' --include='*.py' . β†’ no hits: no literal, default or per-process random key; the factory raises when it is missing; and git ls-files | grep -E '(^|/)\.env$' β†’ no output and git check-ignore -q .env succeeds (exit 0): .env is git-ignored, only .env.example is committed (app-structure.md).
  5. API errors β€” grep -rnE '(errorhandler|register_error_handler)\(HTTPException' --include='*.py' . β†’ one app-level handler that answers JSON under /api/ (no output = HTML error pages) (rest-apis.md).
  6. Removed APIs β€” grep -rnE 'FLASK_ENV|\bapp\.env\b|before_(app_)?first_request|flask\.__version__|from flask import .*\b(Markup|escape)\b' --include='*.py' --include='.env*' --include='.flaskenv' . β†’ no hits (app-structure.md).
  7. Input β€” grep -rn 'request.get_json(' --include='*.py' . β†’ each body goes through one schema (Pydantic model_validate/TypeAdapter with extra="forbid", or the project's existing marshmallow schema): no truthiness checks, Model(**data), silent= or force= (rest-apis.md).
  8. Schema β€” grep -rnE 'create_all\(|text\(["'\'']ALTER' --include='*.py' . β†’ only in tests; a migrations/ folder exists and deploys run flask db upgrade (database.md).
  9. CSRF β€” grep -rn 'CSRFProtect(' --include='*.py' . β†’ initialized in the factory, {{ csrf_token() }} in every POST form, no hand-rolled token check (templates-forms.md).
  10. N+1 β€” grep -rn 'relationship(' --include='*.py' . β†’ lazy="raise_on_sql" (or per-query raiseload("*", sql_only=True)), and list queries that serialize a relationship use selectinload/joinedload (database.md).
  11. SQL β€” grep -rniE '(select|insert|update|delete) .*(" *\+|\+ *"|%s|\.format\()|f["'\''](select|insert|update|delete) ' --include='*.py' . β†’ no hits; text() takes values as :name parameters (database.md).
  12. Dev server β€” grep -rnE 'debug=True|app\.run\(' --include='*.py' . β†’ no debug=True; production starts gunicorn or waitress, never app.run (deployment.md).
  13. Scheduler β€” grep -rnE 'BackgroundScheduler\(|scheduler\.start\(' --include='*.py' . β†’ never in create_app() or at import: cron plus a flask command, or the Redis lease started from wsgi.py (deployment.md).
  14. Async views β€” grep -rn 'async def' --include='*.py' . β†’ flask[async] installed, and nobody expects more throughput: each request still holds a worker (rest-apis.md).

Constraints

MUST DO

  • Build new apps with create_app(test_config=None); a module-level app lives only in wsgi.py. An existing app keeps its structure and style: add the feature in place and suggest the factory, never convert it unasked
  • Require SECRET_KEY and the database URI from the environment, one value shared by every worker, and raise when missing
  • Write DeclarativeBase + Mapped models and select() queries; match the existing style on a Flask-SQLAlchemy 2.x pin
  • Change schemas with Flask-Migrate; pass max_per_page= to every paginate
  • Give every API an app-level JSON HTTPException handler; validate every JSON body with one schema library, Pydantic by default or the project's existing marshmallow/flask-smorest (422 on failure)
  • Use CSRFProtect app-wide for browser forms, hash passwords with Werkzeug, filter rows by owner
  • Ship pytest tests with a fresh database per test, through a fixture that calls the factory (an existing app without one: extend its own suite and fixtures, testing.md)

MUST NOT DO

  • Hardcode a secret, fall back to a literal or secrets.token_*() value, or commit .env: dev secrets go in a git-ignored .env, with only a placeholder .env.example committed
  • Use FLASK_ENV, before_first_request, flask.__version__ or from flask import Markup
  • Return HTML error pages or exception text from an API
  • Call db.create_all() or ALTER TABLE at import or in create_app()
  • Build SQL with f-strings, +, % or .format()
  • Serve with app.run()/debug=True on a server, or gunicorn on Windows; start APScheduler in create_app()

Output Templates

When implementing a Flask feature, provide:

  1. Factory (or existing app setup), extension and config changes, with the environment variables to set
  2. Models plus the flask db migrate/upgrade commands, and the blueprint views
  3. pytest tests using the factory fixture (or the project's existing fixtures), and a short note on decisions, version assumptions and caveats (an async def view still holds one worker per request), written into the README or a comment by the code, not only the chat

Knowledge Reference

Flask 3.1, Werkzeug, application factory, blueprints, Flask-SQLAlchemy 3.1, SQLAlchemy 2.x, Mapped, mapped_column, select(), Flask-Migrate, Alembic, Pydantic v2, marshmallow, flask-smorest, Flask-CORS, Jinja2, Flask-WTF, CSRFProtect, Flask-Login, Flask-JWT-Extended, pytest, gunicorn, waitress, ProxyFix, Celery, RQ, APScheduler

Related Skills

  • django-expert β€” batteries-included Python web apps with the Django ORM, admin and DRF
  • fastapi-expert β€” async-first Python APIs; prefer it over async def Flask views for async-heavy work

Documentation

Related Skills

View on GitHub
GitHub Stars12.5k
CategoryOperations
Updated1d ago
Forks1.2k

Languages

Python

Trust signals

100/100

From repository metadata: license, adoption, age and documentation. Not a code audit β€” see the Safety scan above for what the skill file itself contains.

No cautions
flask-expert β€” Universal Skill: Install & Safety Check | SkillAgent