phase: 72
status: planned
created: 2026-03-02
template: phase-prompt
variant: standard
Phase 72: OAuth2 Authentication
...
### 7. Template Discovery
List available templates:
Available templates:
project - Project definition (PROJECT.md)
requirements - Requirements specification (REQUIREMENTS.md)
roadmap - Development roadmap (ROADMAP.md)
state - Project state (STATE.md)
context - Phase context (CONTEXT.md)
summary - Phase summary (SUMMARY.md) [3 variants]
phase-prompt - Phase plan (PLAN.md)
...
### 8. Template Variant Selection
Automatic variant selection based on context:
```javascript
function selectSummaryVariant(context) {
if (context.isQuickTask) return 'summary-minimal';
if (context.taskCount <= 3) return 'summary-minimal';
if (context.taskCount <= 8) return 'summary-standard';
return 'summary-complex';
}
Tool Use Instructions
Loading and Filling a Template
- Use
Glob to locate the template file in templates/
- Use
Read to load the template content
- Replace all
{{VARIABLE}} placeholders with provided values
- Process conditional blocks (
{{#if}}...{{/if}}, {{#unless}}...{{/unless}})
- Add frontmatter if specified
- Use
Write to save the filled template to the target path
Batch Generation
- Accept list of template-to-target mappings
- Load each template, fill variables with shared + per-file data
- Write all files, collecting results
- Return list of generated files
Template Discovery
- Use
Glob to find all .md and .json files in templates/
- Read first line of each to extract template name/purpose
- Return formatted list
Process Integration
new-project.js - Batch generate PROJECT.md, REQUIREMENTS.md, ROADMAP.md, STATE.md
discuss-phase.js - Generate CONTEXT.md from context template
plan-phase.js - Generate PLAN.md files from phase-prompt template
verify-work.js - Generate UAT.md from uat template
quick.js - Generate plan and summary using minimal variants
debug.js - Generate debug session file from debug template
complete-milestone.js - Generate milestone archive from milestone-archive template
add-tests.js - Generate test plan structure
research-phase.js - Generate RESEARCH.md from research template
map-codebase.js - Batch generate 7 codebase analysis documents
Output Format
{
"operation": "fill|batch|discover",
"status": "success|error",
"template": "project",
"variant": "standard",
"targetPath": ".planning/PROJECT.md",
"variablesFilled": 12,
"conditionalsProcessed": 3,
"generatedFiles": [
".planning/PROJECT.md",
".planning/REQUIREMENTS.md"
]
}
Configuration
| Setting |
Default |
Description |
templatesDir |
templates/ |
Directory containing template files |
summaryVariant |
standard |
Default summary variant |
injectFrontmatter |
true |
Auto-add frontmatter to generated files |
variableDelimiter |
{{...}} |
Variable placeholder syntax |
Error Handling
| Error |
Cause |
Resolution |
Template not found |
Template name does not match any file |
List available templates, suggest closest match |
Unfilled variable |
Variable not provided in data |
Use empty string or placeholder marker |
Target path exists |
File already at target location |
Prompt for overwrite/append/skip |
Invalid conditional |
Malformed if/unless block |
Fix template syntax |
Batch partial failure |
Some files in batch failed |
Report which succeeded and which failed |
Constraints
- Templates must be idempotent (filling same template with same data produces same output)
- Never modify template source files; only read them
- Generated files must be valid markdown (or JSON for config.json)
- Variable names must be uppercase with underscores only
- Conditional blocks must be properly nested and closed
- Batch operations are all-or-nothing within a single process call
1---2name: template-scaffolding3description: Template loading, variable filling, and scaffolding for all GSD artifacts. Manages 22+ templates covering every document type in the GSD system, from PROJECT.md to milestone archives.4allowed-tools: Read Write Edit Glob5metadata:6 source: https://skillmd.com/skills/a5c-ai/template-scaffolding7 author: babysitter-sdk8 version: "1.0.0"9 category: gsd-core10 backlog-id: SK-GSD-00411graph:12 domains: [domain:software-engineering]13 skillAreas: [skill-area:agentic-loops, skill-area:orchestration-loop]14 workflows: [workflow:feature-development]15 topics: [topic:developer-experience]16 roles: [role:tech-lead, role:backend-engineer]17- Loads templates by name from the `templates/` directory18- Fills template variables with provided data19- Handles conditional sections (if/unless blocks)20- Writes filled templates to target paths21- Supports template variants (e.g., summary-minimal vs summary-standard vs summary-complex)22- Supports batch generation (e.g., new-project creates 4+ files at once)2324This corresponds to the original `lib/template.cjs` module in the GSD system.2526## Capabilities2728### 1. Template Loading2930Load templates from the `templates/` directory:3132```33templates/34 project.md # .planning/PROJECT.md35 requirements.md # .planning/REQUIREMENTS.md36 roadmap.md # .planning/ROADMAP.md37 state.md # .planning/STATE.md38 context.md # Phase CONTEXT.md39 summary.md # Phase SUMMARY.md (default)40 summary-minimal.md # Quick task summaries41 summary-standard.md # Standard phase summaries42 summary-complex.md # Multi-wave phase summaries43 phase-prompt.md # PLAN.md template44 planner-subagent-prompt.md # Planner agent prompt45 debug-subagent-prompt.md # Debugger agent prompt46 milestone.md # Milestone definition47 milestone-archive.md # Milestone archive wrapper48 config.json # Default configuration49 continue-here.md # Session handoff document50 verification-report.md # VERIFICATION.md template51 research.md # RESEARCH.md template52 uat.md # UAT.md template53 validation.md # VALIDATION.md template54 debug.md # Debug session template55 discovery.md # Discovery phase template56 codebase/ # 7 codebase analysis templates57 architecture.md58 concerns.md59 conventions.md60 integrations.md61 stack.md62 structure.md63 testing.md64 research-project/ # 5 project research templates65 ARCHITECTURE.md66 FEATURES.md67 PITFALLS.md68 STACK.md69 SUMMARY.md70```7172### 2. Variable Filling7374Replace template variables with actual values:7576```markdown77# {{PROJECT_NAME}}7879## Vision80{{PROJECT_VISION}}8182## Current Milestone: {{MILESTONE_VERSION}}8384### Phase {{PHASE_NUMBER}}: {{PHASE_TITLE}}85Started: {{TIMESTAMP}}86Status: {{PHASE_STATUS}}87```8889Variable syntax: `{{VARIABLE_NAME}}` (double curly braces, uppercase with underscores).9091### 3. Conditional Sections9293Handle optional content based on conditions:9495```markdown96{{#if HAS_RESEARCH}}97## Research98See [RESEARCH.md](./RESEARCH.md) for implementation research.99{{/if}}100101{{#unless QUICK_MODE}}102## Detailed Analysis103This section is included in full mode only.104{{/unless}}105```106107### 4. Template Variants108109Select the right variant based on context:110111```112summary:113 minimal -> quick tasks, simple phases (< 3 tasks)114 standard -> typical phases (3-8 tasks)115 complex -> multi-wave phases (9+ tasks, multiple plans)116117Selection logic:118 if quick_task: use summary-minimal119 elif task_count <= 3: use summary-minimal120 elif task_count <= 8: use summary-standard121 else: use summary-complex122```123124### 5. Batch Generation125126Generate multiple files at once:127128```129new-project batch:130 1. .planning/PROJECT.md <- templates/project.md131 2. .planning/REQUIREMENTS.md <- templates/requirements.md132 3. .planning/ROADMAP.md <- templates/roadmap.md133 4. .planning/STATE.md <- templates/state.md134 5. .planning/config.json <- templates/config.json135136map-codebase batch:137 1. .planning/codebase/ARCHITECTURE.md <- templates/codebase/architecture.md138 2. .planning/codebase/STACK.md <- templates/codebase/stack.md139 3. .planning/codebase/STRUCTURE.md <- templates/codebase/structure.md140 4. .planning/codebase/CONVENTIONS.md <- templates/codebase/conventions.md141 5. .planning/codebase/TESTING.md <- templates/codebase/testing.md142 6. .planning/codebase/INTEGRATIONS.md <- templates/codebase/integrations.md143 7. .planning/codebase/CONCERNS.md <- templates/codebase/concerns.md144```145146### 6. Frontmatter Injection147148Add YAML frontmatter to generated documents:149150```markdown151---152153phase: 72154status: planned155created: 2026-03-02156template: phase-prompt157variant: standard158---159160# Phase 72: OAuth2 Authentication161...162```163164### 7. Template Discovery165166List available templates:167168```169Available templates:170 project - Project definition (PROJECT.md)171 requirements - Requirements specification (REQUIREMENTS.md)172 roadmap - Development roadmap (ROADMAP.md)173 state - Project state (STATE.md)174 context - Phase context (CONTEXT.md)175 summary - Phase summary (SUMMARY.md) [3 variants]176 phase-prompt - Phase plan (PLAN.md)177 ...178```179180### 8. Template Variant Selection181182Automatic variant selection based on context:183184```javascript185function selectSummaryVariant(context) {186 if (context.isQuickTask) return 'summary-minimal';187 if (context.taskCount <= 3) return 'summary-minimal';188 if (context.taskCount <= 8) return 'summary-standard';189 return 'summary-complex';190}191```192193## Tool Use Instructions194195### Loading and Filling a Template1961. Use `Glob` to locate the template file in `templates/`1972. Use `Read` to load the template content1983. Replace all `{{VARIABLE}}` placeholders with provided values1994. Process conditional blocks (`{{#if}}...{{/if}}`, `{{#unless}}...{{/unless}}`)2005. Add frontmatter if specified2016. Use `Write` to save the filled template to the target path202203### Batch Generation2041. Accept list of template-to-target mappings2052. Load each template, fill variables with shared + per-file data2063. Write all files, collecting results2074. Return list of generated files208209### Template Discovery2101. Use `Glob` to find all `.md` and `.json` files in `templates/`2112. Read first line of each to extract template name/purpose2123. Return formatted list213214## Process Integration215216- `new-project.js` - Batch generate PROJECT.md, REQUIREMENTS.md, ROADMAP.md, STATE.md217- `discuss-phase.js` - Generate CONTEXT.md from context template218- `plan-phase.js` - Generate PLAN.md files from phase-prompt template219- `verify-work.js` - Generate UAT.md from uat template220- `quick.js` - Generate plan and summary using minimal variants221- `debug.js` - Generate debug session file from debug template222- `complete-milestone.js` - Generate milestone archive from milestone-archive template223- `add-tests.js` - Generate test plan structure224- `research-phase.js` - Generate RESEARCH.md from research template225- `map-codebase.js` - Batch generate 7 codebase analysis documents226227## Output Format228229```json230{231 "operation": "fill|batch|discover",232 "status": "success|error",233 "template": "project",234 "variant": "standard",235 "targetPath": ".planning/PROJECT.md",236 "variablesFilled": 12,237 "conditionalsProcessed": 3,238 "generatedFiles": [239 ".planning/PROJECT.md",240 ".planning/REQUIREMENTS.md"241 ]242}243```244245## Configuration246247| Setting | Default | Description |248|---------|---------|-------------|249| `templatesDir` | `templates/` | Directory containing template files |250| `summaryVariant` | `standard` | Default summary variant |251| `injectFrontmatter` | `true` | Auto-add frontmatter to generated files |252| `variableDelimiter` | `{{...}}` | Variable placeholder syntax |253254## Error Handling255256| Error | Cause | Resolution |257|-------|-------|------------|258| `Template not found` | Template name does not match any file | List available templates, suggest closest match |259| `Unfilled variable` | Variable not provided in data | Use empty string or placeholder marker |260| `Target path exists` | File already at target location | Prompt for overwrite/append/skip |261| `Invalid conditional` | Malformed if/unless block | Fix template syntax |262| `Batch partial failure` | Some files in batch failed | Report which succeeded and which failed |263264## Constraints265266- Templates must be idempotent (filling same template with same data produces same output)267- Never modify template source files; only read them268- Generated files must be valid markdown (or JSON for config.json)269- Variable names must be uppercase with underscores only270- Conditional blocks must be properly nested and closed271- Batch operations are all-or-nothing within a single process call