Agent skill

Doctrine Fetch Modes

by dev-toolings in dev-toolings/superpowers-symfony

Optimize Doctrine fetching with DTO hydration (SELECT NEW), fetch joins, lazy loading, query hints, and DBAL 4 access

MITAuto-check: notesDatabases

Install Doctrine Fetch Modes

skills CLI
$ npx skills add dev-toolings/superpowers-symfony --skill doctrine-fetch-modes -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install dev-toolings/superpowers-symfony doctrine-fetch-modes --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/dev-toolings/superpowers-symfony.git skills-src && mkdir -p .claude/skills && cp -r skills-src/content/skills/doctrine-fetch-modes .claude/skills/doctrine-fetch-modes && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
doctrine-fetch-modes
GitHub stars
223
Token cost
~560 tokens
SKILL.md length
282 words
Files
2
Skills in repo
44
Repo updated
First seen
Licence
MIT

At a glance

Optimize Doctrine fetching with DTO hydration (SELECT NEW), fetch joins, lazy loading, query hints, and DBAL 4 access

  • Works in 6 steps: Confirm the N+1 or over-fetch in the… → Keep relations on fetch: 'LAZY'; set… → Load the relations a use case needs with… → …
  • Tasks that involve Web performance
  • SKILL.md covers Use when, Default workflow, Guardrails and Progressive disclosure, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Doctrine Fetch Modes is an agent skill from dev-toolings/superpowers-symfony. Optimize Doctrine fetching with DTO hydration (SELECT NEW), fetch joins, lazy loading, query hints, and DBAL 4 access

Its SKILL.md is about 560 tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `reference.md`).

It sits in Databases, covering Web performance. It works with SQL. The repository describes itself as: Claude Code plugin for Symfony 7.4 LTS & 8.x — 44 skills, 7 AI subagents & 13 commands for API Platform v4, Doctrine ORM 3, TDD (Pest/PHPUnit), Messenger, security & DDD. The licence is MIT.

When your agent uses it

  • Tasks that involve Web performance

Example prompts

  • “/doctrine-fetch-modes”

Requirements

  • Pre-approved tools (allowed-tools): Read, Glob, Grep, Write, Edit, Bash

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Confirm the N+1 or over-fetch in the Symfony profiler before changing any mapping.
  2. Keep relations on fetch: 'LAZY'; set fetch: 'EXTRA_LAZY' on large collections so count(), contains() and slice() run targeted SQL.
  3. Load the relations a use case needs with a fetch join in the repository (addSelect() plus leftJoin()).
  4. For read-only lists, project into a readonly DTO with SELECT NEW (constructor argument order must match the NEW list).
  5. Use Query::HINT_READ_ONLY or an index-by alias (createQueryBuilder('p', 'p.id')) when the result is only displayed or looked up by id.
  6. For raw SQL, use the DBAL 4 methods (fetchAllAssociative(), fetchOne(), executeStatement()).

What it can do on your machine

Read from SKILL.md and the folder at commit 459bcd0. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Glob
    • Grep
    • Write
    • Edit
    • Bash

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Doctrine Fetch Modes loads about 560 tokens when it runs. Until then it costs about 35 tokens; SKILL.md has 282 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~35
When it runs · the whole SKILL.md, loaded when a task matches
~560

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Glob, Grep, Write, Edit, Bash

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from dev-toolings/superpowers-symfony at commit 459bcd0, republished under its MIT licence (© dev-toolings). 282 words, ~560 tokens.

Download SKILL.mdSave it as .claude/skills/doctrine-fetch-modes/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
doctrine-fetch-modes
description
Optimize Doctrine fetching with DTO hydration (SELECT NEW), fetch joins, lazy loading, query hints, and DBAL 4 access
allowed-tools
Read, Glob, Grep, Write, Edit, Bash
capabilities
read, search, edit, shell
tags
doctrine, performance

Doctrine Fetch Modes (Symfony)

Use when

  • A list or detail endpoint runs one query per row (N+1) on a relation.
  • A read-only list needs a few columns, not full managed entities.
  • Choosing LAZY, EAGER or EXTRA_LAZY on a mapping, or porting ORM 2 code that relied on PARTIAL objects.
  • A report or projection query drops to raw SQL through DBAL 4.

Default workflow

  1. Confirm the N+1 or over-fetch in the Symfony profiler before changing any mapping.
  2. Keep relations on fetch: 'LAZY'; set fetch: 'EXTRA_LAZY' on large collections so count(), contains() and slice() run targeted SQL.
  3. Load the relations a use case needs with a fetch join in the repository (addSelect() plus leftJoin()).
  4. For read-only lists, project into a readonly DTO with SELECT NEW (constructor argument order must match the NEW list).
  5. Use Query::HINT_READ_ONLY or an index-by alias (createQueryBuilder('p', 'p.id')) when the result is only displayed or looked up by id.
  6. For raw SQL, use the DBAL 4 methods (fetchAllAssociative(), fetchOne(), executeStatement()).

Guardrails

  • PARTIAL in DQL fails on ORM 3.0 to 3.2 and only returns from 3.3: use SELECT NEW DTOs for read-only lists instead.
  • Avoid fetch: 'EAGER' on a mapping; a fetch join in the query gives the same result per use case.
  • SELECT NEW returns DTOs, not managed entities: never modify or flush them.
  • DBAL 4 removed query(), exec() and fetchAll().

Progressive disclosure

  • Use this file for execution posture and risk controls.
  • Open references when deep implementation details are needed.

Output contract

  • Repository methods with the fetch strategy chosen per use case.
  • DTO classes and the SELECT NEW queries that fill them.
  • Query count before and after, from the profiler or doctrine:query:dql --show-sql.

References

  • reference.md

© dev-toolings, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in content/skills/doctrine-fetch-modes of dev-toolings/superpowers-symfony.

  • SKILL.md
  • reference.md

Open the folder on GitHubat commit 459bcd0

Compare with similar skills

Doctrine Fetch Modes next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Doctrine Fetch Modes compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Doctrine Fetch Modes this skilldev-toolings/superpowers-symfony223—~560Automated safety check: NotesMIT
Jpa Patternsdecebals/claude-code-java7511 repos~4kAutomated safety check: PassMIT
Formatting Insight AxesPostHog/posthog40k—~2.1kAutomated safety check: PassCustom licence
Performance TuningNoobyGains/godmode107—~2.3kAutomated safety check: PassMIT
Evolving The Data ModelTriliumNext/Trilium38k—~2.1kAutomated safety check: PassAGPL-3.0
Orchardcore Data MigrationOrchardCMS/OrchardCore8.2k—~1.7kAutomated safety check: PassBSD-3-Clause

Similar skills

  • Jpa Patterns

    decebals/claude-code-java

    JPA/Hibernate patterns and common pitfalls (N+1, lazy loading, transactions, queries).

    751 GitHub starsUsed in 1 repo~4k tokens
    DatabasesAuto-check passed
  • Official

    Pick the right y-axis unit when creating or updating an insight via posthog:insight-create or posthog:insight-update — both TrendsQuery (trendsFilter.aggregationAxisFormat) and SQL insights…

    40k GitHub stars~2.1k tokensUpdated today
    DatabasesAuto-check passed
  • Performance Tuning

    NoobyGains/godmode

    A skill your agent uses when performance is a concern - sluggish pages, slow queries, bloated bundles, high-latency APIs, or whenever someone says "optimize" or "make it faster"

    107 GitHub stars~2.3k tokensUpdated 7 mo ago
    DatabasesAuto-check passed
  • Evolving The Data Model

    TriliumNext/Trilium

    A skill your agent uses when adding a DB migration or a new column/field to a Becca entity in Trilium ("add a migration", "new column on notes/attributes", "ALTER TABLE", "add a field to…

    38k GitHub stars~2.1k tokensUpdated today
    DatabasesAuto-check passed
  • Orchardcore Data Migration

    OrchardCMS/OrchardCore

    Creates and updates OrchardCore data migrations (DataMigration classes with CreateAsync/UpdateFromX).

    8.2k GitHub stars~1.7k tokensUpdated today
    DatabasesAuto-check passed
  • SQL Optimization Patterns

    ynulihao/AgentSkillOS

    Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries.

    617 GitHub starsUsed in 11 repos~3.3k tokens
    DatabasesAuto-check passed

More from dev-toolings/superpowers-symfony

All 44 skills in this repo
  • Symfony Scheduler

    dev-toolings/superpowers-symfony

    Schedule recurring tasks with the Symfony Scheduler component (native since 7.x); define schedules, triggers, and integrate with Messenger

    223 GitHub stars~526 tokensUpdated 4 days ago
    Auto-check: notes
  • API Platform Dto Resources

    dev-toolings/superpowers-symfony

    Map entities to API DTOs in API Platform (v5, 4.4, 4.3) with the Symfony Object Mapper ([Map], stateOptions) for decoupled input/output contracts

    223 GitHub stars~593 tokensUpdated 4 days ago
    Auto-check: notes
  • API Platform Filters

    dev-toolings/superpowers-symfony

    Implement API Platform filters - Parameters API (QueryParameter, v5/4.4/4.3) and the [ApiFilter] attribute deprecated since 4.4 - for search, date, range, boolean, and custom filtering

    223 GitHub stars~610 tokensUpdated 4 days ago
    Auto-check: notes
  • API Platform Resources

    dev-toolings/superpowers-symfony

    Configure API Platform resources (v5, 4.4, 4.3) with explicit operations, pagination, and typed OpenAPI for clean, versioned REST/GraphQL APIs

    223 GitHub stars~560 tokensUpdated 4 days ago
    Auto-check: notes
  • API Platform Security

    dev-toolings/superpowers-symfony

    Secure API Platform resources with security expressions, voters, securityPostValidation, and operation-level access control

    223 GitHub stars~551 tokensUpdated 4 days ago
    Auto-check: notes
  • API Platform Serialization

    dev-toolings/superpowers-symfony

    Control API Platform serialization with groups, [Context], IRI links (readableLink/writableLink), and custom context builders

    223 GitHub stars~519 tokensUpdated 4 days ago
    Auto-check: notes

Works with

Questions about Doctrine Fetch Modes

What does Doctrine Fetch Modes do?

Optimize Doctrine fetching with DTO hydration (SELECT NEW), fetch joins, lazy loading, query hints, and DBAL 4 access. Doctrine Fetch Modes is an agent skill from dev-toolings/superpowers-symfony.

When should I use Doctrine Fetch Modes?

Doctrine Fetch Modes fits situations like: tasks that involve Web performance.

How do I install Doctrine Fetch Modes in Claude Code?

Run `npx skills add dev-toolings/superpowers-symfony --skill doctrine-fetch-modes -a claude-code`. Or copy the skill folder (content/skills/doctrine-fetch-modes in dev-toolings/superpowers-symfony) into .claude/skills/doctrine-fetch-modes in your project. Claude Code loads it when a task matches its description.

How do I install Doctrine Fetch Modes in Codex?

Run `npx skills add dev-toolings/superpowers-symfony --skill doctrine-fetch-modes -a codex`. Or copy the skill folder (content/skills/doctrine-fetch-modes in dev-toolings/superpowers-symfony) into .agents/skills/doctrine-fetch-modes in your project. Codex loads it when a task matches its description.

Can I use Doctrine Fetch Modes in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add dev-toolings/superpowers-symfony --skill doctrine-fetch-modes -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/doctrine-fetch-modes, .gemini/skills/doctrine-fetch-modes, .github/skills/doctrine-fetch-modes and .opencode/skills/doctrine-fetch-modes in your project.

What does Doctrine Fetch Modes need to run?

SKILL.md names no scripts, command-line tools or credentials: Doctrine Fetch Modes is instructions for the agent only. Its frontmatter pre-approves these tools: Read, Glob, Grep, Write, Edit, Bash.

Does Doctrine Fetch Modes access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Doctrine Fetch Modes safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Doctrine Fetch Modes use?

Doctrine Fetch Modes is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Doctrine Fetch Modes use?

About 560 tokens (SKILL.md is roughly 2.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Doctrine Fetch Modes?

Skills that share tags, products or a category with Doctrine Fetch Modes: Jpa Patterns (decebals/claude-code-java, 751 stars), Formatting Insight Axes (PostHog/posthog, 40k stars), Performance Tuning (NoobyGains/godmode, 107 stars) and Evolving The Data Model (TriliumNext/Trilium, 38k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Doctrine Fetch Modes?

dev-toolings (a GitHub organization) maintains it in dev-toolings/superpowers-symfony, which has 223 GitHub stars. The repository holds 44 skills in this directory. The repository was last updated on October 5, 2026.

Source: dev-toolings/superpowers-symfony on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.