Custom Templates

Complete guide to creating, customizing, and managing YAML templates for automated documentation generation.

Overview

Custom templates enable you to create standardized documentation structures that can be reused across projects, teams, and organizations. This guide covers everything from basic template creation to advanced customization techniques.

Template Anatomy

Basic Template Structure

Every YAML template consists of three main sections:

---
# 1. METADATA SECTION
name: "Template Name"
description: "What this template creates"
version: "1.0.0"
category: "template-category"
---

# 2. USER CONTEXT SECTION (Optional)
user_context_required:
  variable_name: "Question to ask user?"

# 3. STRUCTURE SECTION
structure:
  - "# Heading with {{variable_name}}"
  - type: "info_panel"
    title: "Panel Title"
    content_instruction: "What Claude should generate"

Metadata Fields

Field
Required
Description
Example

name

Yes

Template display name

"API Documentation Template"

description

Yes

Brief description of purpose

"Complete REST API documentation"

version

Yes

Semantic version

"1.0.0"

category

Yes

Grouping category

"api-documentation"

sections

No

Content section tags

["auth", "endpoints", "examples"]

output_type

No

Expected output format

"confluence_page"

author

No

Template creator

"Team Name"

created

No

Creation date

"2024-01-15"

updated

No

Last update date

"2024-01-20"

User Context Variables

Define variables that users must provide when using the template:

Best Practices:

  • Use clear, specific questions

  • Provide examples in questions when helpful

  • Keep required context minimal

  • Group related variables logically

Structure Elements

Text Elements

Direct Markdown

Variable Substitution

Panel Elements

Info Panel

Warning Panel

Success Panel

Note Panel

Code Block Elements

Basic Code Block

Multi-language Code Block

Expandable Elements

Table Elements

Creating Your First Template

Step 1: Plan Your Template

Before writing YAML, plan your template:

  1. Identify the Documentation Type

    • API documentation

    • User guide

    • Troubleshooting guide

    • Installation instructions

    • Security documentation

  2. Define Required Information

    • What varies between uses?

    • What context is needed?

    • What stays consistent?

  3. Outline the Structure

    • What sections are needed?

    • What order makes sense?

    • What content types work best?

Step 2: Create the YAML File

Create a new file in templates/yaml/ directory:

Step 3: Write the Template

Start with a basic structure:

Step 4: Test Your Template

Advanced Template Features

Conditional Content

Create content that appears only under certain conditions:

Repeated Sections

Generate multiple similar sections based on user input:

Template Inheritance

Create base templates that can be extended:

Dynamic Content Generation

Templates can include instructions for generating content based on external data:

Template Categories and Organization

Standard Categories

Use these standard categories for consistency:

  • api-documentation: REST APIs, GraphQL APIs, SDK documentation

  • user-guides: End-user documentation, tutorials, how-to guides

  • technical-specs: Architecture documents, design specifications

  • installation: Setup guides, deployment instructions

  • troubleshooting: Problem-solving guides, FAQ documents

  • security: Security guides, best practices, compliance docs

  • reference: Code references, configuration options

Custom Categories

Create custom categories for your organization:

Template Naming Conventions

Use descriptive, consistent names:

Good:

  • rest-api-documentation-v2.yml

  • mobile-app-user-guide.yml

  • security-audit-template.yml

Avoid:

  • template1.yml

  • docs.yml

  • my-template.yml

Content Instruction Best Practices

Writing Effective Instructions

Good Instructions:

Poor Instructions:

Instruction Components

Include these elements in your instructions:

  1. What to Generate: Specific content type

  2. Context: Use template variables

  3. Format: Code examples, step-by-step, bullet points

  4. Audience: Who will read this content

  5. Purpose: Why this content matters

Example Patterns

Step-by-Step Instructions

Code Examples

Best Practices

Troubleshooting

Template Validation and Testing

YAML Syntax Validation

Always validate YAML syntax before using templates:

Template Structure Validation

Check for required fields and proper structure:

Testing Templates

Test templates with different user contexts:

Template Management

Version Control

Track template changes with semantic versioning:

Template Documentation

Document your templates with README files:

Template Sharing

Share templates across teams:

Integration with Development Workflows

CI/CD Integration

Automate documentation generation:

IDE Integration

Create snippets for common template patterns:

Troubleshooting Templates

Common Issues

YAML Parsing Errors

Solution: Validate YAML syntax, check indentation

Missing Context Variables

Solution: Ensure all {{variables}} are defined in user_context_required

Invalid Structure Types

Solution: Use supported structure types (info_panel, code_block, etc.)

Content Generation Failures

Solution: Make instructions more specific and actionable

Debug Mode

Enable debug output when testing templates:

Advanced Examples

Complete API Documentation Template

Next Steps

Last updated