doctrine-events — Claude Code skill: what it does, how to install
doctrine-events — a Claude skill for attaching side effects to Doctrine entity events in Symfony: timestamps, slugs, search index updates, notifications.
MIT ★ 234 updated 2026-10-05
npx skills add dev-toolings/superpowers-symfony --skill doctrine-events -a claude-codeWhat doctrine-events does
This skill covers three ways to attach a side effect to a Doctrine entity's lifecycle in Symfony: a callback, an entity listener, and a global lifecycle listener. Start from the narrow end — a callback for one entity with no dependencies, an entity listener when services are needed, a global listener for logic that spans every entity.
Wiring goes through attributes: #[ORM\HasLifecycleCallbacks], #[AsEntityListener], #[AsDoctrineListener]. Each event argument gets its own class type, such as PostPersistEventArgs or PreUpdateEventArgs. A reference.md file holds the per-event argument table and the path away from subscribers.
The constraints are firm. Attribute listeners target ORM 3, and 3.0 dropped subscribers built on EventSubscriberInterface. Calling flush() from inside a handler damages the unit of work that is still running, so the skill rules it out. Inside preUpdate you change fields through $args->setNewValue() only, and associations stay untouched. Confirm the effect with a functional test against a real database.
What it helps with
- stamp
createdAtandupdatedAtwhen an entity is saved - migrate an
EventSubscriberInterfacesubscriber to ORM 3 attributes - pick between a callback, an entity listener and a global listener
- refresh a search index after
postPersist - keep the running unit of work safe from a stray
flush()
Example prompts for the agent
- Add an entity listener on
Articlethat refreshes the search index after save. - Move this
EventSubscriberInterfacesubscriber to ORM 3 attributes. - Why is my field change ignored in
preUpdate? Rewrite it withsetNewValue().
How to install doctrine-events
1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill doctrine-events -a claude-code2Manually: put the files in place
~/.claude/skills/doctrine-events/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/doctrine-events/
1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill doctrine-events -a codex2Manually: put the files in place
.agents/skills/doctrine-events/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill doctrine-events -a cursor2Manually: put the files in place
.cursor/skills/doctrine-events/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install dev-toolings/superpowers-symfony content/skills/doctrine-events2Manually: put the files in place
.github/skills/doctrine-events/SKILL.md1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill doctrine-events -a gemini-cli2Platform CLI
gemini skills install https://github.com/dev-toolings/superpowers-symfony --path content/skills/doctrine-eventsManually: put the files in place
.devin/skills/doctrine-events/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about doctrine-events
How do I install doctrine-events in Claude Code?
Run npx skills add dev-toolings/superpowers-symfony --skill doctrine-events -a claude-code. The skill file then sits at ~/.claude/skills/doctrine-events/SKILL.md.
What does doctrine-events do?
It walks you through reacting to a Doctrine entity lifecycle event in Symfony: picks the mechanism, writes the listener or callback class with the right attribute, then checks that the side effect fires.
How is an entity listener different from a global lifecycle listener?
An entity listener is bound to one class and can take services. A global listener fires for every entity, so the handler has to check the entity type up front.
Source text
SKILL.md · MIT
--- name: doctrine-events description: React to Doctrine entity lifecycle in Symfony with attribute listeners (#[AsDoctrineListener]/#[AsEntityListener], ORM 3) and lifecycle callbacks capabilities: [read, search, edit, shell] tags: [doctrine] # projected by `bun run build` — do not edit by hand allowed-tools: - Read - Glob - Grep - Write - Edit - Bash --- # Doctrine Events (Symfony) ## Use when - You need side effects on entity persistence (timestamps, slugs, search indexing, notifications). - Migrating an `EventSubscriberInterface` Doctrine subscriber to ORM 3. - Choosing between lifecycle callbacks, entity listeners, and global lifecycle listeners. ## Default workflow 1. Pick the narrowest mechanism: callback (one entity, no deps) → entity listener (one entity, needs services) → lifecycle listener (cross-cutting, all entities). 2. Wire it with attributes (`#[ORM\HasLifecycleCallbacks]`, `#[AsEntityListener]`, `#[AsDoctrineListener]`). 3. Type the event argument by its per-event class (`PostPersistEventArgs`, `PreUpdateEventArgs`, …). 4. Verify the side effect fires with a targeted functional test against a real DB. ## Guardrails - ORM 3.0 removed `EventSubscriberInterface` Doctrine subscribers — never reintroduce them. - Type-check the entity early in a global lifecycle listener (it fires for every entity). - Never call `flush()` inside a Doctrine event handler — it corrupts the in-flight unit of work. - `preUpdate` is restricted: change fields only via `$args->setNewValue()`, never touch associations. ## Progressive disclosure - Use this file for execution posture and risk controls. - Open `reference.md` for the three mechanisms, the event-args matrix, and migration from subscribers. ## Output contract - Listener/callback class with the correct attribute. - Justification for the chosen mechanism. - Validation outcomes (test that the side effect fired). ## References - `reference.md`
© dev-toolings · MIT · dev-toolings/superpowers-symfony