scaffold-domain
Scaffold a full ArchiPy domain slice (DTOs, errors, repository + adapter, logic, service). Use for "add a <name> domain/module/feature", "new resource with CRUD", or "end-to-end endpoint".
- License 许可
- MIT
- 最近更新
- 2026-11-07
- Stars
- ★ 3
- Forks
- 1
01 前言 Front Matter
- name
- scaffold-domain
- description
- Scaffold a full ArchiPy domain slice (DTOs, errors, repository + adapter, logic, service). Use for "add a <name> domain/module/feature", "new resource with CRUD", or "end-to-end endpoint".
03 SKILL.md 正文
Scaffold ArchiPy Domain
Read first
Read these plugin rules in full before generating files (paths relative to this skill directory; Claude Code: ${CLAUDE_SKILL_DIR}/../../rules/):
../../rules/architecture-for-apps.mdc../../rules/using-archipy-utils.mdc../../rules/using-archipy-models.mdc../../rules/using-archipy-repositories.mdc../../rules/using-archipy-logics.mdc../../rules/using-archipy-services.mdc
Before writing files
- Inspect
pyproject.toml, the package tree, neighboring domains, DI containers, and existing tests. - Infer package name, installed extras, naming, transport, and sync/async style from the repository.
- Ask only for unresolved choices that materially change the generated slice:
- Domain name
- Missing infrastructure/extras
- Transport when the app does not already establish one (default FastAPI)
- Preserve existing files. Extend compatible modules; stop and explain conflicts instead of overwriting them.
Compose — do not fork templates
Before generating files, read these plugin skills in full. Resolve ../... paths relative to this SKILL.md file's
directory in the plugin installation ($PLUGIN_ROOT/skills/scaffold-domain/,
$CURSOR_PLUGIN_ROOT/skills/scaffold-domain/, or ${CLAUDE_SKILL_DIR}/) — not relative to the app workspace:
../scaffold-models/SKILL.md../scaffold-adapter/SKILL.md../scaffold-logic/SKILL.md../scaffold-service/SKILL.md
Apply their constraints and Verify sections in order; do not replace them with summaries:
- scaffold-models — domain/repo DTOs, errors, optional entities
- scaffold-adapter — thin wrapper under
repositories/<domain>/adapters/+<domain>_repository.py - scaffold-logic — at least one use-case under
logics/<domain>/ - scaffold-service —
services/<domain>/v1/<domain>_service.py
Install extras as needed: uv add "archipy[<extras>]".
Outcome checklist
- [ ] Domain + repository DTOs with ArchiPy naming (
*InputDTO,*CommandDTO, …); repository methods with 2+ params take one*CommandDTO/*QueryDTO - [ ] Domain error subclassing ArchiPy
BaseErrorhierarchy - [ ]
repositories/<domain>/adapters/+ repository orchestrator - [ ] One logic with
@postgres_sqlalchemy_atomicwhen Postgres SQLAlchemy is in play - [ ] One service v1 (FastAPI router or gRPC servicer)
- [ ] DI notes in
configs/containers.py: ports → adapters → repository → logic → service
Do not
- Call flow:
services → logics → repositories → adapters → ArchiPy. - Cross-domain: logics may call other logics; never another domain’s repository.
- Double quotes, Google-style docstrings, Python 3.14+ typing.
- Do not invent a top-level app
adapters/package. - No atomic / UoW decorators on repositories or services — only logics. There is no decorator named
atomic. - No FastAPI/gRPC imports in logics; no business rules in services/adapters.
Verify
- Run the repository's formatter and linter on generated Python.
- Add or run Behave scenarios that exercise the new endpoints over REST/gRPC with their
@needs-*containers (/scaffold-bdd), covering success, validation, and domain errors. - Confirm imports and DI wiring resolve without constructing production infrastructure.
- Run the
archipy-reviewersubagent on the changes and fix every Must fix finding it reports. - Report created/updated files, dependency changes, and commands run.
Docs
- https://syntaxarc.github.io/ArchiPy/getting-started/project_structure/
- https://syntaxarc.github.io/ArchiPy/getting-started/concepts/
- Bundled:
../archipy-docs/reference.md
04 同仓库更多 Skills
scaffold-utils
Add or wire pure helpers/utils, preferring ArchiPy utils (datetime, JWT, password, file, string). Use for "add a helper/util function", "format dates", "hash passwords", or "generate tokens".
scaffold-service
Scaffold a thin FastAPI router or gRPC servicer under services/{domain}/v{n}/ with AppUtils bootstrap. Use for "add an endpoint/route/API", "expose via REST/gRPC", or "new API version".
scaffold-observability
Configure ArchiPy 5.x OpenTelemetry traces, metrics, logs, and instrumentation. Use for "add tracing/metrics/OTel", "Prometheus/Pushgateway", or migrating off Sentry, Elastic APM, or old Prometheus.
scaffold-models
Scaffold ArchiPy models under models/: domain/repository DTOs, errors, optional entities and types. Use for "add DTO/schema/request/response model", "new error type", or "SQLAlchemy entity".
scaffold-logic
Scaffold an ArchiPy logic (use case) under logics/{domain}/ with a unit-of-work decorator and DTO I/O. Use for "add business logic", "new use case", "transactional operation", or "service layer method".
scaffold-interceptor
Add or wire cross-cutting FastAPI/gRPC interceptors or middleware, preferring ArchiPy's. Use for "add middleware", "request ID/logging/auth interceptor", or "gRPC interceptor".