Files
Claude-Code-Workflow/.claude/skills/command-generator/phases/03-template-loading.md
catlog22 3b92bfae8c feat: add Discuss and Explore subagents for dynamic critique and code exploration
- Implement Discuss Subagent for multi-perspective critique with dynamic perspectives.
- Create Explore Subagent for shared codebase exploration with centralized caching.
- Add tests for CcwToolsMcpCard component to ensure enabled tools are preserved on config save.
- Introduce SessionPreviewPanel component for previewing and selecting sessions for Memory V2 extraction.
- Develop CommandCreateDialog component for creating/importing commands with import and CLI generate modes.
2026-02-27 17:25:52 +08:00

2.5 KiB

Phase 3: Template Loading

Load the command template file for content generation.

Objective

Load the command template from the skill's templates directory. The template provides:

  • YAML frontmatter structure
  • Placeholder variables for substitution
  • Standard command file sections

Input

From Phase 2:

{
  targetPath: string,
  targetDir: string,
  fileName: string,
  fileExists: boolean,
  params: {
    skillName: string,
    description: string,
    location: string,
    group: string | null,
    argumentHint: string
  }
}

Template Location

.claude/skills/command-generator/templates/command-md.md

Execution Steps

Step 1: Locate Template File

// Template is located in the skill's templates directory
const skillDir = '.claude/skills/command-generator';
const templatePath = `${skillDir}/templates/command-md.md`;

Step 2: Read Template Content

const templateContent = Read(templatePath);

if (!templateContent) {
  throw new Error(`Command template not found at ${templatePath}`);
}

Step 3: Validate Template Structure

// Verify template contains expected placeholders
const requiredPlaceholders = ['{{name}}', '{{description}}'];
const optionalPlaceholders = ['{{group}}', '{{argumentHint}}'];

for (const placeholder of requiredPlaceholders) {
  if (!templateContent.includes(placeholder)) {
    throw new Error(`Template missing required placeholder: ${placeholder}`);
  }
}

Step 4: Store Template for Next Phase

const template = {
  content: templateContent,
  requiredPlaceholders: requiredPlaceholders,
  optionalPlaceholders: optionalPlaceholders
};

Template Format Reference

The template should follow this structure:

---
name: {{name}}
description: {{description}}
{{#if group}}group: {{group}}{{/if}}
{{#if argumentHint}}argument-hint: {{argumentHint}}{{/if}}
---

# {{name}} Command

[Template content with placeholders]

Output

{
  status: 'loaded',
  template: {
    content: templateContent,
    requiredPlaceholders: requiredPlaceholders,
    optionalPlaceholders: optionalPlaceholders
  },
  targetPath: targetPath,
  params: params
}

Error Handling

Error Action
Template file not found Throw error with path
Missing required placeholder Throw error with missing placeholder name
Empty template Throw error

Next Phase

Proceed to Phase 4: Content Formatting with template, targetPath, and params.