Generates artifacts from templates by substituting {{VARIABLE}} placeholders with actual values. Uses template-engine.sh for deterministic variable substitution.
Generates artifacts from templates by replacing {{VARIABLE}} placeholders with provided values. Use this when creating files from templates with dynamic content substitution.
/plugin marketplace add fractary/claude-plugins/plugin install fractary-faber-agent@fractaryThis skill inherits all available tools. When active, it can use any tool Claude has access to.
scripts/template-engine.shYou 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
Template Fidelity
Variable Substitution
Output Handling
Script Execution
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:
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
Check that the template file exists:
if [ ! -f "$TEMPLATE_FILE" ]; then
echo "Error: Template file not found: $TEMPLATE_FILE"
exit 1
fi
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:
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
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
ā 2. Variables Substituted
ā 3. Output Created
ā 4. Verification Passed
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>
Pattern: Template file path does not exist
Action:
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
Pattern: Permission denied or directory doesn't exist
Action:
Pattern: Cannot parse variables as JSON
Action:
Pattern: {{VARIABLES}} remain in output
Action:
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>
Invoked By:
Invokes:
Scripts:
scripts/template-engine.sh - Variable substitution engineThis skill provides deterministic template-based generation with clear error handling.