data-access

Implement data access layers with Repository pattern, transaction management, and N+1 prevention.

Updated Feb 3, 2026
One-click install
npx skills add https://github.com/dhruvinrsoni/agentskills-garden --skill data-access
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: data-access
Source: https://github.com/dhruvinrsoni/agentskills-garden/tree/main/skills/30-implementation/data-access
Command: npx skills add https://github.com/dhruvinrsoni/agentskills-garden --skill data-access

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the complexities of implementing efficient and maintainable data access layers, ensuring clean separation of concerns and preventing common performance pitfalls like N+1 queries.

Core Features & Use Cases

  • Repository Pattern Implementation: Scaffolds interfaces and implementations for data entities.
  • N+1 Query Prevention: Detects and resolves inefficient data fetching patterns.
  • Transaction Management: Ensures data integrity for multi-entity operations.
  • Query Optimization: Improves read performance by analyzing and refining queries.
  • Use Case: When developing a new feature that requires saving user profile updates and associated preferences, this Skill will generate the necessary repository methods, wrap the operations in a transaction, and optimize the queries to prevent performance issues.

Quick Start

Implement a repository for the 'User' entity using the project's ORM.

Frequently Asked Questions about data-access

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

FAQPage Schema
How do I prevent N+1 queries when building a data access layer?

To prevent N+1 queries in a data access layer, implement the Repository pattern to optimize read operations and ensure efficient data fetching. This approach detects and resolves inefficient patterns by separating business logic from database operations.

What is the best way to manage database transactions for multi-entity operations?

The best way to manage database transactions for multi-entity operations is by wrapping the operations within a repository implementation. This ensures data integrity by applying transaction management directly within the persistence layer.

How do I separate business logic from database operations using the repository pattern?

Separating business logic from database operations using the repository pattern involves scaffolding interfaces and ORM implementations for data entities. This creates a clean persistence layer that isolates query optimization and transaction management from core logic.

How do I optimize database reads when updating related entities like user profiles and preferences?

To optimize database reads when updating related entities like user profiles and preferences, generate repository methods that analyze and refine queries. This prevents performance issues by detecting N+1 query patterns during the data fetching process.

Do I need an existing ORM to implement a data access layer?

Yes, you need an existing ORM to implement this data access layer, as the repository implementations rely on ORM frameworks to execute database operations. The Skill uses the project's current ORM to scaffold interfaces and manage transactions.

When should I use a repository pattern instead of direct database queries?

You should use a repository pattern instead of direct database queries when you need clean separation of concerns, transaction management for multi-entity operations, and N+1 query detection. It is essential for maintaining efficient and maintainable persistence layer development.