template-creator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMode: Cognitive/Prompt-Driven -- No standalone utility script; use via agent context.
模式:认知/提示驱动 -- 无独立实用脚本;需通过Agent上下文调用。
Template Creator Skill
Template Creator Skill
Creates, validates, and registers templates for the multi-agent orchestration framework.
+==============================================================+
| MANDATORY: Research-Synthesis MUST be invoked BEFORE |
| this skill. Invoke: Skill({ skill: "research-synthesis" }) |
| FAILURE TO RESEARCH = UNINFORMED TEMPLATE = REJECTED |
+==============================================================+
| |
| DO NOT WRITE TEMPLATE FILES DIRECTLY! |
| |
| This includes: |
| - Copying archived templates |
| - Restoring from _archive/ backup |
| - "Quick" manual creation |
| |
| WHY: Direct writes bypass MANDATORY post-creation steps: |
| 1. Template catalog update (template NOT discoverable) |
| 2. README.md update (template INVISIBLE to consumers) |
| 3. Consuming skill update (template NEVER used) |
| 4. CLAUDE.md update (if user-invocable) |
| |
| RESULT: Template EXISTS in filesystem but is NEVER USED. |
| |
| ENFORCEMENT: unified-creator-guard.cjs blocks direct |
| template writes. Override: CREATOR_GUARD=off (DANGEROUS) |
| |
| ALWAYS invoke this skill properly: |
| Skill({ skill: "template-creator" }) |
| |
+==============================================================+为多代理编排框架创建、验证并注册模板。
+==============================================================+
| 强制要求:必须先调用Research-Synthesis |
| 调用方式:Skill({ skill: "research-synthesis" }) |
| 未执行研究将导致模板信息不足,直接被驳回 |
+==============================================================+
| |
| 禁止直接编写模板文件! |
| |
| 包括以下行为: |
| - 复制已归档的模板 |
| - 从_archive/备份中恢复模板 |
| - 「快速」手动创建模板 |
| |
| 原因:直接编写会跳过强制的创建后步骤: |
| 1. 模板目录更新(模板将无法被发现) |
| 2. README.md更新(模板对使用者不可见) |
| 3. 消费型Skill更新(模板永远不会被使用) |
| 4. CLAUDE.md更新(若模板支持用户调用) |
| |
| 后果:模板存在于文件系统中,但永远不会被使用。 |
| |
| 强制管控:unified-creator-guard.cjs会拦截直接的模板写入操作 |
| 临时关闭方式:CREATOR_GUARD=off(危险操作) |
| |
| 请始终正确调用本Skill: |
| Skill({ skill: "template-creator" }) |
| |
+==============================================================+ROUTER UPDATE REQUIRED (CRITICAL - DO NOT SKIP)
必须更新路由(关键步骤 - 请勿跳过)
After creating ANY template, you MUST update:
- - Add template entry
.claude/templates/README.md - - Add catalog entry
.claude/context/artifacts/catalogs/template-catalog.md - CLAUDE.md Section 2 or 8.5 if template is framework-significant or user-invocable
- Consuming creator skill if template standardizes an artifact type
- - Record creation
.claude/context/memory/learnings.md
Verification:
bash
grep "<template-name>" .claude/templates/README.md || echo "ERROR: README NOT UPDATED!"
grep "<template-name>" .claude/context/artifacts/catalogs/template-catalog.md || echo "ERROR: CATALOG NOT UPDATED!"WHY: Templates not in the catalog are invisible to other creators and will never be used.
创建任何模板后,必须更新以下内容:
- - 添加模板条目
.claude/templates/README.md - - 添加目录条目
.claude/context/artifacts/catalogs/template-catalog.md - 若模板为框架核心或支持用户调用,更新CLAUDE.md的第2节或第8.5节
- 若模板标准化了某类工件,更新对应的消费型Skill
- - 记录创建信息
.claude/context/memory/learnings.md
验证方式:
bash
grep "<template-name>" .claude/templates/README.md || echo "ERROR: README未更新!"
grep "<template-name>" .claude/context/artifacts/catalogs/template-catalog.md || echo "ERROR: 目录未更新!"原因: 未录入目录的模板对其他创建者不可见,永远不会被使用。
Overview
概述
Templates ensure consistency across the multi-agent framework. This skill creates templates for:
- Agent definitions - Standardized agent structures
- Skill definitions - Reusable capability patterns
- Workflow definitions - Multi-agent orchestration patterns
- Spawn prompts - Agent spawn prompt templates consumed by
spawn-template-resolver.cjs - Reports - Report document templates
- Code style guides - Language-specific coding standards
- General documents - ADRs, specs, checklists, and other framework documents
Core principle: Templates are the DNA of the system. Consistent templates produce consistent, predictable agents and skills.
模板确保多代理框架的一致性。本Skill可创建以下类型的模板:
- Agent定义 - 标准化的Agent结构
- Skill定义 - 可复用的能力模式
- 工作流定义 - 多代理编排模式
- Spawn提示 - 被消费的Agent启动提示模板
spawn-template-resolver.cjs - 报告 - 报告文档模板
- 代码风格指南 - 特定语言的编码标准
- 通用文档 - ADR、规格说明、检查清单及其他框架文档
核心原则: 模板是系统的DNA。一致的模板能生成一致、可预测的Agent和Skill。
When to Use
使用场景
Always:
- Creating a new type of artifact that will be replicated
- Standardizing an existing pattern across the codebase
- Adding a new template category
- Improving existing templates with better patterns
Exceptions:
- One-off files that will never be replicated
- Temporary/throwaway code
必须使用本Skill的场景:
- 创建会被复用的新型工件
- 标准化代码库中已有的模式
- 添加新的模板类别
- 用更优模式改进现有模板
例外场景:
- 不会被复用的一次性文件
- 临时/可丢弃的代码
Template Types
模板类型
| Type | Location | Count | Purpose | Key Consumers |
|---|---|---|---|---|
| Spawn | | 4 | Agent spawn prompt templates | router, spawn-prompt-assembler |
| Agent | | 2 | Agent definition boilerplate | agent-creator |
| Skill | | 1 | Skill definition boilerplate | skill-creator |
| Workflow | | 1 | Workflow definition boilerplate | workflow-creator |
| Report | | 5 | Report document templates | qa, developer, researcher |
| Code Style | | 3 | Language style guides | developer, code-reviewer |
| Document | | 8+ | General document templates (ADR, spec) | planner, architect, qa |
Cross-Reference: See for the complete inventory (28 active templates). For spawn template resolution logic, see .
.claude/context/artifacts/catalogs/template-catalog.md.claude/lib/spawn/spawn-template-resolver.cjs| 类型 | 存储位置 | 数量 | 用途 | 主要消费者 |
|---|---|---|---|---|
| Spawn | | 4 | Agent启动提示模板 | router, spawn-prompt-assembler |
| Agent | | 2 | Agent定义模板框架 | agent-creator |
| Skill | | 1 | Skill定义模板框架 | skill-creator |
| Workflow | | 1 | 工作流定义模板框架 | workflow-creator |
| Report | | 5 | 报告文档模板 | qa, developer, researcher |
| Code Style | | 3 | 语言风格指南 | developer, code-reviewer |
| Document | | 8+ | 通用文档模板(ADR、规格说明) | planner, architect, qa |
交叉参考: 完整模板清单(28个活跃模板)请查看。Spawn模板解析逻辑请查看。
.claude/context/artifacts/catalogs/template-catalog.md.claude/lib/spawn/spawn-template-resolver.cjsTemplate Security Compliance
模板安全合规
Critical Security Requirements:
- No Secrets (SEC-TC-007): Templates MUST NOT include secrets, credentials, tokens, or API keys
- Path Safety: All template references MUST use relative paths (), never absolute paths
.claude/templates/... - No Sensitive Metadata: Templates MUST NOT expose internal system paths or user directories
- No Windows Reserved Names: Template names MUST NOT use ,
nul,con,prn,aux-com1,com9-lpt1lpt9 - Retention Mandates (SEC-TMPL-006): Templates flagged by SEC-TMPL-006 MUST remain at designated locations
- Spawn Template Placeholder Safety (SEC-TC-001): Spawn templates with tokens in
{{PLACEHOLDER}}fields MUST referenceprompt:fromsanitizeSubstitutionValue()for value sanitization. Unsanitized placeholders in spawn prompts create a prompt injection surface. Do NOT placeprompt-factory.cjstokens where user-provided input is directly substituted without sanitization.{{PLACEHOLDER}} - No Eval/Exec: Templates MUST NOT contain ,
eval(),exec(), or other code execution patternsFunction()
Enforcement: hook blocks direct template writes (default: block mode).
unified-creator-guard.cjs关键安全要求:
- 禁止包含机密信息(SEC-TC-007): 模板不得包含机密信息、凭证、令牌或API密钥
- 路径安全: 所有模板引用必须使用相对路径(),禁止使用绝对路径
.claude/templates/... - 禁止敏感元数据: 模板不得暴露内部系统路径或用户目录
- 禁止Windows保留名称: 模板名称不得使用、
nul、con、prn、aux-com1、com9-lpt1lpt9 - 保留要求(SEC-TMPL-006): 被SEC-TMPL-006标记的模板必须保留在指定位置
- Spawn模板占位符安全(SEC-TC-001): 若Spawn模板的字段包含
prompt:令牌,必须引用{{PLACEHOLDER}}中的prompt-factory.cjs进行值清理。未清理的占位符会导致提示注入风险。禁止将sanitizeSubstitutionValue()令牌直接用于用户提供的输入内容。{{PLACEHOLDER}} - 禁止代码执行模式: 模板不得包含、
eval()、exec()或其他代码执行模式Function()
强制管控: 钩子会拦截直接的模板写入操作(默认:拦截模式)。
unified-creator-guard.cjsThe Iron Law
铁律
NO TEMPLATE WITHOUT PLACEHOLDER DOCUMENTATIONEvery must have a corresponding comment explaining:
{{PLACEHOLDER}}- What value should replace it
- Valid options/formats
- Example value
No exceptions:
- Every placeholder is documented
- Every required field is marked
- Every optional field has a default
无占位符文档的模板一律不允许存在每个必须有对应的注释说明:
{{PLACEHOLDER}}- 应该替换成什么值
- 有效选项/格式
- 示例值
无例外:
- 每个占位符都有文档说明
- 每个必填字段都有标记
- 每个可选字段都有默认值
Workflow Steps
工作流步骤
Step 0: Research-Synthesis (MANDATORY - BLOCKING)
步骤0:Research-Synthesis(强制要求 - 阻塞步骤)
Per CLAUDE.md Section 3 requirement, invoke BEFORE template creation:
research-synthesisjavascript
Skill({ skill: 'research-synthesis' });Research focuses for templates:
- Search existing templates:
Glob: .claude/templates/**/*.md - Review template catalog: Read
.claude/context/artifacts/catalogs/template-catalog.md - Check if similar template already exists in the ecosystem
- If creating for a new domain, research best-practice template structures via WebSearch
BLOCKING: Template creation CANNOT proceed without research-synthesis invocation.
根据CLAUDE.md第3节要求,必须在创建模板前调用:
research-synthesisjavascript
Skill({ skill: 'research-synthesis' });模板相关的研究重点:
- 搜索现有模板:
Glob: .claude/templates/**/*.md - 查看模板目录:阅读
.claude/context/artifacts/catalogs/template-catalog.md - 检查生态系统中是否已存在类似模板
- 若为新领域创建模板,通过WebSearch研究最佳实践模板结构
阻塞规则: 未调用research-synthesis则无法继续创建模板。
Step 0.5: Companion Check
步骤0.5:配套检查
Before proceeding with creation, run the ecosystem companion check:
- Use from
companion-check.cjs.claude/lib/creators/companion-check.cjs - Call to identify companion artifacts
checkCompanions("template", "{template-name}") - Review the companion checklist — note which required/recommended companions are missing
- Plan to create or verify missing companions after this artifact is complete
- Include companion findings in post-creation integration notes
This step is informational (does not block creation) but ensures the full artifact ecosystem is considered.
在开始创建前,运行生态系统配套检查:
- 使用中的
.claude/lib/creators/companion-check.cjscompanion-check.cjs - 调用识别配套工件
checkCompanions("template", "{template-name}") - 查看配套清单,记录缺失的必填/推荐配套项
- 规划在本工件完成后创建或验证缺失的配套项
- 将配套检查结果纳入创建后的集成说明
本步骤为信息性步骤(不阻塞创建),但需确保考虑完整的工件生态系统。
Step 1: Gather Requirements
步骤1:收集需求
Analyze the request:
- Template Type: Which category (spawn, agent, skill, workflow, report, code-style, document)?
- Purpose: What will this template be used for?
- Required Fields: What fields are mandatory?
- Optional Fields: What fields are optional with defaults?
- Validation Rules: What constraints apply?
- Consumers: Which creators/agents will use this template?
Example analysis:
Template Request: "Create a template for security audit reports"
- Type: Report
- Purpose: Standardize security audit report structure
- Required: findings, severity_levels, recommendations
- Optional: compliance_framework, remediation_timeline
- Rules: severity must be CRITICAL|HIGH|MEDIUM|LOW
- Consumers: security-architect, qa分析请求:
- 模板类型:属于哪一类别(spawn、agent、skill、workflow、report、code-style、document)?
- 用途:该模板将用于什么场景?
- 必填字段:哪些字段是必填的?
- 可选字段:哪些字段是可选的,且有默认值?
- 验证规则:有哪些约束条件?
- 消费者:哪些创建者/Agent会使用该模板?
示例分析:
模板请求:"创建安全审计报告模板"
- 类型:Report
- 用途:标准化安全审计报告结构
- 必填字段:findings, severity_levels, recommendations
- 可选字段:compliance_framework, remediation_timeline
- 规则:严重程度必须为CRITICAL|HIGH|MEDIUM|LOW
- 消费者:security-architect, qaStep 2: Template Type Classification
步骤2:模板类型分类
Classify the template to determine output path and validation rules:
| Type | Output Path | Key Fields | Validation Focus |
|---|---|---|---|
| Spawn | | subagent_type, prompt, model, task_id | TaskUpdate protocol, allowed_tools, model |
| Agent | | name, description, tools, skills, model, enforcement_hooks | Frontmatter completeness, alignment sections |
| Skill | | name, version, tools, invoked_by | SKILL.md structure, memory protocol |
| Workflow | | phases, agents, dependencies | Phase ordering, agent references |
| Report | | type, findings, recommendations | Finding severity, evidence requirements |
| Code Style | | language, conventions, examples | Convention clarity, example quality |
| Document | | varies by template type | Section completeness |
对模板进行分类,以确定输出路径和验证规则:
| 类型 | 输出路径 | 关键字段 | 验证重点 |
|---|---|---|---|
| Spawn | | subagent_type, prompt, model, task_id | TaskUpdate协议、允许使用的工具、模型 |
| Agent | | name, description, tools, skills, model, enforcement_hooks | 前置元数据完整性、对齐章节 |
| Skill | | name, version, tools, invoked_by | SKILL.md结构、内存协议 |
| Workflow | | phases, agents, dependencies | 阶段顺序、Agent引用 |
| Report | | type, findings, recommendations | 发现结果的严重程度、证据要求 |
| Code Style | | language, conventions, examples | 约定清晰度、示例质量 |
| Document | | 因模板类型而异 | 章节完整性 |
Step 3: Name Validation (SEC-TC-003)
步骤3:名称验证(SEC-TC-003)
BEFORE constructing the output path, validate the template name.
Template name MUST match this regex:
/^[a-z0-9][a-z0-9-]*[a-z0-9]$/Validation rules:
- Lowercase letters, digits, and hyphens only
- Must start and end with a letter or digit (not a hyphen)
- No path separators (,
/), no\, no special characters.. - No Windows reserved names (,
nul,con,prn,aux-com1,com9-lpt1)lpt9
Rejection examples:
REJECTED: "../hooks/malicious-hook" (path traversal)
REJECTED: "My Template" (spaces, uppercase)
REJECTED: "-leading-hyphen" (starts with hyphen)
REJECTED: "template_with_underscores" (underscores not allowed)
ACCEPTED: "security-audit-report" (valid kebab-case)
ACCEPTED: "agent-template-v2" (valid with version)在构建输出路径前,必须验证模板名称。
模板名称必须符合以下正则表达式:
/^[a-z0-9][a-z0-9-]*[a-z0-9]$/验证规则:
- 仅允许小写字母、数字和连字符
- 必须以字母或数字开头和结尾(不能以连字符开头/结尾)
- 禁止使用路径分隔符(、
/)、\或特殊字符.. - 禁止使用Windows保留名称(、
nul、con、prn、aux-com1、com9-lpt1)lpt9
示例:
被驳回:"../hooks/malicious-hook" (路径遍历风险)
被驳回:"My Template" (包含空格和大写字母)
被驳回:"-leading-hyphen" (以连字符开头)
被驳回:"template_with_underscores" (使用了下划线)
通过:"security-audit-report" (有效的短横线命名)
通过:"agent-template-v2" (包含版本号的有效命名)Step 4: Determine Output Path
步骤4:确定输出路径
Based on the template type classification from Step 2, construct the output path:
.claude/templates/<category>/<validated-template-name>.mdWhere is one of: , , , , , , or root level (no category subdirectory).
<category>spawn/agents/skills/workflows/reports/code-styles/Validate the resolved path:
- Path MUST start with
.claude/templates/ - Path MUST NOT contain segments after normalization
.. - Path MUST end with
.md
根据步骤2的模板类型分类,构建输出路径:
.claude/templates/<category>/<validated-template-name>.md其中为以下之一:、、、、、,或根目录(无类别子目录)。
<category>spawn/agents/skills/workflows/reports/code-styles/验证解析后的路径:
- 路径必须以开头
.claude/templates/ - 路径经过规范化后不得包含段
.. - 路径必须以结尾
.md
Step 5: Content Design
步骤5:内容设计
Design the template content following these standards:
按照以下标准设计模板内容:
Placeholder Format Standard
占位符格式标准
| Placeholder Type | Format | Example |
|---|---|---|
| Required field | | |
| Optional field | | |
| Multi-line | | |
| List item | | |
| 占位符类型 | 格式 | 示例 |
|---|---|---|
| 必填字段 | | |
| 可选字段 | | |
| 多行内容 | | |
| 列表项 | | |
Template Structure
模板结构
markdown
---markdown
---YAML Frontmatter with all required fields
YAML前置元数据,包含所有必填字段
name: { { NAME } }
description: { { DESCRIPTION } }
name: { { NAME } }
description: { { DESCRIPTION } }
... other fields with documentation comments
... 其他带文档注释的字段
{{DISPLAY_NAME}}
{{DISPLAY_NAME}}
POST-CREATION CHECKLIST (BLOCKING - DO NOT SKIP)
创建后检查清单(阻塞步骤 - 请勿跳过)
<!-- Always include blocking checklist -->
<!-- 始终包含阻塞性检查清单 -->
Overview
概述
{{OVERVIEW_DESCRIPTION}}
{{OVERVIEW_DESCRIPTION}}
Sections
章节
<!-- Domain-specific sections -->
<!-- 领域相关章节 -->
Memory Protocol (MANDATORY)
内存协议(强制要求)
<!-- Always include memory protocol -->
undefined<!-- 始终包含内存协议章节 -->
undefinedSecurity Checklist for Spawn Templates (SEC-TC-001)
Spawn模板安全检查清单(SEC-TC-001)
If creating a SPAWN template, you MUST also verify:
- No tokens inside
{{PLACEHOLDER}}fields that accept unsanitized user inputprompt: - Reference to from
sanitizeSubstitutionValue()included in documentationprompt-factory.cjs - TaskUpdate protocol is present in the spawn prompt body
- array does not grant
allowed_toolstool to non-orchestrator agentsTask - No prompt override patterns (,
IGNORE PREVIOUS, etc.) in template bodySYSTEM: - Template size under 50KB
若创建SPAWN模板,必须验证以下内容:
- 字段中没有接受未清理用户输入的
prompt:令牌{{PLACEHOLDER}} - 文档中引用了中的
prompt-factory.cjssanitizeSubstitutionValue() - 启动提示正文中包含TaskUpdate协议
- 数组未给非编排类Agent授予
allowed_tools工具权限Task - 模板正文中没有提示覆盖模式(、
IGNORE PREVIOUS等)SYSTEM: - 模板大小小于50KB
Documentation Comments
文档注释
Add inline documentation for each placeholder:
markdown
---为每个占位符添加内联文档:
markdown
---[REQUIRED] Unique identifier, lowercase-with-hyphens
[必填] 唯一标识符,使用小写字母加连字符
name: { { AGENT_NAME } }
name: { { AGENT_NAME } }
[REQUIRED] Single line, describes what it does AND when to use it
[必填] 单行文本,说明其功能及使用场景
Example: "Reviews mobile app UX against Apple HIG. Use for iOS UX audits."
示例:"根据Apple HIG审核移动应用UX。用于iOS UX审核场景。"
description: { { DESCRIPTION } }
description: { { DESCRIPTION } }
[OPTIONAL] Default: sonnet. Options: haiku, sonnet, opus
[可选] 默认值:sonnet。可选值:haiku, sonnet, opus
model: { { MODEL:sonnet } }
undefinedmodel: { { MODEL:sonnet } }
undefinedStep 6: Write Template File
步骤6:编写模板文件
Write to the validated output path determined in Step 4:
bash
Write: .claude/templates/<category>/<template-name>.md写入步骤4中确定的验证后的输出路径:
bash
Write: .claude/templates/<category>/<template-name>.mdStep 7: Validate Template Structure (BLOCKING)
步骤7:验证模板结构(阻塞步骤)
Before proceeding to registration, verify ALL requirements:
Structural Validation:
[ ] YAML frontmatter is valid syntax
[ ] All required fields have placeholders
[ ] All placeholders follow {{UPPER_CASE}} naming convention
[ ] All placeholders have documentation comments
[ ] POST-CREATION CHECKLIST section present
[ ] Memory Protocol section present
[ ] Verification commands included
[ ] Example values provided where helpfulSecurity Validation (SEC-TC-007):
[ ] No secrets, credentials, or API keys in template content
[ ] No absolute file paths (use relative from PROJECT_ROOT)
[ ] No eval(), exec(), Function() or code execution patterns
[ ] No prompt override patterns ("IGNORE PREVIOUS", "SYSTEM:", etc.)
[ ] Template size under 50KBVerification Commands:
bash
undefined在进行注册前,验证所有要求:
结构验证:
[ ] YAML前置元数据语法有效
[ ] 所有必填字段都有占位符
[ ] 所有占位符遵循{{UPPER_CASE}}命名规范
[ ] 所有占位符都有文档注释
[ ] 存在创建后检查清单章节
[ ] 存在内存协议章节
[ ] 包含验证命令
[ ] 提供示例值(若有帮助)安全验证(SEC-TC-007):
[ ] 模板内容中无机密信息、凭证或API密钥
[ ] 无绝对文件路径(使用相对于PROJECT_ROOT的相对路径)
[ ] 无eval()、exec()、Function()或其他代码执行模式
[ ] 无提示覆盖模式("IGNORE PREVIOUS"、"SYSTEM:"等)
[ ] 模板大小小于50KB验证命令:
bash
undefinedCheck no unresolved placeholders from template-creator itself
检查是否存在来自template-creator自身的未解析占位符
grep "{{" <created-file> | head -5 # Should show only intended placeholders
grep "{{" <created-file> | head -5 # 应仅显示预期的占位符
Check YAML frontmatter is present
检查YAML前置元数据是否存在
head -50 <file> | grep -E "^---$" | wc -l # Should be 2
head -50 <file> | grep -E "^---$" | wc -l # 结果应为2
Check required sections present
检查是否存在必填章节
grep -E "^## Memory Protocol" <file> || echo "ERROR: Missing Memory Protocol!"
**BLOCKING**: Template must pass ALL validation checks before proceeding.grep -E "^## Memory Protocol" <file> || echo "ERROR: 缺少内存协议章节!"
**阻塞规则:** 模板必须通过所有验证检查才能继续。Step 8: Update Template Catalog (MANDATORY - BLOCKING)
步骤8:更新模板目录(强制要求 - 阻塞步骤)
Update the template catalog to ensure the new template is discoverable.
-
Read current catalog:bash
cat .claude/context/artifacts/catalogs/template-catalog.md -
Determine template category based on type:
- Spawn (), Creator (
spawn/,agents/,skills/), Document (root), Report (workflows/), Code Style (reports/)code-styles/
- Spawn (
-
Add template entry in correct category section:markdown
### <template-name>.md | Field | Value | | ------------------ | ------------------------------------------------- | | **Path** | `.claude/templates/<category>/<template-name>.md` | | **Category** | <Category> Templates | | **Status** | active | | **Used By Agents** | <agent-list> | | **Used By Skills** | <skill-list> | **Purpose:** <Purpose description> -
Update Template Categories Summary table (totals row)
-
Verify update:bash
grep "<template-name>" .claude/context/artifacts/catalogs/template-catalog.md || echo "ERROR: CATALOG NOT UPDATED!"
Important: Use when constructing any JSON registry entries (SEC-TC-004). Never manually concatenate strings to build JSON. The field MUST be validated to start with and contain no segments.
JSON.stringify()location.claude/templates/..BLOCKING: Template must appear in catalog. Uncataloged templates are invisible.
更新模板目录,确保新模板可被发现。
-
读取当前目录:bash
cat .claude/context/artifacts/catalogs/template-catalog.md -
根据类型确定模板类别:
- Spawn()、Creator(
spawn/、agents/、skills/)、Document(根目录)、Report(workflows/)、Code Style(reports/)code-styles/
- Spawn(
-
在对应类别章节添加模板条目:markdown
### <template-name>.md | 字段 | 值 | | ------------------ | ------------------------------------------------- | | **路径** | `.claude/templates/<category>/<template-name>.md` | | **类别** | <Category> 模板 | | **状态** | 活跃 | | **被Agent使用** | <agent列表> | | **被Skill使用** | <skill列表> | **用途:** <用途描述> -
更新模板类别汇总表(总计行)
-
验证更新:bash
grep "<template-name>" .claude/context/artifacts/catalogs/template-catalog.md || echo "ERROR: 目录未更新!"
重要提示: 构建任何JSON注册表条目时请使用(SEC-TC-004)。请勿手动拼接字符串构建JSON。字段必须验证为以开头且不包含段。
JSON.stringify()location.claude/templates/..阻塞规则: 模板必须出现在目录中。未录入目录的模板不可见。
Step 9: Update Templates README (MANDATORY - BLOCKING)
步骤9:更新Templates README(强制要求 - 阻塞步骤)
After updating the catalog, update :
.claude/templates/README.md- Add to appropriate section (or create new section)
- Document usage instructions
- Add to Quick Reference table
Entry format:
markdown
undefined更新目录后,更新:
.claude/templates/README.md- 添加到对应章节(或创建新章节)
- 记录使用说明
- 添加到快速参考表
条目格式:
markdown
undefined{{Template Type}} Templates ({{directory}}/
)
{{directory}}/{{模板类型}} 模板({{directory}}/
)
{{directory}}/Use when {{use case}}.
File:
{{directory}}/{{template-name}}.mdUsage:
- Copy template to
{{target-path}} - Replace all values
{{PLACEHOLDER}} - {{Additional steps}}
**Verification:**
```bash
grep "<template-name>" .claude/templates/README.md || echo "ERROR: README NOT UPDATED - BLOCKING!"BLOCKING: README must contain the template entry.
适用于{{使用场景}}。
文件:
{{directory}}/{{template-name}}.md使用方法:
- 将模板复制到
{{target-path}} - 替换所有值
{{PLACEHOLDER}} - {{额外步骤}}
**验证:**
```bash
grep "<template-name>" .claude/templates/README.md || echo "ERROR: README未更新 - 阻塞步骤!"阻塞规则: README必须包含该模板条目。
Step 10: Update CLAUDE.md (CONDITIONAL - BLOCKING)
步骤10:更新CLAUDE.md(条件性 - 阻塞步骤)
If the template is framework-significant or user-invocable:
-
Check if template needs CLAUDE.md entry:
- Is it a new spawn template? -> Update Section 2 (Spawn Templates)
- Is it a new creator template? -> Update relevant creator section
- Is it a user-invocable template? -> Update Section 8.5
-
If YES, add entry:markdown
**{Template Name}:** `.claude/templates/{category}/{name}.md` -
Verify:bash
grep "<template-name>" .claude/CLAUDE.md || echo "WARNING: Template not in CLAUDE.md (may be OK if internal-only)"
Note: Not all templates need CLAUDE.md entries. Only framework-significant ones (spawn templates, creator templates) require this step.
若模板为框架核心或支持用户调用:
-
检查是否需要在CLAUDE.md中添加条目:
- 是否为新的Spawn模板? -> 更新第2节(Spawn模板)
- 是否为新的Creator模板? -> 更新对应的Creator章节
- 是否为用户可调用的模板? -> 更新第8.5节
-
若需要,添加条目:markdown
**{模板名称}:** `.claude/templates/{category}/{name}.md` -
验证:bash
grep "<template-name>" .claude/CLAUDE.md || echo "警告:模板未录入CLAUDE.md(若为内部模板则可忽略)"
注意: 并非所有模板都需要录入CLAUDE.md。仅框架核心模板(Spawn模板、Creator模板)需要执行此步骤。
Step 11: Assign Consumer Agents
步骤11:分配消费者Agent
Templates exist to be consumed by creators and agents. After creation:
-
Identify consumers based on template type:
- Agent templates -> agent-creator skill should reference
- Skill templates -> skill-creator skill should reference
- Workflow templates -> workflow-creator skill should reference
- Report templates -> relevant agents (qa, developer, etc.)
- Spawn templates -> router documentation, spawn-template-resolver
- Code style templates -> developer, code-reviewer
-
Update consuming skill/agent to reference the template:markdown
**Available Templates:** - See `.claude/templates/<category>/<template-name>.md` for standardized <type> template -
Verify at least one consumer references the template:bash
grep -r "<template-name>" .claude/skills/ .claude/agents/ || echo "WARNING: No consumer references template"
WHY: Templates without consumers are dead on arrival. Every template MUST have at least one consuming skill or agent.
模板的存在意义是被创建者和Agent消费。创建完成后:
-
根据模板类型识别消费者:
- Agent模板 -> agent-creator Skill应引用该模板
- Skill模板 -> skill-creator Skill应引用该模板
- 工作流模板 -> workflow-creator Skill应引用该模板
- 报告模板 -> 相关Agent(qa、developer等)
- Spawn模板 -> router文档、spawn-template-resolver
- 代码风格模板 -> developer、code-reviewer
-
更新消费型Skill/Agent以引用该模板:markdown
**可用模板:** - 标准化<类型>模板请查看`.claude/templates/<category>/<template-name>.md` -
验证至少有一个消费者引用了该模板:bash
grep -r "<template-name>" .claude/skills/ .claude/agents/ || echo "警告:无消费者引用该模板"
原因: 没有消费者的模板毫无用处。每个模板必须至少被一个消费型Skill或Agent引用。
Step 12: Integration Verification (BLOCKING - DO NOT SKIP)
步骤12:集成验证(阻塞步骤 - 请勿跳过)
This step verifies the artifact is properly integrated into the ecosystem.
Before calling , run the post-creation validation:
TaskUpdate({ status: "completed" })-
Run the integration checklist:bash
node .claude/tools/cli/validate-integration.cjs .claude/templates/<category>/<template-name>.md -
Verify exit code is 0 (all checks passed)
-
If exit code is 1 (one or more checks failed):
- Read the error output for specific failures
- Fix each failure:
- Missing README entry -> Add to
.claude/templates/README.md - Missing catalog entry -> Add to
template-catalog.md - Missing memory update -> Update
learnings.md
- Missing README entry -> Add to
- Re-run validation until exit code is 0
-
Only proceed when validation passes
This step is BLOCKING. Do NOT mark task complete until validation passes.
Why this matters: The Party Mode incident showed that fully-implemented artifacts can be invisible to the Router if integration steps are missed. This validation ensures no "invisible artifact" pattern.
Reference:
.claude/workflows/core/post-creation-validation.md此步骤验证工件是否已正确集成到生态系统中。
在调用前,运行创建后验证:
TaskUpdate({ status: "completed" })-
运行集成检查清单:bash
node .claude/tools/cli/validate-integration.cjs .claude/templates/<category>/<template-name>.md -
验证退出码为0(所有检查通过)
-
若退出码为1(一项或多项检查失败):
- 读取错误输出查看具体失败项
- 修复每个失败项:
- 缺少README条目 -> 添加到
.claude/templates/README.md - 缺少目录条目 -> 添加到
template-catalog.md - 缺少内存更新 -> 更新
learnings.md
- 缺少README条目 -> 添加到
- 重新运行验证直到退出码为0
-
仅在验证通过后继续
此步骤为阻塞步骤。 验证通过前请勿标记任务完成。
重要性: "派对模式"事件表明,若遗漏集成步骤,即使完全实现的工件也可能对Router不可见。此验证确保不会出现"不可见工件"问题。
参考:
.claude/workflows/core/post-creation-validation.mdStep 13: Completion Checklist (BLOCKING)
步骤13:完成检查清单(阻塞步骤)
All items MUST pass before template creation is complete:
[ ] Research-synthesis skill invoked (Step 0)
[ ] Existence check passed (no duplicate template)
[ ] Template name validates against /^[a-z0-9][a-z0-9-]*[a-z0-9]$/ (Step 3)
[ ] Template file created at .claude/templates/<category>/<name>.md
[ ] All placeholders use {{PLACEHOLDER_NAME}} format
[ ] All placeholders have documentation comments
[ ] POST-CREATION CHECKLIST section present in template
[ ] Memory Protocol section present in template
[ ] No hardcoded values (all configurable via placeholders)
[ ] No secrets, credentials, or absolute paths in template (SEC-TC-007)
[ ] No eval() or code execution patterns in template
[ ] template-catalog.md updated with structured entry (Step 8)
[ ] .claude/templates/README.md updated with template entry (Step 9)
[ ] CLAUDE.md updated if template is framework-significant (Step 10)
[ ] At least one consuming skill/agent references the template (Step 11)
[ ] Integration verification passed (Step 12)
[ ] Template tested with at least one real usage
[ ] Memory files updated (learnings.md)BLOCKING: If ANY item fails, template creation is INCOMPLETE. Fix all issues before proceeding.
所有项必须通过才能完成模板创建:
[ ] 已调用research-synthesis Skill(步骤0)
[ ] 存在性检查通过(无重复模板)
[ ] 模板名称符合/^[a-z0-9][a-z0-9-]*[a-z0-9]$/(步骤3)
[ ] 模板文件已创建于.claude/templates/<category>/<name>.md
[ ] 所有占位符使用{{PLACEHOLDER_NAME}}格式
[ ] 所有占位符都有文档注释
[ ] 模板中存在创建后检查清单章节
[ ] 模板中存在内存协议章节
[ ] 无硬编码值(所有配置都通过占位符实现)
[ ] 模板中无机密信息、凭证或绝对路径(SEC-TC-007)
[ ] 模板中无eval()或代码执行模式
[ ] template-catalog.md已添加结构化条目(步骤8)
[ ] .claude/templates/README.md已添加模板条目(步骤9)
[ ] 若模板为框架核心,已更新CLAUDE.md(步骤10)
[ ] 至少有一个消费型Skill/Agent引用了该模板(步骤11)
[ ] 集成验证通过(步骤12)
[ ] 已用至少一个真实场景测试模板
[ ] 已更新内存文件(learnings.md)阻塞规则: 若有任何一项未通过,模板创建未完成。修复所有问题后再继续。
Architecture Compliance
架构合规
File Placement (ADR-076)
文件放置(ADR-076)
- Templates: (spawn, agents, skills, workflows, reports, code-styles)
.claude/templates/{category}/ - Archived templates:
.claude/templates/_archive/ - Template catalog:
.claude/context/artifacts/catalogs/template-catalog.md - Tests: (NOT in
tests/).claude/
- 模板:(spawn、agents、skills、workflows、reports、code-styles)
.claude/templates/{category}/ - 已归档模板:
.claude/templates/_archive/ - 模板目录:
.claude/context/artifacts/catalogs/template-catalog.md - 测试:(不在
tests/目录下).claude/
Documentation References (CLAUDE.md v2.2.1)
文档参考(CLAUDE.md v2.2.1)
- Reference files use @notation: @TOOL_REFERENCE.md, @SKILL_CATALOG_TABLE.md
- Located in:
.claude/docs/@*.md - See: CLAUDE.md Section 2 (Spawn Templates)
- 参考文件使用@标记:@TOOL_REFERENCE.md、@SKILL_CATALOG_TABLE.md
- 存储位置:
.claude/docs/@*.md - 查看:CLAUDE.md第2节(Spawn模板)
Shell Security (ADR-077)
Shell安全(ADR-077)
- Spawn templates MUST include: for background tasks
cd "$PROJECT_ROOT" || exit 1 - Environment variables control validators (block/warn/off mode)
- See:
.claude/docs/SHELL-SECURITY-GUIDE.md - Apply to: all spawn templates, background task templates
- Spawn模板必须包含:(用于后台任务)
cd "$PROJECT_ROOT" || exit 1 - 环境变量控制验证器(阻塞/警告/关闭模式)
- 查看:
.claude/docs/SHELL-SECURITY-GUIDE.md - 适用范围:所有Spawn模板、后台任务模板
Security Compliance (ADR-085, ADR-086, SEC-TMPL-006)
安全合规(ADR-085、ADR-086、SEC-TMPL-006)
- Templates MUST NOT include hardcoded secrets, credentials, or API keys
- Templates MUST use relative paths (), never absolute paths
.claude/templates/... - Templates MUST NOT expose internal system paths or user directories
- Retention mandates: security-design-checklist.md and error-recovery-template.md must remain at designated locations
- Spawn template placeholder sanitization: reference in
sanitizeSubstitutionValue()prompt-factory.cjs
- 模板不得包含硬编码的机密信息、凭证或API密钥
- 模板必须使用相对路径(),禁止使用绝对路径
.claude/templates/... - 模板不得暴露内部系统路径或用户目录
- 保留要求:security-design-checklist.md和error-recovery-template.md必须保留在指定位置
- Spawn模板占位符清理:引用中的
prompt-factory.cjssanitizeSubstitutionValue()
Recent ADRs
最新ADR
- ADR-075: Router Config-Aware Model Selection
- ADR-076: File Placement Architecture Redesign
- ADR-077: Shell Command Security Architecture
- ADR-085: Template System Overhaul (spawn resolver + dead template cleanup)
- ADR-086: Template-Creator Overhaul to v2.1 Creator Standard
- ADR-075:Router配置感知模型选择
- ADR-076:文件放置架构重设计
- ADR-077:Shell命令安全架构
- ADR-085:模板系统全面升级(spawn解析器 + 废弃模板清理)
- ADR-086:Template-Creator升级到v2.1 Creator标准
Iron Laws of Template Creation
模板创建铁律
These rules are INVIOLABLE. Breaking them causes inconsistency across the framework.
1. NO TEMPLATE WITHOUT PLACEHOLDER DOCUMENTATION
- Every {{PLACEHOLDER}} must have an inline comment
- Comments explain valid values and examples
2. NO TEMPLATE WITHOUT POST-CREATION CHECKLIST
- Users must know what to do after using template
- Blocking steps prevent incomplete artifacts
3. NO TEMPLATE WITHOUT MEMORY PROTOCOL
- All templates must include Memory Protocol section
- Ensures artifacts created from template follow memory rules
4. NO TEMPLATE WITHOUT README UPDATE
- Templates README must document new template
- Undocumented templates are invisible
5. NO PLACEHOLDER WITHOUT NAMING CONVENTION
- Use {{UPPER_CASE_WITH_UNDERSCORES}}
- Never use lowercase or mixed case
6. NO OPTIONAL FIELD WITHOUT DEFAULT
- Format: {{FIELD:default_value}}
- Makes templates usable without full customization
7. NO TEMPLATE WITHOUT VERIFICATION COMMANDS
- Include commands to validate created artifacts
- Users can verify their work is correct
8. NO AGENT TEMPLATE WITHOUT ALIGNMENT SECTIONS
- Agent templates MUST include {{ENFORCEMENT_HOOKS}} placeholder section
- Agent templates MUST include {{RELATED_WORKFLOWS}} placeholder section
- Agent templates MUST include Output Standards block referencing workspace-conventions
- Reference: @HOOK_AGENT_MAP.md and @WORKFLOW_AGENT_MAP.md for archetype sets
9. NO TEMPLATE WITHOUT CATALOG ENTRY
- Every template MUST be registered in template-catalog.md
- Uncataloged templates are invisible to the system
- Verify: grep "<template-name>" .claude/context/artifacts/catalogs/template-catalog.md
10. NO TEMPLATE WITHOUT CONSUMING SKILL/AGENT
- Every template MUST be referenced by at least one consuming skill or agent
- Templates without consumers are dead on arrival
- Verify: grep -r "<template-name>" .claude/skills/ .claude/agents/
11. NO CREATION WITHOUT RESEARCH-SYNTHESIS
- Per CLAUDE.md Section 3, research-synthesis MUST be invoked before any creator
- Template creation is no exception
- Invoke: Skill({ skill: 'research-synthesis' })这些规则不可违反。违反会导致框架不一致。
1. 无占位符文档的模板一律不允许存在
- 每个{{PLACEHOLDER}}必须有内联注释
- 注释说明有效值和示例
2. 无创建后检查清单的模板一律不允许存在
- 用户必须知道使用模板后要做什么
- 阻塞步骤防止工件不完整
3. 无内存协议的模板一律不允许存在
- 所有模板必须包含内存协议章节
- 确保从模板创建的工件遵循内存规则
4. 未更新README的模板一律不允许存在
- Templates README必须记录新模板
- 未文档化的模板不可见
5. 不符合命名规范的占位符一律不允许存在
- 使用{{UPPER_CASE_WITH_UNDERSCORES}}
- 禁止使用小写或混合大小写
6. 无默认值的可选字段一律不允许存在
- 格式:{{FIELD:default_value}}
- 无需完全自定义即可使用模板
7. 无验证命令的模板一律不允许存在
- 包含验证创建后工件的命令
- 用户可验证自己的工作是否正确
8. 无对齐章节的Agent模板一律不允许存在
- Agent模板必须包含{{ENFORCEMENT_HOOKS}}占位符章节
- Agent模板必须包含{{RELATED_WORKFLOWS}}占位符章节
- Agent模板必须包含引用workspace-conventions的输出标准块
- 参考:@HOOK_AGENT_MAP.md和@WORKFLOW_AGENT_MAP.md中的原型集
9. 未录入目录的模板一律不允许存在
- 每个模板必须在template-catalog.md中注册
- 未录入目录的模板对系统不可见
- 验证方式:grep "<template-name>" .claude/context/artifacts/catalogs/template-catalog.md
10. 无消费型Skill/Agent引用的模板一律不允许存在
- 每个模板必须至少被一个消费型Skill或Agent引用
- 没有消费者的模板毫无用处
- 验证方式:grep -r "<template-name>" .claude/skills/ .claude/agents/
11. 未做研究的模板创建一律不允许存在
- 根据CLAUDE.md第3节,任何创建者必须先调用research-synthesis
- 模板创建也不例外
- 调用方式:Skill({ skill: 'research-synthesis' })Reference Template
参考模板
Use as the canonical reference template.
.claude/templates/spawn/universal-agent-spawn.mdBefore finalizing any template, compare:
- Has clear placeholder documentation
- Placeholders are UPPERCASE with underscores
- Has usage examples section
- Has integration notes
- Has POST-CREATION CHECKLIST
- Has Memory Protocol
请将作为标准参考模板。
.claude/templates/spawn/universal-agent-spawn.md在最终确定任何模板前,对比检查:
- 有清晰的占位符文档
- 占位符为大写加下划线格式
- 有使用示例章节
- 有集成说明
- 有创建后检查清单
- 有内存协议
Template Best Practices
模板最佳实践
Placeholder Standards
占位符标准
| Practice | Good | Bad |
|---|---|---|
| Naming | | |
| Required fields | Always present | Sometimes omitted |
| Optional fields | | No default indicator |
| Documentation | Inline comments | Separate docs file |
| Examples | In comments | None provided |
| 实践 | 规范示例 | 不规范示例 |
|---|---|---|
| 命名 | | |
| 必填字段 | 始终存在 | 有时会遗漏 |
| 可选字段 | | 无默认值标识 |
| 文档说明 | 内联注释 | 单独的文档文件 |
| 示例 | 注释中包含示例 | 无示例 |
Structure Standards
结构标准
-
YAML Frontmatter First
- All machine-readable metadata
- Comments explaining each field
-
POST-CREATION CHECKLIST Second
- Blocking steps after using template
- Verification commands
-
Content Sections
- Follow existing pattern for type
- Include all required sections
-
Memory Protocol Last
- Standard format across all templates
- Always present
-
YAML前置元数据优先
- 所有机器可读的元数据
- 每个字段都有注释说明
-
创建后检查清单次之
- 使用模板后的阻塞步骤
- 验证命令
-
内容章节
- 遵循对应类型的现有模式
- 包含所有必填章节
-
内存协议最后
- 所有模板使用标准格式
- 始终存在
Validation Examples
验证示例
Include validation examples in templates:
markdown
undefined在模板中包含验证示例:
markdown
undefinedValidation
验证
After replacing placeholders, validate:
bash
undefined替换占位符后,执行以下验证:
bash
undefinedCheck YAML is valid
检查YAML是否有效
head -50 <file> | grep -E "^---$" | wc -l # Should be 2
head -50 <file> | grep -E "^---$" | wc -l # 结果应为2
Check no unresolved placeholders
检查是否有未解析的占位符
grep "{{" <file> && echo "ERROR: Unresolved placeholders!"
grep "{{" <file> && echo "ERROR: 存在未解析的占位符!"
Check required sections present
检查是否存在必填章节
grep -E "^## Memory Protocol" <file> || echo "ERROR: Missing Memory Protocol!"
undefinedgrep -E "^## Memory Protocol" <file> || echo "ERROR: 缺少内存协议章节!"
undefinedSystem Impact Analysis (MANDATORY)
系统影响分析(强制要求)
After creating a template, complete this 7-point analysis:
[TEMPLATE-CREATOR] System Impact Analysis for: <template-name>
1. README UPDATE (MANDATORY - Step 9)
- Added to .claude/templates/README.md
- Usage instructions documented
- Quick Reference table updated
2. CATALOG UPDATE (MANDATORY - Step 8)
- Added to .claude/context/artifacts/catalogs/template-catalog.md
- Category, status, agents, skills documented
- Purpose clearly stated
3. CLAUDE.MD UPDATE (CONDITIONAL - Step 10)
- Is template framework-significant? If yes, add to CLAUDE.md
- Spawn templates -> Section 2
- Creator templates -> relevant creator section
- User-invocable -> Section 8.5
4. CONSUMER ASSIGNMENT (MANDATORY - Step 11)
- Which skills/agents consume this template?
- Is template reference added to consuming creator skill?
- Verify with grep across skills/ and agents/
5. RELATED TEMPLATES CHECK
- Does this template supersede an existing one?
- Are there related templates that need cross-references?
- Should archived templates be updated or removed?
6. SECURITY COMPLIANCE (SEC-TMPL-006, SEC-TC-001, SEC-TC-007)
- No secrets, credentials, or absolute paths
- Relative paths only
- Retention mandates respected
- Spawn template placeholders sanitized
7. MEMORY UPDATE
- Record creation in learnings.md
- Document any decisions in decisions.md创建模板后,完成以下7点分析:
[TEMPLATE-CREATOR] 系统影响分析:<template-name>
1. README更新(强制要求 - 步骤9)
- 已添加到.claude/templates/README.md
- 已记录使用说明
- 已更新快速参考表
2. 目录更新(强制要求 - 步骤8)
- 已添加到.claude/context/artifacts/catalogs/template-catalog.md
- 已记录类别、状态、Agent、Skill
- 已清晰说明用途
3. CLAUDE.MD更新(条件性 - 步骤10)
- 模板是否为框架核心?若是,添加到CLAUDE.md
- Spawn模板 -> 第2节
- Creator模板 -> 对应Creator章节
- 用户可调用 -> 第8.5节
4. 消费者分配(强制要求 - 步骤11)
- 哪些Skill/Agent会消费该模板?
- 消费型Creator Skill是否已引用该模板?
- 通过在skills/和agents/目录下grep验证
5. 相关模板检查
- 该模板是否取代了现有模板?
- 是否有相关模板需要添加交叉引用?
- 已归档的模板是否需要更新或移除?
6. 安全合规(SEC-TMPL-006、SEC-TC-001、SEC-TC-007)
- 无机密信息、凭证或绝对路径
- 仅使用相对路径
- 遵守保留要求
- Spawn模板占位符已做清理
7. 内存更新
- 在learnings.md中记录创建信息
- 在decisions.md中记录决策Workflow Integration
工作流集成
This skill is part of the unified artifact lifecycle. For complete multi-agent orchestration:
Router Decision:
.claude/workflows/core/router-decision.md- How the Router discovers and invokes this skill's artifacts
Artifact Lifecycle:
.claude/workflows/core/skill-lifecycle.md- Discovery, creation, update, deprecation phases
- Version management and registry updates
- CLAUDE.md integration requirements
External Integration:
.claude/workflows/core/external-integration.md- Safe integration of external artifacts
- Security review and validation phases
Spawn Template Resolver:
.claude/lib/spawn/spawn-template-resolver.cjs- Programmatic template selection for spawn operations
- Template scoring and fallback logic
本Skill是统一工件生命周期的一部分。完整的多代理编排请参考:
Router决策:
.claude/workflows/core/router-decision.md- Router如何发现并调用本Skill的工件
工件生命周期:
.claude/workflows/core/skill-lifecycle.md- 发现、创建、更新、弃用阶段
- 版本管理和注册表更新
- CLAUDE.md集成要求
外部集成:
.claude/workflows/core/external-integration.md- 外部工件的安全集成
- 安全审查和验证阶段
Spawn模板解析器:
.claude/lib/spawn/spawn-template-resolver.cjs- 启动操作的程序化模板选择
- 模板评分和回退逻辑
Cross-Reference: Creator Ecosystem
交叉参考:Creator生态系统
This skill is part of the Creator Ecosystem. Use companion creators when needed:
| Creator | When to Use | Invocation |
|---|---|---|
| agent-creator | Template needs agent integration | |
| skill-creator | Template needs skill integration | |
| workflow-creator | Template needs workflow patterns | |
| schema-creator | Template needs JSON schemas | |
| hook-creator | Template needs hooks | |
本Skill是Creator生态系统的一部分。需要时可使用配套创建者:
| 创建者 | 使用场景 | 调用方式 |
|---|---|---|
| agent-creator | 模板需要Agent集成 | |
| skill-creator | 模板需要Skill集成 | |
| workflow-creator | 模板需要工作流模式 | |
| schema-creator | 模板需要JSON schema | |
| hook-creator | 模板需要钩子 | |
Integration Workflow
集成工作流
After creating a template that needs additional artifacts:
javascript
// 1. Template created for new hook type
// 2. Need to create example hook using template
Skill({ skill: 'hook-creator' });
// 3. Template created for new agent category
// 4. Need to update agent-creator to recognize new category
// Edit .claude/skills/agent-creator/SKILL.md to add category创建需要额外工件的模板后:
javascript
// 1. 为新钩子类型创建模板
// 2. 需要使用模板创建示例钩子
Skill({ skill: 'hook-creator' });
// 3. 为新Agent类别创建模板
// 4. 需要更新agent-creator以识别新类别
// 编辑.claude/skills/agent-creator/SKILL.md添加类别Post-Creation Checklist for Ecosystem Integration
生态系统集成创建后检查清单
After template is fully created and validated:
[ ] Does template need a companion skill? -> Use skill-creator
[ ] Does template need a companion workflow? -> Use workflow-creator
[ ] Does template supersede an existing template? -> Archive old one
[ ] Should template be part of enterprise workflows? -> Update Section 8.6
[ ] Does template interact with spawn-template-resolver? -> Update resolver config模板完全创建并验证后:
[ ] 模板是否需要配套Skill? -> 使用skill-creator
[ ] 模板是否需要配套工作流? -> 使用workflow-creator
[ ] 模板是否取代了现有模板? -> 归档旧模板
[ ] 模板是否应纳入企业工作流? -> 更新第8.6节
[ ] 模板是否与spawn-template-resolver交互? -> 更新解析器配置File Placement & Standards
文件放置与标准
Output Location Rules
输出位置规则
This skill outputs to:
.claude/templates/Subdirectories by type:
- - Agent spawn prompt templates (4 templates)
spawn/ - - Agent definition templates (2 templates)
agents/ - - Skill definition templates (1 template)
skills/ - - Workflow definition templates (1 template)
workflows/ - - Report document templates (5 templates)
reports/ - - Language style guides (3 templates)
code-styles/ - Root level - General document templates (8+ templates)
- - Archived/deprecated templates (14 templates)
_archive/
本Skill的输出位置:
.claude/templates/按类型划分的子目录:
- - Agent启动提示模板(4个模板)
spawn/ - - Agent定义模板(2个模板)
agents/ - - Skill定义模板(1个模板)
skills/ - - 工作流定义模板(1个模板)
workflows/ - - 报告文档模板(5个模板)
reports/ - - 语言风格指南(3个模板)
code-styles/ - 根目录 - 通用文档模板(8+个模板)
- - 已归档/废弃模板(14个模板)
_archive/
Mandatory References
强制参考
- File Placement: See
.claude/docs/FILE_PLACEMENT_RULES.md - Developer Workflow: See
.claude/docs/DEVELOPER_WORKFLOW.md - Artifact Naming: See
.claude/docs/ARTIFACT_NAMING.md - Workspace Conventions: See (output placement, naming, provenance)
.claude/rules/workspace-conventions.md
- 文件放置:查看
.claude/docs/FILE_PLACEMENT_RULES.md - 开发者工作流:查看
.claude/docs/DEVELOPER_WORKFLOW.md - 工件命名:查看
.claude/docs/ARTIFACT_NAMING.md - 工作区约定:查看(输出位置、命名、来源)
.claude/rules/workspace-conventions.md
Enforcement
强制管控
File placement is enforced by hook.
Invalid placements will be blocked in production mode.
file-placement-guard.cjs文件放置由钩子强制管控。生产模式下会阻止无效的放置。
file-placement-guard.cjsAssigned Agents
分配的Agent
This skill is typically invoked by:
| Agent | Role | Assignment Reason |
|---|---|---|
| planner | Planning standardization | Creates templates for new patterns |
| architect | Architecture patterns | Creates templates for architectural artifacts |
| developer | Code patterns | Creates code scaffolding templates |
To invoke this skill:
javascript
Skill({ skill: 'template-creator' });本Skill通常由以下Agent调用:
| Agent | 角色 | 分配原因 |
|---|---|---|
| planner | 规划标准化 | 为新模式创建模板 |
| architect | 架构模式 | 为架构工件创建模板 |
| developer | 代码模式 | 创建代码脚手架模板 |
调用本Skill的方式:
javascript
Skill({ skill: 'template-creator' });Examples
示例
Example 1: Creating a Report Template
示例1:创建报告模板
Request: "Create a template for security audit reports"
Process:
- Research: Invoke , review existing report templates in
research-synthesis.claude/templates/reports/ - Gather: Analyze report type, security focus, audit findings structure
- Validate name: matches
security-audit-report-template/^[a-z0-9][a-z0-9-]*[a-z0-9]$/ - Design: Structure for security audit reports
- Create:
.claude/templates/reports/security-audit-report-template.md
markdown
---请求: "创建安全审计报告模板"
流程:
- 研究:调用,查看
research-synthesis中的现有报告模板.claude/templates/reports/ - 收集需求:分析报告类型、安全重点、审计发现结构
- 验证名称:符合/^[a-z0-9][a-z0-9-]*[a-z0-9]$/
security-audit-report-template - 设计:安全审计报告的结构
- 创建:
.claude/templates/reports/security-audit-report-template.md
markdown
---[REQUIRED] Report identifier, lowercase-with-hyphens
[必填] 报告标识符,使用小写字母加连字符
name: { { REPORT_NAME } }
name: { { REPORT_NAME } }
[REQUIRED] What this report documents
[必填] 本报告记录的内容
description: { { REPORT_DESCRIPTION } }
description: { { REPORT_DESCRIPTION } }
[REQUIRED] Report type: audit, implementation, research, reflection, plan
[必填] 报告类型:audit, implementation, research, reflection, plan
type: audit
type: audit
[REQUIRED] Severity levels for findings
[必填] 发现结果的严重程度级别
severity_levels: [CRITICAL, HIGH, MEDIUM, LOW]
severity_levels: [CRITICAL, HIGH, MEDIUM, LOW]
{{REPORT_DISPLAY_NAME}} Report
{{REPORT_DISPLAY_NAME}} 报告
POST-CREATION CHECKLIST (BLOCKING)
创建后检查清单(阻塞步骤)
After creating this report:
- All findings categorized by severity
- Recommendations actionable and specific
- Evidence provided for all claims
创建本报告后:
- 所有发现结果按严重程度分类
- 建议可操作且具体
- 所有结论都有证据支持
Findings
发现结果
CRITICAL
严重
{{CRITICAL_FINDINGS}}
{{CRITICAL_FINDINGS}}
HIGH
高
{{HIGH_FINDINGS}}
{{HIGH_FINDINGS}}
Recommendations
建议
{{RECOMMENDATIONS}}
{{RECOMMENDATIONS}}
Memory Protocol (MANDATORY)
内存协议(强制要求)
Before starting: Read
After completing: Record patterns to learnings.md
.claude/context/memory/learnings.md
6. **Update catalog**: Add to template-catalog.md under Report Templates
7. **Update README**: Add to reports section in templates README
8. **Assign consumers**: Update security-architect and qa agent references
9. **Update memory**: Record in learnings.md开始前: 阅读
完成后: 将模式记录到learnings.md
.claude/context/memory/learnings.md
6. **更新目录**:在Report模板类别下添加到template-catalog.md
7. **更新README**:在templates README的报告章节添加条目
8. **分配消费者**:更新security-architect和qa Agent的引用
9. **更新内存**:在learnings.md中记录Example 2: Creating a Spawn Template
示例2:创建Spawn模板
Request: "Create a template for specialized agent spawn prompts"
Process:
- Research: Invoke , review
research-synthesis.claude/templates/spawn/universal-agent-spawn.md - Gather: Analyze spawn pattern, specialized vs general-purpose
- Validate name: matches name regex
specialized-agent-spawn - Design: Structure for specialized spawn prompts with security considerations (SEC-TC-001)
- Create:
.claude/templates/spawn/specialized-agent-spawn.md
markdown
---请求: "创建专用Agent启动提示模板"
流程:
- 研究:调用,查看
research-synthesis.claude/templates/spawn/universal-agent-spawn.md - 收集需求:分析启动模式、专用与通用的区别
- 验证名称:符合名称正则
specialized-agent-spawn - 设计:专用启动提示的结构,考虑安全要求(SEC-TC-001)
- 创建:
.claude/templates/spawn/specialized-agent-spawn.md
markdown
---[REQUIRED] Template identifier
[必填] 模板标识符
name: { { TEMPLATE_NAME } }
name: { { TEMPLATE_NAME } }
[REQUIRED] Agent type this template spawns
[必填] 本模板启动的Agent类型
agent_type: { { AGENT_TYPE } }
agent_type: { { AGENT_TYPE } }
[REQUIRED] Recommended model: haiku, sonnet, opus
[必填] 推荐模型:haiku, sonnet, opus
model: { { MODEL:sonnet } }
model: { { MODEL:sonnet } }
[OPTIONAL] Task complexity level
[可选] 任务复杂度级别
complexity: { { COMPLEXITY:medium } }
complexity: { { COMPLEXITY:medium } }
{{AGENT_DISPLAY_NAME}} Spawn Template
{{AGENT_DISPLAY_NAME}} 启动模板
Security Notice (SEC-TC-001)
安全提示(SEC-TC-001)
Placeholder values substituted into the field MUST be sanitized using
from before substitution.
This prevents prompt injection via user-provided task descriptions.
prompt:sanitizeSubstitutionValue()prompt-factory.cjs替换到字段的占位符值必须使用中的进行清理。
这可防止通过用户提供的任务描述进行提示注入。
prompt:prompt-factory.cjssanitizeSubstitutionValue()Usage
用途
Use this template when spawning {{AGENT_TYPE}} agents.
启动{{AGENT_TYPE}} Agent时使用本模板。
Spawn Pattern
启动模式
Task({
subagent_type: '{{AGENT_TYPE}}',
model: '{{MODEL}}',
task_id: '{{TASK_ID}}',
prompt: 'You are {{AGENT_IDENTITY}}. ... TaskUpdate protocol ...'
});
Task({
subagent_type: '{{AGENT_TYPE}}',
model: '{{MODEL}}',
task_id: '{{TASK_ID}}',
prompt: '你是{{AGENT_IDENTITY}}。... TaskUpdate协议 ...'
});
Validation
验证
After using this template:
- task_id is unique and matches prompt
- Model matches agent complexity requirements
- TaskUpdate protocol included in prompt
- Success criteria clearly defined
- No unsanitized user input in prompt field
6. **Update catalog**: Add to template-catalog.md under Spawn Templates
7. **Update README**: Add to spawn section in templates README
8. **Update CLAUDE.md**: Add to Section 2 (Spawn Templates) if framework-standard
9. **Assign consumers**: Update router and spawn-template-resolver references
10. **Update memory**: Record in learnings.md
---使用本模板后:
- task_id唯一且与提示匹配
- 模型符合Agent复杂度要求
- 提示中包含TaskUpdate协议
- 成功标准清晰定义
- 提示字段中无未清理的用户输入
6. **更新目录**:在Spawn模板类别下添加到template-catalog.md
7. **更新README**:在templates README的spawn章节添加条目
8. **更新CLAUDE.md**:若为框架标准模板,添加到第2节(Spawn模板)
9. **分配消费者**:更新router和spawn-template-resolver的引用
10. **更新内存**:在learnings.md中记录
---Troubleshooting
故障排除
Issue: Placeholders Not Rendering
问题:占位符未渲染
Symptoms: appears in final file
{{PLACEHOLDER}}Solution:
- Check placeholder format (double braces, UPPER_CASE)
- Ensure user replaced all placeholders
- Add validation command to catch unreplaced
症状: 最终文件中出现
{{PLACEHOLDER}}解决方案:
- 检查占位符格式(双大括号、大写)
- 确保用户已替换所有占位符
- 添加验证命令检查未替换的占位符
Issue: Template Not Discoverable
问题:模板不可发现
Symptoms: Template exists but not found by creators
Solution:
- Verify template-catalog.md is updated (Step 8)
- Verify README.md is updated (Step 9)
- Check file is in correct directory
- Run:
grep "<template-name>" .claude/context/artifacts/catalogs/template-catalog.md
症状: 模板存在但创建者无法找到
解决方案:
- 验证template-catalog.md已更新(步骤8)
- 验证README.md已更新(步骤9)
- 检查文件是否在正确的目录中
- 运行:
grep "<template-name>" .claude/context/artifacts/catalogs/template-catalog.md
Issue: Inconsistent Template Structure
问题:模板结构不一致
Symptoms: Different templates have different formats
Solution:
- Review existing templates before creating
- Use this skill's patterns
- Compare against reference template (universal-agent-spawn.md)
- Run consistency check across templates
症状: 不同模板格式不同
解决方案:
- 创建前查看现有模板
- 使用本Skill的模式
- 与参考模板(universal-agent-spawn.md)对比
- 运行跨模板一致性检查
Issue: Spawn Template Injection Risk
问题:Spawn模板注入风险
Symptoms: User-provided content in spawn template placeholder could manipulate agent behavior
Solution:
- Review SEC-TC-001 guidance in this skill
- Ensure is referenced
sanitizeSubstitutionValue() - Do not place tokens directly in
{{PLACEHOLDER}}fields for user inputprompt: - Use structured task descriptions that separate user content from system instructions
症状: Spawn模板占位符中的用户提供内容可能操纵Agent行为
解决方案:
- 查看本Skill中的SEC-TC-001指南
- 确保引用了
sanitizeSubstitutionValue() - 禁止将令牌直接用于用户输入的
{{PLACEHOLDER}}字段prompt: - 使用结构化任务描述,将用户内容与系统指令分离
Issue: Creator Guard Blocking Template Write
问题:Creator Guard拦截模板写入
Symptoms: blocks your template write
unified-creator-guard.cjsSolution:
- Ensure you invoked this skill properly:
Skill({ skill: 'template-creator' }) - Check that the creator state is active (3-minute TTL)
- If debugging: (temporary, restore to
CREATOR_GUARD=warnafter)block - Never use in production
CREATOR_GUARD=off
症状: 拦截了模板写入操作
unified-creator-guard.cjs解决方案:
- 确保正确调用本Skill:
Skill({ skill: 'template-creator' }) - 检查创建者状态是否活跃(3分钟TTL)
- 调试时可使用:(临时使用,之后恢复为
CREATOR_GUARD=warn)block - 生产环境中禁止使用
CREATOR_GUARD=off
Memory Protocol (MANDATORY)
内存协议(强制要求)
Before starting:
bash
cat .claude/context/memory/learnings.mdCheck for:
- Previously created templates
- Known template patterns
- User preferences for template behavior
After completing:
- New template pattern ->
.claude/context/memory/learnings.md - Issue found ->
.claude/context/memory/issues.md - Decision made ->
.claude/context/memory/decisions.md
ASSUME INTERRUPTION: If it's not in memory, it didn't happen.
开始前:
bash
cat .claude/context/memory/learnings.md检查内容:
- 之前创建的模板
- 已知的模板模式
- 用户对模板行为的偏好
完成后:
- 新模板模式 ->
.claude/context/memory/learnings.md - 发现的问题 ->
.claude/context/memory/issues.md - 做出的决策 ->
.claude/context/memory/decisions.md
假设会被中断:未记录到内存中的操作视为未发生。
Post-Creation Integration
创建后集成
After creation completes, run the ecosystem integration checklist:
- Call from
runIntegrationChecklist(artifactType, artifactPath).claude/lib/creators/creator-commons.cjs - Call from
queueCrossCreatorReview(artifactType, artifactPath).claude/lib/creators/creator-commons.cjs - Review the impact report — address all items before marking task complete
mustHave - Log any items as follow-up tasks
shouldHave
Integration verification:
- Template added to template-catalog.md
- Template README exists at template location
- Template assigned to consuming skill(s)
- Template examples provided
创建完成后,运行生态系统集成检查清单:
- 调用中的
.claude/lib/creators/creator-commons.cjsrunIntegrationChecklist(artifactType, artifactPath) - 调用中的
.claude/lib/creators/creator-commons.cjsqueueCrossCreatorReview(artifactType, artifactPath) - 查看影响报告 — 在标记任务完成前解决所有项
mustHave - 将项记录为后续任务
shouldHave
集成验证:
- 模板已添加到template-catalog.md
- 模板位置存在模板README
- 模板已分配给消费型Skill
- 提供了模板示例
Ecosystem Alignment Contract (MANDATORY)
生态系统对齐契约(强制要求)
This creator skill is part of a coordinated creator ecosystem. Any artifact created here must align with and validate against related creators:
- for ownership and execution paths
agent-creator - for capability packaging and assignment
skill-creator - for executable automation surfaces
tool-creator - for enforcement and guardrails
hook-creator - and
rule-creatorfor policy and static checkssemgrep-rule-creator - for standardized scaffolds
template-creator - for orchestration and phase gating
workflow-creator - for user/operator command UX
command-creator
本Creator Skill是协同Creator生态系统的一部分。在此创建的任何工件必须与相关创建者对齐并验证:
- :所有权和执行路径
agent-creator - :能力打包和分配
skill-creator - :可执行自动化接口
tool-creator - :强制管控和护栏
hook-creator - 和
rule-creator:策略和静态检查semgrep-rule-creator - :标准化脚手架
template-creator - :编排和阶段门控
workflow-creator - :用户/操作员命令UX
command-creator
Cross-Creator Handshake (Required)
跨Creator握手(必填)
Before completion, verify all relevant handshakes:
- Artifact route exists in and related routing docs.
.claude/CLAUDE.md - Discovery/registry entries are updated (catalog/index/registry as applicable).
- Companion artifacts are created or explicitly waived with reason.
- passes for the created artifact.
validate-integration.cjs - Skill index is regenerated when skill metadata changes.
完成前,验证所有相关握手:
- 工件路由在和相关路由文档中存在。
.claude/CLAUDE.md - 发现/注册表条目已更新(适用的目录/索引/注册表)。
- 已创建配套工件或明确说明放弃原因。
- 已创建工件通过验证。
validate-integration.cjs - Skill元数据更改时重新生成Skill索引。
Research Gate (Exa First, arXiv Fallback)
研究门限(优先使用Exa,备用arXiv)
For new patterns, templates, or workflows, research is mandatory:
- Use Exa first for implementation and ecosystem patterns.
- If Exa is insufficient, use plus arXiv references.
WebFetch - Record decisions, constraints, and non-goals in artifact references/docs.
- Keep updates minimal and avoid overengineering.
对于新模式、模板或工作流,研究是强制要求:
- 优先使用Exa查找实现和生态系统模式。
- 若Exa信息不足,使用加arXiv参考。
WebFetch - 在工件参考/文档中记录决策、约束和非目标。
- 最小化更新,避免过度设计。
Regression-Safe Delivery
回归安全交付
- Follow strict RED -> GREEN -> REFACTOR for behavior changes.
- Run targeted tests for changed modules.
- Run lint/format on changed files.
- Keep commits scoped by concern (logic/docs/generated artifacts).
- 行为变更遵循严格的RED -> GREEN -> REFACTOR流程。
- 对变更模块运行针对性测试。
- 对变更文件运行lint/格式化。
- 提交按关注点划分(逻辑/文档/生成的工件)。