CLI
Commands, flags, tdpxl.json, and exactly what the CLI does to your files.
The CLI is published as @tdpxl/cli; its binary is tdpxl. Run it with npx
(or pnpm dlx, bunx, yarn dlx) from the root of your project:
npx @tdpxl/cli <command> [options]Commands
init
npx @tdpxl/cli initChecks Tailwind v4 and the path alias, finds the stylesheet that imports
Tailwind, writes tdpxl.json and installs the utils and theme items. See
Installation for each step.
| Flag | Effect |
|---|---|
--css <file> | The stylesheet that imports Tailwind, when detection picks the wrong one or none |
-f, --force | Replace an existing tdpxl.json and the theme section without asking |
-y, --yes | Never prompt |
--skip-install | Do not install npm packages; print them instead |
--registry <url or path> | Registry to record in tdpxl.json |
--cwd <dir> | Project directory (default: the current directory) |
add
npx @tdpxl/cli add <items...>
npx @tdpxl/cli add button dialog
npx @tdpxl/cli add use-mobile chart-bar-stacked dashboard-01Resolves each item and all of its registry dependencies (depth first, each item
once), writes the files, rewrites imports and installs missing npm packages.
Requires tdpxl.json, so run init first.
| Flag | Effect |
|---|---|
-o, --overwrite | Replace existing files that differ |
-y, --yes | Never prompt; keep differing files unless --overwrite |
--dry-run | Print what would be created, updated or skipped and which packages would be installed; write nothing |
--skip-install | Do not install npm packages; print them instead |
--registry <url or path> | Use this registry instead of the one in tdpxl.json |
--cwd <dir> | Project directory |
list
npx @tdpxl/cli list
npx @tdpxl/cli list --type ui
npx @tdpxl/cli list --type block --jsonPrints the registry catalogue grouped by type. --type accepts ui, hook,
block, lib or theme; charts and blocks are both block. --json prints
name, type, title and description for each item. list also works
outside a project: without tdpxl.json it reads the default registry.
diff
npx @tdpxl/cli diff
npx @tdpxl/cli diff button theme
npx @tdpxl/cli diff --jsonFor each installed item (or the ones named), compares three things: the version
in tdpxl-lock.json with the registry's, each local file with what was installed
(were you editing it?), and the local file with what the new version would write.
It prints the state of every file that is not up to date and a unified diff from
the local copy to the new registry output, after the same import rewriting add
does. Writes nothing.
| State | Meaning |
|---|---|
update | The registry changed; your copy did not. update replaces it |
modified | You edited it; the registry has nothing new. update leaves it alone |
diverged | Both changed. update merges them (three-way) |
missing | The registry changed and you deleted the file. Restored only with --force |
added | The new version ships a file the installed one did not |
removed | The new version no longer ships this file |
--json prints { registry, items: [{ name, installed, latest, newer, upstreamChanged, localModified, files: [{ path, target, kind, state, localModified, upstreamChanged, baseAvailable, diff }] }] }.
update
npx @tdpxl/cli update # every installed item
npx @tdpxl/cli update button --dry-run
npx @tdpxl/cli update button --mergeBrings installed items to the registry's version, file by file:
- Not edited locally: replaced with the new version.
- Edited locally: three-way merge. The base is what the installed version
wrote (rebuilt from
.tdpxl/base/), ours is your file and theirs is the new version, both after import rewriting. Changes to different regions combine; the result is written and keeps counting as edited. - Conflicts: the file is skipped and reported, and the item stays at its
installed version for that file. With
--mergethe file is written with git-style markers (<<<<<<< local,=======,>>>>>>> tdpxl <version>) for you to resolve.
New registry dependencies of the new version are added, and missing npm packages
are installed as in add. Exit code 1 when a file was skipped or written with
conflict markers.
| Flag | Effect |
|---|---|
--dry-run | Print what each file would get (updated, merged, conflict, skipped…); write nothing |
--merge | Write conflict markers instead of skipping conflicting files |
-f, --force | Replace files the registry changed, discarding your edits to them |
--json | Machine-readable result |
--skip-install, --registry, --cwd | As in add |
To discard edits to a file the registry has not changed, use
add <name> --overwrite.
remove
npx @tdpxl/cli remove card
npx @tdpxl/cli remove card --dry-runDeletes the files an item installed and its record. Files you edited are kept
(it asks in a terminal; --force deletes them). The theme and AGENTS.md
sections are removed from their files, leaving the rest. If other installed
items depend on it, it warns and stops unless you confirm or pass --force.
npm packages are never uninstalled: the CLI lists the ones no remaining tdpxl
item needs, for you to remove if nothing else imports them.
check
npx @tdpxl/cli check
npx @tdpxl/cli check contrast
npx @tdpxl/cli check rules --jsonRe-checks the contrast of your theme in both modes and the style rules of the installed components, and suggests passing values for brand roles that fail. Exits with code 1 on failure, so it can run in CI. What it checks is explained in Customizing.
-h/--help and -v/--version are available on every command.
tdpxl.json
init writes this file at the project root. Every later command reads it.
{
"registry": "<registry URL or folder>",
"css": "app/globals.css",
"aliases": {
"components": "@/components",
"ui": "@/components/ui",
"hooks": "@/hooks",
"lib": "@/lib",
"utils": "@/lib/utils"
}
}| Key | Meaning |
|---|---|
registry | Where items are fetched from: an HTTP(S) base URL or a local folder of item JSON files |
css | The stylesheet that receives the theme section |
aliases.ui | Destination and import path for components (registry:ui) |
aliases.hooks | Destination and import path for hooks |
aliases.components | Destination for charts, and for blocks outside a Next.js App Router project |
aliases.lib | Destination for library files |
aliases.utils | The file cn() is written to and imported from |
The aliases use the prefix of your path alias (@ for "@/*"). Each alias is
resolved to a folder through the paths in tsconfig.json, tsconfig.app.json
or jsconfig.json, so with "@/*": ["./src/*"] the ui alias writes to
src/components/ui/. When the registry is an HTTP URL, init also adds a
$schema entry pointing at the registry's config schema.
You can edit the file by hand, for example to put components in
@/components/tdpxl. Later add commands write and import accordingly.
Where files land
| Item type | Example | Destination |
|---|---|---|
registry:ui | button | <ui>/button.tsx |
registry:hook | use-mobile | <hooks>/use-mobile.ts |
registry:lib | utils | <utils>.ts |
registry:block (chart) | chart-bar-stacked | <components>/chart-bar-stacked.tsx |
registry:block (block) | dashboard-01 | app/dashboard/page.tsx and app/dashboard/components/* in Next.js; <components>/dashboard/… otherwise |
registry:theme | theme | The managed section of the css file |
In a Next.js project the App Router directory is src/app or app, whichever exists.
How imports are rewritten
Registry sources import each other through the registry's own layout. On the way in, the CLI rewrites those specifiers to your aliases:
| In the registry | In your project |
|---|---|
@/registry/ui/<name> | <ui>/<name> |
@/registry/hooks/<name> | <hooks>/<name> |
@/registry/charts/<name> | <components>/<name> |
@/registry/lib/utils, @/lib/utils | <utils> |
Relative imports inside a block are left alone: the block's files keep their
relative positions, so ./components/app-sidebar still resolves.
Staying up to date
Every registry item has a version (semver, starting at 0.1.0) and a sha256
hash of each file as published, before any import rewriting (cssHash for the
theme). The CLI verifies those hashes and refuses content that does not match.
add and update record what they installed in tdpxl-lock.json, next to
tdpxl.json:
{
"lockfileVersion": 1,
"items": {
"button": {
"version": "0.1.0",
"type": "registry:ui",
"registryDependencies": ["spinner", "theme", "utils"],
"dependencies": ["class-variance-authority@^0.7.1", "radix-ui@^1.8.1"],
"files": [
{
"path": "registry/ui/button.tsx",
"type": "registry:ui",
"kind": "file",
"target": "src/components/ui/button.tsx",
"source": "sha256:…",
"written": "sha256:…"
}
]
}
}
}source is the hash of the registry content; written the hash of what that
version writes in your project (after rewriting imports). A file whose hash is
not written has been edited. For the theme and AGENTS.md, only the managed
section between the markers is hashed and merged (kind: "theme" / "agents"),
so your CSS and notes around it never count as edits.
.tdpxl/base/<item>/ keeps the registry source of each installed file: the
common ancestor update merges against. Commit tdpxl-lock.json and .tdpxl/
so every teammate and CI sees the same state. Without the base, an edited file
cannot be merged and update asks for --merge (one conflict over the whole
file) or --force.
The lock is a separate file, not part of tdpxl.json, because it is machine
written and changes on every install or update; tdpxl.json stays the short file
you edit by hand. Projects installed before the lock existed have no records:
run add <name> again (identical files are left alone) to start tracking them.
When a file already exists
- Identical content: left alone and reported as unchanged.
- Different content, interactive terminal: the CLI asks before replacing it.
- Different content with
--yes, or without a terminal (CI): skipped and reported with(exists, use --overwrite). --overwrite: replaced.- Already installed and untouched (per
tdpxl-lock.json): replaced without asking, since there are no edits to lose. - Already installed, edited, and the registry has nothing new: kept and
reported as
(local edits kept).
Dependencies that are already installed are not refreshed by add; if the
registry has a newer version, add points you to tdpxl diff.
The theme is the one exception on a first install: appending the managed section never touches your own CSS, so it is written without asking. Replacing an existing section follows the rules above, because it may discard edits made between the markers.
The summary marks each file with + created, ~ updated or × skipped, and
counts unchanged files.
npm packages
Each item lists the npm packages its source imports. After writing files, the
CLI installs the ones missing from your package.json (dependencies and
devDependencies both count as present) with the package manager it detects from
the nearest lockfile — pnpm-lock.yaml, bun.lock/bun.lockb, yarn.lock or
package-lock.json, searching parent folders for monorepos — and falls back to
the manager that launched the CLI, then npm. With --skip-install it prints the
list so you can install them yourself.
Registry location
The registry is resolved in this order:
--registryon the command line.registryintdpxl.json(foraddandlist).- The
TDPXL_REGISTRYenvironment variable, then the CLI's built-in default (forinit, and forlistoutside a project).
A registry can be a URL or a local folder. A folder is read straight from disk, which is how you test a registry before deploying it:
npx @tdpxl/cli add button --registry ../my-registry/public/r
TDPXL_REGISTRY=https://registry.example.com/r npx @tdpxl/cli initInside an item, registryDependencies are bare names ("button"), always
resolved against the registry you are installing from. See
Registry to host your own.
Current limits
updatecompares lines; two edits on adjacent lines (with no unchanged line between them) are a conflict even when they do not overlap, as ingit merge.- Re-running
addon a file edited beforetdpxl-lock.jsonexisted records it as an edit of the current registry version. If your copy started from an older version, its firstupdatemay report more conflicts than necessary. - Several blocks share a route (
dashboard,login,signup). Adding a second one finds the existingpage.tsxand skips it unless you pass--overwrite.