create-builder
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-builder" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-0ef1c1cd4b13e67ef9a5bf9837ed81de062ba204c63099588f1fa83fa624b356. 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 a Builder pattern implementation for PHP 8.4 that uses a fluent interface and validation to build objects incrementally. Include corresponding unit test examples.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Generates Builder pattern for PHP 8.4. Creates step-by-step object construction with fluent interface and validation. Includes unit tests.
- Audience
- | Scenario | Example | |----------|---------| | Many constructor parameters | Order with 10+ fields | | Optional parameters | Email with optional CC, BCC | | Complex validation | Build-time validation | | Step-by-step construction | Query building | | Multiple representations | Different order types |
- Software, accounts and paid services
- Determine: Target product class Required vs optional properties Validation rules Whether Director is needed
- Testing
- Not tested
Browse files
Frontmatter
name: create-builder
description: Generates Builder pattern for PHP 8.4. Creates step-by-step object construction with fluent interface and validation. Includes unit tests.Builder Pattern Generator
Creates Builder pattern infrastructure for step-by-step construction of complex objects.
When to Use
| Scenario | Example |
|---|---|
| Many constructor parameters | Order with 10+ fields |
| Optional parameters | Email with optional CC, BCC |
| Complex validation | Build-time validation |
| Step-by-step construction | Query building |
| Multiple representations | Different order types |
Component Characteristics
Builder Interface
- Defines building steps
- Returns self for fluent interface
- Has build() method for final product
Concrete Builder
- Implements building steps
- Maintains product state
- Validates before building
Director (Optional)
- Defines construction order
- Reusable build sequences
- Hides complexity from client
Generation Process
Step 1: Analyze Requirements
Determine:
- Target product class
- Required vs optional properties
- Validation rules
- Whether Director is needed
Step 2: Generate Builder Components
Path: src/Domain/{BoundedContext}/Builder/
{Name}BuilderInterface.php— Builder contract{Name}Builder.php— Concrete builder implementationBuilderValidationException.php— Validation exception{Name}Director.php— Optional director for common builds
Step 3: Generate Tests
Path: tests/Unit/Domain/{BoundedContext}/Builder/
{Name}BuilderTest.php— Builder functionality tests
File Placement
| Component | Path |
|---|---|
| Builder Interface | src/Domain/{BoundedContext}/Builder/ |
| Concrete Builder | src/Domain/{BoundedContext}/Builder/ |
| Director | src/Domain/{BoundedContext}/Builder/ |
| Exception | src/Domain/{BoundedContext}/Builder/ |
| Unit Tests | tests/Unit/Domain/{BoundedContext}/Builder/ |
Naming Conventions
| Component | Pattern | Example |
|---|---|---|
| Interface | {Name}BuilderInterface |
OrderBuilderInterface |
| Concrete Builder | {Name}Builder |
OrderBuilder |
| Director | {Name}Director |
OrderDirector |
| Exception | BuilderValidationException |
BuilderValidationException |
| Test | {ClassName}Test |
OrderBuilderTest |
Quick Template Reference
Builder Interface
interface {Name}BuilderInterface
{
public function with{Property1}({Type1} $value): self;
public function with{Property2}({Type2} $value): self;
public function build(): {Product};
public function reset(): self;
}
Concrete Builder
final class {Name}Builder implements {Name}BuilderInterface
{
private ?{Type1} ${property1} = null;
private ?{Type2} ${property2} = null;
private array $errors = [];
public function with{Property1}({Type1} $value): self
{
$this->{property1} = $value;
return $this;
}
public function build(): {Product}
{
$this->validate();
if ($this->errors !== []) {
throw new BuilderValidationException($this->errors);
}
return new {Product}(...);
}
public function reset(): self
{
$this->{property1} = null;
$this->errors = [];
return $this;
}
}
Director
final readonly class {Name}Director
{
public function __construct(private {Name}BuilderInterface $builder) {}
public function buildMinimal{Name}(/* required params */): {Product}
{
return $this->builder
->reset()
->with{Required1}($value1)
->build();
}
public function buildFull{Name}(/* all params */): {Product}
{
return $this->builder
->reset()
->with{Property1}($value1)
->with{Property2}($value2)
->build();
}
}
Usage Example
// Direct builder usage
$order = (new OrderBuilder())
->forCustomer($customerId)
->withShippingAddress($address)
->addItem($item1)
->addItem($item2)
->withDiscountCode('SAVE10')
->build();
// Using Director
$director = new OrderDirector(new OrderBuilder());
$minimalOrder = $director->buildMinimalOrder($customerId, $address, $item);
$giftOrder = $director->buildGiftOrder($customerId, $shipping, $billing, $items, 'Happy Birthday!');
Anti-patterns to Avoid
| Anti-pattern | Problem | Solution |
|---|---|---|
| No Validation | Invalid objects built | Validate in build() |
| Mutable Product | Product can change after build | Return immutable objects |
| Missing Reset | Builder state persists | Add reset() method |
| Too Many Steps | Hard to use | Use Director or defaults |
| No Fluent Interface | Verbose client code | Return self from setters |
References
For complete PHP templates and examples, see:
references/templates.md— Builder, QueryBuilder templatesreferences/examples.md— OrderBuilder, EmailBuilder examples and tests
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 PHP 8.4 Builder 模式的完整生成能力
- 适用于复杂对象构建、可选参数、验证等实际开发场景
- 包含单元测试生成,提升代码质量
Highlights
- description 明确描述了核心功能:生成 Builder 模式、流式接口、验证、单元测试
- 触发词完整,边界清晰,用户能准确理解 Skill 用途
Highlights
- 文档结构完整,包含使用场景、组件特性、生成流程、文件位置、命名规范等
- 提供了详细的代码模板和使用示例
- frontmatter 完整,单文件结构合理
Areas to improve
-
工具来源不明 Reported severity: Minor
文档提供了完整的代码模板和文件结构说明,但未明确说明生成这些文件的具体工具或方法
Recommendation: 建议补充说明生成 Builder 文件的具体工具或 CLI 命令,提升执行可靠性
Highlights
- 提供了完整的 Builder 模式实现模板
- 包含验证机制和异常处理设计
- 给出了 Director 模式的实现方案
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.
Determine: Target product class Required vs optional properties Validation rules Whether Director is needed
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.