TIL : an OpenCode custom command to generate a complete API Platform endpoint
opencodeapi-platformphp
Note, July 2026: setup from the OpenCode era — the technique still transfers to Claude Code’s skills and custom commands.
OpenCode custom commands are Markdown files in .opencode/commands/.
A well-written command replaces 80% of repeated instructions for recurring patterns.
Concrete example for API Platform 3:
# .opencode/commands/new-endpoint.md
Create a complete API Platform endpoint for the `$ARGUMENTS` entity.
## What you must create
1. **Resource class** in `src/ApiResource/{Entity}Resource.php`
- Operations: GetCollection, Get, Post, Patch, Delete
- Serialization groups: `{entity}:read`, `{entity}:write`
- Follow the conventions in AGENTS.md
2. **Functional tests** in `tests/ApiResource/{Entity}ResourceTest.php`
- Extends `AbstractApiResourceTest`
- Tests: list, detail, valid creation, invalid creation (validation),
update, deletion
- Fixtures in `tests/fixtures/{Entity}Fixtures.php`
3. **Verify** tests pass: `php bin/phpunit tests/ApiResource/{Entity}ResourceTest.php`
Usage in OpenCode:
> /new-endpoint Order
The agent creates all 3 files, runs the tests, and fixes errors if any.
Further reading