Documentation
Commands
Commands
Each section below lists a command's synopsis and flags, the files it writes, whether it accepts --dry-run, the TypeScript shape of data in its --json success envelope, and the error codes it can raise. Exit codes in parentheses apply under --json; without it every failure exits 1. The envelope itself, exit codes, and the full error-code table are on Using inrepo from agents and scripts (docs/agents.md in the npm package).
Two flags work with every command:
| Flag | Effect |
|---|---|
--json | stdout carries exactly one JSON envelope. All human output (progress, warnings, banners) goes to stderr. |
--dry-run | Only add, sync, patch, update, and mirror accept it. Other commands fail with USAGE (exit 2). |
Every command can also raise USAGE for an unknown option or an unexpected argument, CONFIG_INVALID for a malformed inrepo.json or package.json#inrepo, and LOCKFILE_INVALID for a malformed inrepo.lock.json. The per-command lists below leave these three out.
A command that fails with a plain error (one with no specific code) reports code ERROR and exits 1.
inrepo init
Creates an empty config. If a config already exists, init does nothing to it.
- In a terminal,
initasks where to put the config (inrepo.jsonorpackage.json#inrepo) and offers to add/inrepo_modules/and/.inrepo/to.gitignore. - Without a terminal, or under
--json,initreadsINREPO_CONFIG=inrepo.jsonorINREPO_CONFIG=package.json, writes that stub, and appends the two.gitignorelines without asking. --agentsadds a short inrepo guidance block toAGENTS.md, creating the file if it is missing. The block sits between<!-- inrepo:agents:start -->and<!-- inrepo:agents:end -->; a rerun replaces it in place and leaves the rest of the file alone. IfCLAUDE.mdexists, does not mentionAGENTS.md, and is not a symlink to it, the same block goes there too. ACLAUDE.mdthat already has the block is kept current.--agentscreates the config first when there is none, the same way plaininitdoes. When setup cannot run (no terminal and noINREPO_CONFIG), it fails withCONFIG_NOT_FOUNDbefore writing any guidance.
Writes: inrepo.json or package.json, .gitignore, and with --agents, AGENTS.md and possibly CLAUDE.md.
Dry run: not supported.
Errors:
CONFIG_NOT_FOUND: no terminal and noINREPO_CONFIG, without--agents.nextCommandisINREPO_CONFIG=inrepo.json inrepo init.ERROR:AGENTS.mdorCLAUDE.mdhas only one of the two markers, or has them in the wrong order. Fix the markers by hand and rerun.
inrepo status
Reports every vendored package, or only <name>: its pin, its patches, whether the checkout has uncaptured edits, and any paused update. Each package also gets a condition and the nextActions that move it forward. status is the right first command for an agent.
status never fetches and never writes to the project. It works without a config: with nothing configured, nextActions is ["inrepo init"]. With a config and no packages, it is ["inrepo add <name>"].
Writes: nothing. To compute changed files, status assembles a tree in the OS temp directory, and only from upstream sources already cached under .inrepo/.
Dry run: not supported (it never writes).
The conditions are listed most urgent first. A package on a legacy overlay suggests inrepo patch <name>, without -m, for uncaptured edits.
Errors: PACKAGE_NOT_FOUND when <name> is neither configured nor locked. details.known lists the accepted names.
inrepo add
Pins a package, builds its checkout in inrepo_modules/<name>/, and records it in the config. It links the checkout into the root package.json only when you pass --dependency or -D, or when the config entry already sets packageJson. Running add again for a package that is already vendored refreshes its pin and keeps its recorded link choice unless a link flag changes it.
| Flag | Meaning |
|---|---|
--dependency | Link the checkout into package.json#dependencies and record "packageJson": "dependencies". |
-D, --dev-dependency, --dev | Link the checkout into package.json#devDependencies and record "packageJson": "devDependencies". Cannot be combined with --dependency. |
--git <url> | Clone URL. Required when the npm registry has no usable repository for the package. |
--repository-directory <path> | Package root inside a monorepo checkout. |
--ref <ref> | Branch, tag, or commit to pin. |
--with-deps | Also vendor the runtime dependency closure and record the graph in the lockfile. Cannot be combined with --no-save. |
--no-save | Do not write the config entry. Also skips first-time setup, and never links into package.json. Cannot be combined with a link flag. |
Writes: config, inrepo.lock.json, inrepo_modules/<name>/, and caches under .inrepo/. Writes package.json only when the package is linked.
Dry run: resolves the commit (and, with --with-deps, the whole closure) and reports what it would vendor. It writes no config, lockfile, package.json, or checkout. Only --with-deps fills the .inrepo/ cache, because resolving dependencies needs the root's manifest at the pinned commit. A dry run in a project without config does not create one.
Errors:
CONFIG_NOT_FOUND: first run without a terminal and withoutINREPO_CONFIG.PACKAGE_NOT_FOUND: the npm registry has no such package.UPSTREAM_UNAVAILABLE: git clone or fetch failed, or the registry request failed.UNCAPTURED_EDITS: the package is already vendored and its checkout has edits that are not ininrepo_patches/.PATCH_APPLY_FAILED: a committed patch does not apply to the pinned commit.CONFIG_INVALID: the package is linked butpackage.jsonis missing or malformed. Nothing is vendored.ERROR:--with-depscould not resolve the closure, for example an unsatisfiable range or an unsupported dependency source. The message names the dependency and the reason.
inrepo sync
Rebuilds every checkout in inrepo_modules/ from inrepo.lock.json plus inrepo_patches/. A configured package that is not locked yet is resolved and pinned.
sync refuses to overwrite a checkout with uncaptured edits. --force discards them after saving a copy under .inrepo/backups/; the backup path is returned in backup.
Packages whose config sets packageJson are linked into that root package.json bucket. Other packages never change package.json. When any package is linked, a missing or malformed package.json fails the run with CONFIG_INVALID before any checkout is rebuilt.
Writes: inrepo_modules/, inrepo.lock.json (new pins only), .inrepo/, and package.json for linked packages. First-time setup can also write the config and .gitignore.
Dry run: reports a would-* or unchanged action per package and writes nothing. It does not run first-time setup, so a project without config fails with CONFIG_NOT_FOUND. It still fails with UNCAPTURED_EDITS when a real sync would.
Errors:
CONFIG_NOT_FOUND: no config and setup cannot run.CONFIG_INVALID: the config has an emptypackagesarray.nextCommandisinrepo add <package>.UNCAPTURED_EDITS(exit 3): a checkout has edits.nextCommandisinrepo patch <name> -m "<reason>".details.packagenames the package, anddetails.fileslists the changed files when they are known. Wheninrepo_patches/also changed (details.overlayChanged: true),nextCommandisinrepo sync --force.PATCH_APPLY_FAILED(exit 3): a patch no longer applies.details.patchanddetails.filename it.UPSTREAM_UNAVAILABLE(exit 4): a fetch failed.
inrepo patch
Captures the edits in inrepo_modules/<name>/ as the next numbered patch, inrepo_patches/<name>/series/NNNN-<subject>.patch. The reason becomes the patch subject. Without <name>, every package is checked. A package with no edits reports captured: false, and nothing is written for it.
-m (or --message) is required for every package on the patch series, which includes every new package. Without it, patch fails with USAGE and nextCommand is inrepo patch <name> -m "<reason>". A package still on a legacy whole-file overlay ignores -m and rewrites its overlay files.
Writes: inrepo_patches/<name>/ and .inrepo/.
Dry run: computes the patch and reports it without writing it or the sync record. -m is optional under --dry-run. Without it, patch.file and patch.subject are null because the file name comes from the message. The upstream cache under .inrepo/ can still be filled.
Errors:
USAGE:-mis missing.PACKAGE_NOT_FOUND:<name>is unknown or not locked yet.nextCommandisinrepo syncfor an unlocked package.UPDATE_IN_PROGRESS(exit 3): an update is paused for this package. Finish it first.ERRORwithnextCommand: "inrepo sync": the checkout is missing, orinrepo_patches/changed since the last sync.UPSTREAM_UNAVAILABLE(exit 4): the upstream cache could not be filled.
inrepo diff
Shows the effective change from the pinned upstream commit to the patched tree, and the patches that produce it. It compares committed state only: uncaptured edits in inrepo_modules/ do not appear. diff exits 0 whether or not anything differs.
Writes: only scratch files and caches under .inrepo/.
Dry run: not supported (it never writes project files).
Errors: PACKAGE_NOT_FOUND, PATCH_APPLY_FAILED, UPSTREAM_UNAVAILABLE.
inrepo update
Moves a package to a newer upstream commit by rebasing its patch series onto it in a scratch repository under .inrepo/updates/<name>/. Only a clean rebase writes anything: the renumbered series, the lockfile pin, a new --ref in config, and the rebuilt checkout. On a conflict, nothing outside .inrepo/ changes. The steps to resolve one are in the update conflict loop.
| Flag | Meaning |
|---|---|
--ref <ref> | New branch, tag, or commit. It is saved to config when the update succeeds. |
--continue | Resume after conflicts are resolved in .inrepo/updates/<name>/repo. |
--abort | Discard the paused update. The project stays as it was. |
Writes: inrepo_patches/<name>/series/, inrepo.lock.json, config (with --ref), inrepo_modules/<name>/, and .inrepo/.
Dry run: resolves the target commit and reports would-update or up-to-date with the patches it would rebase. It writes nothing and cannot predict conflicts. --dry-run cannot be combined with --continue or --abort.
Errors:
UPDATE_CONFLICT(exit 3): the rebase stopped.detailshaspackage,patch: { number, subject },conflictedFiles, andrepoPath.nextCommandisinrepo update <name> --continue.--continueraises the same code while conflict markers remain.UPDATE_IN_PROGRESS(exit 3): an update for this package is already paused.UNCAPTURED_EDITS(exit 3): the checkout has edits that the rebuild would discard. Capture them first.NO_UPDATE_IN_PROGRESS(exit 2):--continueor--abortwith nothing paused.PACKAGE_NOT_FOUND(exit 2):<name>is unknown.UPSTREAM_UNAVAILABLE(exit 4): the target ref could not be resolved.ERROR: the package is still on a legacy overlay (nextCommand: "inrepo migrate <name>"), the scratch repository is missing (nextCommand: "inrepo update <name> --abort"), the package is not locked, or it is a graph-managed--with-depsdependency, which must be updated through its graph root withadd --with-deps.
inrepo migrate
Converts a package's legacy whole-file overlay into inrepo_patches/<name>/series/0001-<subject>.patch. The overlay files are deleted only after replaying the series reproduces the identical tree.
Writes: inrepo_patches/<name>/ and .inrepo/.
Dry run: not supported.
Errors: PACKAGE_NOT_FOUND (unknown or not locked), UPDATE_IN_PROGRESS, and USAGE when the package already has a series or has no overlay to migrate.
inrepo verify
Checks that every checkout matches the lockfile plus the committed patches, and that the recorded dependency graph is consistent. Run it in CI and before an agent reports that it is done.
Writes: only caches and scratch trees under .inrepo/.
Dry run: not supported (it never writes project files).
On success, data is the result below with ok: true and an empty issues array. On drift, verify exits 1 and prints a failure envelope. Its error.code is VERIFY_FAILED, error.details.modules lists the affected modules, error.nextCommand is inrepo sync, and data carries the same result with ok: false.
Branch on issues[].kind, not on message; message text can change between releases. An empty lockfile is itself a failure (empty-lockfile).
tree-drift usually means uncaptured edits. Run inrepo patch <name> -m "<reason>" to keep them, or inrepo sync --force to discard them. Do not follow nextCommand: "inrepo sync" blindly in that case: a plain sync refuses with UNCAPTURED_EDITS.
inrepo mirror
Publishes a filtered snapshot of a committed directory to each configured mirror target (or just <name>), as one commit on top of the target branch. See Mirrors (docs/mirrors.md in the npm package) for the config and the safety checks.
--ref <rev>: source revision to publish. Defaults toHEAD.--overwrite: publish even when the target changed, another mirror wrote it, or the run would roll it back. It still adds a commit on top; target history is never rewritten.-m "<subject>": subject of the mirror commit. Defaults toMirror <short sha>.
Writes: nothing in the project. It pushes to the target repository.
Dry run: builds the commit and reports the changes, but pushes nothing. action is would-push or up-to-date. A dry run still contacts the target, so it can fail with UPSTREAM_UNAVAILABLE, and it still runs every safety check.
Errors:
-
CONFIG_INVALID:- no
mirrorsarray; - an invalid mirror entry;
directorymissing at the revision;- nothing left to publish;
- submodules or non-UTF-8 paths;
- a config on disk that differs from the one committed at the revision;
- git config that sends fetch and push to different repositories.
- no
-
MIRROR_NOT_FOUND: no mirror named<name>.details.knownlists the configured names. -
MIRROR_TARGET_CHANGED(exit 3): the target cannot be published to without--overwrite.details.reasonis:foreign-tip: the tip was not written by inrepo, or was edited after.other-mirror: another mirror wrote the branch.rollback: the revision does not descend from the last mirrored one.
nextCommandisinrepo mirror <name> --overwrite. Port any changes made on the target first. -
MIRROR_HISTORY_MISSING: the clone lacks the last mirrored commit or is shallow. Fetch full history. -
UPSTREAM_UNAVAILABLE(exit 4): fetching from or pushing to the target failed, including a push rejected because the branch moved.details.urlis redacted.