Skip to content
Back to skills

Create Repository

ASecurity

Scaffold a repository — interface in Domain, Eloquent implementation in Infrastructure, plus binding and test

  • 8 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 12, 2026
ai-agentsphpbashdatabase

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add Chemaclass/satscribe --skill create-repository --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Create Repository?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Create Repository
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/chemaclass-create-repository/badge)](https://www.skillsdirectory.com/skills/chemaclass-create-repository)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
description: Scaffold a repository — interface in Domain, Eloquent implementation in Infrastructure, plus binding and test
argument-hint: "<Module>/<Entity>"
disable-model-invocation: true
allowed-tools: "Read, Write, Edit, Glob, Grep, Bash(vendor/bin/phpunit *), Bash(composer *)"
---

# New Repository

Create the repository in `$ARGUMENTS` (e.g. `Chat/Message`). Repositories are the **only** place Eloquent may appear.

Read `modules/Chat/Infrastructure/Repository/ChatRepository.php` and mirror it. Layer rules: `.claude/rules/architecture.md`.

## Files

```
modules/<Module>/Domain/Repository/<Entity>RepositoryInterface.php
modules/<Module>/Infrastructure/Repository/<Entity>Repository.php
tests/Feature/<Module>/<Entity>RepositoryTest.php
modules/<Module>/<Module>ServiceProvider.php          # binding
```

## Interface (Domain)

```php
namespace Modules\<Module>\Domain\Repository;

interface <Entity>RepositoryInterface
{
    public function find(int $id): ?<Entity>;

    public function save(<Entity> $entity): <Entity>;

    public function delete(<Entity> $entity): void;

    // public function findActiveByUser(string $npub): array;
}
```

Method names describe **domain intent** (`findActiveByUser`), not query mechanics (`findByStatusAndDate`).

## Implementation (Infrastructure)

```php
namespace Modules\<Module>\Infrastructure\Repository;

use App\Models\<Entity>;

final readonly class <Entity>Repository implements <Entity>RepositoryInterface
{
    public function find(int $id): ?<Entity>
    {
        return <Entity>::find($id);
    }

    public function save(<Entity> $entity): <Entity>
    {
        $entity->save();

        return $entity;
    }
}
```

## Binding

```php
<Entity>RepositoryInterface::class => <Entity>Repository::class,
```

## Test — Feature suite, needs a real DB

```php
final class <Entity>RepositoryTest extends TestCase
{
    use RefreshDatabase;

    public function test_find_with_existing_id_returns_entity(): void { /* … */ }

    public function test_find_with_unknown_id_returns_null(): void { /* … */ }
}
```

Consumers (Actions, Services) mock the **interface** in their own unit tests.

## Specific to repositories

- Queries live here, never in Actions, Services, or Controllers
- Return models or domain objects — never a query builder
- Eager-load relations here so callers can't cause N+1
- Missing model? Create it in `app/Models/` plus a migration

```bash
composer test
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…