$npx -y skills add maksimzayats/specx --skill specx-foundationUse specx foundation bases in Python services, or add a tiny project-local foundation/ base for missing categories or stateful framework bases.
| 1 | # specx Foundation |
| 2 | |
| 3 | Use this skill when a service class needs an explicit base, or when a new class |
| 4 | category may need a project-local foundation base. Read |
| 5 | `references/foundation.md` before editing foundation-related code. |
| 6 | |
| 7 | ## Workflow |
| 8 | |
| 9 | 1. Prefer packaged scoped bases from `specx.core.foundation`, |
| 10 | `specx.delivery.foundation`, and `specx.infrastructure.foundation`. |
| 11 | 2. Do not create an empty `src/<package>/foundation/` package. |
| 12 | 3. Add a project-local `foundation/` module only when current code needs a real |
| 13 | project-local base category or a stateful framework base that must not be |
| 14 | shared globally, such as a SQLAlchemy declarative base. |
| 15 | 4. Keep project-local foundation limited to base definitions: marker bases, |
| 16 | common external-base wrappers, justified ABCs, and stateful framework bases. |
| 17 | Put stable cross-scope concrete primitives under `shared/`, not |
| 18 | `foundation/`. |
| 19 | 5. Give every project source class, including each local base, a docstring that |
| 20 | explains what it protects and includes a concrete usage example. |
| 21 | 6. Make every non-foundation project source class inherit an explicit scoped |
| 22 | base. |
| 23 | 7. Name each class with the suffix implied by its base ancestry, such as |
| 24 | `TaskDTO`, `TaskEntity`, `TaskResponseSchema`, `CreateTaskUseCase`, or |
| 25 | `TaskTitleNormalizerService`. |
| 26 | 8. Use `BaseLifecycle` for delivery app lifespan managers such as |
| 27 | `FastAPILifecycle`. |
| 28 | 9. Prefer `@dataclass(frozen=True, kw_only=True, slots=True)` for commands, |
| 29 | queries, DTOs, entities, and other core data classes unless the user asks for |
| 30 | another model type. |
| 31 | 10. Keep `BaseCommand` and `BaseQuery` as use-case input bases, independent from |
| 32 | `BaseDTO`. Commands and queries are not result DTOs. |
| 33 | 11. When an application value has a limited known set, model it with |
| 34 | `BaseStrEnum` instead of plain `str` or `Literal[...]`. |
| 35 | 12. Keep business rules, delivery behavior, adapter code, and runtime wiring out |
| 36 | of project-local foundation modules. |
| 37 | |
| 38 | ## Code Style |
| 39 | |
| 40 | Use blank lines as logical separators in all code. Keep related statements |
| 41 | together, but separate independent setup, action, assertion, response, branch, |
| 42 | and transformation groups so long blocks stay readable. |
| 43 | |
| 44 | ## References |
| 45 | |
| 46 | - `references/foundation.md` - packaged base catalog, import paths, extension |
| 47 | rules, and architecture guardrails. |