add-doctrine-query

add-doctrine-query is a skill for Claude Code, Codex from tarlepp/symfony-flex-backend. It costs 31 tokens per session (1,637 once invoked), scanned A, original, MIT.

Repository guidance for Doctrine database queries in PHP applications. Doctrine is a PHP library that maps application objects to database records and provides tools for searching and sorting them.

In plain words
What is it for?
Use it when adding or changing repository queries, searchable fields, query parameters, ID lookups, or database-related tests.
Why use it?
It helps keep filters, searches, joins, sorting, pagination, counts, and missing-result behavior consistent with the existing application and its tests.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when adding or changing repository queries, searchable fields, query parameters, ID lookups, or database-related tests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tarlepp/symfony-flex-backend/add-doctrine-query
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add tarlepp/symfony-flex-backend --skill add-doctrine-query
Clone the repo
git clone --depth 1 https://github.com/tarlepp/symfony-flex-backend

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for add-doctrine-query

README.md
[![agentmods](https://agentmods.dev/badge/skills/tarlepp/symfony-flex-backend/add-doctrine-query/github.svg)](https://agentmods.dev/skills/tarlepp/symfony-flex-backend/add-doctrine-query)
Your own site
<a href="https://agentmods.dev/skills/tarlepp/symfony-flex-backend/add-doctrine-query"><img src="https://agentmods.dev/badge/skills/tarlepp/symfony-flex-backend/add-doctrine-query/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for add-doctrine-query

Your own site · 80×15
<a href="https://agentmods.dev/skills/tarlepp/symfony-flex-backend/add-doctrine-query"><img src="https://agentmods.dev/badge/skills/tarlepp/symfony-flex-backend/add-doctrine-query.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 31 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,637 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00031 $0.01637
Opus 5.5 $0.00012 $0.00655
Sonnet 5.5 $0.00006 $0.00327
Haiku 4.5 $0.00003 $0.00164

Measured yesterday against content hash d672246574bf, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

add-doctrine-query scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/skills/add-doctrine-query/SKILL.md · 136 lines

How it starts

The opening of the file, as written. The whole thing — 136 lines — stays where its author put it; the contents beside it link to each section on GitHub.

What is this?

Use this skill when adding or changing repository queries, query criteria, searchable fields, joins, sorting, pagination, counts, or ID lookups. For entity mapping or index changes, also follow .github/skills/add-doctrine-entity/SKILL.md. For a full endpoint change, also follow .github/skills/add-rest-resource/SKILL.md.

Follow the shared skill guidance, including .github/copilot-instructions.md and doc/AI_RULES.md.

Table of Contents ᐞ

Workflow ᐞ

  1. Read composer.json for supported PHP, Doctrine ORM, and DBAL versions, symfony.lock for recipes, and config/packages/doctrine.yaml for mappings and database types. Inspect the target entity, repository, resource, callers, and nearby tests. Trace request criteria through RequestHandler, controller processing, and resource normalization when API query parameters are affected. Do not assume that raw HTTP input and repository arguments have the same shape.
  2. Establish the expected result type, matching rules, relationship semantics, ordering, pagination, and missing-result behavior. Distinguish no filter from an empty list, null, zero, or an empty string. Ask when these choices change an unspecified API contract or access boundary. Preserve existing authorization and data-visibility restrictions; user-provided criteria must not replace mandatory restrictions.
  3. Keep data access in repositories under src/Repository/, following BaseRepository<TEntity>, $entityName, and local dependency-injection conventions. Keep business orchestration in resources or services. First check RepositoryMethodsTrait, RepositoryWrappersTrait, RepositoryHelper, and SearchTerm for reusable behavior rather than duplicating a generic query or introducing a parallel repository pattern.
  4. Choose the narrowest existing method that meets the need. Standard findBy() and findOneBy() delegate to Doctrine's entity repository; advanced methods use this project's criteria/search helpers and queued query customizations. These paths are not interchangeable. For a custom query, use the existing createQueryBuilder() wrapper, whose default alias is entity, and declare entity, scalar, list, or array-shape return types accurately. Preserve single-result cardinality errors instead of masking them with an arbitrary first row or an empty result.
  5. Bind untrusted values with query parameters and the appropriate DBAL type. Parameters do not protect field names, aliases, operators, or sort directions: resolve dynamic identifiers through validated, intended choices rather than interpolating arbitrary request strings into DQL or SQL. Preserve the existing criteria grammar and error handling. Reuse UuidHelper and nearby UUID-binding patterns for binary UUID fields, and check configured enum and date/time types. For lists, verify the installed DBAL's supported array binding and UUID conversion rather than assuming a scalar type converts every element.
  6. Keep filtering and search consistent with RepositoryHelper and the repository's $searchColumns. Verify AND/OR grouping, null comparisons, empty-list behavior, and relationship aliases. Preserve existing search tokenization, LIKE wildcard behavior, and database collation semantics unless the requested contract changes them. Do not silently ignore an invalid new filter, widen the matching set, or catch query failures and return success-shaped empty results.
  7. Choose joins deliberately: an inner join excludes roots without a match; a left join may preserve them until a WHERE predicate excludes them. Select joined associations only when fetching them is needed. Check for duplicate root rows, lazy-loading/N+1 queries, and changed result shapes. When using addLeftJoin(), addInnerJoin(), or addCallback(), inspect BaseRepository::processQueryBuilder(): queued customizations are consumed during processing, not automatically applied by every repository method. Ensure required restrictions reach each related list, count, and ID query; do not assume one queued callback persists across those calls.
  8. Preserve sorting and pagination contracts. RepositoryHelper::processOrderBy() handles string directions and SortDirection; resource normalization may affect what reaches it. findByAdvanced() currently returns an empty array for a non-positive limit, uses no paginator when the limit is absent, and uses OffsetPaginator with a Window when a limit is supplied. Do not replace this with row-level limits on collection fetch joins, which can truncate pages or associations. Use deterministic ordering for new paged queries, with a stable tie-breaker where needed, without changing existing ordering implicitly.
  9. Keep count and ID results aligned with the matching root entities. countAdvanced() counts distinct root IDs and findIds() selects distinct IDs; joins must not inflate totals. For custom aggregates or grouped queries, verify the intended count explicitly instead of copying the list query blindly. Review generated SQL and query plans when a performance claim matters. Add an index only when justified, through entity mapping and a reviewed migration using the entity skill; never change a live schema with ad hoc SQL or doctrine:schema:update.
  10. Follow .github/skills/write-tests/SKILL.md. Use real-database Functional tests such as tests/Functional/Repository/UserRepositoryTest.php to prove query results; mock QueryBuilder expectations alone cannot verify SQL semantics. Inspect existing repository test helpers before adding setup. Cover matching and excluded entities, no matches, relevant null/empty inputs, relation duplicates or missing relations, search combinations, ordering ties, and pagination boundaries. Assert exact IDs and order, not only row counts, and verify count/ID consistency where affected. For shared helper changes, extend tests/Integration/Rest/RepositoryHelperTest.php or tests/Unit/Rest/SearchTermTest.php as appropriate. For API query changes, also exercise the real HTTP boundary and its authorization, validation, response shape, and paging behavior.
  11. Update existing query-parameter documentation or API metadata when accepted filters, search, ordering, pagination, or results change. A query-only change does not require a migration unless persisted mapping changes.

Read the full file on GitHub · 136 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 136 lines · 31 tokens per session scan A d672246574bf

Subscribe to this mod's changes

add-doctrine-query is a skill published in the GitHub repository tarlepp/symfony-flex-backend (288 stars, last pushed today), licensed MIT. It adds 31 tokens to every session and 1,637 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-21.

Related

Other skills, from other repositories

horse-database-pooling

Guide for setting up thread-safe database connection pooling (FireDAC / UniDAC) in multithreaded Horse applications.

HashLoad/horse · 30 tokens

api-platform-performance

Tune API Platform 4.3 + Doctrine + Symfony performance — recognize the 4.x default trap eagerloading.forceeager: true (often counter-productive, switch to false + targeted join fetches), use EXTRALAZY for large collections, project DTOs in DQL (NEW App\\Dto\\PostListItem(...)) to avoid hydrating full entities for list…

gerard-labs/superpowers-api-platform · 0 tokens

doctrine-batch-processing

Process large-volume Doctrine datasets (million-row imports, mass updates, ETL) without memory blowup. Use toIterable() + EntityManager::clear() per batch, partial hydration with DQL projection (NEW App\Dto\X(...)), HINTREADONLY when entities aren't mutated, MEMORYPEAKUSAGE tracking. Trigger on "iterate over all…

gerard-labs/superpowers-api-platform · 108 tokens

doctrine-fetch-modes

Tune Doctrine fetch modes to eliminate N+1 and over-hydration — LAZY (default), EXTRALAZY for huge collections (count(), contains() without load), EAGER per-property only with justification, partial hydration with addSelect(), IndexBy for O(1) lookups, HINTREADONLY. Covers the API Platform 4.x eagerloading.forceeager…

gerard-labs/superpowers-api-platform · 130 tokens

doctrine-transactions

Handle Doctrine transactions correctly — EntityManager::wrapInTransaction() for atomic multi-entity writes, doctrinetransaction Messenger middleware for command-bus atomicity, Doctrine\ORM\OptimisticLockException handling with #[Version] column, isolation levels, flush strategies (per-request vs explicit). Trigger…

gerard-labs/superpowers-api-platform · 92 tokens

api-integration-architect

Design, implement, debug, and optimize API integrations with expert-level patterns for REST, GraphQL, webhooks, and authentication flows.

sickn33/agentic-awesome-skills · 33 tokens