app-factory

app-factory is a command for Claude Code from swesmith/davila7__claude-code-templates.734b8a50. It costs 0 tokens per session (2,558 once invoked), scanned A, a copy of app-factory, MIT.

A Flask application setup based on the factory pattern: a function that creates and configures the app when needed. It also organizes features into blueprints, which are separate groups of routes and related code.

In plain words
What is it for?
Use it to start a Flask project with configuration management, database and authentication extensions, modular blueprints, and logging.
Why use it?
It gives larger Flask projects a consistent structure for different settings, shared extensions, error handling, and logging.

Command for Claude Code

Written for Claude Code: installed under .claude/.

Good fit Use it to start a Flask project with configuration management, database and authentication extensions, modular blueprints, and logging.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/swesmith/davila7__claude-code-templates.734b8a50/app-factory
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/swesmith/davila7__claude-code-templates.734b8a50

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for app-factory

README.md
[![agentmods](https://agentmods.dev/badge/commands/swesmith/davila7__claude-code-templates.734b8a50/app-factory/github.svg)](https://agentmods.dev/commands/swesmith/davila7__claude-code-templates.734b8a50/app-factory)
Your own site
<a href="https://agentmods.dev/commands/swesmith/davila7__claude-code-templates.734b8a50/app-factory"><img src="https://agentmods.dev/badge/commands/swesmith/davila7__claude-code-templates.734b8a50/app-factory/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for app-factory

Your own site · 80×15
<a href="https://agentmods.dev/commands/swesmith/davila7__claude-code-templates.734b8a50/app-factory"><img src="https://agentmods.dev/badge/commands/swesmith/davila7__claude-code-templates.734b8a50/app-factory.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,558 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.02558
Opus 5 $0.00000 $0.01279
Sonnet 5 $0.00000 $0.00512
Haiku 4.5 $0.00000 $0.00256

Measured 6d ago against content hash 2b42862b53d1, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

app-factory scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to app-factory — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

cli-tool/templates/python/examples/flask-app/.claude/commands/app-factory.md · 384 lines

How it starts

The opening of the file, as written. The whole thing — 384 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Flask Application Factory Pattern

Create a scalable Flask application using the factory pattern with blueprints and configuration management.

Purpose

This command helps you set up a Flask application using the application factory pattern, which is the recommended approach for larger Flask applications.

Usage

/app-factory

What this command does

  1. Creates application factory with proper structure
  2. Sets up configuration management for different environments
  3. Implements blueprints for modular design
  4. Configures extensions (database, auth, etc.)
  5. Adds error handling and logging

Example Output

# app/__init__.py
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_login import LoginManager
from flask_mail import Mail
from flask_wtf.csrf import CSRFProtect
from flask_cors import CORS
import logging
from logging.handlers import RotatingFileHandler
import os

# Initialize extensions
db = SQLAlchemy()
migrate = Migrate()
login = LoginManager()
mail = Mail()
csrf = CSRFProtect()
cors = CORS()

def create_app(config_class=None):
    """Application factory function."""
    app = Flask(__name__)
    
    # Load configuration
    if config_class is None:
        config_class = os.environ.get('FLASK_CONFIG', 'development')
    
    if isinstance(config_class, str):
        from app.config import config
        app.config.from_object(config[config_class])
    else:
        app.config.from_object(config_class)
    
    # Initialize extensions
    db.init_app(app)
    migrate.init_app(app, db)
    login.init_app(app)
    mail.init_app(app)
    csrf.init_app(app)
    cors.init_app(app)
    
    # Configure login manager
    login.login_view = 'auth.login'
    login.login_message = 'Please log in to access this page.'
    login.login_message_category = 'info'
    
    # Register blueprints
    from app.main import bp as main_bp
    app.register_blueprint(main_bp)
    
    from app.auth import bp as auth_bp
    app.register_blueprint(auth_bp, url_prefix='/auth')
    
    from app.api import bp as api_bp
    app.register_blueprint(api_bp, url_prefix='/api')
    
    from app.admin import bp as admin_bp
    app.register_blueprint(admin_bp, url_prefix='/admin')
    
    # Error handlers
    from app.errors import bp as errors_bp
    app.register_blueprint(errors_bp)
    
    # Configure logging
    if not app.debug and not app.testing:
        if not os.path.exists('logs'):
            os.mkdir('logs')
        
        file_handler = RotatingFileHandler(
            'logs/app.log', 
            maxBytes=10240, 
            backupCount=10
        )
        file_handler.setFormatter(logging.Formatter(
            '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'
        ))
        file_handler.setLevel(logging.INFO)
        app.logger.addHandler(file_handler)
        
        app.logger.setLevel(logging.INFO)
        app.logger.info('Flask application startup')
    
    return app

# Import models (avoid circular imports)
from app import models

Read the full file on GitHub · 384 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 384 lines · 0 tokens per session scan A 2b42862b53d1

Subscribe to this mod's changes

app-factory is a command published in the GitHub repository swesmith/davila7__claude-code-templates.734b8a50 (2 stars, last pushed 8mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,558 tokens. A static security scan graded it A with 0 findings. It is 100% identical to app-factory, differing in 0 lines, and is treated as a copy.