api-platform-state-providers

api-platform-state-providers is a skill for Claude Code from gerard-labs/superpowers-api-platform. It costs 118 tokens per session (554 once invoked), scanned A, original, MIT.

A guide for building API Platform 4.3 state providers, which turn data from sources such as databases or external services into API responses. It covers both single-item and collection responses.

In plain words
What is it for?
Use it when an API response needs data transformation, header-based versions or locales, a non-database source, or decoration of the standard database read process.
Why use it?
It helps keep read logic in the right part of an API and avoid mixing fetching with permissions or saving data.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the gerard plugin — 53 skills, 25 commands, 7 agents, 1 hook shipped together

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.

agentmods
npx agentmods add skills/gerard-labs/superpowers-api-platform/api-platform-state-providers
Any agent
npx skills add gerard-labs/superpowers-api-platform --skill api-platform-state-providers
Clone the repo
git clone --depth 1 https://github.com/gerard-labs/superpowers-api-platform

Made for: Claude Code.

Or install gerard, the plugin that ships this one along with the rest of its 53 skills, 25 commands, 7 agents, 1 hook.

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 api-platform-state-providers

README.md
[![agentmods](https://agentmods.dev/badge/skills/gerard-labs/superpowers-api-platform/api-platform-state-providers.svg)](https://agentmods.dev/skills/gerard-labs/superpowers-api-platform/api-platform-state-providers)
Your own site
<a href="https://agentmods.dev/skills/gerard-labs/superpowers-api-platform/api-platform-state-providers"><img src="https://agentmods.dev/badge/skills/gerard-labs/superpowers-api-platform/api-platform-state-providers.svg" alt="Measured on agentmods" height="20"></a>
Per session 118 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 554 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00118 $0.00554
Opus 5 $0.00059 $0.00277
Sonnet 5 $0.00024 $0.00111
Haiku 4.5 $0.00012 $0.00055

Measured 6d ago against content hash b73487ef95aa, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

api-platform-state-providers 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 6d ago.

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.

skills/api-platform-state-providers/SKILL.md · 45 lines

What it actually says

API Platform 4.3 — State Providers

Use when

  • A Get / GetCollection operation needs a transformation between the data source and the API representation.
  • You want to decorate the Doctrine read pipeline (e.g. to add audit logging or shape an Output DTO).
  • A response payload depends on a request header (versioning, locale).
  • A Resource is backed by a non-Doctrine source (external API, in-memory store, search engine).

Default workflow

  1. Scaffold with php bin/console make:state-provider.
  2. Inject the Doctrine item / collection providers via #[Autowire(service: '…')] (modern decoration pattern).
  3. Discriminate collection vs item with $operation instanceof CollectionOperationInterface.
  4. Return null for missing items (API Platform emits a 404 automatically).
  5. Wire on the operation: new Get(provider: MyProvider::class).

Guardrails

  • Inject a repository or a service, never EntityManagerInterface directly inside a Provider.
  • Do not code role checks inside the Provider — use security: on the operation or a voter.
  • Do not persist from a Provider; that is the Processor's job.
  • Remove any SerializerAwareProviderInterface / SerializableProvider implementation — those interfaces are deprecated since 4.2 and gone in 5.0.

Progressive disclosure

  • SKILL.md covers the basic pattern and rules.
  • reference.md carries the full decoration recipe, the collection-vs-item discriminator, a header-versioned example, and an N+1-avoidance reminder.

Output contract

  • A new Provider class in src/State/ wired on the operation.
  • Functional tests covering the happy path and the null/404 case.
  • No legacy interfaces remaining; no hardcoded security inside the Provider.

References

  • reference.md
Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 6d ago First seen · 45 lines · 118 tokens per session scan A b73487ef95aa

Subscribe to this mod's changes

api-platform-state-providers is a skill published in the GitHub repository gerard-labs/superpowers-api-platform (2 stars, last pushed 3mo ago), licensed MIT. It adds 118 tokens to every session and 554 once invoked, about $0.0006 per session on Opus 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-08-31.