本文へ移動
cccskills
無料GitHub で公開

acc-create-repository

Generates DDD Repository interfaces and implementation stubs for PHP 8.5. Creates domain interfaces in Domain layer, implementation in Infrastructure.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md4.5 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Repository Generator

Generate DDD-compliant Repository interfaces and implementation stubs.

Repository Characteristics

  • Interface in Domain: Contract defined in Domain layer
  • Implementation in Infrastructure: Doctrine/Eloquent/etc. implementation
  • Works with Aggregates: Not entities directly
  • Collection-like: Find, save, remove operations
  • No business logic: Only persistence operations

Generation Process

Step 1: Generate Interface

Path: src/Domain/{BoundedContext}/Repository/

  1. {AggregateRoot}RepositoryInterface.php — Domain contract

Step 2: Generate Implementation

Path: src/Infrastructure/Persistence/Doctrine/

  1. Doctrine{AggregateRoot}Repository.php — Doctrine implementation

Step 3: Generate In-Memory Repository (Optional)

Path: tests/Infrastructure/Persistence/

  1. InMemory{AggregateRoot}Repository.php — For unit testing

Step 4: Generate Integration Tests

Path: tests/Integration/Infrastructure/Persistence/


File Placement

ComponentPath
Interfacesrc/Domain/{BoundedContext}/Repository/
Doctrine Implsrc/Infrastructure/Persistence/Doctrine/
In-Memorytests/Infrastructure/Persistence/
Integration Teststests/Integration/Infrastructure/Persistence/

Naming Conventions

ComponentPatternExample
Interface{AggregateRoot}RepositoryInterfaceOrderRepositoryInterface
Doctrine ImplDoctrine{AggregateRoot}RepositoryDoctrineOrderRepository
In-MemoryInMemory{AggregateRoot}RepositoryInMemoryOrderRepository

Quick Template Reference

Interface

interface {AggregateRoot}RepositoryInterface
{
    public function findById({AggregateRoot}Id $id): ?{AggregateRoot};

    public function save({AggregateRoot} $aggregate): void;

    public function remove({AggregateRoot} $aggregate): void;

    public function nextIdentity(): {AggregateRoot}Id;
}

Doctrine Implementation

final readonly class Doctrine{AggregateRoot}Repository implements {AggregateRoot}RepositoryInterface
{
    public function __construct(
        private EntityManagerInterface $em
    ) {}

    public function findById({AggregateRoot}Id $id): ?{AggregateRoot}
    {
        return $this->em->find({AggregateRoot}::class, $id->value);
    }

    public function save({AggregateRoot} $aggregate): void
    {
        $this->em->persist($aggregate);
        $this->em->flush();
    }

    public function remove({AggregateRoot} $aggregate): void
    {
        $this->em->remove($aggregate);
        $this->em->flush();
    }

    public function nextIdentity(): {AggregateRoot}Id
    {
        return {AggregateRoot}Id::generate();
    }
}

In-Memory Implementation

final class InMemory{AggregateRoot}Repository implements {AggregateRoot}RepositoryInterface
{
    private array $items = [];

    public function findById({AggregateRoot}Id $id): ?{AggregateRoot}
    {
        return $this->items[$id->value] ?? null;
    }

    public function save({AggregateRoot} $aggregate): void
    {
        $this->items[$aggregate->id()->value] = $aggregate;
    }

    public function clear(): void
    {
        $this->items = [];
    }
}

Design Rules

RuleGoodBad
Layer PlacementInterface in DomainInterface in Infrastructure
Aggregate ScopeRepository per aggregate rootRepository per entity
Query MethodsSimple filtersBusiness logic in queries
IdentitynextIdentity() methodExternal ID generation

Anti-patterns to Avoid

Anti-patternProblemSolution
Entity RepositoryBypasses aggregateOnly aggregate roots
Business QueriesLogic in repositoryUse Specification pattern
Infrastructure LeakDomain depends on ORMInterface in Domain
Generic RepositoryToo abstractSpecific per aggregate
Missing nextIdentityCan't generate IDsAdd to interface

References

For complete PHP templates and examples, see:

  • references/templates.md — Interface, Doctrine, In-Memory, Test templates
  • references/examples.md — Order, User repositories with Doctrine and In-Memory implementations

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Master backend architectures, REST API design, microservices, and server-side development across multiple languages. Use this as a central index to access specialized sub-skills.

日本語の概要は準備中です。原文の説明を表示しています。

MikeCheng1208/BattleTree22026年7月22日 更新

在每次回复中使用固定前缀并列出本次实际参考的指令/文件,便于校验是否遵循上下文与规则。

日本語の概要は準備中です。原文の説明を表示しています。

MikeCheng1208/BattleTree22026年7月22日 更新

Automate 21risk tasks via Rube MCP (Composio). Always search tools first for current schemas.

日本語の概要は準備中です。原文の説明を表示しています。

MikeCheng1208/BattleTree22026年7月22日 更新

Automate 2chat tasks via Rube MCP (Composio). Always search tools first for current schemas.

日本語の概要は準備中です。原文の説明を表示しています。

MikeCheng1208/BattleTree22026年7月22日 更新

Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.

日本語の概要は準備中です。原文の説明を表示しています。

MikeCheng1208/BattleTree22026年7月22日 更新

[00] META. Orchestrate skills into dynamic chains for complex tasks. Analyzes the task, discovers available skills, builds an optimal chain, explains why each skill is needed, and executes step-by-step with user confirmation. Use for any complex task requiring multiple thinking/research/analysis steps. Triggers on "plan this", "how to approach", "what's the strategy", "build a plan", or any multi-step problem requiring skill orchestration.

日本語の概要は準備中です。原文の説明を表示しています。

MikeCheng1208/BattleTree22026年7月22日 更新

MikeCheng1208 のスキルをすべて見る

このスキルの問題を報告する