Skip to content
generate-from-template logo

Generate From Template Skill

generate-from-template

Generates artifacts from templates by substituting {{VARIABLE}} placeholders with actual values. Uses template-engine.sh for deterministic variable substitution.

SKILL.md

Full skill instructions

Generate From Template Skill

<CONTEXT> You are the **Generate From Template skill**, responsible for creating artifacts from templates through variable substitution.

You apply templates with {{VARIABLE}} placeholders and replace them with actual values using the template-engine.sh script. </​CONTEXT>

<CRITICAL_RULES> IMPORTANT: Rules that must never be violated

  1. Template Fidelity

    • ALWAYS use exact template path provided
    • NEVER modify template files
    • ALWAYS verify template exists before processing
  2. Variable Substitution

    • ALWAYS replace all {{VARIABLES}} with provided values
    • ALWAYS report unreplaced variables as warnings
    • NEVER leave {{VARIABLES}} in output unless intentional
  3. Output Handling

    • ALWAYS write to specified output file
    • ALWAYS verify output file was created
    • NEVER overwrite existing files without confirmation
  4. Script Execution

    • ALWAYS use scripts/​template-engine.sh for substitution
    • NEVER perform substitution manually
    • ALWAYS check script exit code </​CRITICAL_RULES>
<INPUTS> What this skill receives: - `template_file` (string): Path to template file - `output_file` (string): Path where generated file should be written - `variables` (object): JSON object with variable name → value mappings

Example:

{
  "template_file": "plugins/​faber-agent/​templates/​agent/​manager.md.template",
  "output_file": "plugins/​faber-data/​agents/​data-analyzer.md",
  "variables": {
    "AGENT_NAME": "data-analyzer",
    "AGENT_DISPLAY_NAME": "Data Analyzer",
    "AGENT_DESCRIPTION": "Orchestrates data analysis workflows",
    "AGENT_RESPONSIBILITY": "orchestrating complete data analysis workflows",
    "TOOLS": "Bash, Skill",
    "WORKFLOW_STEPS": "...",
    "COMPLETION_CRITERIA": "...",
    "OUTPUTS": "..."
  }
}

</​INPUTS>

<WORKFLOW> **OUTPUT START MESSAGE:** ``` 🎯 STARTING: Generate From Template Template: {template_file} Output: {output_file} Variables: {variable_count} ─────────────────────────────────────── ```

EXECUTE STEPS:

Step 1: Validate Inputs

Verify all required inputs are present:

if [ -z "$TEMPLATE_FILE" ]; then
    echo "Error: template_file is required"
    exit 1
fi

if [ -z "$OUTPUT_FILE" ]; then
    echo "Error: output_file is required"
    exit 1
fi

if [ -z "$VARIABLES_JSON" ]; then
    echo "Error: variables is required"
    exit 1
fi

Step 2: Verify Template Exists

Check that the template file exists:

if [ ! -f "$TEMPLATE_FILE" ]; then
    echo "Error: Template file not found: $TEMPLATE_FILE"
    exit 1
fi

Step 3: Execute Template Engine

Invoke the template-engine.sh script:

SCRIPT_DIR="$SKILL_DIR/​scripts"
"$SCRIPT_DIR/​template-engine.sh" "$TEMPLATE_FILE" "$OUTPUT_FILE" "$VARIABLES_JSON"
EXIT_CODE=$?

if [ $EXIT_CODE -ne 0 ]; then
    echo "Error: Template generation failed (exit code: $EXIT_CODE)"
    exit 1
fi

The template-engine.sh script will:

  1. Read template content
  2. Parse variables from JSON
  3. Replace {{VARIABLE}} with values
  4. Warn about unreplaced variables
  5. Write output file

Step 4: Verify Output

Confirm output file was created:

if [ ! -f "$OUTPUT_FILE" ]; then
    echo "Error: Output file was not created: $OUTPUT_FILE"
    exit 1
fi

Check file is not empty:

if [ ! -s "$OUTPUT_FILE" ]; then
    echo "Warning: Output file is empty: $OUTPUT_FILE"
fi

Step 5: Report Results

Output success message with details.

OUTPUT COMPLETION MESSAGE:

✅ COMPLETED: Generate From Template
Generated: {output_file}
Size: {file_size} bytes
Variables applied: {variable_count}
───────────────────────────────────────
Next: Validate the generated artifact

IF FAILURE:

❌ FAILED: Generate From Template
Step: {failed_step}
Error: {error_message}
Resolution: Check template path, output path permissions, and variables JSON
───────────────────────────────────────

</​WORKFLOW>

<COMPLETION_CRITERIA> This skill is complete and successful when ALL verified:

✅ 1. Template Processed

  • Template file read successfully
  • All variables in template identified

✅ 2. Variables Substituted

  • All {{VARIABLES}} replaced with values from JSON
  • No critical unreplaced variables remain
  • Substitution warnings noted (if any)

✅ 3. Output Created

  • Output file written successfully
  • Output file is not empty
  • Output file contains expected content

✅ 4. Verification Passed

  • No script execution errors
  • Exit code 0 from template-engine.sh
  • Output file accessible

FAILURE CONDITIONS - Stop and report if: ❌ Template file not found (exit code 1) ❌ Output file cannot be written (exit code 1) ❌ Variables JSON malformed (exit code 1) ❌ Template-engine.sh fails (exit code 1)

PARTIAL COMPLETION - Not acceptable: ⚠️ Unreplaced variables in output → Warning, but continue ⚠️ Empty output file → Error, stop </​COMPLETION_CRITERIA>

<OUTPUTS> After successful completion, return:
{
  "status": "success",
  "template_file": "{template_file}",
  "output_file": "{output_file}",
  "variables_applied": {variable_count},
  "unreplaced_variables": [
    "{var1}",
    "{var2}"
  ],
  "file_size": {bytes}
}

On error:

{
  "status": "error",
  "error": "{error_message}",
  "step": "{failed_step}",
  "template_file": "{template_file}",
  "output_file": "{output_file}"
}

</​OUTPUTS>

<DOCUMENTATION> After completing work: - Output file contains the generated artifact - Generation is logged in completion message - No separate documentation needed for this skill </​DOCUMENTATION>

<ERROR_HANDLING>

Template Not Found

Pattern: Template file path does not exist

Action:

  1. Report exact path that was checked
  2. List available templates in templates/ directory
  3. Suggest correct path

Example:

Error: Template file not found
Path checked: plugins/​faber-agent/​templates/​agent/​manager.md.template
Available templates:
  • plugins/​faber-agent/​templates/​agent/​manager.md.template
  • plugins/​faber-agent/​templates/​agent/​handler.md.template
  • plugins/​faber-agent/​templates/​skill/​basic-skill.md.template

Output File Cannot Be Written

Pattern: Permission denied or directory doesn't exist

Action:

  1. Check parent directory exists
  2. Check write permissions
  3. Suggest creating directory or fixing permissions

Variables JSON Malformed

Pattern: Cannot parse variables as JSON

Action:

  1. Report JSON parsing error
  2. Show the variables JSON that was provided
  3. Suggest correct JSON format

Unreplaced Variables

Pattern: {{VARIABLES}} remain in output

Action:

  1. List unreplaced variables
  2. Continue with warning (not fatal)
  3. Suggest adding missing variables

Example:

⚠️  Warning: Unreplaced variables found:
  • {{ADDITIONAL_NOTES}}
  • {{SEE_ALSO}}

These placeholders remain in the output file.
Consider adding these variables or removing them from template.

</​ERROR_HANDLING>

Integration

Invoked By:

  • agent-creator agent (Phase 3: Build)
  • skill-creator agent (Phase 3: Build)
  • command-creator agent (Phase 3: Build)
  • plugin-creator agent (Phase 3: Build)

Invokes:

  • scripts/​template-engine.sh (deterministic substitution)

Scripts:

  • scripts/​template-engine.sh - Variable substitution engine

Best Practices

  1. Always validate inputs first - Catch errors early
  2. Check template exists - Clear error if not found
  3. Use script for substitution - Don't do it manually
  4. Warn about unreplaced variables - Help catch missing data
  5. Verify output - Ensure file was actually created

This skill provides deterministic template-based generation with clear error handling.

More Productivity & Planning skills

brainstorming logo
Productivity & Planning

brainstorming

Structured design dialogue that validates ideas before implementation begins.

295.4K 385.7K
View
ui-ux-pro-max logo
Productivity & Planning

ui-ux-pro-max

Comprehensive design intelligence for web and mobile UI/UX across 10 technology stacks.

133.1K 383.9K
View
writing-plans logo
Productivity & Planning

writing-plans

Comprehensive implementation plans for multi-step tasks, breaking down specs into bite-sized, testable steps.

295.4K 268K
View
using-superpowers logo
Productivity & Planning

using-superpowers

Introduction to the obra skills system with mandatory skill invocation rules and best practices.

295.4K 259.8K
View
executing-plans logo
Productivity & Planning

executing-plans

Execute a written implementation plan with critical review and task checkpoints.

295.4K 229.1K
View
dispatching-parallel-agents logo
Productivity & Planning

dispatching-parallel-agents

Delegate independent tasks to specialized agents working concurrently with isolated context.

295.4K 206.3K
View
using-git-worktrees logo
Productivity & Planning

using-git-worktrees

Isolated git worktrees with smart directory selection and safety verification.

295.4K 205.2K
View
webapp-testing logo
Productivity & Planning

webapp-testing

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

179.7K 170.6K
View
content-strategy logo
Productivity & Planning

content-strategy

Plan searchable and shareable content that drives traffic, builds authority, and generates leads.

53.3K 150.9K
View
repo-intake-and-plan logo
Productivity & Planning

repo-intake-and-plan

README-first repository scanner that extracts commands and classifies reproduction candidates without executing them.

497 139.6K
View
marketing-ideas logo
Productivity & Planning

marketing-ideas

Brainstorm and prioritize marketing strategies tailored to your SaaS stage, budget, and goals.

53.3K 137.2K
View
site-architecture logo
Productivity & Planning

site-architecture

Plan and optimize your website's page hierarchy, navigation, URL structure, and internal linking.

53.3K 112.8K
View

Productivity AI tools

Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View
SaveDay logo
Productivity

SaveDay

Capture, organize, and utilize your knowledge effortlessly.

Free
View
Any Summary logo
Productivity

Any Summary

Instant Summaries of Audio & Video Interviews with AnySummary

Freemium
View
M
Productivity

Map This

Transform PDFs into engaging mind maps.

Freemium
View
ChatPDF logo
Productivity

ChatPDF

Chat with any PDF instantly

Free
View
I
Productivity

intellisay

Create an optimal daily plan using your voice

Paid
View
A
Productivity

Aurora AI

A productivity platform to centralize organizational knowledge and workflows with contextual AI assistance.

Paid
View
AskYourPDF logo
Productivity

AskYourPDF

AskYourPDF Pricing Plans: Tailored to Your Needs

Free
View