Skip to content

refactor: convert scaffold templates to claude-native format with unified mode dispatch#136

Merged
l50 merged 2 commits into
mainfrom
scaffold-claude-native
Jul 2, 2026
Merged

refactor: convert scaffold templates to claude-native format with unified mode dispatch#136
l50 merged 2 commits into
mainfrom
scaffold-claude-native

Conversation

@l50

@l50 l50 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Key Changes:

  • Replaced Go template conditional blocks ({{if eq .Mode ...}}) with a single unified prompt that dispatches mode at runtime via natural language keywords, making the scaffolded files compatible with Claude Code's native agent format
  • Added YAML frontmatter to system.md.tmpl so generated agents work directly as Claude Code subagents via symlink
  • Consolidated duplicate edit/readonly rule sets into a single document with clearly labeled mode-specific subsections, reducing template size by ~35%
  • Added a test asserting that rendered output opens with YAML frontmatter and contains no residual template syntax

Added:

  • YAML frontmatter block in system.md.tmpl — includes name, description, tools, and model fields so the generated system.md doubles as a Claude Code agent definition without modification
  • TestRenderClaudeNativeOutput test in scaffold/templates_test.go — verifies frontmatter presence, agent name field, and absence of {{ in all three rendered template outputs

Changed:

  • Mode dispatch strategy across all templates — replaced compile-time {{if eq .Mode "edit"}} / {{if eq .Mode "readonly"}} branching with runtime keyword detection ("readonly", "report only", "analysis only", "do not modify"), so a single rendered file handles both modes
  • system.md.tmpl hard rules — merged the two separate numbered lists into one document with ## Edit-mode rules and ## Readonly-mode rules subsections; trimmed redundant phrasing and consolidated rules 10 and 17–19 for concision
  • system.md.tmpl workflow phases — collapsed the duplicated Phase 3 and Phase 4 blocks into a single shared sequence with inline mode annotations; removed the redundant "Read after writing" step in favor of trusting the Edit tool's output
  • system.md.tmpl output format — converted top-level ## report sections to ###/#### headings nested under ## Edit-mode report and ## Readonly-mode report headers; inlined "What was changed" / "Why" and "What is wrong" / "Suggested fix" labels to reduce vertical space
  • agent.md.tmpl — rewrote as a single unified execution rules block with "Edit mode only" and "Readonly mode only" subsections; collapsed output compliance into a single paragraph referencing system.md rather than duplicating the full section list
  • task.md.tmpl — merged the two conditional task prompts into one paragraph that states the default (fix in place) and the opt-in keyword for readonly; removed the trailing {{end}} blocks
  • README.md.tmpl — updated mode description from "conditional prompts via Go template syntax" to "dispatched at runtime" and added the Claude Code symlink instruction with trigger keyword examples

Removed:

  • All {{if eq .Mode "edit"}} / {{if eq .Mode "readonly"}} / {{end}} conditional blocks from all four templates — mode selection is now entirely prose-driven at runtime
  • Duplicate rule sets — the standalone readonly HARD RULES section and the standalone edit HARD RULES section are replaced by the unified two-subsection layout
  • Separate Code to review and fix: / Code to analyze (read-only): INPUT labels — replaced with a single label that describes both modes

l50 added 2 commits July 2, 2026 14:45
**Added:**

- `TestRenderClaudeNativeOutput` test in `scaffold/templates_test.go` — asserts that the rendered `system.md` opens with YAML frontmatter containing the agent name, and that none of the rendered prompt files contain leftover `{{` template syntax

**Changed:**

- `system.md.tmpl` — replaced Go template `{{if eq .Mode ...}}` branching with a single unified prompt that dispatches mode at runtime via prose keywords ("readonly", "report only", etc.); added YAML frontmatter (`name`, `description`, `tools`, `model`) so the rendered file works as a Claude Code sub-agent without modification; collapsed duplicate edit/readonly rule sections into clearly labelled `## Edit-mode rules` and `## Readonly-mode rules` blocks; tightened wording throughout to reduce token count
- `agent.md.tmpl` — removed `{{if eq .Mode}}` conditionals; merged edit and readonly execution rules into one block with mode-specific sub-sections; condensed output compliance instructions to reference `system.md` sections by name rather than repeating them inline
- `task.md.tmpl` — collapsed separate edit/readonly template branches into a single task prompt that describes both modes in prose; replaced `≤` with `<=` for plain-text compatibility
- `README.md.tmpl` — updated modes description to reflect runtime dispatch; added instructions for symlinking `system.md` into `~/.claude/agents/` to reuse the same file as a Claude Code agent
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@l50 l50 merged commit a35a321 into main Jul 2, 2026
5 checks passed
@l50 l50 deleted the scaffold-claude-native branch July 2, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant