repository

Enforce fixed CRUD vocabulary for PostgreSQL repository methods.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill defines and enforces a fixed vocabulary for repository methods in the PostgreSQL data layer to avoid ad-hoc or inconsistent CRUD operations across models.

Core Features & Use Cases

  • Standardized CRUD verbs (create, select, select_many, update, delete, exists, count, upsert) in repositories.
  • Enforces wrapping of CRUDRepository and the use of on_integrity to handle unique constraints.
  • Provides a consistent pattern for loads, order, and pagination helpers (sqla_select, sqla_offset_query, unique_scalars), ensuring predictable data access and error handling.
  • Validates repository anatomy (inherits BaseRepository, uses self._crud, and safe interaction with DBGateway).

Quick Start

Create a new repository class under src/database/psql/repositories following the Widget pattern.

Frequently Asked Questions about repository

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

FAQPage Schema
How do I enforce a consistent CRUD vocabulary for PostgreSQL repositories?

To enforce consistent CRUD vocabulary for PostgreSQL repositories, apply a fixed method set including create, select, update, delete, and upsert. This standardizes data access operations across models, ensuring predictable method names and integrity constraint handling.

What is the best way to standardize Result[T] returns and error handling in domain-driven SQL repositories?

Standardizing Result[T] returns and error handling in domain-driven SQL repositories requires wrapping CRUDRepository methods and using on_integrity decorators. This pattern ensures consistent error capture for unique constraints across all create, update, and upsert flows.

How do I implement pagination and ordering helpers in a PostgreSQL repository?

Implement pagination and ordering in PostgreSQL repositories by applying helper functions like sqla_select and sqla_offset_query. These standardized helpers enforce predictable data loading and pagination structures across your data access layer.

Does this repository pattern support automatic handling of unique constraint violations?

Yes, the repository pattern supports automatic handling of unique constraint violations by enforcing the use of on_integrity decorators. This mechanism safely captures and manages database integrity errors during create and upsert operations.

How do I validate repository anatomy to ensure it inherits BaseRepository and uses DBGateway?

Validate repository anatomy by checking that your class inherits BaseRepository, interacts safely with DBGateway, and uses self._crud for operations. This structural enforcement guarantees repositories follow the required PostgreSQL data access pattern.