maksimzayats/specx/specx-add-core-use-case

Claude Code and agent skill by maksimzayats/specx

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Add or refactor a specx core scope use case. Use when implementing an externally meaningful application action under a core scope use_cases package, adding same-file command/query inputs, result DTOs, coordinating services, opening a unit-of-work transaction, or moving behavior out of delivery or infrastructure into class-based application code.

Install

npx vskill@latest install maksimzayats/specx/specx-add-core-use-case

SKILL.md

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

  1. Name the action directly, for example CreateInvoiceUseCase.
  2. Put it under core/<scope>/use_cases/<action>.py.
  3. Inherit BaseUseCase from specx.core.foundation.use_case.
  4. Define exactly one same-file input class: a Command for state-changing

use cases or a Query for read-only use cases. Even empty inputs are explicit.

  1. 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.

  1. 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.

  1. execute(...) accepts exactly one keyword-only argument named command or

query and returns DTOs, not entities.

  1. 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.

  1. Keep framework schemas, routers, ORM models, Redis clients, HTTP clients,

and entity return types out of the use case.

  1. Mark secret-bearing dataclass fields with field(repr=False) and never log

whole commands, queries, or DTOs that may contain sensitive values.

  1. 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.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
201
Repository forks
34
7-day trend score
0

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/maksimzayats/specx/specx-add-core-use-case/badge)](https://verified-skill.com/skills/maksimzayats/specx/specx-add-core-use-case)

Something wrong with this skill or its page? Tell us.