generate-model

generate-model is a command for Claude Code from TheBeardedBearSAS/claude-craft. It costs 6 tokens per session (2,673 once invoked), scanned A, original, MIT.

A code-generation command for creating a SQLAlchemy database model with fields, relationships, validation, indexes, and constraints. SQLAlchemy is a Python library that maps application objects to database tables, and Alembic manages database structure changes over time.

In plain words
What is it for?
Use it to scaffold models such as users, products, or orders from a name and optional field definitions, including foreign-key relationships.
Why use it?
It reduces the repetitive work of defining a model and preparing the database migration needed to create or change its table.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter.

Part of the claude-craft plugin — 56 skills, 94 commands, 47 agents, 5 hooks shipped together

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.

agentmods
npx agentmods add commands/thebeardedbearsas/claude-craft/generate-model
Clone the repo
git clone --depth 1 https://github.com/TheBeardedBearSAS/claude-craft

Made for: Claude Code.

Or install claude-craft, the plugin that ships this one along with the rest of its 56 skills, 94 commands, 47 agents, 5 hooks.

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 generate-model

README.md
[![agentmods](https://agentmods.dev/badge/commands/thebeardedbearsas/claude-craft/generate-model.svg)](https://agentmods.dev/commands/thebeardedbearsas/claude-craft/generate-model)
Your own site
<a href="https://agentmods.dev/commands/thebeardedbearsas/claude-craft/generate-model"><img src="https://agentmods.dev/badge/commands/thebeardedbearsas/claude-craft/generate-model.svg" alt="Measured on agentmods" height="20"></a>
Per session 6 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,673 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found 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.00006 $0.02673
Opus 5 $0.00003 $0.01337
Sonnet 5 $0.00001 $0.00535
Haiku 4.5 $0.00001 $0.00267

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

Security

Grade A, and why

generate-model 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 2d 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.

.claude/commands/python/generate-model.md · 411 lines

How it starts

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

Génération Model SQLAlchemy

Tu es un développeur Python senior. Tu dois générer un model SQLAlchemy complet avec relations, validations et migration Alembic.

Arguments

$ARGUMENTS

Arguments :

  • Nom du model (ex: User, Product, Order)
  • (Optionnel) Champs au format field:type (ex: name:str email:str:unique)

Exemple : /python:generate-model Product name:str price:decimal category_id:uuid:fk

MISSION

Étape 1 : Analyser les Besoins

Identifier :

  • Nom du model et de la table
  • Champs et leurs types
  • Relations (ForeignKey, OneToMany, ManyToMany)
  • Index et contraintes
  • Validations

Étape 2 : Model SQLAlchemy 2.0

# app/models/{model}.py
from datetime import datetime
from decimal import Decimal
from typing import TYPE_CHECKING, Optional
from uuid import UUID, uuid4

from sqlalchemy import (
    Boolean,
    CheckConstraint,
    Column,
    DateTime,
    ForeignKey,
    Index,
    Numeric,
    String,
    Text,
    UniqueConstraint,
)
from sqlalchemy.dialects.postgresql import UUID as PGUUID
from sqlalchemy.orm import Mapped, mapped_column, relationship

from app.db.base_class import Base

if TYPE_CHECKING:
    from app.models.category import Category
    from app.models.order_item import OrderItem


class {Model}(Base):
    """
    Model {Model}.

    Représente {description}.

    Attributes:
        id: Identifiant unique UUID
        name: Nom du {model}
        description: Description optionnelle
        price: Prix du {model}
        is_active: Statut actif/inactif
        category_id: ID de la catégorie parente
        created_at: Date de création
        updated_at: Date de dernière modification
    """
    __tablename__ = "{model}s"

    # Contraintes de table
    __table_args__ = (
        UniqueConstraint("name", "category_id", name="uq_{model}_name_category"),
        CheckConstraint("price >= 0", name="ck_{model}_price_positive"),
        Index("ix_{model}s_category_active", "category_id", "is_active"),
    )

    # Colonnes
    id: Mapped[UUID] = mapped_column(
        PGUUID(as_uuid=True),
        primary_key=True,
        default=uuid4,
    )
    name: Mapped[str] = mapped_column(
        String(255),
        nullable=False,
        index=True,
    )
    slug: Mapped[str] = mapped_column(
        String(255),
        nullable=False,
        unique=True,
        index=True,
    )
    description: Mapped[Optional[str]] = mapped_column(
        Text,
        nullable=True,
    )
    price: Mapped[Decimal] = mapped_column(
        Numeric(10, 2),
        nullable=False,
        default=Decimal("0.00"),
    )
    quantity: Mapped[int] = mapped_column(
        default=0,
    )
    is_active: Mapped[bool] = mapped_column(
        Boolean,
        default=True,
        index=True,
    )

    # Foreign Keys
    category_id: Mapped[Optional[UUID]] = mapped_column(
        PGUUID(as_uuid=True),
        ForeignKey("categories.id", ondelete="SET NULL"),
        nullable=True,
        index=True,
    )

    # Timestamps
    created_at: Mapped[datetime] = mapped_column(
        DateTime,
        default=datetime.utcnow,
    )
    updated_at: Mapped[datetime] = mapped_column(
        DateTime,
        default=datetime.utcnow,
        onupdate=datetime.utcnow,
    )

    # Relations
    category: Mapped[Optional["Category"]] = relationship(
        "Category",
        back_populates="{model}s",
        lazy="selectin",
    )
    order_items: Mapped[list["OrderItem"]] = relationship(
        "OrderItem",
        back_populates="{model}",
        cascade="all, delete-orphan",
    )

    def __repr__(self) -> str:
        return f"<{Model}(id={self.id}, name={self.name}, price={self.price})>"

    @property
    def is_in_stock(self) -> bool:
        """Vérifie si le {model} est en stock."""
        return self.quantity > 0

    def update_stock(self, quantity_change: int) -> None:
        """Met à jour le stock."""
        new_quantity = self.quantity + quantity_change
        if new_quantity < 0:
            raise ValueError("Stock insuffisant")
        self.quantity = new_quantity

Read the full file on GitHub · 411 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. 2d ago First seen · 411 lines · 6 tokens per session scan A 01f08f0a97e6

Subscribe to this mod's changes

generate-model is a command published in the GitHub repository TheBeardedBearSAS/claude-craft (105 stars, last pushed 3d ago), licensed MIT. It adds 6 tokens to every session and 2,673 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.