Skip to content

[feat]: add --no-overwrite flag to add command #10119

@CodeSquar

Description

@CodeSquar

Description

Currently, the shadcn CLI provides an --overwrite flag to automatically replace existing components and a --yes flag to skip setup confirmations. However, there is no flag to automatically skip or say "no" when the CLI detects that a component already exists in the project.

This makes it difficult to automate the installation of multiple components via scripts when we want to ensure that any local customizations made to existing components are preserved without manual intervention.

Proposed Solution

Add a new flag (e.g., --no-overwrite or --skip) to the add command.

When this flag is present:

  • If a component already exists in the target directory, the CLI should skip it instead of prompting the user.
  • The CLI should continue installing any other requested components that do not yet exist.
  • A summary message could be displayed at the end: Skipped X existing components.

Use Case

  1. Mass updates/additions: When running a script to ensure a set of components is present in a project, but wanting to protect those that have already been tailored by the team.
  2. Automation: In environments where an interactive TTY is not available and we want to avoid the "Overwrite?" prompt from hanging the process or forcing a "yes" via other tools.

Affected component/components

All components.

Additional Context

Additional Context

This would be the logical counterpart to the existing -o, --overwrite flag, providing full control over how the CLI handles file collisions in non-interactive modes.

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues and PRs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions