CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/flask-best-practices

Flask patterns -- application factory, blueprints, error handlers, extensions, request lifecycle, configuration, logging, CLI commands

98

1.28x
Quality

98%

Does it follow best practices?

Impact

98%

1.28x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-4/

{
  "context": "Tests whether the agent follows Flask best practices including application factory, configuration classes, blueprints, error handling, request lifecycle logging, and proper project structure when building a support ticket system.",
  "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": "Config classes",
      "description": "Configuration is organized into classes (Development, Testing, Production) that inherit from a base config, with environment variables and sensible defaults -- not hardcoded values scattered in the factory",
      "max_score": 10
    },
    {
      "name": "Blueprints in separate files",
      "description": "Tickets, comments, and health routes use separate Blueprint objects in separate files under app/routes/",
      "max_score": 8
    },
    {
      "name": "Blueprints registered in factory",
      "description": "Blueprints are imported inside create_app() and registered with app.register_blueprint()",
      "max_score": 8
    },
    {
      "name": "Custom exception hierarchy",
      "description": "Agent defines AppError base class with subclasses and routes raise these exceptions rather than returning error dicts",
      "max_score": 10
    },
    {
      "name": "Consistent error envelope",
      "description": "All error responses use {\"error\": {\"code\": \"...\", \"message\": \"...\"}} or equivalent consistent shape for all error types",
      "max_score": 10
    },
    {
      "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": "Request logging with before/after hooks",
      "description": "Request logging uses before_request and/or after_request hooks (storing start time on flask.g, computing duration in after_request) -- after_request returns the response",
      "max_score": 10
    },
    {
      "name": "Generic exception handler",
      "description": "A catch-all Exception handler logs with app.logger.exception() and returns 500 without leaking internal details",
      "max_score": 8
    },
    {
      "name": "Error handlers registered centrally",
      "description": "Error handlers are registered via register_error_handlers(app) in create_app() -- not per-blueprint",
      "max_score": 8
    },
    {
      "name": "Test fixtures use factory with testing config",
      "description": "tests/conftest.py creates the app via create_app() with testing config and provides app/client fixtures",
      "max_score": 10
    }
  ]
}

evals

tile.json