Skip to main content
skill CX Codex

doctrine-transactions — Claude Code skill: setup and usage

doctrine-transactions guides Claude Code on managing Doctrine ORM 3 transactions, locking strategies, and flush boundaries in Symfony applications. Fits concurrent row edits and rollback recovery.

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-transactions -a claude-code
Open on GitHub

What doctrine-transactions does

The skill enforces putting transaction boundaries in service layers instead of controllers. Because Doctrine ORM 3 dropped EntityManager::transactional(), it guides the model to group modifications inside wrapInTransaction() with a single flush(). Outside an explicit transaction, each flush commits individually, which causes partial writes.

It also sets concurrency controls. Edits rely on #[ORM\Version] for optimistic locking, while tight critical sections receive PESSIMISTIC_WRITE. Transactions and locks must stay brief: making HTTP calls or sending emails inside them is prohibited.

When a flush fails, a constraint breaks, or a rollback occurs, the skill directs the agent to clear the EntityManager. You cannot reuse entity instances from a failed unit of work, so fresh data must be retrieved from scratch.

What it helps with

  • Wrap multi-table writes inside wrapInTransaction() using Doctrine ORM 3
  • Add optimistic concurrency checks via #[ORM\Version]
  • Guard sensitive updates with short PESSIMISTIC_WRITE blocks
  • Reset the EntityManager after constraint errors and rollbacks

Example prompts for the agent

  • Refactor order checkout to use wrapInTransaction() with a single flush in the service
  • Add optimistic locking with #[ORM\Version] to the user profile entity and catch OptimisticLockException
  • Protect wallet balance updates with PESSIMISTIC_WRITE and keep HTTP calls outside the transaction

How to install doctrine-transactions

1Skills CLI (Vercel)

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

2Manually: put the files in place

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

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

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about doctrine-transactions

How to install doctrine-transactions in Claude Code?

Run npx skills add dev-toolings/superpowers-symfony --skill doctrine-transactions -a claude-code or save the definition file to ~/.claude/skills/doctrine-transactions/SKILL.md.

What does doctrine-transactions do?

It instructs Claude Code to organize Symfony database operations with clean service boundaries, Doctrine ORM 3 transaction wrappers, and explicit locking.

Why does the skill forbid HTTP calls inside transactions?

Pessimistic locks and database transactions tie up database connections. Network calls add latency, keeping database locks open and increasing timeout risks.

Source text

SKILL.md · MIT
---
name: doctrine-transactions
description: Handle Doctrine transactions (ORM 3 wrapInTransaction), optimistic/pessimistic locking, flush strategies, and transaction boundaries
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 Transactions (Symfony)

## Use when
- Several writes must succeed or fail together.
- Two users or workers can edit the same row concurrently.
- Deciding where to flush and who owns the transaction boundary.
- Recovering after a failed flush, a constraint violation, or a lost connection.

## Default workflow
1. Place the transaction boundary in the service layer, not in the controller.
2. Group related changes and flush once, inside `wrapInTransaction()`.
3. Pick the concurrency strategy: `#[ORM\Version]` optimistic locking for edits, `PESSIMISTIC_WRITE` for short critical sections.
4. Handle `OptimisticLockException` and constraint violations explicitly.
5. After a rollback, clear the EntityManager and re-fetch what you still need.

## Guardrails
- On ORM 3, `EntityManager::transactional()` is gone: use `wrapInTransaction()`.
- Outside an explicit transaction each flush commits on its own, so avoid several flushes per operation.
- Keep transactions and pessimistic locks short; no HTTP calls or mail inside.
- Do not reuse entities from a failed unit of work.

## Progressive disclosure
- Use this file for execution posture and risk controls.
- Open references when deep implementation details are needed.

## Output contract
- Transaction boundaries with a single flush per operation.
- The locking strategy chosen per entity, and how conflicts reach the user.
- Rollback handling and the state of the EntityManager after it.

## 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 →
bootstrap-check bootstrap-check runs a pass/fail check over a Symfony project's setup: .env, services, Doctrine mappings, routes. Each failure comes with the fix. CX Codex +1 ★ 234repo stars ports-and-adapters ports-and-adapters guides Claude Code in setting up Hexagonal Architecture in Symfony, isolating domain models from Doctrine, HTTP, and vendor SDKs. CX Codex +1 ★ 234repo stars config-env-parameters The config-env-parameters skill guides changes to Symfony environment variables, parameters, and secrets across environments. Use it when configuration needs a clear home and safe injection into the app. CX Codex +1 ★ 234repo stars doctrine-fixtures-foundry doctrine-fixtures-foundry teaches the agent to build Doctrine test data with Zenstruck Foundry v2 factories: named states, sequences and entity relations. Triggers when you write fixtures or migrate factories from Foundry v1. CX Codex +1 ★ 234repo stars 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

Project sponsors

Companies that keep this analytics open