Level 2 Skills: Template-Based Generation
Learn to build Level 2 AI skills that use templates and placeholders for structured, consistent output generation across documents, code, and content.
Level 2 Skills: Template-Based Generation
When you need consistent structure with variable content, Level 2 skills are your answer. These template-based skills combine fixed structure with dynamic elements, producing output that is both predictable in format and flexible in content.
Level 2 skills bridge the gap between simple prompt enhancement and complex tool-enabled capabilities. They use templates, placeholders, and structured generation to create documents, code, configurations, and content that follows defined patterns while adapting to specific inputs.
In this guide, we will explore how to design, build, and deploy Level 2 template-based skills for real-world applications.
Understanding Level 2 Skills
Level 2 skills occupy a specific place in the complexity hierarchy:
| Level | Complexity | Capabilities |
|---|---|---|
| 1 | Minimal | Prompt enhancement: tone, style, vocabulary |
| 2 | Low | Template-based generation with placeholders |
| 3 | Medium | Tool-enabled capabilities |
| 4 | High | Multi-agent coordination |
| 5 | Very High | Autonomous workflows |
Core Characteristics
Level 2 skills have defining traits:
Template Structure: Output follows defined patterns with fixed and variable sections.
Placeholder System: Dynamic content inserts into predefined locations.
Consistent Format: Same template produces consistently structured output.
Input Mapping: Input data maps to specific template locations.
Validation Ready: Structured output can be validated against schemas.
What Level 2 Skills Do
Template-based generation covers:
- Document Generation: Reports, proposals, specifications
- Code Generation: Boilerplate, configurations, tests
- Content Creation: Blog posts, emails, descriptions
- Data Formatting: JSON, YAML, XML from inputs
- Structured Responses: API responses, form outputs
What Level 2 Skills Cannot Do
These skills have limitations:
- Cannot access external files or APIs
- Cannot execute code to validate output
- Cannot make decisions based on tool results
- Cannot coordinate with other skills
- Cannot perform complex multi-step reasoning
For these capabilities, you need Level 3 and above.
Template Design Principles
Effective templates require careful design.
Template Anatomy
A template has three types of content:
## Template Components
### Fixed Content
Text that never changes:
- Headers and titles
- Standard disclaimers
- Structural elements
- Boilerplate sections
### Placeholder Content
Variables that get filled in:
- {variable_name}
- {{double_braces}}
- ${dollar_syntax}
- <<angle_brackets>>
### Conditional Content
Sections that appear based on conditions:
- If X, include section A
- If Y, include section B
- If neither, omit section
Placeholder Conventions
Choose a consistent placeholder syntax:
## Placeholder Syntax
### Simple Variables
{name} - Simple text replacement
{company_name} - Underscore separated
{projectTitle} - Camel case
### Typed Placeholders
{date:YYYY-MM-DD} - With format specification
{amount:currency} - With type hint
{list:items} - Collection type
### Nested Placeholders
{user.name} - Dot notation for objects
{project.settings.theme} - Deep nesting
### Default Values
{name|Anonymous} - Fallback if not provided
{count|0} - Default number
Template Sections
Organize templates into logical sections:
## Section Structure
### Required Sections
Always present in output:
- Header
- Core content
- Footer
### Optional Sections
Include based on conditions:
- If input has X → include section Y
- If level is advanced → include details
- If requested → include appendix
### Repeating Sections
Loop over collections:
- For each item → generate subsection
- For each file → generate entry
- For each error → generate message
Building Level 2 Skills
Let us create template-based skills step by step.
Example: Technical Specification Generator
---
name: tech-spec-generator
description: Generates technical specifications from requirements
version: 1.0.0
---
# Technical Specification Generator
Generate consistent technical specifications from project requirements.
## Input Schema
```json
{
"projectName": "string",
"version": "string",
"author": "string",
"date": "string (YYYY-MM-DD)",
"summary": "string",
"requirements": [
{
"id": "string",
"title": "string",
"description": "string",
"priority": "high|medium|low",
"acceptance": ["string"]
}
],
"technical": {
"language": "string",
"framework": "string",
"database": "string",
"deployment": "string"
},
"timeline": {
"phases": [
{
"name": "string",
"duration": "string",
"deliverables": ["string"]
}
]
}
}
Template
# Technical Specification: {projectName}
**Version:** {version}
**Author:** {author}
**Date:** {date}
---
## Executive Summary
{summary}
---
## Requirements
{FOR EACH requirement IN requirements}
### {requirement.id}: {requirement.title}
**Priority:** {requirement.priority}
{requirement.description}
**Acceptance Criteria:**
{FOR EACH criterion IN requirement.acceptance}
- [ ] {criterion}
{END FOR}
{END FOR}
---
## Technical Architecture
### Technology Stack
| Component | Technology |
|-----------|------------|
| Language | {technical.language} |
| Framework | {technical.framework} |
| Database | {technical.database} |
| Deployment | {technical.deployment} |
### System Design
[Based on requirements, generate appropriate system design section]
---
## Project Timeline
{FOR EACH phase IN timeline.phases}
### Phase: {phase.name}
**Duration:** {phase.duration}
**Deliverables:**
{FOR EACH deliverable IN phase.deliverables}
- {deliverable}
{END FOR}
{END FOR}
---
## Appendices
### Glossary
[Generate relevant technical terms based on content]
### References
[Include relevant references based on technology stack]
---
*Generated on {date} using Tech Spec Generator v{version}*
Generation Rules
Placeholder Filling
- Map input fields to placeholders
- Format dates as specified
- Handle missing optional fields gracefully
- Validate required fields are present
Conditional Sections
- If requirements.length > 10: Add "Requirements Summary" section
- If technical.database exists: Add "Database Schema" section
- If timeline.phases.length > 3: Add "Milestone Overview"
Loop Processing
- For each item in arrays, generate subsection
- Maintain consistent formatting
- Handle empty arrays gracefully
Content Generation
Where template says [Generate X]:
- Use context to create appropriate content
- Match tone and style of surrounding content
- Keep consistent with other sections
### Example: Code Template Generator
```markdown
---
name: api-endpoint-generator
description: Generates API endpoint code from specifications
version: 1.0.0
---
# API Endpoint Generator
Generate consistent API endpoint implementations from specifications.
## Input Schema
```json
{
"endpoint": {
"method": "GET|POST|PUT|DELETE|PATCH",
"path": "/path/to/resource",
"description": "What this endpoint does"
},
"parameters": [
{
"name": "param_name",
"type": "string|number|boolean|object",
"location": "path|query|body",
"required": true,
"description": "What this parameter does"
}
],
"response": {
"success": {
"status": 200,
"schema": {}
},
"errors": [
{
"status": 400,
"message": "Error message"
}
]
},
"options": {
"language": "typescript|python|go",
"framework": "express|fastapi|gin",
"includeTests": true
}
}
TypeScript/Express Template
/**
* {endpoint.description}
* {endpoint.method} {endpoint.path}
*/
router.{endpoint.method.toLowerCase()}('{endpoint.path}', async (req: Request, res: Response) => {
try {
// Extract parameters
{FOR EACH param IN parameters WHERE param.location == 'path'}
const {param.name} = req.params.{param.name};
{END FOR}
{FOR EACH param IN parameters WHERE param.location == 'query'}
const {param.name} = req.query.{param.name} as {param.type};
{END FOR}
{FOR EACH param IN parameters WHERE param.location == 'body'}
const {param.name} = req.body.{param.name};
{END FOR}
// Validate required parameters
{FOR EACH param IN parameters WHERE param.required}
if (!{param.name}) {
return res.status(400).json({ error: '{param.name} is required' });
}
{END FOR}
// TODO: Implement business logic
const result = await handleRequest({
{FOR EACH param IN parameters}
{param.name},
{END FOR}
});
return res.status({response.success.status}).json(result);
} catch (error) {
console.error('Error in {endpoint.path}:', error);
return res.status(500).json({ error: 'Internal server error' });
}
});
{IF options.includeTests}
Test Template
describe('{endpoint.method} {endpoint.path}', () => {
it('should return {response.success.status} on success', async () => {
const response = await request(app)
.{endpoint.method.toLowerCase()}('{endpoint.path}')
{FOR EACH param IN parameters WHERE param.location == 'query'}
.query({ {param.name}: 'test_value' })
{END FOR}
{FOR EACH param IN parameters WHERE param.location == 'body'}
.send({ {param.name}: 'test_value' })
{END FOR}
.expect({response.success.status});
expect(response.body).toBeDefined();
});
{FOR EACH error IN response.errors}
it('should return {error.status} when {error.message}', async () => {
const response = await request(app)
.{endpoint.method.toLowerCase()}('{endpoint.path}')
.expect({error.status});
expect(response.body.error).toBeDefined();
});
{END FOR}
});
{END IF}
## Template Types and Patterns
Different templates suit different purposes.
### Document Templates
For generating documents like reports and proposals:
```markdown
## Document Template Pattern
### Structure
1. **Front Matter**: Title, metadata, summary
2. **Introduction**: Context and purpose
3. **Body Sections**: Main content (repeating pattern)
4. **Conclusion**: Summary and next steps
5. **Appendices**: Supporting material
### Characteristics
- Prose-heavy content
- Hierarchical headings
- Formal structure
- Professional tone
Code Templates
For generating source code:
## Code Template Pattern
### Structure
1. **Header**: Comments, imports, metadata
2. **Configuration**: Constants, types, configs
3. **Implementation**: Main code (repeating for each entity)
4. **Exports**: Module exports
5. **Tests**: Test cases if requested
### Characteristics
- Syntax-aware generation
- Indentation matters
- Language-specific patterns
- Type annotations
Data Templates
For generating structured data:
## Data Template Pattern
### Structure
1. **Schema Definition**: Field names and types
2. **Data Mapping**: Input to output fields
3. **Transformation Rules**: How to convert values
4. **Validation**: Schema compliance
### Characteristics
- Strict format requirements
- Type coercion
- Nested structures
- Array handling
Content Templates
For generating marketing or user-facing content:
## Content Template Pattern
### Structure
1. **Hook**: Attention-grabbing opening
2. **Body**: Main message with variations
3. **Call to Action**: What reader should do
4. **Metadata**: Tags, categories, SEO
### Characteristics
- Persuasive tone
- Variable length
- Multiple versions
- A/B testing support
Advanced Template Techniques
Conditional Logic
Handle branching in templates:
## Conditional Patterns
### Simple If
{IF condition}
Content to include when true
{END IF}
### If-Else
{IF condition}
Content when true
{ELSE}
Content when false
{END IF}
### Multi-Condition
{IF level == 'beginner'}
Beginner content
{ELSE IF level == 'intermediate'}
Intermediate content
{ELSE}
Advanced content
{END IF}
### Existence Check
{IF feature EXISTS}
Feature documentation: {feature.description}
{END IF}
Iteration Patterns
Handle collections:
## Iteration Patterns
### Simple Loop
{FOR EACH item IN collection}
- {item}
{END FOR}
### Indexed Loop
{FOR EACH item, index IN collection}
{index + 1}. {item}
{END FOR}
### Filtered Loop
{FOR EACH item IN collection WHERE item.active}
- {item.name}
{END FOR}
### Nested Loops
{FOR EACH category IN categories}
## {category.name}
{FOR EACH item IN category.items}
- {item}
{END FOR}
{END FOR}
### Empty Handling
{IF collection.length > 0}
{FOR EACH item IN collection}
- {item}
{END FOR}
{ELSE}
No items available.
{END IF}
Transformation Functions
Transform values during insertion:
## Value Transformations
### Text Transforms
{name|uppercase} - Convert to UPPERCASE
{name|lowercase} - Convert to lowercase
{name|capitalize} - Capitalize First Letters
{name|slug} - convert-to-slug-format
### Number Transforms
{amount|currency} - $1,234.56
{percent|percentage} - 45.67%
{bytes|filesize} - 1.2 MB
### Date Transforms
{date|short} - Jan 15, 2025
{date|long} - January 15, 2025
{date|iso} - 2025-01-15
{date|relative} - 2 days ago
### Collection Transforms
{items|count} - Number of items
{items|first} - First item
{items|last} - Last item
{items|join:', '} - Comma-separated list
Computed Fields
Generate values from other values:
## Computed Fields
### Derivations
{fullName = firstName + ' ' + lastName}
{totalPrice = quantity * unitPrice}
{averageScore = scores|average}
### Conditional Computation
{status = score >= 70 ? 'Pass' : 'Fail'}
{priority = issues.critical > 0 ? 'High' : 'Normal'}
### Aggregations
{totalItems = categories|map:items|flatten|count}
{uniqueTags = items|map:tags|flatten|unique}
Validation and Error Handling
Templates need robust validation.
Input Validation
## Input Validation Rules
### Required Fields
These fields must be present:
- projectName: non-empty string
- author: non-empty string
- requirements: non-empty array
### Type Validation
Ensure correct types:
- version: string matching semver pattern
- date: string matching YYYY-MM-DD
- priority: one of ['high', 'medium', 'low']
### Relationship Validation
Cross-field rules:
- If hasDatabase, technical.database required
- If includeTests, testFramework must be specified
### Error Messages
Return clear errors:
- "projectName is required"
- "date must be in YYYY-MM-DD format"
- "testFramework required when includeTests is true"
Output Validation
## Output Validation
### Structure Checks
- All required sections present
- Placeholders fully resolved
- No orphaned loop markers
### Content Checks
- No placeholder syntax in output
- Lists have content
- Code blocks properly closed
### Format Checks
- Valid markdown (if markdown output)
- Valid code syntax (if code output)
- Valid JSON/YAML (if data output)
Testing Level 2 Skills
Template skills need thorough testing.
Test Categories
## Test Suite
### Template Rendering Tests
- All placeholders resolve correctly
- Loops generate expected iterations
- Conditionals branch correctly
### Edge Case Tests
- Empty collections
- Missing optional fields
- Maximum size inputs
- Minimum size inputs
### Format Tests
- Output is valid markdown/code/data
- Structure matches schema
- Syntax is correct
### Consistency Tests
- Same input produces same output
- Similar inputs produce similar outputs
Example Tests
## Test: Tech Spec Generator
### Test: Basic Generation
Input: Minimal valid input
Expected: All required sections present, valid markdown
### Test: Complex Requirements
Input: 10 requirements with all fields
Expected: All requirements rendered, proper numbering
### Test: Empty Timeline
Input: timeline.phases = []
Expected: Timeline section omitted or shows placeholder
### Test: All Options Enabled
Input: All optional features enabled
Expected: All optional sections present
Conclusion
Level 2 template-based skills bring structure to AI generation. By combining fixed templates with dynamic content, they produce consistent, predictable output while remaining flexible enough to handle varied inputs.
Key principles for effective Level 2 skills:
- Clear template structure: Define fixed vs. variable sections
- Consistent placeholder syntax: Use one style throughout
- Robust conditional logic: Handle all branches
- Clean iteration patterns: Process collections reliably
- Strong validation: Catch problems early
Start with simple templates for documents you create often. As you gain experience, build more sophisticated templates with complex conditionals, nested loops, and computed fields.
Level 2 skills are your foundation for structured generation—master them and you will be ready for tool-enabled Level 3 skills that can validate, transform, and enhance template output using external capabilities.