dapper-conventions

Enforce Dapper repository patterns for IDbConnectionFactory and IUnitOfWork.

Updated Mar 29, 2026
One-click install
npx skills add https://github.com/roromanenko/NewsParser --skill dapper-conventions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dapper-conventions
Source: https://github.com/roromanenko/NewsParser/tree/main/.claude/skills/dapper-conventions
Command: npx skills add https://github.com/roromanenko/NewsParser --skill dapper-conventions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

NewsParser Dapper repository conventions for Infrastructure/Persistence/Repositories/. Use when adding a new repository class, adding a method to an existing repository, writing a query with multi-table stitching, using pgvector, or writing an update/delete operation. Triggers on: "add repository", "new repository", "add method to repository", "Dapper query", "pgvector query", "ExecuteAsync", "repository pattern", "add GetPendingFor", "write a query", "IDbConnectionFactory", "IUnitOfWork".

Core Features & Use Cases

  • Repository class structure — Constructor injection pattern with internal access and matching namespace/usings.
  • Connection lifecycle — per-operation connections and UoW integration guidance.
  • CommandDefinition usage — always wrap in CommandDefinition with cancellationToken.
  • SQL constants organization — place SQL in *Sql.cs per aggregate.
  • Update and insert patterns — enum to string binding, vector support, and insert/return patterns.
  • pgvector and JSONB handling — parameter binding and maps for vector, KeyFacts, SelectedMediaFileIds.
  • Multi-row loading and stitching — separate queries with in-memory or Dapper multi-mapping patterns.
  • ILIKE escape handling and SKIP LOCKED cautions — safe search patterns and transaction context.
  • IUnitOfWork usage — optional optimization for atomic operations.
  • Method-name catalogue — mapping to common repository method signatures.
  • Checklist for new methods — validation rules for code style and safety.

Quick Start

Follow these conventions when implementing or reviewing a Dapper repository to ensure consistency.

Frequently Asked Questions about dapper-conventions

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

FAQPage Schema
How do I structure a Dapper repository with IDbConnectionFactory and IUnitOfWork?

Dapper repository patterns use constructor injection with internal access for IDbConnectionFactory and IUnitOfWork, managing connections per-operation while centralizing SQL in a dedicated Sql.cs class per aggregate to ensure consistency.

What's the best way to handle pgvector and JSONB fields in Dapper queries?

Handling pgvector and JSONB in Dapper requires specific parameter binding and maps for vector and JSON fields like KeyFacts or SelectedMediaFileIds, alongside standard enum to string binding for insert and update operations.

How do I use CommandDefinition with cancellation tokens in a Dapper repository?

Dapper repository conventions require wrapping all queries in CommandDefinition with cancellation tokens, ensuring safe per-operation connection management and integration with IUnitOfWork for atomic transactions.

How do I organize SQL constants for multi-table stitching in Dapper?

Multi-table stitching in Dapper uses separate queries with in-memory or Dapper multi-mapping patterns, placing all SQL constants in a dedicated Sql.cs file per aggregate to centralize organization and avoid ad-hoc implementations.

Does Dapper repository pattern support SKIP LOCKED and ILIKE escape handling?

Dapper repository patterns include safe search patterns with ILIKE escape handling and SKIP LOCKED cautions, requiring careful transaction context management to avoid locking issues during concurrent database operations.

When should I use IUnitOfWork instead of per-operation connections in Dapper?

IUnitOfWork serves as an optional optimization for atomic operations in Dapper repositories, while per-operation connections remain the standard for isolated queries requiring independent connection lifecycle management.