Problem
When a template file's content is entirely wrapped in a conditional that evaluates to false, the template produces an empty string. Currently, ailloy cast still writes this empty string to disk, creating empty files in the target project.
This is common with multi-agent molds where files are conditional on agent.targets:
{{- if has "claude" .agent.targets -}}
[file content]
{{- end -}}
When casting with --set agent.targets="[copilot]", the above produces an empty CLAUDE.md file — polluting the target project.
Proposed Solution
After ProcessTemplate() returns the rendered content, check if strings.TrimSpace(processed) == "". If so, skip os.WriteFile and optionally log a debug message.
Suggested location: internal/commands/cast.go in the file-writing loop, after template processing and before os.WriteFile.
Use Case
This is needed for the nimble-mold multi-agent output architecture (nimble-giant/nimble-mold#3). Molds that target multiple agents (Claude, Copilot, Cursor) use content-level conditionals to include/exclude files based on agent.targets. Without this fix, non-targeted agent files are written as empty files.
Acceptance Criteria
- Files whose template output is empty (whitespace-only after trimming) are not written to disk
- A debug/verbose log message indicates the file was skipped
- Files with actual content continue to be written normally
Problem
When a template file's content is entirely wrapped in a conditional that evaluates to false, the template produces an empty string. Currently,
ailloy caststill writes this empty string to disk, creating empty files in the target project.This is common with multi-agent molds where files are conditional on
agent.targets:{{- if has "claude" .agent.targets -}} [file content] {{- end -}}When casting with
--set agent.targets="[copilot]", the above produces an emptyCLAUDE.mdfile — polluting the target project.Proposed Solution
After
ProcessTemplate()returns the rendered content, check ifstrings.TrimSpace(processed) == "". If so, skipos.WriteFileand optionally log a debug message.Suggested location:
internal/commands/cast.goin the file-writing loop, after template processing and beforeos.WriteFile.Use Case
This is needed for the nimble-mold multi-agent output architecture (nimble-giant/nimble-mold#3). Molds that target multiple agents (Claude, Copilot, Cursor) use content-level conditionals to include/exclude files based on
agent.targets. Without this fix, non-targeted agent files are written as empty files.Acceptance Criteria