Token导航 LogoToken导航

Agent Skill · 前端设计

models(models 前端)

用于辅助 Python 项目开发、测试、依赖管理和常见框架工作流。它适合让 Agent 阅读 Python 代码、定位测试问题、整理运行命令、生成脚本或分析数据处理逻辑。使用时需要确认项目虚拟环境、依赖版本和测试入口;涉及执行脚本、读写文件、访问数据库或调用外部 API 时,应先明确运行目录和输入输出范围,避免误改生产数据。

models 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 9,918。

总安装 190周安装 8GitHub Stars 101下载 67核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:models(models 前端)
来源仓库:https://github.com/dvf/opinionated-django
仓库路径:skills/models
安装命令:
npx skills add https://github.com/dvf/opinionated-django --skill models
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dvf/opinionated-django --skill models

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

models 规范 Django 模型定义结构与字段排列顺序。适用于新增或修改模型时保持代码整洁与查询效率。强制导入顺序与成员分组,便于团队协作与维护。models 属于前端设计类 Skill,可作为该场景下的辅助能力补充。使用前应查阅同应用其他模型及关联仓库,避免索引遗漏。

建议同步更新 admin.py 注册以保持后台管理一致性。

来源仓库内路径:skills/models

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/dvf/opinionated-django --skill models;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

models 怎么安装?

在终端执行 npx skills add https://github.com/dvf/opinionated-django --skill models。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

models 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

models 需要什么权限?

权限级别是只读。该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

models 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

models 用的人多吗?

公开数据是累计安装 190 次,近一周安装 8 次,下载 67 次,GitHub 101 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

models 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。
  • 标注为只读权限,试用阶段不容易误改本地文件。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。
  • 只想先试试效果、不希望它改动本地文件的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
models

models 前端 · 本页

190101只读未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Structure a Django Model

You are defining or restructuring a Django model in an opinionated, fully type-safe Django project. Every convention below is mandatory. Do not deviate.

BEFORE WRITING CODE

Read the model file being created or modified, plus:

  • src/project/ids.py — existing ID prefixes
  • Any existing models in the same app — for cross-model index considerations
  • The repository that queries this model — to understand real query patterns
  • src/<app>/admin.py — existing admin registrations

Model Structure

Every model follows this exact ordering of members:

from typing import ClassVar

from django.db import models

from project.ids import generate_xxx_id

class MyEntity(models.Model):
    # 1. Meta — ALWAYS first, before any field
    class Meta:
        verbose_name = "my entity"
        verbose_name_plural = "my entities"
        indexes = [
            models.Index(fields=["-created_at"], name="idx_%(class)s_recent"),
        ]
        constraints = [
            models.UniqueConstraint(fields=["slug"], name="uq_%(class)s_slug"),
        ]

    # 2. ClassVar prefix
    __prefix__: ClassVar[str] = "xxx"

    # 3. Identifiers — primary key, slugs, external refs
    id = models.CharField(
        max_length=64, primary_key=True, default=generate_xxx_id, editable=False
    )
    slug = models.SlugField(max_length=255)

    # 4. Time fields — created, updated, any dates/datetimes
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    # 5. Workflow / status / state (if applicable)
    status = models.CharField(max_length=20, choices=STATUS_CHOICES, default="draft")

    # 6. Everything else — domain fields
    name = models.CharField(max_length=255)
    description = models.TextField(blank=True)

    # 7. Relations — ForeignKey, OneToOne, ManyToMany (always last among fields)
    category = models.ForeignKey("categories.Category", on_delete=models.CASCADE)

    # 8. __str__ — only if useful, and the only method allowed
    def __str__(self) -> str:
        return self.name

Rules

Meta First

class Meta is always the first thing inside the model body — before __prefix__, before the primary key, before any field. This is non-negotiable. It puts the most important structural information (naming, indexes, ordering, constraints) at the top where it's immediately visible.

The ordering inside Meta itself:

  1. verbose_name and verbose_name_plural
  2. indexes
  3. constraints (unique constraints, check constraints)
  4. Anything else (ordering, abstract, etc.)

Always Declare verbose_name and verbose_name_plural

Every model's Meta must include both:

class Meta:
    verbose_name = "order item"
    verbose_name_plural = "order items"
  • Use lowercase, human-readable English
  • Never rely on Django's automatic pluralization — it gets edge cases wrong ("categorys", "order items" → "order itemss")
  • The verbose_name should read naturally in admin headers and log messages

Field Ordering

Fields are grouped by role, in this order:

  1. Identifiers — primary key, slugs, external reference codes, SKUs
  2. Time fields — created_at, updated_at, published_at, any date or datetime
  3. Workflow / status / state — status, stage, is_active, is_published (skip if the model has no lifecycle)
  4. Domain fields — everything else: name, description, price, quantity, etc.
  5. Relations — ForeignKey, OneToOneField, ManyToManyField — always last among fields

This ordering makes scanning a model top-to-bottom predictable: "what is it, when was it, where is it in its lifecycle, what does it contain, what does it relate to."

Uniqueness and Constraints in Meta

All uniqueness and constraints are declared in Meta.constraints — never use unique=True on individual fields. This keeps all structural rules in one place, right at the top of the model.

class Meta:
    verbose_name = "product"
    verbose_name_plural = "products"
    indexes = [
        models.Index(fields=["-created_at"], name="idx_%(class)s_recent"),
    ]
    constraints = [
        models.UniqueConstraint(fields=["sku"], name="uq_%(class)s_sku"),
        models.UniqueConstraint(fields=["store", "slug"], name="uq_%(class)s_store_slug"),
        models.CheckConstraint(check=models.Q(price__gte=0), name="ck_%(class)s_price_pos"),
    ]

Constraint naming convention:

  • Unique: uq_%(class)s_<short_description>
  • Check: ck_%(class)s_<short_description>

UniqueConstraint is strictly more powerful than unique=True — it supports multi-column uniqueness, conditional uniqueness (condition=), and naming. Use it exclusively.

Field verbose_name and help_text

Any field whose name is more than one word (joined by underscores) should have an explicit verbose_name so it reads cleanly in the admin:

price_at_purchase = models.DecimalField(
    verbose_name="price at purchase",
    max_digits=10,
    decimal_places=2,
)

Any field whose purpose is not immediately obvious from its name needs help_text. This shows up in the admin form below the field and serves as inline documentation:

idempotency_key = models.CharField(
    max_length=255,
    help_text="Client-generated key to prevent duplicate order submissions.",
)
retention_days = models.IntegerField(
    verbose_name="retention days",
    default=90,
    help_text="Number of days to retain this record before archival.",
)

Rules:

  • Single-word fields (name, price, status) don't need a verbose_name — Django infers it fine
  • Multi-word fields (price_at_purchase, is_published, created_by) always get an explicit verbose_name
  • Obscure or domain-specific fields always get help_text — if a new developer would need to ask "what is this?", add it
  • Keep help_text to one sentence, written for someone reading the admin form

Specify Indexes in Meta

All indexes are declared in Meta.indexes — never use db_index=True on individual fields. Centralizing indexes makes them reviewable at a glance and enables composite indexes that db_index=True cannot express.

class Meta:
    verbose_name = "order"
    verbose_name_plural = "orders"
    indexes = [
        models.Index(fields=["customer", "created_at"], name="idx_%(class)s_cust_created"),
        models.Index(fields=["status", "-created_at"], name="idx_%(class)s_status_recent"),
    ]

Index naming convention: idx_%(class)s_<short_description> — Django interpolates %(class)s to the lowercased model name, keeping names unique across models.

Optimize Indexes for How the Model Is Used

Don't index speculatively. Read the repository that queries this model and index for the queries that actually exist:

  • Filter + order → composite index with filter columns first, order column last: fields=["status", "-created_at"]
  • Foreign key lookups → Django auto-creates indexes on ForeignKey fields, but if you always filter the FK *with* another column, replace it with a composite: fields=["order", "product"]
  • Prefix for descending sort → use - prefix: fields=["-created_at"] for queries that ORDER BY created_at DESC
  • Covering queries → if a query only reads a small set of columns, consider include (Postgres): models.Index(fields=["status"], include=["total"], name="idx_%(class)s_status_cov")
  • Partial indexes → if a query always filters on a condition, use condition: models.Index(fields=["created_at"], condition=models.Q(status="pending"), name="idx_%(class)s_pending")
  • Don't duplicate — Django auto-creates an index for every ForeignKey and UniqueConstraint. Don't add a redundant single-column index for those.
  • Don't over-index — every index slows writes. Three or four well-chosen indexes beat eight speculative ones.

No Business Logic

Models contain ZERO business logic:

  • No custom managers
  • No save() overrides
  • No signals
  • No properties that compute
  • __str__ is the only method allowed — and only if it adds value (skip it if the default ModelName object (pk) is fine)

Admin Registration

Every model gets registered in src/<app>/admin.py with a clean, fast-loading configuration. The admin should be aesthetic — well-organized, readable, and snappy even on large tables.

from django.contrib import admin

from .models.order import Order, OrderItem

class OrderItemInline(admin.TabularInline):
    model = OrderItem
    fields = ("id", "product", "quantity", "price_at_purchase")
    readonly_fields = ("id",)
    extra = 0
    show_change_link = True

@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
    list_display = ("id", "date", "total")
    list_per_page = 25
    search_fields = ("id",)
    readonly_fields = ("id",)
    ordering = ("-date",)
    fieldsets = (
        (None, {"fields": ("id", "date")}),
        ("Details", {"fields": ("total",)}),
    )
    inlines = [OrderItemInline]

Admin Rules

  • list_display — id first, then the most useful columns. Keep it to 4-6 fields max for readability.
  • list_per_page = 25 — default 100 is too slow on large tables. 25 keeps the admin snappy.
  • search_fields — always include id. Add name/title fields if they exist. Never search on unindexed columns.
  • readonly_fields — always include id (ULID PKs should never be edited). Add computed or auto-set fields.
  • ordering — explicit ordering so the admin doesn't rely on the default PK sort. Use -created_at or the most natural time field.
  • fieldsets — structure the change view for readability. Always place identifiers (id, timestamps) in the first fieldset at the top so they're immediately visible. Group remaining fields logically: fieldsets = ((None, {"fields": ("id", "created_at", "updated_at")}), ("Details", {"fields": ("name", "description", "status")}), ("Relations", {"fields": ("category",)}),) The first fieldset (with None title) keeps IDs and timestamps prominent with no collapsible header. Use named sections for the rest.
  • list_select_related — specify FK fields shown in list_display to avoid N+1 queries: list_select_related = ("customer",)
  • raw_id_fields — use for any FK to a large table. The default dropdown loads every row: raw_id_fields = ("product",)
  • extra = 0 on inlines — never show empty inline forms by default.
  • show_change_link = True on inlines — lets you click through to the inline's own admin page.
  • TabularInline for child models on the parent's admin.
  • No list_filter on unindexed columns — filtering on unindexed columns causes full table scans.
  • autocomplete_fields — prefer over raw_id_fields when the related model has search_fields configured for a better UX: autocomplete_fields = ("customer",)
  • date_hierarchy — use on the primary date field if the model is time-series-like (orders, events, logs). Only use on indexed date fields.

Full Example

from typing import ClassVar

from django.db import models

from products.models.product import Product
from project.ids import generate_itm_id, generate_ord_id

class Order(models.Model):
    class Meta:
        verbose_name = "order"
        verbose_name_plural = "orders"
        indexes = [
            models.Index(fields=["-date"], name="idx_%(class)s_recent"),
            models.Index(fields=["status", "-date"], name="idx_%(class)s_status_recent"),
        ]
        constraints = [
            models.UniqueConstraint(
                fields=["idempotency_key"],
                name="uq_%(class)s_idempotency",
            ),
        ]

    __prefix__: ClassVar[str] = "ord"

    # Identifiers
    id = models.CharField(
        max_length=64, primary_key=True, default=generate_ord_id, editable=False
    )
    idempotency_key = models.CharField(
        verbose_name="idempotency key",
        max_length=255,
        help_text="Client-generated key to prevent duplicate order submissions.",
    )

    # Time
    date = models.DateTimeField(auto_now_add=True)

    # Status
    status = models.CharField(max_length=20, default="pending")

    # Domain
    total = models.DecimalField(max_digits=12, decimal_places=2)

    def __str__(self) -> str:
        return f"Order {self.id} on {self.date}"

class OrderItem(models.Model):
    class Meta:
        verbose_name = "order item"
        verbose_name_plural = "order items"
        indexes = [
            models.Index(fields=["order", "product"], name="idx_%(class)s_ord_prd"),
        ]

    __prefix__: ClassVar[str] = "itm"

    # Identifiers
    id = models.CharField(
        max_length=64, primary_key=True, default=generate_itm_id, editable=False
    )

    # Domain
    quantity = models.PositiveIntegerField()
    price_at_purchase = models.DecimalField(
        verbose_name="price at purchase",
        max_digits=10,
        decimal_places=2,
        help_text="Snapshot of the product price at the time the order was placed.",
    )

    # Relations
    order = models.ForeignKey(Order, related_name="items", on_delete=models.CASCADE)
    product = models.ForeignKey(Product, on_delete=models.CASCADE)

    def __str__(self) -> str:
        return f"{self.quantity} x {self.product.name} (Order {self.order_id})"  # type: ignore[attr-defined]

Admin for the example above:

from django.contrib import admin

from .models.order import Order, OrderItem

class OrderItemInline(admin.TabularInline):
    model = OrderItem
    fields = ("id", "product", "quantity", "price_at_purchase")
    readonly_fields = ("id",)
    extra = 0
    show_change_link = True

@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
    list_display = ("id", "status", "date", "total")
    list_per_page = 25
    search_fields = ("id", "idempotency_key")
    readonly_fields = ("id", "date")
    ordering = ("-date",)
    date_hierarchy = "date"
    fieldsets = (
        (None, {"fields": ("id", "date")}),
        ("Details", {"fields": ("status", "total", "idempotency_key")}),
    )
    inlines = [OrderItemInline]

Verify

After creating or modifying models:

uv run python src/manage.py makemigrations && uv run python src/manage.py migrate
uv run ruff check src
uv run ruff format --check src
uv run pyrefly check src
uv run pytest

All must pass. Fix any issue rather than silencing it.

Checklist

  • class Meta is the first thing inside the model body
  • verbose_name and verbose_name_plural are set — never relying on Django's auto-pluralization
  • Field order: identifiers → time → status/state → domain → relations
  • All indexes in Meta.indexes — no db_index=True on fields
  • All uniqueness in Meta.constraints via UniqueConstraint — no unique=True on fields
  • Check constraints in Meta.constraints where applicable
  • Indexes match actual query patterns from the repository layer
  • No over-indexing — only index what is queried
  • Multi-word fields have explicit verbose_name
  • Obscure or domain-specific fields have help_text
  • No business logic — no custom managers, save(), signals, or computed properties
  • __str__ only if useful, and the only method allowed
  • Model registered in admin with list_display, list_per_page = 25, search_fields, readonly_fields, ordering, fieldsets
  • fieldsets places id and timestamps in the first (untitled) fieldset at the top of the change view
  • FKs to large tables use raw_id_fields or autocomplete_fields
  • Inlines use extra = 0 and show_change_link = True
  • Migrations generated and applied
  • ruff, pyrefly, pytest all pass

平台分布

Codex

36.48%
按下载量换算24

Claude

29.27%
按下载量换算20

Cursor

19.14%
按下载量换算13

Gemini CLI

9.79%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills