unirepo-cli
v0.6.0
Published
CLI tool for creating and managing git-subtree monorepos — run your agents across repos
Maintainers
Readme
unirepo
One workspace to refactor your whole stack in one go
Work across multiple repos like they’re one. Unirepo turns multiple GitHub repositories into a single unified workspace. Edit backend, frontend, and shared code in one tree, commit from one place, and push changes back to each repo using the same branch by default.
Built for AI coding agents
AI agents need full context to make correct changes—not one repo at a time. Unirepo gives them a single workspace to refactor your entire stack, keep changes consistent, and push updates back to each repo.
Example task
You need to update:
api/for a new endpointweb/for the UIshared/for shared types
Without unirepo
# clone and branch in each repo
git clone [email protected]:org/api.git
git clone [email protected]:org/web.git
git clone [email protected]:org/shared.git
cd api
git checkout -b feature-auth
cd ../web
git checkout -b feature-auth
cd ../shared
git checkout -b feature-auth
# edit in 3 separate checkouts
# commit in each repo
cd ../api
git add .
git commit -m "feat: add auth"
cd ../web
git add .
git commit -m "feat: add auth UI"
cd ../shared
git add .
git commit -m "feat: add auth types"
# push from each repo
cd ../api
git push -u origin feature-auth
cd ../web
git push -u origin feature-auth
cd ../shared
git push -u origin feature-authWith unirepo
# create one workspace and one branch
unirepo init my-workspace <repo...>
cd my-workspace
unirepo branch feature-auth
# edit api/, web/, and shared/ together
# commit once from the workspace
git add .
git commit -m "feat: add auth flow"
# push changed subtrees
unirepo pushSame workflow, fewer commands
unirepo keeps your upstream repos separate while removing:
- Repo and branch juggling
- Repeated setup and commands
- Context switching
- Inconsistent cross-repo changes
It enables:
- One place to see the full change
- Safe cross-repo refactors
- A single workspace for humans and AI
Install
npm install -g unirepo-cliOnce installed, the command is just unirepo:
unirepo --versionOr use without installing:
npx unirepo-cli <command>Why it works well for agents
AI coding agents work best when they can see the full change at once.
- Update backend, frontend, and shared contracts in one pass
- Commit coordinated changes from one repo
- Check affected subtrees with
unirepo status - Push only changed subtrees with
unirepo push - Reuse the generated
AGENTS.mdworkflow guide
Commands
| Command | Description |
| --- | --- |
| init <dir> <repo...> | Create a new workspace from one or more repos |
| add <repo> | Add another repo to the workspace |
| pull [subtree...] | Pull upstream changes into tracked subtrees |
| status | Show subtrees, branches, and what changed |
| branch [name] | Create or show the current workspace branch |
| push [subtree...] | Push changed subtrees upstream |
| pr [subtree...] | Open pull requests for changed subtree repos |
init
unirepo init <dir> <repo-url> [repo-url...]Creates a new git repo at <dir>, imports each URL as a subtree, and generates an AGENTS.md workflow guide.
| Flag | Effect |
| --- | --- |
| --full-history | Import full git history (default: squash) |
add
unirepo add <repo-url> [--prefix <name>] [--branch <name>]Adds a repo to an existing workspace. The directory name defaults to the repo name.
| Flag | Effect |
| --- | --- |
| --prefix <name> | Override the subtree directory name |
| --branch <name> | Import from a specific upstream branch |
| --full-history | Import full git history |
pull
unirepo pull [subtree...] [--prefix <name>]Pulls upstream changes. Without arguments, pulls all tracked subtrees. When you use --branch without naming a subtree, unirepo skips tracked subtrees that do not have that upstream branch.
| Flag | Effect |
| --- | --- |
| --prefix <name> | Pull only one tracked subtree |
| --branch <name> | Pull a specific upstream branch |
| --full-history | Pull full history instead of squash |
status
unirepo status [--json]Shows tracked subtrees, their upstream branches, the current workspace branch, each subtree's effective push branch, and which subtrees have changes.
branch
unirepo branch [name]With a name: creates and switches to a new branch. That branch becomes the default push target for subtrees that do not have their own configured override. Without: shows the current branch and effective push targets.
Per-subtree push branches
By default, unirepo branch <name> sets the workspace branch and subtrees push and open PRs from that same branch.
If one subtree repo needs a different branch target, configure it in local git config:
git config unirepo.subtree.api.pushBranch feature-api
git config unirepo.subtree.web.pushBranch feature/web-auth
unirepo statusRemove an override and go back to the workspace branch default:
git config --unset unirepo.subtree.api.pushBranchpush
unirepo push [subtree...] [--dry-run]Pushes changed subtrees upstream. Without arguments, auto-detects which subtrees have changes. Each subtree pushes to its configured push branch or the current workspace branch by default.
| Flag | Effect |
| --- | --- |
| --branch <name> | Override the push branch name for all selected subtrees |
| --dry-run | Show what would run without executing |
pr
unirepo pr [subtree...] --title <title> [--body <text>]Opens one GitHub pull request per changed subtree repo. Without subtree arguments, unirepo auto-detects changed subtrees. Use explicit subtree names when you want PRs for only part of the workspace. By default, each PR head matches that subtree's effective push branch.
| Flag | Effect |
| --- | --- |
| --title <title> | Shared PR title for all selected repos |
| --body <text> | Shared PR description |
| --base <name> | Override the base branch for all selected repos |
| --head <name> | Override the head branch name for all selected subtrees |
| --draft | Create draft pull requests |
| --dry-run | Show the gh pr create commands without executing |
How It Works
unirepo is a thin wrapper around git subtree. Each repo you add becomes a directory in your workspace with a matching git remote. When you push, unirepo splits your commits per subtree and pushes each to its upstream.
There's no lock-in — the workspace is a standard git repo. You can always fall back to raw git subtree commands.
Development
npm test # run tests
npm run build # syntax checkLicense
MIT — see LICENSE.
