Skip to content

fix(cli): implement --force flag to protect existing skill files#324

Merged
mrgoonie merged 1 commit into
nextlevelbuilder:mainfrom
alfredo-petri:fix/force-flag-implementation
Jun 21, 2026
Merged

fix(cli): implement --force flag to protect existing skill files#324
mrgoonie merged 1 commit into
nextlevelbuilder:mainfrom
alfredo-petri:fix/force-flag-implementation

Conversation

@alfredo-petri

Copy link
Copy Markdown
Contributor

Problem

--force is registered in index.ts and described in the README, but has no effect. template.ts calls writeFile() unconditionally without checking whether the file already exists.

This means:

  • Users running uipro init a second time silently overwrite their customized skill files
  • The --force flag advertised in the README is misleading — it does nothing

Fix

Add a file existence check in generatePlatformFiles before calling writeFile:

  • If file exists and --force was not passed → skip with a clear message
  • If file exists and --force was passed → overwrite (previous behavior for all cases)
  • Propagate force through generateAllPlatformFilestemplateInstallinitCommand

Behavior after this PR

uipro init --ai claude          # skips if SKILL.md already exists, prints warning
uipro init --ai claude --force  # overwrites regardless

🤖 Generated with Claude Code

The --force option was accepted by Commander but ignored: writeFile()
always overwrote existing files silently. Users expecting protection
against accidental overwrites had no way to preserve existing configs.

- generatePlatformFiles: check file existence before writing; skip with
  a clear message when file exists and force=false
- generateAllPlatformFiles / templateInstall: propagate force parameter
- initCommand: pass options.force through to templateInstall

Behavior change:
  uipro init --ai claude         → skips if SKILL.md already exists
  uipro init --ai claude --force → overwrites regardless

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@mrgoonie mrgoonie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary: This is a focused fix for the advertised --force behavior in the template installer path. It correctly threads the force option through init -> templateInstall -> generatePlatformFiles and prevents accidental overwrite of an existing generated skill file when --force is absent.

Risk level: Low

Mandatory gates:

  • Duplicate/prior implementation: clear — searched existing issues/PRs for the force/overwrite behavior and found no overlapping implementation besides this PR.
  • Project standards: passed — the change stays inside the CLI init/template generation path and reuses the existing fs access helper pattern.
  • Strategic necessity: clear value — avoiding silent overwrites protects user-customized skill files and makes the documented --force flag meaningful.
  • CI/checks: missing/unstable — no status checks are reported for this PR in GitHub, and this cron environment does not have bun installed to run the package build.

Findings:

  • Critical: none.
  • Important: none.
  • Suggestion: consider adding a small CLI/template unit or smoke test later for the no-force skip path and the --force overwrite path, because this behavior is easy to regress.

Verdict: APPROVE

@mrgoonie mrgoonie added agent:github-maintain Processed by github-maintain automation pr:reviewed PR reviewed by maintain workflow pr:approved-by-maintain Approved by github-maintain workflow labels Jun 21, 2026
@mrgoonie mrgoonie merged commit c522197 into nextlevelbuilder:main Jun 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:github-maintain Processed by github-maintain automation pr:approved-by-maintain Approved by github-maintain workflow pr:reviewed PR reviewed by maintain workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants