Install
$ agentstack add skill-maksimzayats-specx-specx-add-core-use-case ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
specx Add Core Use Case
Use this skill for one application action at a time. Read references/use-case.md before writing the use case.
Workflow
- Name the action directly, for example
CreateInvoiceUseCase. - Put it under
core//use_cases/.py. - Inherit
BaseUseCasefromspecx.core.foundation.use_case. - Define exactly one same-file input class: a
Commandfor state-changing
use cases or a Query for read-only use cases. Even empty inputs are explicit.
- Make commands inherit
specx.core.foundation.command.BaseCommand, queries inherit
specx.core.foundation.query.BaseQuery, and result DTOs inherit specx.core.foundation.dto.BaseDTO. Prefer @dataclass(frozen=True, kw_only=True, slots=True) for all of these core data classes unless the user asks for another model type.
- Treat commands and queries as input contracts, not DTOs. Do not make
commands or queries inherit BaseDTO, put them under dtos/, or add a DTO suffix.
execute(...)accepts exactly one keyword-only argument namedcommandor
query and returns DTOs, not entities.
- Inject services, capabilities, gateways, and UoW managers with
Injected[...]. Keep infrastructure/runtime settings out of core use cases; expose required business policy as a typed core value or collaborator. For transactional persistence, inject the scope UnitOfWorkManager and open the active unit of work inside execute(...). Do not inject repositories, SQLAlchemy sessions/engines/session factories, or concrete infrastructure adapters directly into use cases.
- Keep framework schemas, routers, ORM models, Redis clients, HTTP clients,
and entity return types out of the use case.
- Mark secret-bearing dataclass fields with
field(repr=False)and never log
whole commands, queries, or DTOs that may contain sensitive values.
- Add or update flat unit tests for the behavior. The test receives the
native pytest container fixture, registers local doubles or inline mocks before resolution, and resolves the use case with container.resolve(UseCaseClass). If the use case injects a UnitOfWorkManager, also add a core integration test under tests/integration/core/... against the real persistence graph (and the transactional database graph when database-backed).
CheckReadinessUseCase may live under core/health when readiness checks any required external dependency or multiple delivery layers reuse the policy. Add a core CheckLivenessUseCase only when framework-independent liveness policy is genuinely reused across deliveries; keep a simple process-only liveness response in delivery. HTTP paths, status codes, headers, and schemas always stay in delivery.
Transaction Rule
A use case may open one unit-of-work scope inside execute(...) when database work is part of the action. Inject the manager, not Provider[UnitOfWork] and not an active UoW instance, repository, SQLAlchemy session/engine/session factory, or concrete infrastructure adapter. Read/effect services may receive the active unit_of_work, but services do not open transactions. Repository calls from a use case stay rooted in the manager-owned unit_of_work variable.
Commands are allowed to change state. Queries are read-only and should not call repository mutators such as add, save, create, update, or delete, or invoke gateways with external write effects.
Code Style
Use blank lines as logical separators in all code. Keep related statements together, but separate independent setup, action, assertion, response, branch, and transformation groups so long blocks stay readable.
References
references/use-case.md- use-case class shape, DTO examples, UoW examples,
and test guidance.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: maksimzayats
- Source: maksimzayats/specx
- License: MIT
- Homepage: https://specx.dev
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.