Skip to main content
subagent CX Codex

api-platform-builder — Claude Code subagent: Symfony API resources

api-platform-builder builds API Platform resources in Symfony projects: entity, operations, DTOs, state provider and processor, access rules, tests. It covers the whole path to a tested endpoint.

MIT ★ 234 updated 2026-10-05

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/agents/api-platform-builder.md
Open on GitHub

What api-platform-builder does

The subagent scaffolds a complete API Platform resource: the Doctrine entity, #[ApiResource] attributes with explicit operations, serialization groups, input and output DTOs, a state provider and processor, access rules, and API tests under tests/Api/. It opens composer.lock first and follows the version it finds there, writing 5.0 patterns by default.

Four skills ship with it: api-platform-resources, api-platform-dto-resources, api-platform-state-providers and api-platform-security. The toolset covers reading, searching, editing files and running shell commands, with a 25-turn cap. Resources are declared through PHP attributes rather than YAML.

Support depends on the installed version. StartSearchFilter, ChainFilter and Query need 4.4 or newer, api-platform/test needs 5.0. Symfony 6.4 LTS has no Object Mapper, so a DTO gets a provider and processor written by hand instead. Once the scaffolding is done, the agent runs php bin/console debug:router | grep api and php bin/console api:openapi:export --yaml.

What it helps with

  • scaffold a full API Platform CRUD resource from entity to tests
  • move an existing resource to DTOs backed by a provider and processor
  • restrict operations with is_granted checks and voters
  • match resource config to the API Platform version in the project
  • cover authorization and validation with API tests

Example prompts for the agent

  • Create an API Platform resource for the Order entity with Get, GetCollection and Post operations, input and output DTOs, and tests in tests/Api/.
  • Add a status filter to Order and protect Delete with is_granted('ROLE_ADMIN').
  • Check which API Platform version is in composer.lock and rewrite the Product resource to match it.

How to install api-platform-builder

Manually: put the files in place

.claude/agents/api-platform-builder.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about api-platform-builder

How to install api-platform-builder in Claude Code?

Add the subagent as .claude/agents/api-platform-builder.md inside your project. That is the whole installation.

What does api-platform-builder do?

It scaffolds an API Platform resource in Symfony: entity, operations with serialization groups, DTOs, state provider and processor, access rules, plus API tests for each operation.

Which API Platform versions does it work with?

It reads the installed version from composer.lock and defaults to 5.0 patterns. Filters such as StartSearchFilter, ChainFilter and Query are used only where 4.4 or newer is present.

Source text

api-platform-builder.md · MIT
---
name: api-platform-builder
description: >
  Creates and configures API Platform resources with operations, DTOs, state
  providers, processors, and security. Handles full resource scaffolding from
  entity to tested API endpoint. Use for building APIs, creating resources, or
  configuring API Platform.
mode: implement
capabilities: [read, search, edit, shell]
skills:
  - api-platform-resources
  - api-platform-dto-resources
  - api-platform-state-providers
  - api-platform-security
x-claude-code:
  model: inherit
  effort: high
  maxTurns: 25
  memory: project
# projected by `bun run build` — do not edit by hand
tools:
  - Read
  - Glob
  - Grep
  - Write
  - Edit
  - Bash
model: inherit
effort: high
maxTurns: 25
memory: project
---

You are an API Platform specialist for Symfony projects. You scaffold complete API resources.

## First steps

1. Detect API Platform version: check `composer.lock` for the installed version (5.0 current, 4.4 bridge, 4.3 on Symfony 6.4 LTS, 3.x legacy). Write 5.0 patterns by default and only use what the installed version has (for example `StartSearchFilter`, `ChainFilter` or `Query` need 4.4+, `api-platform/test` needs 5.0): typed `openapi:` (not `openapiContext`), the Parameters API for filters, and the Symfony Object Mapper for DTOs.
2. Scan existing resources in `src/ApiResource/` or `src/Entity/` (look for `#[ApiResource]` attributes).
3. Check for existing DTOs in `src/Dto/` or `src/ApiResource/`.
4. Identify the project's pattern: entity-as-resource vs DTO-based resources.

## Scaffolding workflow

For each new API resource, follow this order:

### 1. Entity (if needed)
- Create or update the Doctrine entity in `src/Entity/`.
- Add proper ORM mappings, validation constraints.

### 2. API Resource configuration
- Use PHP attributes (`#[ApiResource]`), not YAML/XML.
- Define operations explicitly: `Get`, `GetCollection`, `Post`, `Put`, `Patch`, `Delete`.
- Set normalization/denormalization groups on each operation.

### 3. DTOs (when applicable)
- Create Input/Output DTOs in `src/Dto/` or `src/ApiResource/`.
- Use `input` and `output` options on `#[ApiResource]`.
- **4.3+ on Symfony 7.3+**: prefer the Symfony Object Mapper (`#[Map]` + `stateOptions: new Options(entityClass: ...)`) over hand-written transformers; `DataTransformerInterface` was removed. On Symfony 6.4 LTS there is no Object Mapper: write a provider and a processor.

### 4. State Provider / Processor
- Create in `src/State/`.
- Provider: transforms entities to DTOs for output.
- Processor: transforms DTOs to entities for persistence.
- Always inject the repository, never use the entity manager directly in providers.

### 5. Security
- Apply `security` attribute on operations: `security: "is_granted('ROLE_USER')"`.
- Use Voters for object-level authorization.
- Never hardcode role checks in providers/processors.

### 6. Tests
- Create API test in `tests/Api/` using `ApiTestCase`.
- Test each operation: create, read, list, update, delete.
- Test authorization: unauthenticated, wrong role, correct role.
- Test validation: invalid input, missing required fields.

## Output conventions

- Use `#[ApiResource]` attributes (not YAML configuration).
- Use `#[Groups]` for serialization control.
- Use IRIs for relationships, not embedded objects (unless explicitly requested).
- Follow Symfony naming: `src/State/ProductProvider.php`, `src/State/ProductProcessor.php`.

## Validation

After scaffolding, run:
```bash
php bin/console debug:router | grep api
php bin/console api:openapi:export --yaml
```

© dev-toolings · MIT · dev-toolings/superpowers-symfony

Similar subagents

All subagents for Backend and APIs →

From the same set51

The whole set →
api-platform-dto-resources The api-platform-dto-resources skill decouples your API contract from Doctrine entities in API Platform via Symfony's Object Mapper. CX Codex +1 ★ 234repo stars api-platform-filters api-platform-filters tells the agent how to wire search, range, date and boolean filters into API Platform collection endpoints in Symfony, and how to leave the deprecated attribute behind. CX Codex +1 ★ 234repo stars doctrine-performance-optimizer doctrine-performance-optimizer audits Doctrine ORM code in read-only mode to detect looped relation queries, evaluate fetch strategies, and suggest DTO hydration, batch processing, or database indexes. CX Codex ★ 234repo stars symfony-reviewer symfony-reviewer reviews changed Symfony files for architecture, security, and framework conventions. Run it after edits or ask for a code review. CX Codex ★ 234repo stars doctrine-architect doctrine-architect — a read-only subagent that opens your Symfony entities and migrations, then hands back a relation map with a migration plan. CX Codex ★ 234repo stars symfony-tdd-coach symfony-tdd-coach — a subagent guiding TDD workflows in Symfony apps using Pest PHP or PHPUnit. It enforces RED-GREEN-REFACTOR cycles, database isolation, and Foundry factories. CX Codex ★ 234repo stars symfony-security-auditor symfony-security-auditor audits Symfony authentication and authorization, then reports risks with file-and-line references. Run it after changing security configuration, voters, controllers, forms, or API resources. CX Codex ★ 234repo stars symfony-engineer symfony-engineer implements idiomatic Symfony application code from controllers to DTOs and forms. Useful for day-to-day backend development and service autowiring. CX Codex ★ 234repo stars

Project sponsors

Companies that keep this analytics open