backend-repository

Abstract data storage behind a repository interface with typed domain entities.

Updated Jun 4, 2025
One-click install
npx skills add https://github.com/alexei-lexx/budget --skill backend-repository
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-repository
Source: https://github.com/alexei-lexx/budget/tree/main/.claude/skills/backend-repository
Command: npx skills add https://github.com/alexei-lexx/budget --skill backend-repository

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Abstracts data storage behind a repository interface, decoupling business logic from database specifics and ensuring typed domain entities are returned.

Core Features & Use Cases

  • Interface-first design: define ports in backend/src/services/ports and implement them in backend/src/repositories
  • User-scoping and soft-delete: queries must filter by userId and archived records are excluded by default
  • Hydration and validation: read records through a Zod schema typed to the entity before returning
  • Error handling and portability: centralize errors at the repository boundary and write portable queries usable across SQL/NoSQL
  • Configuration via constructor: inject dependencies instead of reading environment variables inside the class

Quick Start

Create a backend repository for an entity by defining a ports interface, implementing it in a repository class, and wiring repository-level rules (user scoping, soft delete, hydration, and error handling) into the data layer.

Frequently Asked Questions about backend-repository

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

FAQPage Schema
How do I decouple business logic from database specifics in a TypeScript backend?

You can decouple business logic by abstracting data storage behind a repository interface, implementing interface-first design with ports, and returning typed domain entities. This centralizes data access rules and keeps your core logic portable.

What is the best way to implement user-scoped data access and soft-delete behavior in backend repositories?

Implementing user-scoped data access and soft-delete behavior requires repositories to filter queries by userId and exclude archived records by default. This enforces data isolation and preserves historical data without exposing deleted entities to the application layer.

How does Zod schema hydration and validation work when reading database records?

Hydration and validation work by reading raw database records through a Zod schema typed to the domain entity before returning them. This validates data at the repository boundary, ensuring only correctly structured typed objects reach your business logic.

Can I write portable repository queries that work across both SQL and NoSQL backends?

Yes, you can write portable queries across SQL and NoSQL backends by centralizing data access behind a repository interface. This abstraction decouples your business logic from specific database engines, enabling portable data layer implementations.

Why centralize error handling at the repository boundary in a backend data layer?

Centralizing error handling at the repository boundary ensures database exceptions are caught and translated before reaching business logic. This decouples your application from specific database error formats and provides consistent typed domain entity returns.

How do I inject dependencies into a backend repository class instead of reading environment variables?

You configure backend repositories via constructor injection, passing dependencies directly into the class instead of reading environment variables inside. This pattern supports interface-first design, improves testability, and cleanly separates data access configuration from implementation.