This document defines the intended CLI surface for bricks. The conceptual
model behind these commands lives in product-model.md;
terms appear in glossary.md.
The command language is source-oriented. A consumer adds a source, pulls it, installs source projects from it, and later merges source changes into installed bricks.
bricks init
bricks source add talent-platform git@github.com:recruitment-co/talent-platform.git --pull
bricks source projects talent-platform
bricks install talent-platform/job-board-app --with-dependent-libs
bricks merge job-board-appThe first-use flow starts from an existing Git-backed Nx repo. source add --pull makes the whole source repo available under .bricks/sources, then
install copies selected source into the consumer workspace.
Only pull sources you trust. Pulling installs the source repo's dependencies and evaluates its Nx project graph, so source-controlled lifecycle scripts and Nx plugins can execute locally.
- Commands run from the root of a consumer Nx workspace unless stated otherwise.
- Workspace metadata lives at
.bricks/config.json. - Source repos are cloned or updated under
.bricks/sources/<name>. .bricks/config.jsonis committed portable metadata; local cache paths are derived and are not written into config.- Human-readable output is the default.
- Human-readable command runs use phase-level task progress so long Git, package-manager, Nx, copy, merge, and metadata steps are visible.
- Commands used by AI agents and scripts should support
--json. --jsonand--quietsuppress task progress and interactive prompts.- Mutating commands should support
--dry-runand report planned file, metadata, Git, Nx, and package-manager changes without writing them. - Conflicts should be normal Git conflicts in the copied source files.
Source project references use:
<source>/<project>[@ref]
Examples:
bricks install talent-platform/job-board-app
bricks install talent-platform/job-offer-ui@main<source> is the local source name from .bricks/config.json. <project> is
an Nx project discovered in the pulled source repo. @ref is optional and
defaults to the source's configured ref.
| Flag | Applies To | Behavior |
|---|---|---|
--json |
All commands | Print machine-readable output. |
--dry-run |
Mutating commands | Report the plan without writing changes. |
--quiet |
All commands | Suppress non-essential human output. |
--verbose |
All commands | Include diagnostic details in human or JSON output. |
--help |
All commands | Print command usage. |
Initialize Bricks metadata in the current consumer Nx workspace.
bricks init [--json] [--dry-run]- Verify the current directory is the root of an Nx workspace.
- Create
.bricks/. - Create
.bricks/config.json. - Initialize empty source and installed-brick records.
.bricks/config.json
Register a Git-backed Nx repo as a source and make it available for pulling.
bricks source add <name> <git-url> [--ref <ref>] [--pull] [--json] [--dry-run]| Argument | Meaning |
|---|---|
<name> |
Local source name used in source project references. |
<git-url> |
Git URL or local path for a repo containing an Nx workspace. |
Relative local paths are resolved from the consumer workspace root before they
are written to .bricks/config.json or cloned into .bricks/sources.
| Flag | Behavior |
|---|---|
--ref <ref> |
Default ref used when a command omits @ref. |
--pull |
Pull immediately after registering the source. |
- Validate
<name>and<git-url>. - Write the source record to
.bricks/config.json. - If
--pullis present, pull the source immediately.
.bricks/config.json.bricks/sources/<name>when--pullis present
Clone or update source repos under .bricks/sources.
This is a trusted-source operation. It installs dependencies from the pulled repo and evaluates the repo's Nx project graph.
bricks source pull [name] [--ref <ref>] [--json] [--dry-run]- Resolve one source or all configured sources.
- Clone the source repo when
.bricks/sources/<name>does not exist. - Fetch and checkout the requested ref when the source already exists.
- Verify the pulled repo is an Nx workspace.
- Install the pulled source repo dependencies inside
.bricks/sources/<name>. - Build the source Nx project graph.
- Detect:
- apps,
- libraries,
- project-to-project dependencies,
- package dependencies,
- dev dependencies needed for build, test, lint, or tooling.
- Store analysis metadata for later
install,status,diff, andmergecommands.
--ref chooses the ref to pull for this operation. It records the pulled ref
and commit but does not replace the source's configured default ref.
.bricks/sources/<name>.bricks/config.jsonsource analysis metadata
This command does not copy source into the consumer workspace. It only makes the full source repo locally available for analysis and later install.
List configured sources and their latest pulled commit.
bricks source list [--json]The human output should show source name, repo URL, default ref, last pulled ref, pulled commit, and whether the local source cache is present.
List installable Nx projects discovered in a pulled source.
bricks source projects <name> [--json]The human output should show project name, project type, source path, package dependencies, dev dependencies, Nx tooling requirements, and dependent Nx libraries.
Remove a configured source and its local cache.
bricks source remove <name> [--force] [--json] [--dry-run]- Refuse to remove a source that still has installed bricks unless
--forceis present. - Remove the source record from
.bricks/config.json. - Remove
.bricks/sources/<name>. - With
--force, also remove install records that point at the source. Copied source files in the consumer workspace are not deleted.
Copy source from a pulled source repo into the consumer workspace.
bricks install [<source>/<project>[@ref]] \
[--as <alias>] \
[--target <path>] \
[--with-dependent-libs] \
[--no-package-install] \
[--no-nx-add] \
[--json] [--dry-run]| Flag | Behavior |
|---|---|
--as <alias> |
Local installed-brick name. Defaults to the source project name. |
--target <path> |
Consumer workspace path for the copied source. |
--with-dependent-libs |
Also install Nx libraries required by the selected project. |
--no-package-install |
Do not add detected package dependencies automatically. |
--no-nx-add |
Do not initialize detected Nx tooling packages automatically. |
--keep-partial |
Keep copied files/package edits when a failure occurs. |
- Resolve the source project reference.
- In interactive human mode, when no reference is provided, prompt for a configured source and then one uninstalled project from that source.
- If the selected source has missing or stale analysis, prompt before pulling and analyzing it.
- In
--json,--quiet, or non-interactive mode, require an explicit<source>/<project>[@ref]. - Ensure the source is configured.
- Pull the source if the required ref is not available locally.
- Resolve
<project>in the source Nx project graph. - Read package dependencies and dev dependencies from each copied project's
local
package.json. - Extract tooling package providers from resolved target executors and
syncGenerators. - Initialize missing tooling packages with
nx addunless--no-nx-addis present. - Report dependent Nx libraries.
- Filter package names supplied by copied source projects.
- Add the remaining package dependencies unless
--no-package-installis present. - Copy the selected project into the consumer workspace.
- If
--with-dependent-libsis present, copy required source libraries too. - Refresh package-manager workspace links after copied manifests exist.
- Copy tracked workspace helpers imported by copied root-level project configs, preserving conflicting consumer files.
- Merge TypeScript aliases for copied projects into
tsconfig.base.json. - Update Nx metadata so copied projects are visible to the consumer workspace.
- Record project-specific dependency metadata in
.bricks/config.json.
Interactive prompts are rendered through Listr task prompts, not standalone terminal prompts, so selection UIs do not fight the active progress renderer.
<projectRoot>/package.json is authoritative for package requirements. Runtime
requirements come from dependencies, peerDependencies, and
optionalDependencies; local build and test requirements come from
devDependencies. A source project without a local manifest contributes an
empty package contract.
Resolved target executors and syncGenerators contribute Nx tooling package
requirements. Bricks routes missing tooling packages through
nx add <package> --updatePackageScripts=true before copying source. These
initializers may update workspace configuration and are durable preparation:
failed initializers produce nx-add-failed warnings while remaining tooling
packages continue to run.
The workspace refresh runs after copying even with --no-package-install.
It does not add detected external requirements, but it lets package managers
link copied workspace packages declared through their local manifests.
If the consumer workspace already declares a package with a range that does not
overlap the source requirement, Bricks keeps the consumer range, skips adding
that package, and records a dependency-range-conflict-kept-existing warning.
Other missing, non-conflicting package dependencies are still installed.
- Copy an app.
- Copy a library.
- Copy a project plus its dependent Nx libraries.
Update installed bricks by merging newer source commits into local copies.
bricks merge [alias] [--all] [--with-dependent-libs] [--no-nx-add] [--ref <ref>] [--json] [--dry-run]| Flag | Behavior |
|---|---|
--all |
Merge every installed brick in dependency-first order. |
--with-dependent-libs |
With one alias, merge installed source dependencies first. |
--no-nx-add |
Do not initialize missing Nx tooling packages automatically. |
--ref <ref> |
Merge from a specific source ref instead of the recorded ref. |
- Resolve one installed brick, or every installed brick when
--allis set. - Pull the related source repo.
- Determine the recorded base commit, local copy, and incoming source commit.
- Perform a three-way merge for changed files.
- Write clean merges into the consumer workspace.
- Leave standard Git conflict markers in files that cannot merge cleanly.
- Report divergent binary files as conflicts without rewriting local bytes.
- Keep the install record at the old base commit while conflicts remain.
- Initialize missing incoming Nx tooling packages after a clean merge.
- Reconcile incoming local-manifest package requirements.
- Advance the install record after the merge completes cleanly.
When merging one alias, Bricks detects installed source dependencies for that
brick. In interactive human mode, it prompts to merge all dependencies or only
the selected brick. In non-interactive mode, use --with-dependent-libs to
merge the installed dependency bricks too. Partial dependency selection is not
supported.
Package reconciliation is best effort during merge. Failed Nx initializers
record nx-add-failed; package-manager failures record
package-reconcile-failed. Both preserve the source merge and consumer
dependencies.
Bricks should not invent a separate conflict workflow. Consumers resolve conflicts the same way they resolve normal Git merge conflicts: edit files, run tests, and commit the result.
For divergent binary files, Bricks cannot place textual conflict markers. It
reports the binary path as conflicted and leaves the local file untouched. The
consumer replaces or keeps the file manually, then runs bricks merge continue.
Finish a merge after manual conflict resolution.
bricks merge continue <alias> [--all] [--no-nx-add] [--json] [--dry-run]| Flag | Behavior |
|---|---|
--all |
Continue every pending merge state in a batch. |
--no-nx-add |
Do not initialize missing Nx tooling packages automatically. |
- Read
.bricks/merge/<alias>.json. - Refuse to continue while copied text files still contain conflict markers.
- Initialize missing incoming Nx tooling packages.
- Reconcile incoming local-manifest package requirements.
- Advance the install record to the incoming source commit.
- Remove the merge-state file.
As with a clean merge, Nx initializer and package reconciliation failures record warnings without blocking merge completion.
Remove an installed-brick record without deleting copied source files.
bricks remove <alias> [--json] [--dry-run]- Refuse to remove a record while it has unresolved merge state.
- Remove the install record from
.bricks/config.json. - Leave copied source files in the consumer workspace.
Show sources and installed bricks.
bricks status [--json]The human output should show:
- configured sources,
- pulled source commits,
- installed aliases,
- target paths,
- recorded base commits,
- whether source updates are available,
- whether any installed brick has unresolved merge conflicts.
Show the difference between an installed local copy and a source commit.
bricks diff <alias> [--ref <ref>] [--json]- Resolve the installed brick.
- Resolve the source commit.
- Compare local files against source files.
- Print a human diff by default or structured file changes with
--json.
Binary differences are returned as structured entries with binary: true
instead of text patches.
Plan which local installed-brick edits could be contributed back to a source repo.
bricks contribute plan <source> \
[--ref <ref>] \
[--json] [--dry-run]| Flag | Behavior |
|---|---|
--ref <ref> |
Source ref to refresh and contribute against. |
- Refresh the source repo and analysis for the selected ref.
- Scan every installed brick from
<source>. - Compare each installed file against that install record's source
baseCommit. - Omit local files ignored by the consumer workspace's Git ignore rules.
- Print candidate files with source path, target path, status, and whether the source also changed since install.
Create a dedicated writable source worktree and apply every candidate local edit as uncommitted source changes.
bricks contribute open <source> \
[--ref <ref>] \
[--branch <name>] \
[--editor <command>] \
[--json] [--dry-run]| Flag | Behavior |
|---|---|
--ref <ref> |
Source ref to refresh and contribute against. |
--branch <name> |
Dedicated contribution branch name. |
--editor <command> |
Editor command used in interactive human mode. |
- Recompute the contribution plan for
<source>. - Require at least one candidate file.
- Create
.bricks/worktrees/<source>/<branch>from the refreshed source ref. - Apply all candidates with a reverse three-way merge: source base, current source, and local consumer edit.
- Preserve conflict markers when text files conflict.
- Persist a contribution session under
.bricks/contributions/. - In interactive human mode, launch the configured editor when available.
Review the worktree with normal Git and IDE tools. Keep generic source changes,
edit what needs cleanup, and drop consumer-only changes with commands such as
git restore -- <path> for tracked files or git clean -f -- <path> for
untracked files.
Show the active contribution session for a source.
bricks contribute status <source> [--json]Commit the reviewed source contribution worktree.
bricks contribute commit <source> [--message <message>] [--json]| Flag | Behavior |
|---|---|
--message <message> |
Commit message for source edits. |
- Require an active opened contribution worktree.
- Require conflict markers to be resolved.
- Stage the current worktree state.
- Create a commit on the dedicated contribution branch.
Push the prepared source contribution branch.
bricks contribute push <source> \
[--remote <name>] \
[--branch <name>] \
[--json]| Flag | Behavior |
|---|---|
--remote <name> |
Git remote to push to. Defaults to origin. |
--branch <name> |
Remote branch name to update. |
- Require an active opened contribution worktree.
- Require the source worktree to be clean.
- Push
HEADto the selected remote branch. - Return a GitHub compare URL when the remote is a GitHub repository.
Validate Bricks state in the consumer workspace.
bricks doctor [--json].bricks/config.jsonexists and parses.- Configured sources are reachable.
- Source caches exist under
.bricks/sources/<name>. - Install record paths are safe workspace-relative paths.
- Installed target paths exist.
- Copied projects are visible to Nx.
- Package dependencies, dev dependencies, and Nx tooling packages are present.
- Merge conflict state is reported clearly.
- Install warnings, such as failed Nx metadata normalization, are reported.