All docs
CLI · caret add

caret add

Copies the files for a single component (and any peer files it declares) into the current project. Files are physical sources — no symlinks, no node_modules dependency, no version bookkeeping. After add, you own the code.

Usage

sh
caret add <component> [--dir <path>]
# or
npx caret-cli add <component>

Flags

FlagDefaultDescription
--dir <path>caret/Target directory (relative to cwd)

Where files come from

The CLI ships its own copy of the registry inside the npm tarball. At add time it searches three locations in order:

  1. Bundled with the package — node_modules/caret-cli/registry/
  2. Workspace dev environment — useful when contributing to Caret itself
  3. Current working directory — for advanced custom registry overrides

First location applies to virtually every consumer.

Example

sh
$ caret add prompt
^ Adding prompt
  text, password, confirm, select, multi-select, number

  + caret/components/prompt/index.tsx
  + caret/components/prompt/shared.tsx
  + caret/components/prompt/text.tsx
  + caret/components/prompt/password.tsx
  + caret/components/prompt/confirm.tsx
  + caret/components/prompt/select.tsx
  + caret/components/prompt/multi-select.tsx
  + caret/components/prompt/number.tsx

 8 file(s) written

Required dependencies:
  npm install ink react

See specs/prompt.md for the full specification.

Runtime dependencies

Each component declares its runtime deps in the registry manifest. add prints them after the copy completes — install once per project, reuse for every subsequent add:

Common depUsed by
ink, reactEvery interactive component (prompt.*, spinner, form, modal, search, pager, toast)
chalkEvery component that emits color (most of them)
figletsplash, logo, textToArt
jimpimageToArt only
qrcodeqrcode component only

Re-running add

Running add for a component you already have copies the latest version on top of your local files. Diff first if you've modified the component — Caret won't ask before overwriting.

Local edits get overwritten
Treat caret add like shadcn add — useful for the first installation, intentional and version-controlled afterwards. If you've forked a component, run git diff before you re-add.

Custom destination

sh
caret add error --dir src/ui
# writes:  src/ui/components/error.ts

Exit codes

CodeMeaning
0All files copied successfully
1Unknown component, missing file, or IO error

See caret list for the full component catalog.