acc-create-repository
Generates DDD Repository interfaces and implementation stubs for PHP 8.5. Creates domain interfaces in Domain layer, implementation in Infrastructure.
Best use case
acc-create-repository is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Generates DDD Repository interfaces and implementation stubs for PHP 8.5. Creates domain interfaces in Domain layer, implementation in Infrastructure.
Teams using acc-create-repository should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/acc-create-repository/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How acc-create-repository Compares
| Feature / Agent | acc-create-repository | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Generates DDD Repository interfaces and implementation stubs for PHP 8.5. Creates domain interfaces in Domain layer, implementation in Infrastructure.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 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
| Component | Path |
|-----------|------|
| Interface | `src/Domain/{BoundedContext}/Repository/` |
| Doctrine Impl | `src/Infrastructure/Persistence/Doctrine/` |
| In-Memory | `tests/Infrastructure/Persistence/` |
| Integration Tests | `tests/Integration/Infrastructure/Persistence/` |
---
## Naming Conventions
| Component | Pattern | Example |
|-----------|---------|---------|
| Interface | `{AggregateRoot}RepositoryInterface` | `OrderRepositoryInterface` |
| Doctrine Impl | `Doctrine{AggregateRoot}Repository` | `DoctrineOrderRepository` |
| In-Memory | `InMemory{AggregateRoot}Repository` | `InMemoryOrderRepository` |
---
## Quick Template Reference
### Interface
```php
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
```php
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
```php
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
| Rule | Good | Bad |
|------|------|-----|
| Layer Placement | Interface in Domain | Interface in Infrastructure |
| Aggregate Scope | Repository per aggregate root | Repository per entity |
| Query Methods | Simple filters | Business logic in queries |
| Identity | `nextIdentity()` method | External ID generation |
---
## Anti-patterns to Avoid
| Anti-pattern | Problem | Solution |
|--------------|---------|----------|
| Entity Repository | Bypasses aggregate | Only aggregate roots |
| Business Queries | Logic in repository | Use Specification pattern |
| Infrastructure Leak | Domain depends on ORM | Interface in Domain |
| Generic Repository | Too abstract | Specific per aggregate |
| Missing nextIdentity | Can't generate IDs | Add 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 implementationsRelated Skills
acc-create-use-case
Generates Application Use Cases for PHP 8.5. Creates orchestration services that coordinate domain objects, handle transactions, and dispatch events. Includes unit tests.
acc-create-state
Generates State pattern for PHP 8.5. Creates state machines with context, state interface, and concrete states for behavior changes. Includes unit tests.
acc-create-saga-pattern
Generates Saga pattern components for PHP 8.5. Creates Saga interfaces, steps, orchestrator, state management, and compensation logic with unit tests.
acc-create-retry-pattern
Generates Retry pattern for PHP 8.5. Creates resilience component with exponential backoff, jitter, and configurable retry strategies. Includes unit tests.
acc-create-responder
Generates ADR Responder classes for PHP 8.5. Creates HTTP response builders with PSR-7/PSR-17 support. Includes unit tests.
acc-create-rate-limiter
Generates Rate Limiter pattern for PHP 8.5. Creates request throttling with token bucket, sliding window, and fixed window algorithms. Includes unit tests.
acc-create-psr6-cache
Generates PSR-6 Cache implementation for PHP 8.5. Creates CacheItemPoolInterface and CacheItemInterface implementations with TTL handling and deferred saves. Includes unit tests.
acc-create-psr3-logger
Generates PSR-3 Logger implementation for PHP 8.5. Creates LoggerInterface implementations with log levels, context interpolation, and LoggerAwareTrait usage. Includes unit tests.
acc-create-psr20-clock
Generates PSR-20 Clock implementation for PHP 8.5. Creates ClockInterface implementations including SystemClock, FrozenClock, and OffsetClock for time abstraction and testing. Includes unit tests.
acc-create-psr17-http-factory
Generates PSR-17 HTTP Factories implementation for PHP 8.5. Creates RequestFactoryInterface, ResponseFactoryInterface, StreamFactoryInterface, UriFactoryInterface, ServerRequestFactoryInterface, UploadedFileFactoryInterface. Includes unit tests.
acc-create-psr16-simple-cache
Generates PSR-16 Simple Cache implementation for PHP 8.5. Creates CacheInterface with get/set/delete operations and TTL handling. Includes unit tests.
acc-create-psr15-middleware
Generates PSR-15 HTTP Middleware implementation for PHP 8.5. Creates MiddlewareInterface and RequestHandlerInterface with pipeline composition. Includes unit tests.