crud-repository

Enforce CRUD repository patterns with tenant scoping and pagination in Go.

357|65|Updated Jul 29, 2022
One-click install
npx skills add https://github.com/ArtisanCloud/PowerX --skill crud-repository
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: crud-repository
Source: https://github.com/ArtisanCloud/PowerX/tree/main/.codex/skills/crud/repository
Command: npx skills add https://github.com/ArtisanCloud/PowerX --skill crud-repository

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Enforces consistent repository patterns to prevent scattered, insecure, or inconsistent data access implementations by establishing BaseRepository conventions, tenant scoping, pagination, and unified error semantics so services remain testable and transaction-safe.

Core Features & Use Cases

  • Rule Set & Linting: Declarative rules for file naming, method signatures, imports, tenant scope checks, pagination, and soft-delete behavior.
  • Templates & Patterns: Ready-to-use interface+implementation templates, TenantScope and Paginate helpers, and constructor conventions to simplify DI and transaction propagation.
  • Use Case: Migrate ad-hoc Go data access code into a consistent BaseRepository pattern to ensure all queries include tenant_id, list endpoints support paging, and services can translate repository errors into HTTP semantics.

Quick Start

Validate the repository files under internal/repository and pkg/corex/db/persistence/repository against the crud_repository rules and report any violations.

Frequently Asked Questions about crud-repository

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

FAQPage Schema
How do I enforce multi-tenant CRUD repository patterns in Go to ensure tenant_id is always present in queries?

To enforce multi-tenant CRUD repository patterns in Go, you can apply standardized linting rules that validate method signatures and ensure tenant_id is present in all queries. This prevents scattered, insecure data access by establishing consistent BaseRepository conventions.

What is the best way to standardize soft deletes and pagination across multiple GORM repositories?

The best way to standardize soft deletes and pagination across GORM repositories is to use declarative rules and ready-to-use templates. This enforces predictable behavior and ensures list endpoints consistently support paging through dedicated Paginate helpers.

How do I migrate ad-hoc Go data access code into a consistent BaseRepository pattern?

To migrate ad-hoc Go data access code into a BaseRepository pattern, apply interface and implementation templates that validate method signatures include context.Context and *gorm.DB. This ensures transaction propagation and unified error semantics for testable services.

Does this repository validation approach require specific dependencies or platforms to work?

This repository validation approach requires Go code structured under internal/repository and pkg/corex/db/persistence/repository. It specifically validates GORM usage by checking that method signatures include *gorm.DB and context.Context to ensure proper transaction support.

How do I map repository errors to HTTP semantics in a service-repo layer?

To map repository errors to HTTP semantics in a service-repo layer, establish unified error semantics during CRUD operations. This allows services to translate predictable repository errors into appropriate HTTP responses while maintaining transaction safety.