Skip to main content
template-renderer Render templates by replacing {{TOKEN}} placeholders with actual values, supporting all three templates (specification, plan, tasks) with schema validation and security sanitization
跳到安装 Skills Marketplace 发现并探索由社区构建的 Agent Skills
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/oimiragieo/agent-studio --skill template-renderer命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
下载 Zip 下载中... name template-renderer description Render templates by replacing {{TOKEN}} placeholders with actual values, supporting all three templates (specification, plan, tasks) with schema validation and security sanitization version 1.0.0 model sonnet invoked_by both user_invocable true tools ["Read","Write","mcp__filesystem__read_text_file","mcp__filesystem__write_file"] args <template-name> <output-path> [--tokens <json-file>] best_practices ["Sanitize all token values to prevent injection attacks","Validate template paths within PROJECT_ROOT only","Use token whitelist (only allow predefined tokens)","Validate output against schema for specification templates","Preserve Markdown formatting during token replacement","Error on missing required tokens","Warn on unused tokens provided"] error_handling strict streaming not_supported verified false lastVerifiedAt "2026-02-19T05:29:09.098Z" source builtin trust_score 100 provenance_sha 1218b5a52d8f08cb
Template Renderer
Template Renderer Skill - Renders templates by replacing {{TOKEN}} placeholders with actual values. Supports specification-template.md, plan-template.md, and tasks-template.md with schema validation and security controls (SEC-SPEC-003, SEC-SPEC-004).
- Render all three template types (specification, plan, tasks)
- Token replacement with {{TOKEN}} → value substitution
- Security: Token value sanitization (prevent injection)
- Security: Token whitelist enforcement (only predefined tokens allowed)
- Security: Template path validation (PROJECT_ROOT only)
- Schema validation for specification templates
- Error handling for missing required tokens
- Warning system for unused tokens
- Preserve Markdown formatting and structure
Step 1: Validate Inputs (SECURITY - MANDATORY)
Template Path Validation (SEC-SPEC-002):
Verify template file exists within PROJECT_ROOT
Reject any path traversal attempts (../)
Only allow templates from .claude/templates/
Token Whitelist Validation (SEC-SPEC-003):
const SPEC_TOKENS = [
'FEATURE_NAME' ,
'VERSION' ,
'AUTHOR' ,
'DATE' ,
'STATUS' ,
'ACCEPTANCE_CRITERIA_1' ,
'ACCEPTANCE_CRITERIA_2' ,
'ACCEPTANCE_CRITERIA_3' ,
'TERM_1' ,
'TERM_2' ,
'TERM_3' ,
'HTTP_METHOD' ,
'ENDPOINT_PATH' ,
'PROJECT_NAME' ,
];
const PLAN_TOKENS = [
'PLAN_TITLE' ,
'DATE' ,
'FRAMEWORK_VERSION' ,
'STATUS' ,
'EXECUTIVE_SUMMARY' ,
'TOTAL_TASKS' ,
'FEATURES_COUNT' ,
'ESTIMATED_TIME' ,
'STRATEGY' ,
'KEY_DELIVERABLES_LIST' ,
,
,
,
,
,
,
];
= [
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
];
**Example 1: Render Specification Template**
'PHASE_N_NAME'
'PHASE_N_PURPOSE'
'PHASE_N_DURATION'
'DEPENDENCIES'
'PARALLEL_OK'
'VERIFICATION_COMMANDS'
const
TASKS_TOKENS
'FEATURE_NAME'
'VERSION'
'AUTHOR'
'DATE'
'STATUS'
'PRIORITY'
'ESTIMATED_EFFORT'
'RELATED_SPECS'
'DEPENDENCIES'
'FEATURE_DISPLAY_NAME'
'FEATURE_DESCRIPTION'
'BUSINESS_VALUE'
'USER_IMPACT'
'EPIC_NAME'
'EPIC_GOAL'
'SUCCESS_CRITERIA'
Token Value Sanitization (SEC-SPEC-004):
function sanitizeTokenValue (value ) {
return String (value)
.replace (/[<>]/g , '' )
.replace (/\$\{/g , '' )
.replace (/\{\{/g , '' )
.trim ();
}
Step 2: Read Template Read the template file using Read or mcpfilesystem read_text_file:
.claude/templates/specification-template.md (46 tokens)
.claude/templates/plan-template.md (30+ tokens)
.claude/templates/tasks-template.md (20+ tokens)
Step 3: Token Replacement Replace all {{TOKEN}} placeholders with sanitized values:
function renderTemplate (templateContent, tokenMap ) {
let rendered = templateContent;
for (const [token, value] of Object .entries (tokenMap)) {
if (!isAllowedToken (token, templateType)) {
throw new Error (`Token not in whitelist: ${token} ` );
}
const sanitizedValue = sanitizeTokenValue (value);
const regex = new RegExp (`\\{\\{${token} \\}\\}` , 'g' );
rendered = rendered.replace (regex, sanitizedValue);
}
const missingTokens = rendered.match (/\{\{[A-Z_0-9]+\}\}/g );
if (missingTokens) {
throw new Error (`Missing required tokens: ${missingTokens.join(', ' )} ` );
}
return rendered;
}
Step 4: Schema Validation (Specification Templates Only) For specification templates, validate the rendered output against JSON Schema:
const yamlMatch = rendered.match (/^---\n([\s\S]*?)\n---/ );
if (!yamlMatch) {
throw new Error ('No YAML frontmatter found' );
}
const yaml = require ('js-yaml' );
const frontmatter = yaml.load (yamlMatch[1 ]);
const schema = JSON .parse (
fs.readFileSync ('.claude/schemas/specification-template.schema.json' , 'utf8' )
);
const Ajv = require ('ajv' );
const ajv = new Ajv ();
const validate = ajv.compile (schema);
if (!validate (frontmatter)) {
throw new Error (`Schema validation failed: ${JSON .stringify(validate.errors)} ` );
}
Step 5: Write Output Write the rendered template to the output path using Write or mcpfilesystem write_file:
Verify output path is within PROJECT_ROOT
Create parent directories if needed
Write file with UTF-8 encoding
Step 6: Verification Run post-rendering checks:
grep "{{" <output-file> && echo "ERROR: Unresolved tokens found!" || echo "✓ All tokens resolved"
head -50 <output-file> | grep -E "^---$" | wc -l
Always validate template paths : Use PROJECT_ROOT validation before reading
Sanitize all token values : Prevent injection attacks (SEC-SPEC-004)
Enforce token whitelist : Only allow predefined tokens (SEC-SPEC-003)
Error on missing tokens : Don't silently ignore missing required tokens
Warn on unused tokens : Help users catch typos in token names
Preserve Markdown formatting : Don't alter indentation, bullets, code blocks
Validate schema for specs : Run JSON Schema validation for specification templates
Log all operations : Record template, tokens used, output path to memory
ERROR: Missing required tokens in template:
- {{FEATURE_NAME}}
- {{ACCEPTANCE_CRITERIA_1}}
Provide these tokens in the token map.
Invalid Token (Not in Whitelist) :
ERROR: Token not in whitelist: INVALID_TOKEN
Allowed tokens for specification-template: FEATURE_NAME, VERSION, AUTHOR, DATE, ...
ERROR: Template path outside PROJECT_ROOT
Path: ../../etc/passwd
Only templates from .claude/templates/ are allowed.
Schema Validation Failure (Specification Templates):
ERROR: Schema validation failed:
- /version: must match pattern "^\d+\.\d+\.\d+$"
- /acceptance_criteria: must have at least 1 item
WARNING: Unused tokens provided:
- EXTRA_TOKEN_1
- EXTRA_TOKEN_2
These tokens are not in the template. Check for typos.
Skill ({
skill : 'template-renderer' ,
args : {
templateName : 'specification-template' ,
outputPath : '.claude/context/artifacts/specifications/my-feature-spec.md' ,
tokens : {
FEATURE_NAME : 'User Authentication' ,
VERSION : '1.0.0' ,
AUTHOR : 'Claude' ,
DATE : '2026-01-28' ,
STATUS : 'draft' ,
ACCEPTANCE_CRITERIA_1 : 'User can log in with email and password' ,
ACCEPTANCE_CRITERIA_2 : 'Password meets complexity requirements' ,
ACCEPTANCE_CRITERIA_3 : 'Failed login attempts are logged' ,
},
},
});
Example 2: Render Plan Template
Skill ({
skill : 'template-renderer' ,
args : {
templateName : 'plan-template' ,
outputPath : '.claude/context/plans/my-feature-plan.md' ,
tokens : {
PLAN_TITLE : 'User Authentication Implementation Plan' ,
DATE : '2026-01-28' ,
FRAMEWORK_VERSION : 'Agent-Studio v3.1.0' ,
STATUS : 'Phase 0 - Research' ,
EXECUTIVE_SUMMARY : 'Implementation plan for JWT-based authentication...' ,
TOTAL_TASKS : '14 atomic tasks' ,
ESTIMATED_TIME : '2-3 weeks' ,
STRATEGY : 'Foundation-first (schema) → Core features' ,
},
},
});
Example 3: Render Tasks Template
Skill ({
skill : 'template-renderer' ,
args : {
templateName : 'tasks-template' ,
outputPath : '.claude/context/artifacts/tasks/auth-tasks.md' ,
tokens : {
FEATURE_NAME : 'user-authentication' ,
VERSION : '1.0.0' ,
AUTHOR : 'Engineering Team' ,
DATE : '2026-01-28' ,
FEATURE_DISPLAY_NAME : 'User Authentication' ,
FEATURE_DESCRIPTION : 'JWT-based authentication system' ,
BUSINESS_VALUE : 'Enables user account management' ,
USER_IMPACT : 'Users can securely access personalized features' ,
},
},
});
node .claude/skills/template-renderer/scripts/main.cjs \
--template specification-template \
--output ./my-spec.md \
--tokens '{"FEATURE_NAME":"My Feature","VERSION":"1.0.0","AUTHOR":"Claude","DATE":"2026-01-28"}'
node .claude/skills/template-renderer/scripts/main.cjs \
--template plan-template \
--output ./my-plan.md \
--tokens-file ./tokens.json
Example 5: Integration with spec-gathering
const tokens = {
FEATURE_NAME : gatheredRequirements.featureName ,
VERSION : '1.0.0' ,
AUTHOR : 'Claude' ,
DATE : new Date ().toISOString ().split ('T' )[0 ],
ACCEPTANCE_CRITERIA_1 : gatheredRequirements.criteria [0 ],
ACCEPTANCE_CRITERIA_2 : gatheredRequirements.criteria [1 ],
ACCEPTANCE_CRITERIA_3 : gatheredRequirements.criteria [2 ],
};
Skill ({
skill : 'template-renderer' ,
args : {
templateName : 'specification-template' ,
outputPath : `.claude/context/artifacts/specifications/${featureName} -spec.md` ,
tokens : tokens,
},
});
Memory Protocol (MANDATORY) cat .claude/context/memory/learnings.md
New pattern -> .claude/context/memory/learnings.md
Issue found -> .claude/context/memory/issues.md
Decision made -> .claude/context/memory/decisions.md
ASSUME INTERRUPTION: Your context may reset. If it's not in memory, it didn't happen.