Token导航 LogoToken导航

Agent Skill · 开发

architecture(架构)

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

architecture 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在开发类的 21,746 个 Skill 里排第 19,668。

总安装 261周安装 11GitHub Stars 101下载 92核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

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

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

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

architecture 指导 Django 项目架构设计,采用类型安全的分层模式。适用于新项目初始化或现有项目改造,分离 ORM 与业务逻辑。强制使用 Pydantic DTO 和依赖注入,确保类型系统一致性。使用前需确认项目是否已配置 uv 和 django-stubs 支持。

建议阅读完整文档后再实施,避免违反约定导致类型检查失败。

来源仓库内路径:skills/architecture

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

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

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

architecture 怎么安装?

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

architecture 支持哪些 AI 工具?

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

architecture 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

architecture 是免费的吗?

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

architecture 用的人多吗?

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

architecture 安全吗?

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

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

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

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

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。

不太适合

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

开发类 Skill 对比

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

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
architecture

架构 · 本页

261101需要联网未明确通过

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

SKILL.md 原文

Implement a Django Feature

You are implementing a feature in an opinionated, fully type-safe Django project managed with uv. Every convention below is mandatory. Do not deviate.

Why this architecture exists: Django's ORM is powerful but hard to type — querysets, model instances, related managers, and F()/Q() expressions don't play well with static type checkers. This project solves that by pushing all ORM usage into repositories that return Pydantic DTOs. Services receive repos via constructor injection and contain pure business logic with zero ORM imports. Views are thin dispatchers. The result: everything from the repository boundary outward is fully typed, IDE-friendly, and testable in isolation.

Tooling: uv is the package manager. All commands use uv run. Never use pip, poetry, or raw python — always uv run python, uv run pytest, etc. To add a dependency: uv add <package>.

BEFORE WRITING CODE

Gather current project state by reading:

  • src/project/ids.py — existing ID prefixes (must be unique)
  • src/project/services.py — registered repos/services
  • src/project/settings.py — INSTALLED_APPS
  • src/project/api/__init__.py — NinjaAPI(), mounted resource routers, exception handlers
  • src/project/api/<resource>/ — existing per-resource route packages
  • src/project/types.py — AuthedRequest and other shared request types
  • ARCHITECTURE.md if present — full pattern reference
  • Any existing app the feature touches

Then state your implementation plan: models, DTOs, repos, services, routes, tests, and ID prefixes.


LAYER-BY-LAYER IMPLEMENTATION

Follow this exact order. Do not skip layers. Each layer has rules that are non-negotiable.

Layer 1: ID Generator

Add to src/project/ids.py:

generate_xxx_id = _make_generator("xxx")  # 3-4 char prefix

Prefixes must be unique across the project and short enough to be readable in logs.

Layer 2: Model

File: src/<app>/models/<entity>.py

Follow the models skill for full conventions. The key rules:

  • class Meta is always first inside the model body — with verbose_name, verbose_name_plural, and indexes
  • CharField(max_length=64) primary key with prefixed ULID default — NEVER UUIDs, NEVER auto-increment
  • __prefix__: ClassVar[str] on every model
  • All indexes in Meta.indexes — never db_index=True on fields. Optimize for queries the repository actually runs.
  • ZERO business logic — no custom managers, no save() overrides, no signals, no properties that compute
  • __str__ is the only method allowed
from typing import ClassVar
from django.db import models
from project.ids import generate_xxx_id

class MyEntity(models.Model):
    class Meta:
        verbose_name = "my entity"
        verbose_name_plural = "my entities"
        indexes = [
            models.Index(fields=["created_at"], name="idx_%(class)s_created"),
        ]

    __prefix__: ClassVar[str] = "xxx"
    id = models.CharField(max_length=64, primary_key=True, default=generate_xxx_id, editable=False)
    # fields...
    def __str__(self):
        return self.name

If this is a new app, add it to INSTALLED_APPS in src/project/settings.py using the dotted path to its AppConfig (e.g., "myapp.apps.MyAppConfig").

Then run:

uv run python src/manage.py makemigrations && uv run python src/manage.py migrate

Layer 3: DTO

File: src/<app>/dtos/<entity>.py

RULES:

  • ALL ID fields are str — never UUID
  • model_config = ConfigDict(from_attributes=True) — always
  • For Django RelatedManager fields (reverse FKs, M2M), add the coercion validator:
@field_validator("children", mode="before")
@classmethod
def coerce_related_manager(cls, v):
    if hasattr(v, "all"):
        return list(v.all())
    return v

Layer 4: Repository

File: src/<app>/repositories/<entity>.py

RULES:

  • ORM objects NEVER leave this layer — every public method returns a DTO or list[DTO]
  • Convert with MyEntityDTO.model_validate(orm_obj)
  • prefetch_related() when the DTO has nested relations
  • @transaction.atomic on any method with multiple writes
  • One repo per aggregate root — child entities are managed by the parent's repo
  • All ID params are str

Layer 5: Service

File: src/<app>/services/<entity>.py

RULES:

  • Receives repos via __init__ — NEVER instantiates them, NEVER imports models
  • Contains all business logic: validation, orchestration, cross-repo coordination
  • Touches ZERO ORM — no .objects, no F(), no Q(), no model imports
  • Returns DTOs

Layer 6: Register in svcs

Add to src/project/services.py:

from myapp.repositories.my_entity import MyEntityRepository
from myapp.services.my_entity import MyEntityService

# Register the repository
registry.register_factory(MyEntityRepository, MyEntityRepository)

# Register the service with a factory that pulls its repo dependencies
def _my_entity_service_factory(container: svcs.Container) -> MyEntityService:
    repo = container.get(MyEntityRepository)
    return MyEntityService(repo)

registry.register_factory(MyEntityService, _my_entity_service_factory)

Both repos and services get registered. Service factories wire up repo dependencies via the container. The get() helper at the bottom of the file makes them available anywhere.

Layer 7: API Routes

Routes live in a per-resource package under src/project/api/ — NOT in app directories. Each resource is its own subpackage:

src/project/
└── api/
    ├── __init__.py          # NinjaAPI(), exception handlers, mounts routers
    ├── my_entities/
    │   ├── __init__.py      # re-exports `router` from routes
    │   ├── routes.py        # handlers
    │   └── schemas.py       # ninja.Schema input models
    └── other_resource/
        ├── __init__.py
        ├── routes.py
        └── schemas.py

RULES:

  • Input schemas are ninja.Schema classes defined in schemas.py next to the routes
  • Output schemas reuse the DTOs from the app — do not duplicate
  • The resource package's __init__.py re-exports the router from routes (e.g. from.routes import router)
  • The top-level src/project/api/__init__.py creates the NinjaAPI() instance, registers exception handlers, and mounts each resource router with api.add_router("/my-entities", my_entities_router)
  • Pattern: from project.services import get, then get(MyEntityService) to obtain a wired service
  • Every handler's first arg is typed request: AuthedRequest — never untyped. AuthedRequest lives in src/project/types.py and narrows request.user to an authenticated Django User
  • ID path params are str
  • Handlers do NOT try/except — errors bubble up to the central exception handler (see below)

src/project/api/my_entities/routes.py:

from typing import List

from ninja import Router, Status

from myapp.dtos.my_entity import MyEntityDTO
from myapp.services.my_entity import MyEntityService
from project.services import get
from project.types import AuthedRequest

from .schemas import CreateMyEntityIn

router = Router()

@router.get("/", response=List[MyEntityDTO])
def list_entities(request: AuthedRequest):
    return get(MyEntityService).list_entities()

@router.post("/", response={201: MyEntityDTO})
def create_entity(request: AuthedRequest, payload: CreateMyEntityIn):
    return Status(201, get(MyEntityService).create_entity(name=payload.name))

@router.get("/{entity_id}/", response=MyEntityDTO)
def get_entity(request: AuthedRequest, entity_id: str):
    return get(MyEntityService).get_entity(entity_id)
Central exception handlers

Services raise plain Python exceptions — ValueError for bad input, LookupError for missing records, PermissionError for forbidden access. They do NOT know about HTTP. The mapping happens once, centrally, in src/project/api/__init__.py:

  • ValueError → 400 {"detail": str(exc)}
  • LookupError → 404 {"detail": str(exc)}
  • PermissionError → 403 {"detail": str(exc)}
@api.exception_handler(ValueError)
def on_value_error(request, exc: ValueError):
    return api.create_response(request, {"detail": str(exc)}, status=400)

Route handlers MUST NOT wrap service calls in try/except — errors bubble up and the central handler turns them into responses.

Layer 8: Admin

File: src/<app>/admin.py

Follow the models skill for full admin conventions. The key rules:

  • Register every model with @admin.register
  • list_display — id first, then 3-5 most useful columns
  • list_per_page = 25 — keeps the admin fast on large tables
  • search_fields — always include id, plus name/title fields
  • readonly_fields — always include id (ULID PKs are never edited)
  • ordering — explicit, usually -created_at or the primary time field
  • list_select_related — specify FKs shown in list_display to avoid N+1s
  • raw_id_fields or autocomplete_fields for FKs to large tables
  • TabularInline for child models — extra = 0, show_change_link = True

TESTS

Write three test layers in tests/<app>/. No test file may be skipped.

test_repo.py — Real database, validate ORM ↔ DTO conversion

@pytest.mark.django_db
def test_create_and_get():
    repo = MyEntityRepository()
    dto = repo.create(name="Test", ...)
    assert isinstance(dto, MyEntityDTO)
    assert dto.id.startswith("xxx_")
    fetched = repo.get_by_id(dto.id)
    assert fetched == dto

@pytest.mark.django_db
def test_list_all():
    repo = MyEntityRepository()
    repo.create(name="A", ...)
    repo.create(name="B", ...)
    assert len(repo.list_all()) == 2

test_service.py — Mock the repos, validate business logic

Services are tested WITHOUT a database. Mock the repository. This is the most important test layer — it proves your business logic is correct independently of Django.

from unittest.mock import MagicMock

def test_create_delegates_to_repo():
    repo = MagicMock()
    expected = MyEntityDTO(id="xxx_fake", name="Test", ...)
    repo.create.return_value = expected

    service = MyEntityService(repo)
    result = service.create_entity(name="Test", ...)

    assert result == expected
    repo.create.assert_called_once_with(name="Test", ...)

def test_business_rule_rejects_bad_input():
    repo = MagicMock()
    # configure mock to trigger the rule
    service = MyEntityService(repo)

    with pytest.raises(ValueError, match="..."):
        service.do_something_invalid(...)

test_api.py — Integration through HTTP

@pytest.mark.django_db
def test_create(client):
    resp = client.post("/my-entities/", data={...}, content_type="application/json")
    assert resp.status_code == 201
    assert resp.json()["id"].startswith("xxx_")

@pytest.mark.django_db
def test_list_empty(client):
    resp = client.get("/my-entities/")
    assert resp.status_code == 200
    assert resp.json() == []

@pytest.mark.django_db
def test_get_by_id(client):
    create_resp = client.post("/my-entities/", data={...}, content_type="application/json")
    eid = create_resp.json()["id"]
    resp = client.get(f"/my-entities/{eid}/")
    assert resp.status_code == 200
    assert resp.json()["id"] == eid

RELIABLE SIGNALS (CELERY)

When a business operation needs to trigger async side-effects (notifications, cache invalidation, analytics), use reliable signals — NOT standard Django signals.

Signal Definition

File: src/<app>/signals.py

from project.signals import ReliableSignal

my_event = ReliableSignal()

Sending

Call send_reliable() inside a transaction.atomic() block in the service layer. Arguments MUST be JSON-serializable — pass entity IDs, never model instances:

# In the service method
def create_entity(self, name: str) -> MyEntityDTO:
    with transaction.atomic():
        entity = self.repo.create(name=name)
        my_event.send_reliable(sender=None, entity_id=entity.id)
    return entity

Receivers

File: src/<app>/receivers.py

Register with @receiver. Load receivers in apps.py → ready().

CRITICAL: Every receiver MUST be idempotent. The system guarantees at-least-once delivery, not exactly-once. A receiver may run more than once for the same event. Design accordingly:

  • Check if the action was already performed before performing it
  • Use database constraints or flags to prevent duplicate effects
  • Never assume a receiver runs exactly once
from django.dispatch import receiver
from .signals import my_event

@receiver(my_event)
def on_my_event(obj_id: str, **kwargs):
    # Idempotent: guard against duplicate execution
    if already_processed(obj_id):
        return
    do_work(obj_id)

apps.py

class MyAppConfig(AppConfig):
    def ready(self):
        from . import receivers  # noqa: F401

Testing Receivers

Test receivers in isolation. Mock external dependencies. Verify idempotency by calling the receiver twice with the same arguments:

def test_receiver_is_idempotent():
    on_my_event(obj_id="xxx_fake")
    on_my_event(obj_id="xxx_fake")  # second call must be safe
    # assert side-effect happened exactly once

RULES

  • NEVER use standard send() for post-commit side-effects — use send_reliable()
  • Arguments MUST be JSON-serializable (strings, numbers, booleans)
  • Receivers MUST be idempotent — this is non-negotiable
  • Receivers MUST NOT import or touch ORM models directly — use a repository if DB access is needed

VERIFY

Run all four checks. ALL must pass before you report done.

uv run ruff check src
uv run ruff format --check src
uv run pyrefly check src
uv run pytest

If anything fails, fix it and re-run.


COMPLETION CHECKLIST

Before reporting done, confirm every item:

  • ID generator in src/project/ids.py with unique 3-4 char prefix
  • Model: Meta first (verbose names + indexes), __prefix__ ClassVar, CharField PK with ULID default, zero logic
  • DTO: str IDs, from_attributes=True, RelatedManager coercion if needed
  • Repository: returns DTOs only, model_validate(), @transaction.atomic for multi-writes
  • Service: repos via __init__, zero ORM, business logic only
  • Repo and service registered in src/project/services.py
  • Routes in src/project/api/<resource>/routes.py, schemas in schemas.py, mounted in src/project/api/__init__.py using from project.services import get
  • request: AuthedRequest annotation on every handler
  • Central exception handlers registered in src/project/api/__init__.py (ValueError→400, LookupError→404, PermissionError→403)
  • Admin registered per models skill conventions (list_display, list_per_page = 25, search_fields, readonly_fields, ordering, raw_id_fields/autocomplete_fields for large FKs, inlines with extra = 0)
  • App in INSTALLED_APPS (if new) using dotted AppConfig path
  • Migrations generated and applied
  • test_repo.py: real DB, asserts ID prefix
  • test_service.py: mocked repos, tests business logic
  • test_api.py: HTTP integration, asserts status codes + response shape
  • Signals in src/<app>/signals.py if async side-effects needed
  • Receivers in src/<app>/receivers.py — idempotent, loaded in ready()
  • ruff check, ruff format --check, pyrefly check, pytest all pass

平台分布

Codex

33.67%
按下载量换算31

Claude

30.18%
按下载量换算28

Cursor

20.87%
按下载量换算19

Gemini CLI

8.89%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

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

继续浏览同类 Skills