Skip to main content
skill CX Codex

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

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add dev-toolings/superpowers-symfony --skill doctrine-events -a claude-code
Open on GitHub

What 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 createdAt and updatedAt when an entity is saved
  • migrate an EventSubscriberInterface subscriber 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 Article that refreshes the search index after save.
  • Move this EventSubscriberInterface subscriber to ORM 3 attributes.
  • Why is my field change ignored in preUpdate? Rewrite it with setNewValue().

How to install doctrine-events

1Skills CLI (Vercel)

npx skills add dev-toolings/superpowers-symfony --skill doctrine-events -a claude-code

2Manually: put the files in place

~/.claude/skills/doctrine-events/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/doctrine-events/

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

Similar skills

All skills for Backend and APIs →

From the same set51

The whole set →
doctrine-batch-processing doctrine-batch-processing is a Claude Code skill for processing large Doctrine datasets in memory-conscious imports, exports, and backfills. CX Codex +1 ★ 234repo stars controller-cleanup The controller-cleanup skill extracts business logic from fat Symfony controllers into services, handlers and commands. Leaves actions lean, delegating and responding only. CX Codex +1 ★ 234repo stars brainstorming brainstorming structures feature discovery for Symfony projects: clarifies unclear requirements, identifies framework components, and compares architecture designs. CX Codex +1 ★ 234repo stars runner-selection The runner-selection skill detects whether Symfony commands belong in Docker, DDEV, or the host environment. Use it when the right command prefix is unclear or containers may be stopped. CX Codex +1 ★ 234repo stars form-types-validation form-types-validation generates Symfony form types, configures DTO validation groups, handles HTTP 422 responses, and sets up multi-step flows. CX Codex +1 ★ 234repo stars tdd-with-phpunit The tdd-with-phpunit skill guides PHPUnit-driven work on Symfony features, from checking a failing test to refactoring after it passes. Use it for command, form, and external-service tests. CX Codex +1 ★ 234repo stars using-symfony-superpowers using-symfony-superpowers is a Claude Code skill that detects the Symfony version, selects a skill, and sequences steps for complex tasks. CX Codex +1 ★ 234repo stars interfaces-and-autowiring interfaces-and-autowiring guides Symfony dependency injection in Claude Code by binding interfaces, configuring #[Target] aliases, and decorating services cleanly. CX Codex +1 ★ 234repo stars

Project sponsors

Companies that keep this analytics open