| name | full-feature |
| description | 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.
|
Full Feature Recipe
Step-by-step guide for building a complete feature that spans model, routes, and templates in a Flask + SQLAlchemy application.
Follow this template for each new feature. The steps must be completed in order — each step depends on the previous.
Feature Template
Use the template in template.md for the step-by-step implementation checklist.
Step 1: Define the Model
Add the SQLAlchemy model in models.py:
class NewEntity(db.Model):
__tablename__ = 'new_entities'
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
name = db.Column(db.String(100), nullable=False)
created_at = db.Column(db.DateTime, default=lambda: datetime.now(timezone.utc))
Then create and apply a migration:
flask db migrate -m "Add new_entities table"
flask db upgrade
Step 2: Create the Blueprint
Create routes/new_entity.py:
from flask import Blueprint, render_template, request, redirect, url_for, flash
from flask_login import login_required, current_user
from models import db, NewEntity
new_entity_bp = Blueprint('new_entity', __name__)
@new_entity_bp.route('/new-entities')
@login_required
def list_entities():
entities = NewEntity.query.filter_by(user_id=current_user.id).all()
return render_template('new_entity.html', entities=entities)
Register in create_app():
from routes.new_entity import new_entity_bp
app.register_blueprint(new_entity_bp)
Step 3: Add CRUD Routes
Add create, edit, and delete routes in the blueprint (see flask-sqlalchemy-wiring skill for patterns).
Step 4: Create the Template
Create templates/new_entity.html extending base.html:
- List view with search/filter
- Add form (modal or inline)
- Edit form (modal with data attributes)
- Delete form with confirmation
Step 5: Add Styles
Create static/css/new_entity.css and link it in the template:
{% block extra_css %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/new_entity.css') }}">
{% endblock %}
Step 6: Add Navigation
Add a nav link in base.html:
<a href="{{ url_for('new_entity.list_entities') }}"
class="{% if 'new_entity' in request.endpoint %}active{% endif %}">
New Entity
</a>
Step 7: Verify
- Run the app:
flask run --debug --port 5001
- Navigate to the new page
- Test Create → Read → Update → Delete
- Test with a different user to verify data isolation
- Test validation (required fields, duplicates)
- Check
flask routes to confirm all endpoints registered
Checklist