Skip to content

Add agent skills for building integrations - #53

Merged
veewee merged 1 commit into
phpro:v2.xfrom
veewee:agent-skills
Sep 3, 2026
Merged

Add agent skills for building integrations#53
veewee merged 1 commit into
phpro:v2.xfrom
veewee:agent-skills

Conversation

@veewee

@veewee veewee commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Introduces .agents/skills/ — skills that teach a coding agent how to build an integration with this package. Aimed at consumers of the library, not at contributors.

.agents/skills/ is the cross-runtime location (Claude Code, Codex, Copilot CLI, Gemini CLI). .claude/skills is git-ignored so it can be a local symlink.

Six task-oriented skills

Each is usable on its own — asking for just a response model pulls only that skill.

Skill Use when
generate-http-api-call A whole endpoint: request + response + handler + tests. Orchestrates the rest.
configure-http-client Client and transport setup: base URI, auth, logging, plugin order, preset choice. Once per API.
generate-http-request A RequestInterface model: URI templates, parameters, BodyType.
generate-http-response A decoded payload into a strictly typed value object.
generate-http-request-handler The class that runs one call, and where error handling belongs.
test-http-integration Mock client vs VCR cassettes, and what each layer should assert.

Reference files (loaded on demand, not up front) cover the plugin catalogue and priority levels, the full encoder/decoder matrix, psl/type usage, and VCR cassette handling.

Conventions they encode

  1. One vertical slice per endpoint, grouped per endpoint on disk — not Model/ + Request/ + RequestHandler/ folders.
  2. A handler interface per endpoint, so consumers mock one call instead of an API client.
  3. Strictly typed response models, validated once at the boundary — never a stored raw array with ?? null accessors. psl/type is the recommended validator; symfony/serializer, valinor, webmozart/assert and plain PHP are documented alternatives, since we can't require psl of everyone.
  4. Client and transport configured once per API, in a factory the tests reuse — so the tested plugin stack is the production one.
  5. Error handling at the layer that owns it: client plugin → transport decorator → request handler, in that order of preference.
  6. Handler tests run through the real transport against a recorded cassette; mock clients are for plugins, encoders and error paths.

Verification

  • Every referenced API checked against this branch's source: ClientBuilder priority levels, FormatterBuilder, the *::createDecorator() formatters, all encoders and decoders, SerializerTransport::withOutputType(), PathNamingStrategy options, FilesystemRecorder regex filters, and psl/type's shape($elements, $allowUnknownFields).
  • All 49 PHP snippets extracted and linted on PHP 8.4 — the three that don't parse standalone are deliberate catalogue fragments.
  • All internal markdown links resolve.
  • A baseline run without the skills produced exactly the drift they target: technical folder grouping, no handler interfaces, fromArray()/toArray() instead of parsed types, and handler tests mocking TransportInterface.

Examples use an imaginary "Crumbs Bakery" API (App\Infrastructure\Bakery, GET /orders/{orderId}) throughout, so snippets compose across skills.

Introduces `.agents/skills/` — skills that teach a coding agent how to
build an integration with this package, aimed at consumers rather than
contributors.

Six task-oriented skills, each usable on its own:

* `generate-http-api-call` — orchestrates a full endpoint slice
* `configure-http-client` — config, client and transport factory, once per API
* `generate-http-request` — request models, URI templates, BodyType
* `generate-http-response` — strictly typed response models
* `generate-http-request-handler` — handler + interface, error handling layers
* `test-http-integration` — mock client vs VCR cassettes

Reference files cover the plugin catalogue and priorities, the
encoder/decoder matrix, psl/type usage and VCR cassette handling.

Strict typing with a single validation step at the boundary is presented
as the non-negotiable rule; psl/type is the recommended way to get there,
with symfony/serializer, valinor and webmozart/assert documented as
alternatives, since the package cannot require psl of everyone.

All examples use an imaginary "Crumbs Bakery" API so snippets compose
across skills. `.claude/skills` is git-ignored so Claude Code can pick
these up through a local symlink.
@veewee
veewee merged commit 3d48b73 into phpro:v2.x Sep 3, 2026
4 checks passed
@veewee
veewee deleted the agent-skills branch September 4, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant