AgentSkillsCN

Template Generation

代码与文档模板生成技能

SKILL.md
--- frontmatter
description: Code and document template generation skill

Template Generation

Code and document template generation skill

Template Generation Skill

Generates code and document templates for target projects.

Template Generation Skill

Generates code and document templates for target projects.

Process

Step 1: Determine Template Categories

Based on stack, identify template categories:

StackCategories
Pythonservice-class, repository, model, schema, test-class
TypeScriptcomponent, hook, service, test
Javacontroller, service, repository, entity, dto, test
ABAPglobal-class, service-class, test-class, enhancement

Step 2: Generate Code Templates

For each category:

  1. Create template file with variable placeholders
  2. Apply stack naming conventions
  3. Include proper imports/dependencies
  4. Add documentation comments

Template structure:

code
templates/{language}/{category}/{template-name}.{ext}

Step 3: Generate Document Templates

Create standard document templates:

TemplatePurpose
implementation_plan.mdImplementation planning
technical_spec.mdTechnical specification
test_plan.mdTest planning

Step 4: Variable Placeholders

Use consistent variable placeholders:

VariableDescription
{CLASS_NAME}Class name
{METHOD_NAME}Method name
{FILE_NAME}File name
{DESCRIPTION}Description text
{TICKET_ID}Ticket identifier
code
templates/{language}/{category}/{template-name}.{ext}

Output

Templates in project structure:

code
{TARGET}/
├── templates/
│   ├── {language}/
│   │   ├── service-class/
│   │   ├── test-class/
│   │   └── ...
│   └── docs/
│       ├── implementation_plan.md
│       └── technical_spec.md
code
{TARGET}/
├── templates/
│   ├── {language}/
│   │   ├── service-class/
│   │   ├── test-class/
│   │   └── ...
│   └── docs/
│       ├── implementation_plan.md
│       └── technical_spec.md

Best Practices

  • Follow stack-specific conventions: Research and apply naming conventions, file structure, and code style patterns specific to the target technology stack
  • Use consistent placeholder naming: Establish a clear convention for template variables (e.g., {CLASS_NAME}, {METHOD_NAME}) and document all placeholders
  • Include helpful comments in templates: Add comments explaining template structure, required variables, and usage examples to guide future users
  • Validate templates with real examples: Generate sample outputs from templates using realistic values to ensure they produce correct, runnable code
  • Organize templates by category: Group templates logically (by language, by pattern type, by use case) to make them easy to discover and maintain
  • Version templates when patterns change: Update template version numbers and changelogs when modifying templates to track evolution and breaking changes

Fallback Procedures

  • If template category unknown: Create minimal generic template
  • If style guide unavailable: Use default conventions

References

  • knowledge/stack-capabilities.json
  • patterns/templates/template-pattern.json

Prerequisites

[!IMPORTANT] Requirements:

  • Knowledge: stack-capabilities.json, best-practices.json