create-factory
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-factory" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-9c5d600b91ef9e01537a54f06b63746f685db783f091302b096304a445d96c4c. 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 Domain-Driven Design (DDD) factory for PHP 8.4. Provides factory implementations for instantiating complex domain objects with creation logic that includes validation and encapsulation, along with accompanying unit tests.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Generates DDD Factory for PHP 8.4. Creates factories for complex domain object instantiation with validation and encapsulated creation logic. Includes unit tests.
- Audience
- | Scenario | Example | |----------|---------| | Complex construction logic | `OrderFactory::createFromCart()` | | Multiple creation paths | `User::register()`, `User::createAdmin()` | | Aggregate creation | `PolicyFactory::createWithCoverage()` | | Reconstruction from persistence | `OrderFactory::reconstitute()` | | Creation with validation | `InvoiceFactory::create()` |
- Testing
- Not tested
Browse files
Frontmatter
name: create-factory
description: Generates DDD Factory for PHP 8.4. Creates factories for complex domain object instantiation with validation and encapsulated creation logic. Includes unit tests.Factory Generator
Generate DDD-compliant Factories for complex domain object creation.
Factory Characteristics
- Encapsulates Creation: Hides complex instantiation logic
- Validates Input: Ensures valid object creation
- Named Constructors: Provides semantic creation methods
- Domain Layer: Lives in Domain, no infrastructure dependencies
- Returns Valid Objects: Never creates invalid domain objects
- Static or Instance: Static for simple, instance for dependencies
When to Use Factory
| Scenario | Example |
|---|---|
| Complex construction logic | OrderFactory::createFromCart() |
| Multiple creation paths | User::register(), User::createAdmin() |
| Aggregate creation | PolicyFactory::createWithCoverage() |
| Reconstruction from persistence | OrderFactory::reconstitute() |
| Creation with validation | InvoiceFactory::create() |
Generation Process
Step 1: Determine Factory Type
- Static Factory: No dependencies, simple validation
- Instance Factory: Needs domain services or repositories
Step 2: Generate Factory
Path: src/Domain/{BoundedContext}/Factory/
{Entity}Factory.php— Main factory class
Step 3: Define Creation Methods
create()— Primary creation with validationcreateFrom{Source}()— Creation from other objectsreconstitute()— Reconstruction from persistence (no validation)
Step 4: Generate Tests
Path: tests/Unit/Domain/{BoundedContext}/Factory/
File Placement
| Component | Path |
|---|---|
| Factory | src/Domain/{BoundedContext}/Factory/ |
| Unit Tests | tests/Unit/Domain/{BoundedContext}/Factory/ |
Naming Conventions
| Pattern | Example |
|---|---|
| Factory Class | {EntityName}Factory |
| Create Method | create(), createFrom{Source}() |
| Named Constructor | create{Variant}() |
| Reconstitute | reconstitute() |
| Validation | validate{Aspect}() |
Quick Template Reference
Static Factory
final class {Entity}Factory
{
public static function create({parameters}): {Entity}
{
self::validate({parameters});
return new {Entity}({constructorArgs});
}
public static function createFrom{Source}({SourceType} $source): {Entity}
{
return new {Entity}({mappedArgs});
}
public static function reconstitute({allFields}): {Entity}
{
return new {Entity}({allArgs});
}
private static function validate({parameters}): void
{
{validationLogic}
}
}
Instance Factory
final readonly class {Entity}Factory
{
public function __construct(
private {DomainService} $service,
private {Repository} $repository
) {}
public function create({parameters}): {Entity}
{
{creationLogicWithDependencies}
}
}
Anti-patterns to Avoid
| Anti-pattern | Problem | Solution |
|---|---|---|
| Infrastructure in Factory | DB calls in factory | Keep pure domain logic |
| No Validation | Creates invalid objects | Validate before creation |
| Too Many Parameters | Hard to use | Use Value Objects, Builder |
| Mutable Factory | Stateful creation | Make stateless or readonly |
| Missing Reconstitute | Can't hydrate from DB | Add reconstitute method |
References
For complete PHP templates and examples, see:
references/templates.md— Static Factory, Instance Factory, Test templatesreferences/examples.md— Order, User, Policy factory examples and tests
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 PHP 8.4 DDD 工厂生成能力,解决复杂领域对象实例化的实际问题
- 包含验证、封装创建逻辑及单元测试,功能完整
Highlights
- description 明确描述功能与目标版本,触发词精准完整
Highlights
- 结构清晰,包含生成步骤、文件路径、命名规范与模板示例
- frontmatter 完整,文档组织良好
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.