acc-create-psr13-link
Generates PSR-13 Hypermedia Links implementation for PHP 8.5. Creates LinkInterface, EvolvableLinkInterface, and LinkProviderInterface for HATEOAS support. Includes unit tests.
Best use case
acc-create-psr13-link is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Generates PSR-13 Hypermedia Links implementation for PHP 8.5. Creates LinkInterface, EvolvableLinkInterface, and LinkProviderInterface for HATEOAS support. Includes unit tests.
Teams using acc-create-psr13-link should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/acc-create-psr13-link/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How acc-create-psr13-link Compares
| Feature / Agent | acc-create-psr13-link | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Generates PSR-13 Hypermedia Links implementation for PHP 8.5. Creates LinkInterface, EvolvableLinkInterface, and LinkProviderInterface for HATEOAS support. Includes unit tests.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# PSR-13 Hypermedia Links Generator
## Overview
Generates PSR-13 compliant hypermedia link implementations for HATEOAS REST APIs.
## When to Use
- Building REST APIs with HATEOAS
- Creating hypermedia-driven resources
- Link relation management
- URI templates
## Generated Components
| Component | Description | Location |
|-----------|-------------|----------|
| Link | LinkInterface impl | `src/Infrastructure/Http/Link/` |
| LinkProvider | Provider impl | `src/Infrastructure/Http/Link/` |
| Unit Tests | PHPUnit tests | `tests/Unit/Infrastructure/Http/Link/` |
## Template: Link
```php
<?php
declare(strict_types=1);
namespace App\Infrastructure\Http\Link;
use Psr\Link\EvolvableLinkInterface;
use Stringable;
final readonly class Link implements EvolvableLinkInterface
{
/** @param string[] $rels */
public function __construct(
private string $href,
private array $rels = [],
private array $attributes = [],
private bool $templated = false,
) {
}
public function getHref(): string
{
return $this->href;
}
public function isTemplated(): bool
{
return $this->templated || str_contains($this->href, '{');
}
public function getRels(): array
{
return $this->rels;
}
public function getAttributes(): array
{
return $this->attributes;
}
public function withHref(string|Stringable $href): static
{
return new self((string) $href, $this->rels, $this->attributes, $this->templated);
}
public function withRel(string $rel): static
{
$rels = [...$this->rels, $rel];
return new self($this->href, array_unique($rels), $this->attributes, $this->templated);
}
public function withoutRel(string $rel): static
{
$rels = array_filter($this->rels, fn($r) => $r !== $rel);
return new self($this->href, array_values($rels), $this->attributes, $this->templated);
}
public function withAttribute(string $attribute, string|Stringable $value): static
{
$attributes = $this->attributes;
$attributes[$attribute] = (string) $value;
return new self($this->href, $this->rels, $attributes, $this->templated);
}
public function withoutAttribute(string $attribute): static
{
$attributes = $this->attributes;
unset($attributes[$attribute]);
return new self($this->href, $this->rels, $attributes, $this->templated);
}
}
```
## Template: Link Provider
```php
<?php
declare(strict_types=1);
namespace App\Infrastructure\Http\Link;
use Psr\Link\EvolvableLinkProviderInterface;
use Psr\Link\LinkInterface;
final readonly class LinkProvider implements EvolvableLinkProviderInterface
{
/** @param LinkInterface[] $links */
public function __construct(
private array $links = [],
) {
}
public function getLinks(): iterable
{
return $this->links;
}
public function getLinksByRel(string $rel): iterable
{
foreach ($this->links as $link) {
if (in_array($rel, $link->getRels(), true)) {
yield $link;
}
}
}
public function withLink(LinkInterface $link): static
{
return new self([...$this->links, $link]);
}
public function withoutLink(LinkInterface $link): static
{
$links = array_filter(
$this->links,
fn($l) => $l !== $link,
);
return new self(array_values($links));
}
}
```
## Template: Resource with Links
```php
<?php
declare(strict_types=1);
namespace App\Presentation\Api\Resource;
use App\Domain\User\Entity\User;
use App\Infrastructure\Http\Link\Link;
use App\Infrastructure\Http\Link\LinkProvider;
use Psr\Link\LinkProviderInterface;
final readonly class UserResource implements LinkProviderInterface
{
private LinkProvider $linkProvider;
public function __construct(
public string $id,
public string $email,
public string $name,
) {
$this->linkProvider = new LinkProvider([
(new Link("/api/users/{$this->id}"))->withRel('self'),
(new Link("/api/users/{$this->id}/posts"))->withRel('posts'),
(new Link('/api/users'))->withRel('collection'),
]);
}
public static function fromEntity(User $user): self
{
return new self(
$user->getId()->toString(),
$user->getEmail()->toString(),
$user->getName(),
);
}
public function getLinks(): iterable
{
return $this->linkProvider->getLinks();
}
public function getLinksByRel(string $rel): iterable
{
return $this->linkProvider->getLinksByRel($rel);
}
public function toArray(): array
{
$data = [
'id' => $this->id,
'email' => $this->email,
'name' => $this->name,
'_links' => [],
];
foreach ($this->getLinks() as $link) {
foreach ($link->getRels() as $rel) {
$data['_links'][$rel] = [
'href' => $link->getHref(),
'templated' => $link->isTemplated(),
];
}
}
return $data;
}
}
```
## Usage Example
```php
<?php
use App\Infrastructure\Http\Link\Link;
use App\Infrastructure\Http\Link\LinkProvider;
// Create links
$selfLink = (new Link('/api/users/123'))
->withRel('self')
->withAttribute('title', 'User Profile');
$collectionLink = (new Link('/api/users'))
->withRel('collection');
$templateLink = (new Link('/api/users/{id}'))
->withRel('user');
// Create provider
$provider = (new LinkProvider())
->withLink($selfLink)
->withLink($collectionLink)
->withLink($templateLink);
// Get links by relation
foreach ($provider->getLinksByRel('self') as $link) {
echo $link->getHref(); // /api/users/123
}
```
## Requirements
```json
{
"require": {
"psr/link": "^2.0"
}
}
```Related Skills
acc-create-value-object
Generates DDD Value Objects for PHP 8.5. Creates immutable, self-validating objects with equality comparison. Includes unit tests.
acc-create-use-case
Generates Application Use Cases for PHP 8.5. Creates orchestration services that coordinate domain objects, handle transactions, and dispatch events. Includes unit tests.
acc-create-unit-test
Generates PHPUnit unit tests for PHP 8.5. Creates isolated tests with AAA pattern, proper naming, attributes, and one behavior per test. Supports Value Objects, Entities, Services.
acc-create-test-double
Generates test doubles (Mocks, Stubs, Fakes, Spies) for PHP 8.5. Creates appropriate double type based on testing needs with PHPUnit MockBuilder patterns.
acc-create-test-builder
Generates Test Data Builder and Object Mother patterns for PHP 8.5. Creates fluent builders with sensible defaults and factory methods for test data creation.
acc-create-strategy
Generates Strategy pattern for PHP 8.5. Creates interchangeable algorithm families with context class, strategy interface, and concrete implementations. Includes unit tests.
acc-create-state
Generates State pattern for PHP 8.5. Creates state machines with context, state interface, and concrete states for behavior changes. Includes unit tests.
acc-create-specification
Generates DDD Specification for PHP 8.5. Creates reusable business rule objects for validation, filtering, and querying with composite pattern support. Includes unit tests.
acc-create-saga-pattern
Generates Saga pattern components for PHP 8.5. Creates Saga interfaces, steps, orchestrator, state management, and compensation logic with unit tests.
acc-create-retry-pattern
Generates Retry pattern for PHP 8.5. Creates resilience component with exponential backoff, jitter, and configurable retry strategies. Includes unit tests.
acc-create-responder
Generates ADR Responder classes for PHP 8.5. Creates HTTP response builders with PSR-7/PSR-17 support. Includes unit tests.
acc-create-repository
Generates DDD Repository interfaces and implementation stubs for PHP 8.5. Creates domain interfaces in Domain layer, implementation in Infrastructure.