agentleFS
1tomany1tomany/agent-skills/doctrine/SKILL.md

doctrine

Skill0 starsChanged 35 days agoMITView on GitHub

Use when working with modern versions of the Doctrine Object Relational Mapper (ORM) or Doctrine Database Abstraction Layer (DBAL)

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. riddhimohansharma/codebase-kb-engine★ 0same name
    2. scottcrosby-securebine/doctrine-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository7 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use correct @var, @param, and @return PHPDoc comments.

    line 24
  2. Very specific:

    If the primary key is an integer, it should have the type ?non-negative-int.

    line 25
  3. Distinctive:

    All custom methods should be placed at the bottom of the class after the lifecycle callback methods.

    line 29

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Doctrine Skill

Overview

This skill outlines how to use the Doctrine ORM and DBAL in a modern PHP application. Though not always, you will frequently find Doctrine used in the context of a Symfony application.

Documentation links

Entity conventions

Ensuring that entities are "structured" well is important, especially as an application grows. All entities should use the following structure:

  • Composite primary keys should be avoid at all costs.
  • Implement the \Stringable interface. If a StringableTrait is available, use that, otherwise implement the __toString() method as outlined below.
  • Use correct @var, @param, and @return PHPDoc comments.
  • If the primary key is an integer, it should have the type ?non-negative-int.
  • A setter should be manually added for the primary key property.
  • The #[OrderBy] attribute should be added for collections and sort the collection by primary key in ascending order by default.
  • Empty strings should be nullified using the trim() expressions below to ensure a string is either NULL or not empty.
  • All custom methods should be placed at the bottom of the class after the lifecycle callback methods. They should be grouped by visibility (public, protected, private), and then ordered by: setter/getter pair, is'ers, has'ers, can'ers, should'ers, and then alphabetically.
<?php

namespace App\Entity;

use App\Repository\AccountRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Serializer\Attribute\Ignore;

use function max;
use function random_int;
use function strtolower;
use function trim;

#[ORM\Entity(AccountRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Account implements \Stringable
{
    /**
     * @var ?non-negative-int
     */
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    #[Groups(['read', 'read:event'])]
    private ?int $id = null;

    #[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)]
    #[Groups(['read', 'read:event'])]
    private ?\DateTimeImmutable $createdAt = null;

    #[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)]
    #[Groups(['read', 'read:event'])]
    private ?\DateTimeImmutable $updatedAt = null;

    /**
     * @var ?non-empty-string
     */
    #[ORM\Column(type: Types::TEXT)]
    #[Groups(['read', 'read:event'])]
    private ?string $name = null;

    /**
     * @var ?non-empty-lowercase-string
     */
    #[ORM\Column(type: Types::TEXT)]
    #[Groups(['read', 'read:event'])]
    private ?string $email = null;

    /**
     * @var ?non-empty-string
     */
    #[ORM\Column(type: Types::TEXT, nullable: true)]
    #[Groups(['read', 'read:event'])]
    private ?string $nickName = null;

    /**
     * @var Collection<int, User>
     */
    #[ORM\OneToMany(targetEntity: User::class, mappedBy: 'account', cascade: ['persist', 'remove'], orphanRemoval: true)]
    #[ORM\OrderBy(['id' => 'ASC'])]
    #[Groups(['read:account:users'])]
    private Collection $users;

    public function __construct()
    {
        $this->setCreatedAt(new \DateTimeImmutable());
        $this->setUpdatedAt(new \DateTimeImmutable());

        $this->users = new ArrayCollection();
    }

    /**
     * @return non-empty-string
     */
    public function __toString(): string
    {
        return sprintf('Account:%d', $this->getId());
    }

    /**
     * @return ?non-negative-int
     */
    public function getId(): ?int
    {
        return $this->id;
    }

    public function setId(int $id): static
    {
        $this->id = max(0, $id);

        return $this;
    }

    public function getCreatedAt(): ?\DateTimeImmutable
    {
        return $this->createdAt;
    }

    public function setCreatedAt(\DateTimeImmutable $createdAt): static
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    public function getUpdatedAt(): ?\DateTimeImmutable
    {
        return $this->updatedAt;
    }

    public function setUpdatedAt(\DateTimeImmutable $updatedAt): static
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

    /**
     * @return ?non-empty-string
     */
    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): static
    {
        $this->name = '' = ($name = trim($name)) ? $name : null;

        return $this;
    }

    /**
     * @return ?non-empty-lowercase-string
     */
    public function getEmail(): ?string
    {
        return $this->email;
    }

    public function setEmail(string $email): static
    {
        $this->email = '' = ($email = trim($email)) ? strtolower($email) : null;

        return $this;
    }

    /**
     * @return ?non-empty-string
     */
    public function getNickName(): ?string
    {
        return $this->nickName;
    }

    public function setNickName(?string $nickName): static
    {
        $this->nickName = '' = ($nickName = trim((string) $nickName)) ? $nickName : null;

        return $this;
    }

    /**
     * @return Collection<int, User>
     */
    public function getUsers(): Collection
    {
        return $this->users;
    }

    public function addUser(User $user): static
    {
        if (!$this->users->contains($user)) {
            $this->users->add($user);
            $user->setAccount($this);
        }

        return $this;
    }

    public function removeUser(User $user): static
    {
        if ($this->users->removeElement($user)) {
            if ($user->getAccount() === $this) {
                $user->setAccount(null);
            }
        }

        return $this;
    }

    #[ORM\PreUpdate]
    public function preUpdate(): void
    {
        $this->setUpdatedAt(new \DateTimeImmutable());
    }

    public function getXyz(): int
    {
        return random_int(1, 100);
    }

    public function hasXyz(): bool
    {
        return true;
    }

    public function isXyz(): bool
    {
        return true;
    }

    public function canXyz(): bool
    {
        return true;
    }

    public function shouldXyz(): bool
    {
        return true;
    }

    public function createUser(
        string $name,
        string $username,
    ): static {
        return $this->addUser(new User()->setName($name)->setUsername($username));
    }
}

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.