Flask patterns -- application factory, blueprints, error handlers, extensions, request lifecycle, configuration, logging, CLI commands
98
98%
Does it follow best practices?
Impact
98%
1.28xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent follows Flask best practices for request lifecycle hooks (before_request, after_request), flask.g usage, and proper project structure when building an event registration API.",
"type": "weighted_checklist",
"checklist": [
{
"name": "create_app factory",
"description": "app/__init__.py defines a create_app() function that creates and returns a Flask app -- not a module-level app",
"max_score": 10
},
{
"name": "Blueprints for routes",
"description": "Events and registrations routes use separate Blueprint objects in separate files under app/routes/",
"max_score": 8
},
{
"name": "before_request sets request ID on g",
"description": "A before_request hook reads X-Request-ID from request headers (or generates a UUID) and stores it on flask.g -- not a module-level variable",
"max_score": 10
},
{
"name": "after_request returns response with request ID",
"description": "An after_request hook adds the X-Request-ID header to the response AND returns the response object (not forgetting the return)",
"max_score": 10
},
{
"name": "Custom exception hierarchy",
"description": "Agent defines AppError base class with subclasses (NotFoundError, ValidationError, or similar) and routes raise these exceptions",
"max_score": 10
},
{
"name": "Consistent error envelope",
"description": "All error responses use {\"error\": {\"code\": \"...\", \"message\": \"...\"}} shape",
"max_score": 8
},
{
"name": "Extensions init_app pattern",
"description": "Extensions are instantiated in extensions.py without app and bound via init_app() in the factory",
"max_score": 8
},
{
"name": "Error handlers in factory",
"description": "Error handlers are registered centrally via register_error_handlers(app) called inside create_app()",
"max_score": 8
},
{
"name": "Generic exception handler logs error",
"description": "Catch-all Exception handler logs with app.logger.exception() before returning 500",
"max_score": 8
},
{
"name": "Config from environment",
"description": "Configuration uses environment variables with defaults, and create_app() accepts a config parameter for testing",
"max_score": 8
},
{
"name": "Per-request state on g not globals",
"description": "All per-request state (request ID, DB connections, etc.) is stored on flask.g -- no module-level mutable globals used for request-scoped data",
"max_score": 12
}
]
}