Skip to content

gh aw fix dry-run mutates dispatcher files without --write #47141

Description

@PureWeen

Summary

gh aw fix modifies repository files even when run without --write, despite its documented dry-run contract: “Without --write (dry-run mode), no files are modified.”

The command rewrites .github/agents/agentic-workflows.md and can rewrite .github/skills/agentic-workflows/SKILL.md whenever those files differ from the bundled/current dispatcher templates.

Confirmed with stable v0.82.14, v0.82.15 prerelease, and current public main.

Minimal reproduction

In a throwaway repository:

git init
gh aw init
printf '\n<!-- preserve-this-local-change -->\n' >> .github/agents/agentic-workflows.md
git add . && git commit -m baseline
gh aw fix --verbose
git diff --exit-code

gh aw fix reports that it updated the custom agent and git diff shows the file was overwritten, despite no --write flag.

Expected behavior

Dry-run mode reports what would change but does not modify any file.

Actual behavior

The dispatcher agent and skill are written immediately when their content differs from the generated templates.

Root cause

pkg/cli/fix_command.go correctly passes the write flag to workflow codemods, but runFixCommand later calls these functions unconditionally:

ensureAgenticWorkflowsDispatcher(verbose, false)
ensureAgenticWorkflowsAgent(verbose)

Both functions write files through os.WriteFile when content differs and do not receive the dry-run flag.

TestFixCommand_UpdatesPromptAndAgentFiles currently uses Write: false while asserting that files are created or overwritten, so the test codifies behavior that conflicts with the CLI help.

Agentic implementation plan

  1. Pass the write/dry-run state into dispatcher artifact refresh.
  2. When write == false, compare content without writing and report Would update ... when a difference exists.
  3. When write == true, preserve the current update behavior.
  4. Split or update TestFixCommand_UpdatesPromptAndAgentFiles to cover both modes:
    • dry-run leaves existing files byte-for-byte unchanged;
    • --write updates the agent and skill.
  5. Update gh aw fix --help to explicitly list dispatcher agent/skill refresh among write-mode actions.

This preserves useful drift reporting while honoring the documented no-write guarantee.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions