create-prototype
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-prototype":https://skillpi.com/zh/skills/deepskill-9b6e5d840465852d069746dc2c6e91c4063ed0bab7548b2b08153e67eafe582e。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为 PHP 8.4 生成原型模式实现。包含深拷贝与浅拷贝策略、可定制的克隆行为、原型注册表以及不可变对象的复制方案设计。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 减记
- 实测状态
- 未测试
文件浏览
Frontmatter
name: create-prototype
description: Generates Prototype pattern implementations for PHP 8.4. Creates deep/shallow copy, clone customization, prototype registries, and immutable object duplication.Prototype Pattern Generator
Generate Prototype pattern implementations for PHP 8.4 with proper deep/shallow copy semantics.
Pattern Overview
Prototype creates new objects by cloning existing instances, avoiding costly construction and enabling runtime object configuration.
Generation Templates
1. Basic Prototype with Clone
<?php
declare(strict_types=1);
namespace {Namespace}\Domain\{Context};
// Cloning is opted into via the __clone() magic method — PHP has no Cloneable interface
final class {Name}
{
public function __construct(
private readonly {IdType} $id,
private string $title,
private array $metadata,
private \DateTimeImmutable $createdAt,
) {}
public function __clone(): void
{
// Deep copy mutable objects
$this->createdAt = clone $this->createdAt;
// Arrays are copied by value (shallow), but nested objects need cloning
$this->metadata = array_map(
fn (mixed $item) => is_object($item) ? clone $item : $item,
$this->metadata,
);
}
public function withTitle(string $title): self
{
$clone = clone $this;
$clone->title = $title;
return $clone;
}
public function withMetadata(array $metadata): self
{
$clone = clone $this;
$clone->metadata = $metadata;
return $clone;
}
}
2. Prototype Registry
<?php
declare(strict_types=1);
namespace {Namespace}\Domain\{Context};
final class {Name}PrototypeRegistry
{
/** @var array<string, {Name}> */
private array $prototypes = [];
public function register(string $key, {Name} $prototype): void
{
$this->prototypes[$key] = $prototype;
}
public function create(string $key): {Name}
{
if (!isset($this->prototypes[$key])) {
throw new \InvalidArgumentException(
sprintf('Prototype "%s" not registered. Available: %s', $key, implode(', ', array_keys($this->prototypes))),
);
}
return clone $this->prototypes[$key];
}
public function has(string $key): bool
{
return isset($this->prototypes[$key]);
}
/** @return list<string> */
public function keys(): array
{
return array_keys($this->prototypes);
}
}
3. Immutable Value Object Prototype
<?php
declare(strict_types=1);
namespace {Namespace}\Domain\{Context}\ValueObject;
final readonly class {Name}
{
public function __construct(
private string $currency,
private int $amount,
private string $locale,
) {}
// Immutable "clone" via named constructors
public function withAmount(int $amount): self
{
return new self(
currency: $this->currency,
amount: $amount,
locale: $this->locale,
);
}
public function withCurrency(string $currency): self
{
return new self(
currency: $currency,
amount: $this->amount,
locale: $this->locale,
);
}
// Factory from prototype
public static function fromPrototype(self $prototype, int $amount): self
{
return new self(
currency: $prototype->currency,
amount: $amount,
locale: $prototype->locale,
);
}
}
4. Deep Clone with Object Graph
<?php
declare(strict_types=1);
namespace {Namespace}\Domain\{Context};
final class {Name}
{
/** @var list<{ChildType}> */
private array $children;
private ?{IdType} $pendingId = null;
public function __construct(
private readonly {IdType} $id,
private {ConfigType} $config,
array $children = [],
) {
$this->children = $children;
}
public function __clone(): void
{
// PHP 8.3+: __clone() may reassign a readonly property of the object being cloned
if ($this->pendingId !== null) {
$this->id = $this->pendingId;
$this->pendingId = null;
}
// Deep clone config object
$this->config = clone $this->config;
// Deep clone collection of children
$this->children = array_map(
fn ({ChildType} $child): {ChildType} => clone $child,
$this->children,
);
}
public function duplicate({IdType} $newId): self
{
$this->pendingId = $newId;
try {
return clone $this;
} finally {
$this->pendingId = null;
}
}
}
Detection Patterns (Audit)
# Missing __clone on classes with mutable properties
Grep: "class.*\{" --glob "**/Domain/**/*.php"
# Then check for mutable object properties without __clone
# Shallow copy issues (clone without __clone)
Grep: "clone \$this" --glob "**/*.php"
Grep: "function __clone" --glob "**/*.php"
# Manual copy-paste construction (prototype candidate)
Grep: "new self\(.*\$this->" --glob "**/*.php"
# Prototype registry candidates
Grep: "array.*prototype|registry.*clone" --glob "**/*.php"
Anti-Patterns to Avoid
// BAD: Serialization for deep copy (slow, breaks resources)
$clone = unserialize(serialize($original));
// BAD: No __clone with mutable objects
$clone = clone $original;
$clone->getAddress()->setCity('New'); // Modifies original!
// BAD: Clone readonly object without proper handling
final readonly class Order
{
// Cannot modify properties after clone!
// Use "with" methods returning new instances instead
}
Output Format
### Prototype Pattern: {Name}
**Files Generated:**
- `src/Domain/{Context}/{Name}.php` — Prototype with __clone
- `src/Domain/{Context}/{Name}PrototypeRegistry.php` — Registry (if needed)
**Clone Strategy:**
- Deep copy: [list mutable properties]
- Shallow copy: [list immutable/scalar properties]
- Readonly: [list readonly properties — use with* methods]当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 PHP 8.4 原型模式的完整实现方案,涵盖深拷贝、浅拷贝、克隆定制、原型注册表等高级特性
- 包含检测模式和反模式指导,帮助用户识别和避免常见错误
- 代码模板质量高,符合现代 PHP 开发规范
待提升项
-
触发词不全 原报告严重程度:轻微
description 描述了功能但未提供具体触发指令示例,用户不清楚如何触发该 Skill
改进建议:在 description 或 skill_body 开头添加触发示例,如:'当用户请求"生成 PHP 原型模式"或"创建深拷贝类"时触发'
待提升项
-
缺少 When to Use 章节 原报告严重程度:轻微
文档未明确说明该 Skill 的适用场景和使用时机
改进建议:在 Pattern Overview 后添加 'When to Use' 章节,说明何时应该使用原型模式
-
缺少端到端示例 原报告严重程度:轻微
虽然有代码模板,但缺少完整的用户交互示例展示从触发到生成结果的完整流程
改进建议:添加一个完整的端到端示例,展示用户输入和 Skill 输出的对应关系
亮点
- 文档结构清晰,包含多个实用模板和检测模式
- frontmatter 完整,代码示例详细且符合 PHP 8.4 规范
待提升项
-
模板占位符未说明 原报告严重程度:轻微
代码模板中包含 {Namespace}、{Context}、{Name} 等占位符,但未提供替换说明
改进建议:在 Output Format 前添加占位符说明章节,解释每个占位符的含义和替换规则
亮点
- 代码实现基于 PHP 8.4 最新语法,可靠性高
- 正确处理了 readonly 属性的克隆问题,覆盖主要异常场景
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。