Use when fixing template issues in create-faster - indentation, spacing, typos, or formatting problems in .hbs files
Fix formatting, spacing, and syntax issues in Handlebars templates systematically.
Core principle: Audit comprehensively, fix consistently, verify output.
Use this skill when:
Do NOT use for:
adding-templates skill)extracting-templates skill)What IS a template: .hbs files in templates/ rendered by Handlebars.
What is NOT a template (generated programmatically, fix in code instead):
package.json files ā generated by package-json-generator.ts.env.example files ā generated by env-generator.tstemplates/
āāā stack/{framework}/ # Stack base files (Next.js, Expo, Hono, TanStack Start)
āāā libraries/{library}/ # Per-app libraries (shadcn, better-auth, mdx, pwa, nativewind)
āāā project/
ā āāā database/{provider}/ # Docker compose files (postgres, mysql)
ā āāā orm/{provider}/ # ORM config + schema (drizzle, prisma)
ā āāā tooling/{tool}/ # Dev tools (biome, husky)
āāā repo/{type}/ # Repo root files (single, turborepo)
YAML Frontmatter (per-file configuration):
---
path: src/lib/db/schema.ts # Output path for single repo
mono:
scope: app | pkg | root # Monorepo scope
path: schema.ts # Monorepo path
only: mono | single # Repo type filter
---
Handlebars helpers:
isMono ā check if turborepohasLibrary "name" ā check if current app has libraryhas "category" "value" ā check database/orm/toolinghasContext "key" ā check if key exists in contextappPort appName ā get port for appeq, ne, and, or ā logical operatorsRendering config (preventIndent: false): Handlebars auto-indents block content to match the helper's indentation. This is a major source of double-indentation issues.
Stack-specific suffix: file.ext.{stack}.hbs (e.g., route-nextjs.ts.nextjs.hbs) ā only included for matching stack.
Problem:
"start": "next start {{#if (isMono)}}--port {{appPort appName}}{{/if}}",
When condition is false, renders:
"start": "next start ", // ā trailing space!
Fix:
"start": "next start{{#if (isMono)}} --port {{appPort appName}}{{/if}}",
Space moved INSIDE conditional.
When {{#if}} evaluates to false on its own line, Handlebars leaves a blank line.
Problem:
{{#if (hasLibrary "mdx")}}
import createMDX from '@next/mdx';
{{/if}}
import type { NextConfig } from 'next';
When mdx not selected: blank line before import.
Fix options:
{{~#if}}...{{~/if}} to strip whitespace (careful: also strips newlines when true)Problem:
{{#if (has "database" "postgres")}}
import { pgTable } from 'drizzle-orm/pg-core';
{{/if}}
{{#if (has "database" "mysql")}}
import { mysqlTable } from 'drizzle-orm/mysql-core';
{{/if}}
One always false ā blank line.
Problem:
{{#if condition}}
content
{{/if}} // ā wrong indent level
Fix: Match surrounding code indentation.
Problem:
<View {{#if (hasLibrary "nativewind")}}className='...'{{/if}}>
When false: <View > (trailing space).
Fix:
<View{{#if (hasLibrary "nativewind")}} className='...'{{/if}}>
digraph fixing_templates {
"Start" [shape=doublecircle];
"Audit ALL templates" [shape=box];
"Identify patterns" [shape=box];
"Group by issue type" [shape=box];
"Fix systematically" [shape=box];
"Verify generation" [shape=box];
"Test renders correctly?" [shape=diamond];
"Fix issues" [shape=box];
"Done" [shape=doublecircle];
"Start" -> "Audit ALL templates";
"Audit ALL templates" -> "Identify patterns";
"Identify patterns" -> "Group by issue type";
"Group by issue type" -> "Fix systematically";
"Fix systematically" -> "Verify generation";
"Verify generation" -> "Test renders correctly?";
"Test renders correctly?" -> "Done" [label="yes"];
"Test renders correctly?" -> "Fix issues" [label="no"];
"Fix issues" -> "Verify generation";
}
DO NOT fix one issue and stop. Audit ALL templates first.
Search for common patterns:
# Trailing spaces before conditionals
grep -r ' {{#if' templates/
# Double spaces in conditionals
grep -r '{{#if ' templates/
# Trailing spaces in general
grep -r ' $' templates/
# Mixed indentation (tabs vs spaces)
grep -rP '\t' templates/
# Consecutive blank lines
grep -rP '\n\n\n+' templates/
# JSX elements with inline conditionals
grep -rn '<[A-Z][a-zA-Z]* {{#if' templates/
# Adjacent mutually-exclusive conditionals
grep -rn '{{/if}}' templates/ | grep -A1 '{{#if'
Count occurrences to know the scope BEFORE starting fixes.
Group similar issues:
Pattern A: Conditional trailing spaces
Pattern B: Blank lines from false conditionals
Pattern C: Wrong indentation
Pattern D: JSON validity issues from conditionals
tsconfig.json.hbs, components.json.hbs, etc.DO ONE pattern type at a time across ALL files.
Don't fix:
DO fix:
Why: Consistency. Same fix applied everywhere.
CRITICAL: Don't assume visual inspection is enough.
Test generation:
# Single repo mode (conditionals = false)
bunx create-faster test-single --app test-single:nextjs
# Turborepo mode (conditionals = true)
bunx create-faster test-turbo --app web:nextjs --app api:hono
Verify:
jq .)cd apps/cli && bun test
All existing tests must pass after template changes.
| Excuse | Reality |
|---|---|
| "I'll just fix this one file" | Audit finds issues across many files. Systematic audit required. |
| "Visual inspection is enough" | Must test actual generation. Trailing spaces invisible. |
| "It's just spacing, not important" | Invalid JSON, broken scripts. Very important. |
| "I'll fix as I find them" | Reactive = missing 90%+ of issues. Proactive audit required. |
| "Too tedious to check all files" | grep does it in 2 seconds. No excuse. |
| "I need to fix package.json.hbs" | Package.json is generated programmatically, not from templates. |
STOP immediately if you think:
These thoughts = baseline failure pattern (fixed 1, missed 100+).
# Trailing spaces before conditionals (most common)
grep -rn ' {{#if' templates/
# Double spaces in conditions
grep -rn '{{#if ' templates/
# JSX elements with inline conditionals
grep -rn '<[A-Z][a-zA-Z]* {{#if' templates/
# All trailing spaces
grep -rn ' $' templates/
# Tabs (should be spaces)
grep -rPn '\t' templates/
# Multiple blank lines
grep -rPn '\n\n\n+' templates/
# Logic bugs: eq with helper name instead of calling helper
grep -rn 'eq hasContext' templates/
grep -rn 'eq hasLibrary' templates/