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

api-platform-user

Skill2 starsChanged 6 months agoMITView on GitHub

Implement the canonical API Platform 4.3 + Symfony 7.4+ User entity — `User implements UserInterface, PasswordAuthenticatedUserInterface`, `#[UniqueEntity('email')]`, a transient `$plainPassword` validated only on `user:create`, the persisted hashed `$password` excluded from every serialization group, a `UserPasswordHasher` State Processor decorating `api_platform.doctrine.orm.state.persist_processor` to hash on POST/PUT/PATCH + nuke `plainPassword` from memory, a Repository implementing `PasswordUpgraderInterface` for automatic rehashing when the algorithm cost changes, and a `/me` endpoint backed by a `CurrentUserProvider` (Provider-based, REST + GraphQL compatible — not a custom controller). Includes the lightweight `md5` password hashing config for the test environment to speed the suite ×5. Trigger on "User entity", "password hashing", "/me endpoint", "registration", or "current user".

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are 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.

  • 3

    Very specific

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

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

    Write the UserPasswordHasher State Processor that decorates persist_processor and hashes $plainPassword, then nukes it from memory.

    line 24
  2. Very specific:

    Add the /me endpoint via a CurrentUserProvider (Provider-based, REST + GraphQL compatible).

    line 26
  3. Distinctive:

    Hash-light in tests: only — never in any other environment.

    line 34
  4. Very specific:

    Test-only password hashing config in config/packages/test/security.yaml.

    line 45

≈ “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 — User entity (UserInterface, password hashing, /me)

Use when

  • Bootstrapping a new project that needs authenticated users.
  • Adding registration (POST /api/users open) + self-profile updates (PUT /api/users/{id} constrained to object == user).
  • Exposing the current authenticated user via /me.
  • Adopting auto-rehashing when the password hashing algorithm evolves.

Default workflow

  1. Implement User implements UserInterface, PasswordAuthenticatedUserInterface. Persist $password (hashed), keep $plainPassword transient.
  2. Apply #[UniqueEntity('email')] + Default + user:create validation context on the POST operation.
  3. Write the UserPasswordHasher State Processor that decorates persist_processor and hashes $plainPassword, then nukes it from memory.
  4. Implement PasswordUpgraderInterface in the Repository for transparent rehashing.
  5. Add the /me endpoint via a CurrentUserProvider (Provider-based, REST + GraphQL compatible).
  6. Configure md5 hashing only in config/packages/test/security.yaml to speed the test suite ×5.

Guardrails

  • $password is NEVER in a serialization group. It must not appear in any response.
  • $plainPassword is NEVER persisted (no #[ORM\Column]), only validated on user:create.
  • Hashing in the Processor, not in the controller — that's the canonical 4.x pattern.
  • /me via Provider, not Controller — for REST + GraphQL compatibility.
  • Hash-light in tests only — never in any other environment.

Progressive disclosure

  • SKILL.md covers posture and rules.
  • reference.md carries the full entity, Processor, Repository with PasswordUpgraderInterface, /me Provider, test hashing config, and best practices.

Output contract

  • A User entity following the canonical pattern.
  • A UserPasswordHasher Processor that hashes and nukes $plainPassword.
  • A UserRepository implements PasswordUpgraderInterface for auto-rehashing.
  • A /me endpoint backed by CurrentUserProvider.
  • Test-only password hashing config in config/packages/test/security.yaml.

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.