usecase

Enforce transport-agnostic Request and UseCase patterns with strict transaction boundaries.

33|5|Updated Feb 12, 2024
One-click install
npx skills add https://github.com/ocbunknown/fastapi-claude-template --skill usecase-ocbunknown
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: usecase
Source: https://github.com/ocbunknown/fastapi-claude-template/tree/main/.claude/skills/usecase
Command: npx skills add https://github.com/ocbunknown/fastapi-claude-template --skill usecase-ocbunknown

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps engineering teams enforce a disciplined use-case pattern across codebases, ensuring that business logic resides in a single, transport-agnostic file that pairs a Request with a UseCase and uses strict transaction rules.

Core Features & Use Cases

  • One file, exactly one Request class and one UseCase class per domain.
  • Dataclass(slots=True) usage and proper type annotations.
  • DBGateway transaction rules to ensure a single open session per use case.
  • Avoidance of anti-patterns through explicit guidelines and examples.
  • Registration of use cases in the application bootstrap for discovery.

Quick Start

Create a new use case file under src/application/v1/usecases/<domain>/ containing a single Request and a UseCase class, and wrap all database interactions in a single async with self.database: block.

Frequently Asked Questions about usecase

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Python use case with strict transaction boundaries?▼

To structure a Python use case with strict transaction boundaries, create a single file containing one Request subclass and one UseCase subclass, then wrap all database interactions in a single async with self.database block.

What is the transport-agnostic use case pattern and when should I apply it?▼

The transport-agnostic use case pattern isolates business logic in a single file pairing a Request with a UseCase class. Apply it when you need consistent application logic decoupled from specific delivery mechanisms across your codebase.

How do I register a new use case in the application bootstrap?▼

To register a new use case in the application bootstrap, add it to the setup_use_cases function with correct imports and ensure it outputs a Result object for proper discovery and execution.

What are common anti-patterns when using DBGateway transaction contexts?▼

A common anti-pattern when using DBGateway transaction contexts is opening multiple database sessions within a single use case. Avoid this by enforcing a single async with self.database block to maintain transactional integrity.

Does my use case Request class need dataclass slots?▼

Yes, your use case Request class needs dataclass slots. The pattern requires Dataclass(slots=True) usage with proper type annotations to enforce memory efficiency and strict data structure definitions.