create-action
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "create-action" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-f9aef6ae0efdb76bf87139d647ac6862944c1e9393bc43a549c248373d18e7cf. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Generate an ADR action class for PHP 8.4: create a single-responsibility HTTP endpoint handler that supports PSR-7 and includes unit tests.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Generates ADR Action classes for PHP 8.4. Creates single-responsibility HTTP endpoint handlers with PSR-7 support. Includes unit tests.
- Testing
- Not tested
Browse files
Frontmatter
name: create-action
description: Generates ADR Action classes for PHP 8.4. Creates single-responsibility HTTP endpoint handlers with PSR-7 support. Includes unit tests.Action Generator
Generate ADR-compliant Action classes for HTTP endpoints.
Action Characteristics
- Single Responsibility: One action = one HTTP endpoint
- Input Parsing: Collects and parses request input
- Domain Invocation: Calls UseCase/Handler
- Response Delegation: Passes result to Responder
- No Business Logic: Thin coordination layer
- Invokable: Single
__invoke()method
Template
<?php
declare(strict_types=1);
namespace Presentation\Api\{Context}\{Action};
use Application\{Context}\UseCase\{Action}\{Action}Command;
use Application\{Context}\UseCase\{Action}\{Action}Handler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
final readonly class {Action}Action
{
public function __construct(
private {Action}Handler $handler,
private {Action}Responder $responder,
) {
}
public function __invoke(ServerRequestInterface $request): ResponseInterface
{
{inputParsing}
$command = new {Action}Command(
{commandProperties}
);
$result = $this->handler->handle($command);
return $this->responder->respond($result);
}
{privateMethods}
}
Test Template
<?php
declare(strict_types=1);
namespace Tests\Unit\Presentation\Api\{Context}\{Action};
use Application\{Context}\UseCase\{Action}\{Action}Command;
use Application\{Context}\UseCase\{Action}\{Action}Handler;
use Application\{Context}\UseCase\{Action}\{Action}Result;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Presentation\Api\{Context}\{Action}\{Action}Action;
use Presentation\Api\{Context}\{Action}\{Action}Responder;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamInterface;
#[Group('unit')]
#[CoversClass({Action}Action::class)]
final class {Action}ActionTest extends TestCase
{
private {Action}Handler $handler;
private {Action}Responder $responder;
private {Action}Action $action;
protected function setUp(): void
{
$this->handler = $this->createMock({Action}Handler::class);
$this->responder = $this->createMock({Action}Responder::class);
$this->action = new {Action}Action($this->handler, $this->responder);
}
public function testInvokesHandlerWithCommand(): void
{
$request = $this->createRequest([{testData}]);
$result = $this->createMock({Action}Result::class);
$response = $this->createMock(ResponseInterface::class);
$this->handler
->expects($this->once())
->method('handle')
->with($this->callback(fn ({Action}Command $cmd) =>
{commandAssertions}
))
->willReturn($result);
$this->responder
->expects($this->once())
->method('respond')
->with($result)
->willReturn($response);
$actual = ($this->action)($request);
self::assertSame($response, $actual);
}
private function createRequest(array $body): ServerRequestInterface
{
$stream = $this->createMock(StreamInterface::class);
$request = $this->createMock(ServerRequestInterface::class);
$request->method('getParsedBody')->willReturn($body);
$request->method('getBody')->willReturn($stream);
return $request;
}
}
Action Patterns by HTTP Method
GET (Read Single)
<?php
declare(strict_types=1);
namespace Presentation\Api\User\GetById;
use Application\User\UseCase\GetUserById\GetUserByIdQuery;
use Application\User\UseCase\GetUserById\GetUserByIdHandler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
final readonly class GetUserByIdAction
{
public function __construct(
private GetUserByIdHandler $handler,
private GetUserByIdResponder $responder,
) {
}
public function __invoke(ServerRequestInterface $request): ResponseInterface
{
$userId = $request->getAttribute('id');
$query = new GetUserByIdQuery(userId: $userId);
$result = $this->handler->handle($query);
return $this->responder->respond($result);
}
}
GET (List with Pagination)
<?php
declare(strict_types=1);
namespace Presentation\Api\User\ListAll;
use Application\User\UseCase\ListUsers\ListUsersQuery;
use Application\User\UseCase\ListUsers\ListUsersHandler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
final readonly class ListUsersAction
{
public function __construct(
private ListUsersHandler $handler,
private ListUsersResponder $responder,
) {
}
public function __invoke(ServerRequestInterface $request): ResponseInterface
{
$queryParams = $request->getQueryParams();
$query = new ListUsersQuery(
page: (int) ($queryParams['page'] ?? 1),
perPage: (int) ($queryParams['per_page'] ?? 20),
search: $queryParams['search'] ?? null,
);
$result = $this->handler->handle($query);
return $this->responder->respond($result);
}
}
POST (Create)
<?php
declare(strict_types=1);
namespace Presentation\Api\User\Create;
use Application\User\UseCase\CreateUser\CreateUserCommand;
use Application\User\UseCase\CreateUser\CreateUserHandler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
final readonly class CreateUserAction
{
public function __construct(
private CreateUserHandler $handler,
private CreateUserResponder $responder,
) {
}
public function __invoke(ServerRequestInterface $request): ResponseInterface
{
$body = (array) $request->getParsedBody();
$command = new CreateUserCommand(
email: $body['email'] ?? '',
name: $body['name'] ?? '',
);
$result = $this->handler->handle($command);
return $this->responder->respond($result);
}
}
PUT/PATCH (Update)
<?php
declare(strict_types=1);
namespace Presentation\Api\User\Update;
use Application\User\UseCase\UpdateUser\UpdateUserCommand;
use Application\User\UseCase\UpdateUser\UpdateUserHandler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
final readonly class UpdateUserAction
{
public function __construct(
private UpdateUserHandler $handler,
private UpdateUserResponder $responder,
) {
}
public function __invoke(ServerRequestInterface $request): ResponseInterface
{
$userId = $request->getAttribute('id');
$body = (array) $request->getParsedBody();
$command = new UpdateUserCommand(
userId: $userId,
name: $body['name'] ?? null,
email: $body['email'] ?? null,
);
$result = $this->handler->handle($command);
return $this->responder->respond($result);
}
}
DELETE
<?php
declare(strict_types=1);
namespace Presentation\Api\User\Delete;
use Application\User\UseCase\DeleteUser\DeleteUserCommand;
use Application\User\UseCase\DeleteUser\DeleteUserHandler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
final readonly class DeleteUserAction
{
public function __construct(
private DeleteUserHandler $handler,
private DeleteUserResponder $responder,
) {
}
public function __invoke(ServerRequestInterface $request): ResponseInterface
{
$userId = $request->getAttribute('id');
$command = new DeleteUserCommand(userId: $userId);
$result = $this->handler->handle($command);
return $this->responder->respond($result);
}
}
File Placement
| Component | Path |
|---|---|
| Action | src/Presentation/Api/{Context}/{Action}/{Action}Action.php |
| Action Interface | src/Presentation/Shared/Action/ActionInterface.php |
| Test | tests/Unit/Presentation/Api/{Context}/{Action}/{Action}ActionTest.php |
Generation Instructions
When asked to create an Action:
- Identify HTTP method (GET, POST, PUT, DELETE)
- Determine input source (body, query params, route attributes)
- Identify Command/Query DTO (what to pass to handler)
- Generate Action class with proper namespace
- Generate test with mocked dependencies
Naming Conventions
| HTTP Method | Action Name | Command/Query |
|---|---|---|
| GET (single) | Get{Resource}ByIdAction | Get{Resource}ByIdQuery |
| GET (list) | List{Resource}sAction | List{Resource}sQuery |
| POST | Create{Resource}Action | Create{Resource}Command |
| PUT | Update{Resource}Action | Update{Resource}Command |
| PATCH | Patch{Resource}Action | Patch{Resource}Command |
| DELETE | Delete{Resource}Action | Delete{Resource}Command |
References
For detailed patterns and examples:
references/templates.md— Additional Action templatesreferences/examples.md— Real-world Action examples
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供完整的 ADR Action 类生成模板,支持多种 HTTP 方法
- 包含单元测试模板,提升代码质量保障
- 遵循 PSR-7 标准,具有良好的兼容性
Areas to improve
-
触发词描述不够具体 Reported severity: Minor
description 描述了核心功能但未提供具体的触发关键词,可能导致边界场景识别不准确
Recommendation: 建议补充具体的触发关键词列表,如 'generate action', 'create adr action', 'php action class' 等
Highlights
- description 清晰表达了为 PHP 8.4 生成 ADR 动作类的核心功能
Highlights
- 文档结构完整,包含特性说明、模板、测试、示例、文件位置、生成指令等
- 提供了完整的 PHP 代码模板和测试模板
- frontmatter 完整,包含 name 和 description
Areas to improve
-
异常处理覆盖不足 Reported severity: Minor
模板中未明确说明如何处理请求解析失败、参数验证失败等异常情况
Recommendation: 建议在模板中添加异常处理机制,如 try-catch 块或参数验证逻辑
Highlights
- 代码模板遵循单一职责原则,结构清晰
- 依赖注入方式合理,便于测试和维护
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.