Skip to content
agents.store
stackstack

stack-flask-sqlalchemy

Flask + SQLAlchemy architecture plugin. How the application factory, the Flask-SQLAlchemy session, Alembic migrations and Jinja2 templates fit together: where db is created, the app context, the transaction boundary, expire_on_commit, N+1 at the route-to-template edge, and a full-feature recipe. Tool knowledge comes from its dependencies flask-dev and sqlalchemy-dev.

v2.0.4Updated

  • stack
  • flask-sqlalchemy
  • architecture
  • agents-store
  • flask
  • sqlalchemy
  • python
  • alembic

Install

Pick your agent for the steps.

Install on Claude Code

  1. 1.Add the marketplace

    /plugin marketplace add Agents-Store/claude-plugins
  2. 2.Install the plugin

    /plugin install stack-flask-sqlalchemy@agents-store-claude-plugins

    Type it inside Claude Code.

Claude Code install docs

What is inside

Skills (2)

  • full-feature

    Use when the user asks to "add a new feature", "create a new page", "build CRUD for a new entity", "add a new section to the app", "implement a full feature end-to-end", or needs a step-by-step recipe for building a complete feature across Flask + SQLAlchemy layers.

  • layers-and-boundaries

    Use when the user asks about "Flask SQLAlchemy architecture", "where to create db in Flask", "Flask app context and SQLAlchemy session", "when to commit in Flask", "Flask transaction boundary", "expire_on_commit in Flask-SQLAlchemy", "DetachedInstanceError in Flask", "Working outside of application context", "N+1 in a Jinja template", "lazy raise in Flask", "data saved in tests but lost in production", or needs the rules for where each layer of a Flask + SQLAlchemy app starts and ends.

Agents (1)

  • stack-orchestrator

    Use this agent when the user needs help coordinating work across Flask and SQLAlchemy layers — building features that span models, routes, and templates, debugging cross-layer issues, or planning multi-step implementations. <example> Context: User is building a new feature end-to-end user: "Build a finance tracking page where I can add expenses and see monthly earnings from appointments" assistant: "I'll use the stack-orchestrator agent to coordinate the implementation across model, routes, and templates." <commentary> Feature spans all layers — model (Spending), routes (finance blueprint), templates (finance.html), and queries (aggregate earnings from Appointment). Orchestrator coordinates the full implementation. </commentary> </example> <example> Context: User is debugging a cross-layer issue user: "My appointments page shows the wrong client name — it shows 'None' instead of the actual name" assistant: "I'll use the stack-orchestrator agent to trace the data flow from model through route to template." <commentary> Issue spans model relationships (Appointment→Client), the route's query (a missing joinedload, or a lazy='raise' error), and template rendering. Orchestrator traces the full data path. </commentary> </example> <example> Context: User wants to add authentication to existing pages user: "I need to add login/register and make sure each user only sees their own clients" assistant: "I'll use the stack-orchestrator agent to wire Flask-Login with the User model and add auth to all routes." <commentary> Auth touches every layer — User model, login routes, @login_required decorators, template conditionals, and query scoping by user_id (owned_by). The login flow itself is in flask-dev (auth-flask-login), the User model in sqlalchemy-dev. </commentary> </example>

README

Flask + SQLAlchemy architecture plugin for Agents Store. It describes how the application factory, the Flask-SQLAlchemy session, Alembic migrations and Jinja2 templates fit together: where db is created, what the app context owns, where the transaction ends, what expire_on_commit does to a request, and how a template stays free of queries. It names its parts in dependencies; what one tool does and how to drive it is taught by that tool's own plugin.

Note: Flask and SQLAlchemy are local Python libraries, not external services: there is no MCP server and no .env.example because there are no service URLs to configure. The value is in the boundaries.

Architecture

LayerLibraryRole
InterfaceFlask, Jinja2, Flask-Login, Flask-WTFRoutes, templates, sessions, CSRF
DataSQLAlchemy 2.0, Flask-SQLAlchemy, Flask-Migrate (Alembic)Models, queries, schema through migrations

The boundaries between them are what this plugin owns:

BoundaryRule
Where db livesextensions.py, created without an app; the factory imports the models
App contextOne session per app context; scripts, threads and tasks open their own and pass ids, not instances
TransactionOne commit() per unit of work, in the route; rollback() after an IntegrityError
Expiryexpire_on_commit stays on; Post/Redirect/Get; ids across contexts
Route to templatelazy='raise' on the model, selectinload / joinedload in the route, a statement-count test
SchemaMigrations only; no create_all() outside test fixtures

Dependencies

Declared in plugin.json and installed together with the stack. They hold the tool-level knowledge:

PluginTeaches
flask-devproject-scaffold (the files of a new project), auth-flask-login (login, registration, logout, CSRF), app-patterns (factory, blueprints, config, CRUD views, testing), Jinja2, the Flask CLI
sqlalchemy-devModels (model-patterns, including the Flask-Login User model), queries and owner-scoped queries (query-patterns), Alembic and Flask-Migrate (cli-recipes), SQLAlchemy 2.1

Prerequisites

  • Python 3.10 or newer
  • Flask 3.1 or newer
  • Flask-SQLAlchemy 3.1 with "SQLAlchemy<2.1": a plain install resolves SQLAlchemy 2.1, and a MappedAsDataclass base fails on it (pallets-eco/flask-sqlalchemy#1420; plain db.Model works), so pin SQLAlchemy<2.1 to be safe until Flask-SQLAlchemy supports 2.1:
pip install Flask Flask-SQLAlchemy "SQLAlchemy<2.1" Flask-Migrate Flask-Login Flask-WTF python-dotenv

Installation

claude plugin install stack-flask-sqlalchemy@agents-store-claude-plugins

flask-dev and sqlalchemy-dev come with it.

Skills

SkillDescription
layers-and-boundariesWhere db lives, the app context, the transaction boundary, expire_on_commit, N+1 at the route-to-template edge, what test fixtures hide
full-featureStep-by-step recipe for building a feature across model, migration, routes and templates

New project: flask-dev → project-scaffold. Login: flask-dev → auth-flask-login. CRUD views: flask-dev → app-patterns. Models and queries: sqlalchemy-dev.

Agent

stack-orchestrator — Cross-layer coordinator for building features that span models, migrations, routes and templates, and for debugging problems at the boundaries.