com um clique
stk-api
// Generate async CRUD API endpoints for an existing stk model. Use when adding API routes, REST endpoints, or CRUD operations to an stk blueprint.
// Generate async CRUD API endpoints for an existing stk model. Use when adding API routes, REST endpoints, or CRUD operations to an stk blueprint.
Scaffold a new stk blueprint with models, views, templates, and Alembic migration. Use when creating a new feature module, adding a new section to the app, or scaffolding a blueprint.
Background knowledge for stk async Quart framework development. Auto-loads when working on stk-based code: models, views, templates, database queries, auth patterns, Vue frontend. Provides conventions, patterns, and gotchas so Claude writes correct async Quart code instead of Flask patterns.
Generate and review an Alembic database migration for stk. Use when adding or changing models, creating migrations, or managing database schema changes.
| name | stk-api |
| description | Generate async CRUD API endpoints for an existing stk model. Use when adding API routes, REST endpoints, or CRUD operations to an stk blueprint. |
| argument-hint | [ModelName] |
Models available:
!grep -rn "class.*Base" stk/*/models.py 2>/dev/null
Existing API routes:
!grep -rn "@bp\.\(get\|post\|put\|delete\|patch\)\|@bp\.route" stk/*/views.py 2>/dev/null | head -30
Find the model named $ARGUMENTS in the codebase. Read its full definition to understand fields, relationships, and existing to_dict()/from_dict().
Generate these endpoints in the model's blueprint views.py:
GET /api/<plural> — List with pagination, search, filteringPOST /api/<singular>/ — Create (note trailing slash)POST /api/<singular>/<id> — Update (POST, not PUT — stk convention)DELETE /api/<singular>/<id> — DeleteEvery endpoint must:
async def@auth_required("session") + @roles_required("admin")await g.db_session.execute(...) or await g.db_session.get(...)select() and .where() from sqlalchemy (NOT .filter() for new code, though existing code may use it)await Activity.register(current_user.id, "Action", data)await g.db_session.rollback() on error, log.exception() for logging{"message": "..."} for success/error responsesList endpoint must include:
PER_PAGE = 25 constant at module levelpage and per_page query paramssearch param with ilike on text fieldsawait g.db_session.execute(select(func.count()).select_from(Model)) then .scalar()import orjson as json and return Response(json.dumps(response_data), content_type="application/json"){"items": [...], "total": N, "perPage": N}Create/Update endpoints must:
{item: {...}} wrapper: json_data.get("item", {})await instance.from_dict(data), add to sessionawait instance.from_dict(data)await g.db_session.flush() before activity logging on create (to get the ID)Error responses: Return {"message": "..."} with status codes: 400 (validation), 404 (not found), 412 (server error).
If a page route doesn't exist yet, add one:
@bp.get("/<plural>/")
async def <plural>_page():
return await render_template("cms/<plural>.html")
Verify:
uv run ruff check --fix . && uv run ruff format .uv run python checks.py