refactor: convert scaffold templates to claude-native format with unified mode dispatch#136
Merged
Conversation
**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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Key Changes:
{{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 formatsystem.md.tmplso generated agents work directly as Claude Code subagents via symlinkAdded:
system.md.tmpl— includesname,description,tools, andmodelfields so the generatedsystem.mddoubles as a Claude Code agent definition without modificationTestRenderClaudeNativeOutputtest inscaffold/templates_test.go— verifies frontmatter presence, agent name field, and absence of{{in all three rendered template outputsChanged:
{{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 modessystem.md.tmplhard rules — merged the two separate numbered lists into one document with## Edit-mode rulesand## Readonly-mode rulessubsections; trimmed redundant phrasing and consolidated rules 10 and 17–19 for concisionsystem.md.tmplworkflow 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 outputsystem.md.tmploutput format — converted top-level##report sections to###/####headings nested under## Edit-mode reportand## Readonly-mode reportheaders; inlined "What was changed" / "Why" and "What is wrong" / "Suggested fix" labels to reduce vertical spaceagent.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 referencingsystem.mdrather than duplicating the full section listtask.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}}blocksREADME.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 examplesRemoved:
{{if eq .Mode "edit"}}/{{if eq .Mode "readonly"}}/{{end}}conditional blocks from all four templates — mode selection is now entirely prose-driven at runtimeCode to review and fix:/Code to analyze (read-only):INPUT labels — replaced with a single label that describes both modes