scaffold-adapter
Scaffold a domain adapter under repositories/{domain}/adapters/ wrapping an ArchiPy adapter or external client. Use for "add Postgres/Redis/Kafka/S3/HTTP client", "integrate <service>", or "new adapter".
- License 许可
- MIT
- 最近更新
- 2026-11-07
- Stars
- ★ 3
- Forks
- 1
01 前言 Front Matter
- name
- scaffold-adapter
- description
- Scaffold a domain adapter under repositories/{domain}/adapters/ wrapping an ArchiPy adapter or external client. Use for "add Postgres/Redis/Kafka/S3/HTTP client", "integrate <service>", or "new adapter".
03 SKILL.md 正文
Scaffold ArchiPy Adapter
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-adapters.mdc../../rules/using-archipy-repositories.mdc
Before writing files
- Inspect
pyproject.toml, the target domain, neighboring adapters, ports, DI wiring, and tests. - Infer installed extras, naming, sync/async style, and existing ArchiPy integration.
- Ask only for unresolved choices:
- Domain and adapter purpose
- Sync or async when the repository does not establish one
- New external client when ArchiPy has no matching adapter
- Preserve existing adapters and contracts. Extend compatible code; do not overwrite.
Prefer ArchiPy
If ArchiPy already ships the client (Redis, Postgres, Kafka, …), prefer:
uv add "archipy[<extra>]"
and a thin domain wrapper — not a full reimplementation.
Generate
repositories/<domain>/
├── adapters/
│ └── <domain>_<purpose>_adapter.py # e.g. user_db_adapter.py
└── <domain>_repository.py # create stub if missing
- Thin wrapper: wrap ArchiPy adapter (or external client); own entity construction / query building; map client errors →
domain errors with
raise ... from e. - No in-memory mocks for BDD: scenarios run this adapter against its testcontainer (
@needs-*). A port-conforming fake is allowed only for a third-party API that has no container. - Ports: depend on ArchiPy ports when wrapping library adapters; add a local ABC only when the domain needs a custom contract.
Do not
- Sync and async must be separate classes.
- No business logic in adapters — map data and talk to infrastructure only.
- Do not create a top-level
adapters/<name>/package — domain adapters live under repositories. - Wire via DI in
configs/containers.py. - Never leak raw driver exceptions; always map with
raise ... from e.
Verify
- Run the repository's formatter and linter on generated Python.
- Run the Behave scenarios that reach this adapter through the services layer (its
@needs-*container,/scaffold-bdd); if Docker is unavailable, say so. - Confirm imports, port conformance, exception chaining, and DI wiring.
- Run the
archipy-reviewersubagent on the changes and fix every Must fix finding it reports. - Report files, dependency changes, and commands run.
Docs
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".