Skip to content

feat(init): add --dry-run flag to preview changes without writing#1032

Open
hed0rah wants to merge 2 commits intortk-ai:developfrom
hed0rah:feat/init-dry-run
Open

feat(init): add --dry-run flag to preview changes without writing#1032
hed0rah wants to merge 2 commits intortk-ai:developfrom
hed0rah:feat/init-dry-run

Conversation

@hed0rah
Copy link
Copy Markdown

@hed0rah hed0rah commented Apr 5, 2026

Summary

  • Adds --dry-run to rtk init so users can preview exactly what files would be created or modified before committing to a global install
  • All write operations (hook files, settings.json patches, RTK.md, .clinerules, .windsurfrules, etc.) are guarded — output shows [dry-run] would write: <abs_path> instead of touching the filesystem
  • Combines with --verbose (-v) to also print the full file contents that would be written, making it useful for auditing or CI validation

Test plan

  • rtk init -g --dry-run — prints paths, no files created, verify with rtk init --show still showing "not installed"
  • rtk init -g --dry-run -v — same as above but also prints file contents inline
  • rtk init -g then rtk init -g --dry-run — "already up to date" shown for existing files instead of silently skipping
  • rtk init --agent cline --dry-run — shows abs path to .clinerules in current dir
  • rtk init --agent windsurf --dry-run — same for .windsurfrules
  • rtk init -g --gemini --dry-run — shows hook file + settings.json patch
  • Verify no files/directories are created under any flag combination with --dry-run

Adds `--dry-run` to `rtk init` and all sub-modes (default, hook-only,
claude-md, codex, cline, windsurf, gemini, copilot, opencode).

When `--dry-run` is passed:
- No files are created, updated, or patched
- Each would-be write prints: `[dry-run] would create/update <abs-path>`
- Files already up to date still report their absolute path
- Combined with `-v` / `--verbose`: prints the full content that would
  be written, including for already-present files

Examples:
  rtk init -g --dry-run          # preview global install, no side effects
  rtk init --agent cline --dry-run -v  # preview + show full content
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 5, 2026

CLA assistant check
All committers have signed the CLA.

…n. footer

In dry-run mode, all final success/confirmation messages ("hook installed",
"Restart X. Test with: git status", "Cascade will now use rtk...") were
printing unconditionally after write-guarded blocks, making the output look
like changes were actually applied.

Gate all per-mode success blocks behind `if !dry_run`. Add a consistent
`[dry-run] Nothing written.` footer to every init sub-mode so users have
unambiguous confirmation that no filesystem changes occurred.

Affected modes: claude-code, hook-only, claude-md, cline, windsurf,
opencode, gemini.
@hed0rah
Copy link
Copy Markdown
Author

hed0rah commented Apr 5, 2026

suppressed misleading success messages like "Gemini CLI hook installed (global)." and "Restart Gemini CLI. Test with: git status" that were printing even in dry-run, and printed: [dry-run] Nothing written. instead

@aeppling aeppling self-assigned this Apr 7, 2026
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.

3 participants