agentleFS
gerard-labsgerard-labs/superpowers-api-platform/skills/api-platform-filters/SKILL.md

api-platform-filters

Skill2 starsChanged 6 months agoMITView on GitHub

Build API Platform 4.3 filters with the modern `parameters` + `QueryParameter` pattern. Use when adding search, sort, range, full-text, or sparse-fieldset filtering to an operation. Covers `ExactFilter`, `PartialSearchFilter` (caseSensitive 4.3), `IriFilter` (nested), `UuidFilter` (4.3), `ComparisonFilter` (gt/gte/lt/lte/ne 4.3), `SortFilter` (nullsComparison), `FreeTextQueryFilter`, `OrFilter`, `ExistsFilter`, `BackedEnumFilter`, `PropertyFilter` (sparse, native 4.3), JSON:API `SparseFieldset`. Plus mandatory `property:` argument in 4.3, dot-notation nested, `castToNativeType` / `castToArray` / `castFn`, `strictQueryParameterValidation`, per-parameter security, Parameter Providers (IriConverter/ReadLink/custom), Doctrine SQL Filters for multi-tenant. **Never** `#[ApiFilter]` or `extends AbstractFilter` — legacy belongs to `api-platform-upgrade`.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Add castToNativeType / castToArray / castFn where the value needs a type or transformation.

    line 25
  2. Distinctive:

    Write tests that exercise each filter + boundary cases.

    line 27

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

API Platform 4.3 — Filters (modern parameters pattern)

Use when

  • Adding any query filter, sort, range, or full-text search to a GetCollection.
  • Replacing existing #[ApiFilter] annotations (legacy) with the 4.3 modern pattern.
  • Implementing a custom filter via FilterInterface + Json Schema + OpenAPI traits.
  • Wiring a Parameter Provider (IRI converter, read link, custom dynamic group).
  • Enforcing multi-tenant row-level security via a Doctrine SQL Filter.

Default workflow

  1. Identify the columns that must be filterable, sortable, or full-text searchable.
  2. Declare parameters: [...] on the operation with one new QueryParameter(filter: new XxxFilter(), property: '...') per parameter.
  3. Add castToNativeType / castToArray / castFn where the value needs a type or transformation.
  4. Index every filtered column (#[ORM\Index]) and a functional index for case-insensitive partial searches.
  5. Write tests that exercise each filter + boundary cases.

Guardrails

  • property is mandatory in 4.3 on ExactFilter, IriFilter, PartialSearchFilter, UuidFilter — otherwise InvalidArgumentException at compile time. Use the literal property name or the :property placeholder.
  • Never use #[ApiFilter] or extends AbstractFilter in new code — both are deprecated since 4.2 and removed in 5.0.
  • IriFilter for FKs, never an ExactFilter on a scalar userId (IRI-only rule).
  • Indexing is non-optional — without an index, a filter becomes a full scan.
  • PartialSearchFilter sparingly — a case-insensitive partial search bypasses btree indexes; add a functional index on LOWER(col) when used.

Progressive disclosure

  • SKILL.md lists posture, the modern pattern, and rules.
  • reference.md carries the full catalogue, dot-notation nested filters, FreeTextQueryFilter + OrFilter, ComparisonFilter operators (incl. ne 4.3), SortFilter nullsComparison, custom filter recipe (interfaces + traits), Parameter Providers (4.3), PropertyFilter native (4.3), default global parameters, Doctrine SQL Filter for multi-tenant, and the make:filter orm/odm generator.

Output contract

  • parameters: [...] arrays on operations — no #[ApiFilter] left.
  • Tests asserting each filter against controlled data.
  • Indices added on filtered columns (Doctrine #[ORM\Index]).
  • Custom filters implement FilterInterface, JsonSchemaFilterInterface, OpenApiParameterFilterInterface (with the OpenApiFilterTrait + BackwardCompatibleFilterDescriptionTrait).

References

  • reference.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.