Skip to main content
skill CX Codex

api-platform-serialization — Claude Code skill: what it does

Skill configures API Platform serialization: field groups per operation, IRIs instead of nested objects, computed properties, and normalizer options.

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 api-platform-serialization -a claude-code
Open on GitHub

What api-platform-serialization does

The skill teaches the agent how to control which fields appear in API Platform responses. It shows how to set normalizationContext and denormalizationContext separately for list, read, create, and update operations, mark properties with #[Groups], and force IRIs instead of nested objects with readableLink: false and writableLink: false. For computed fields the skill recommends custom normalizers, for dynamic groups a decorator of api_platform.serializer.context_builder, and for cycle prevention #[MaxDepth] with enable_max_depth.

The skill distinguishes Symfony Serializer attributes (Attribute) from old annotations (Annotation): the agent will use the former. It reminds that a related entity embeds only when it shares a group with the parent; without one it renders as an IRI. The agent will hide secret fields with #[Ignore] and add password only to the create group.

Output includes a matrix of fields per operation, registered normalizers and context builders, and tests or OpenAPI showing the resulting field set.

What it helps with

  • Expose different fields for list, read, and write operations in API Platform
  • Replace nested objects with IRIs in responses
  • Add a computed or role-dependent field to a resource
  • Set date format or other normalizer options for a property
  • Prevent serialization cycles in related entities

Example prompts for the agent

  • Set up serialization groups: product list should return id, name, and price, while create should accept name, price, and categoryId but not id
  • Replace the nested category object with an IRI in GET /products
  • Add a computed field discountedPrice to the read operation response

How to install api-platform-serialization

1Skills CLI (Vercel)

npx skills add dev-toolings/superpowers-symfony --skill api-platform-serialization -a claude-code

2Manually: put the files in place

~/.claude/skills/api-platform-serialization/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/api-platform-serialization/

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

Questions about api-platform-serialization

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

Run npx skills add dev-toolings/superpowers-symfony --skill api-platform-serialization -a claude-code, the skill will be available at ~/.claude/skills/api-platform-serialization/SKILL.md.

What does api-platform-serialization do?

It teaches the agent to control field composition in API Platform: assign groups per operation, force IRIs for relations, add computed fields via normalizers, and prevent cycles.

How to replace a nested object with an IRI?

Apply #[ApiProperty(readableLink: false, writableLink: false)] to the relation property. Nested object appears only when the related entity shares a group with the parent.

Source text

SKILL.md · MIT
---
name: api-platform-serialization
description: "Control API Platform serialization with groups, #[Context], IRI links (readableLink/writableLink), and custom context builders"
capabilities: [read, search, edit, shell]
tags: [api-platform]
# projected by `bun run build` — do not edit by hand
allowed-tools:
  - Read
  - Glob
  - Grep
  - Write
  - Edit
  - Bash
---

# Api Platform Serialization (Symfony)

## Use when
- Operations must expose different fields (list, read, create, update).
- A related resource must render as an IRI or be embedded.
- A response needs computed or role-dependent fields.
- A property needs normalizer options such as a date format.

## Default workflow
1. Name groups `entity:operation` and set `normalizationContext` and `denormalizationContext` per operation.
2. Tag properties with `#[Groups]` from the Serializer `Attribute` namespace, not the old `Annotation` one.
3. Control relations with `#[ApiProperty(readableLink: false, writableLink: false)]` to force IRIs.
4. Apply per-property options with `#[Context]` instead of writing a normalizer.
5. Add computed fields in a custom normalizer, and dynamic groups in a decorator of `api_platform.serializer.context_builder`.
6. Prevent cycles with `#[MaxDepth]` and `enable_max_depth`, and hide secrets with `#[Ignore]`.

## Guardrails
- Use separate read and write groups: for example `password` only in the create group, `id` only in read groups.
- A related resource is embedded only when it shares a group with the parent; otherwise it renders as an IRI.
- `#[MaxDepth]` has no effect unless `enable_max_depth` is true in the context.
- Keep entities clean: computed fields belong in normalizers.

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

## Output contract
- The groups and contexts per operation, as a field matrix.
- Normalizers or context builders added, and how they are registered.
- Tests or OpenAPI output showing the resulting fields.

## 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 →
symfony-cache Configure Symfony Cache pools, entry expiry, and tag-based invalidation with this skill. It helps when caching costly reads or preventing a burst of recomputations after a key expires. CX Codex +1 ★ 234repo stars test-doubles-mocking test-doubles-mocking — a skill for creating test doubles with PHPUnit mocks in Symfony, used to replace slow or external dependencies, verify method calls, and write simplified repository fakes in isolated unit tests. CX Codex +1 ★ 234repo stars rate-limiting rate-limiting guides Claude Code through setting up Symfony RateLimiter policies, controller attributes, and 429 responses with Retry-After headers. CX Codex +1 ★ 234repo stars api-platform-tests The api-platform-tests skill guides functional tests for Symfony API Platform resources, including response checks, filters, JSON schemas, and access control. Use it while building or changing API endpoints. CX Codex +1 ★ 234repo stars symfony-scheduler Configures recurring tasks with the Symfony Scheduler component without system crontab entries. Useful for scheduled report generation, database cleanups, and Messenger syncs. CX Codex +1 ★ 234repo stars tdd-with-pest tdd-with-pest guides RED-GREEN-REFACTOR in Symfony projects using Pest v4. Use it to write new tests, reproduce bugs before a fix, or move PHPUnit tests to Pest syntax. CX Codex +1 ★ 234repo stars api-platform-versioning api-platform-versioning keeps API Platform clients alive through renames and removals: deprecation with a sunset date first, parallel versions as the last resort. CX Codex +1 ★ 234repo stars functional-tests functional-tests guides Claude Code in writing functional Symfony tests using WebTestCase, KernelTestCase, loginUser, and DAMA rollback. CX Codex +1 ★ 234repo stars

Project sponsors

Companies that keep this analytics open