create-template-method
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-template-method" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-e7f593941e301c03602402aa53f4a4ee937877bef0eed9f1f620fffacfbcd7fb. 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 Template Method pattern implementation for PHP 8.4. Create a base class that defines an abstract algorithm skeleton with customizable steps, allowing subclasses to override specific parts without changing structure, and include unit tests.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Generates Template Method pattern for PHP 8.4. Creates abstract algorithm skeleton with customizable steps, allowing subclasses to override specific parts without changing structure. Includes unit tests.
- Audience
- | Scenario | Example | |----------|---------| | Common algorithm structure | Data import/export with format variations | | Controlled extension points | Report generation with customizable sections | | Code reuse across variants | Order processing with type-specific steps | | Invariant parts protection | Template rendering with hooks |
- Testing
- Not tested
Browse files
Frontmatter
name: create-template-method
description: Generates Template Method pattern for PHP 8.4. Creates abstract algorithm skeleton with customizable steps, allowing subclasses to override specific parts without changing structure. Includes unit tests.Template Method Pattern Generator
Creates Template Method pattern infrastructure for algorithm skeletons with customizable steps.
When to Use
| Scenario | Example |
|---|---|
| Common algorithm structure | Data import/export with format variations |
| Controlled extension points | Report generation with customizable sections |
| Code reuse across variants | Order processing with type-specific steps |
| Invariant parts protection | Template rendering with hooks |
Component Characteristics
Abstract Template Class
- Defines algorithm skeleton
- Implements invariant steps
- Declares abstract/hook methods
- Calls methods in sequence
Concrete Implementations
- Override specific steps
- Provide algorithm variants
- Inherit common behavior
- Maintain overall structure
Hook Methods
- Optional override points
- Default empty implementation
- Allow customization
- Don't break flow
Generation Process
Step 1: Generate Abstract Template
Path: src/Domain/{BoundedContext}/Template/
Abstract{Name}Template.php— Algorithm skeleton with template method
Step 2: Generate Concrete Templates
Path: src/Domain/{BoundedContext}/Template/ or src/Application/{BoundedContext}/
{Variant1}{Name}Template.php— First variant implementation{Variant2}{Name}Template.php— Second variant implementation{Variant3}{Name}Template.php— Third variant implementation
Step 3: Generate Support Classes (Optional)
Path: src/Domain/{BoundedContext}/ValueObject/
{Name}Result.php— Result value object{Name}Config.php— Configuration value object
Step 4: Generate Tests
{Variant}{Name}TemplateTest.php— Individual template testsAbstract{Name}TemplateTest.php— Template skeleton tests
File Placement
| Component | Path |
|---|---|
| Abstract Template | src/Domain/{BoundedContext}/Template/ |
| Concrete Templates (Domain logic) | src/Domain/{BoundedContext}/Template/ |
| Concrete Templates (App logic) | src/Application/{BoundedContext}/ |
| Unit Tests | tests/Unit/Domain/{BoundedContext}/Template/ |
Naming Conventions
| Component | Pattern | Example |
|---|---|---|
| Abstract | Abstract{Name}Template |
AbstractDataImporterTemplate |
| Concrete | {Variant}{Name}Template |
CsvDataImporterTemplate |
| Template Method | execute() or process() |
execute() |
| Hook Method | before{Step}(), after{Step}() |
beforeValidation() |
| Test | {ClassName}Test |
CsvDataImporterTemplateTest |
Quick Template Reference
Abstract Template
abstract readonly class Abstract{Name}Template
{
public function execute({InputType} $input): {OutputType}
{
$this->validate($input);
$data = $this->extract($input);
$transformed = $this->transform($data);
$result = $this->load($transformed);
$this->afterLoad($result);
return $result;
}
abstract protected function extract({InputType} $input): array;
abstract protected function transform(array $data): array;
protected function validate({InputType} $input): void
{
// Default validation
}
protected function afterLoad({OutputType} $result): void
{
// Hook method - optional override
}
}
Concrete Template
final readonly class {Variant}{Name}Template extends Abstract{Name}Template
{
protected function extract({InputType} $input): array
{
// Variant-specific extraction
}
protected function transform(array $data): array
{
// Variant-specific transformation
}
}
Usage Example
// Create templates for different formats
$csvImporter = new CsvDataImporterTemplate();
$jsonImporter = new JsonDataImporterTemplate();
$xmlImporter = new XmlDataImporterTemplate();
// Use same interface
$result = $csvImporter->execute($fileContent);
Common Template Method Variants
| Domain | Variants |
|---|---|
| Data Import | CSV, JSON, XML, Excel |
| Report Generation | PDF, Excel, HTML, Email |
| Order Processing | Standard, Express, International |
| Document Rendering | Markdown, LaTeX, HTML |
| Payment Flow | Card, Bank Transfer, Digital Wallet |
Anti-patterns to Avoid
| Anti-pattern | Problem | Solution |
|---|---|---|
| Too many abstract methods | Hard to implement | Use hook methods with defaults |
| Public template steps | Breaks encapsulation | Make steps protected/private |
| Mutable state | Side effects | Use readonly classes, pass data |
| Deep inheritance | Complexity | Limit to 2-3 levels max |
| Breaking LSP | Inconsistent behavior | Maintain contract in overrides |
References
For complete PHP templates and examples, see:
references/templates.md— Abstract Template, Concrete Template, Hook Methods templatesreferences/examples.md— DataImporter, ReportGenerator, OrderProcessor with tests
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供完整的模板方法模式生成方案,适用于数据导入、报表生成等多个高频场景
- 包含抽象模板、具体实现、钩子方法和单元测试的完整架构
- 具有明确的代码生成路径和命名规范,实用性强
Areas to improve
-
触发场景变体覆盖 Reported severity: Minor
可补充更多模板方法模式的触发场景变体
Recommendation: 增加更多领域特定的触发示例,如缓存处理、日志记录等场景
Highlights
- description 完整描述了核心功能和使用场景
- 包含详细的适用场景表格和具体示例
- 触发词清晰准确,边界定义明确
Areas to improve
-
执行出口条件 Reported severity: Minor
缺少明确的执行完成条件和错误处理说明
Recommendation: 补充生成完成后的验证步骤和常见错误处理方案
Highlights
- Phase/步骤划分清晰,包含4个生成阶段
- 提供完整的文件放置和命名规范
- 包含端到端代码示例和快速参考模板
Areas to improve
-
PHP 8.4 特性说明 Reported severity: Minor
缺少对 PHP 8.4 特定特性的详细说明和使用指导
Recommendation: 补充 PHP 8.4 新特性在模板方法模式中的应用说明
-
依赖管理指导 Reported severity: Minor
未明确说明如何处理依赖管理和自动加载配置
Recommendation: 增加 composer.json 配置建议和自动加载设置指导
Highlights
- 提供完整的代码模板和结构定义
- 包含单元测试生成和反模式提醒
- 有明确的最佳实践和Liskov替换原则指导
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.