Branches
A full copy of the backend, schema and data, where the agent can change anything.
Every project starts with one branch, main, the one your users talk to. A new branch is a full
copy of its parent: the same schema and the same rows. Nothing done on it reaches main until
you promote it, and nothing on it is held for approval.
Create one
npx shipmantis branch create try-tagsCreated try-tags from main at version 4.
Use it with --branch try-tags, or MANTIS_BRANCH=try-tags.Pass --from <branch> to copy another branch instead of main. A name is a lowercase letter
followed by up to 20 lowercase letters, digits and dashes.
From PHP, the same operations:
use Shipmantis\Mantis\Laravel\Facades\Mantis;
Mantis::branches()->create('try-tags'); // from main
Mantis::branches()->create('try-more', from: 'try-tags');
Mantis::branches()->list();
Mantis::onBranch('try-tags')->table('todos')->select();
Mantis::branches()->promote('try-tags');
Mantis::branches()->delete('try-tags');A Laravel app runs on a branch when MANTIS_BRANCH names it: the default database connection
becomes that branch's database, so php artisan migrate and Eloquent work on the copy.
Use it
Every command, every MCP tool and the client take the branch the same way:
| Where | How |
|---|---|
| The CLI | --branch try-tags, or MANTIS_BRANCH=try-tags in the environment or .env.local. |
| The MCP tools | The branch argument, or MANTIS_BRANCH. |
| The client | createClient({ ..., branch: "try-tags" }). |
Without one, everything uses main.
npx shipmantis push --branch try-tagsOn a branch every step applies at once, including the ones that would be held on main. That is
the point: the agent drops the column, runs the app against the branch, and sees what breaks.
Files are the exception: they belong to the project, every branch
reads main's files, and uploads and deletes with a branch selected are refused.
Promote it
npx shipmantis branch promote try-tagsPromoting applies the branch's schema to the branch it came from, as one migration. The data is
not copied: rows written on the branch stay there. If the parent is main and the migration has
a destructive step, it is held for a person's approval like any other push, and the command exits
with code 2.
List, reset, and delete
npx shipmantis branch list
npx shipmantis branch reset try-tags
npx shipmantis branch reset try-tags --snapshot <snapshot-id>
npx shipmantis branch delete try-tagslist shows each branch and the one it came from. reset drops a non-main branch's diverged
changes and re-clones it cleanly from its parent (or restores a saved --snapshot — see
Snapshots & reset). Deleting a branch drops its copy of the data. main can't be
deleted or reset to a parent.
Workflows
Let the agent try a destructive change. On a branch nothing is held, so it can drop a column,
run the tests against the copy and see what breaks, while main keeps serving users:
npx shipmantis branch create drop-legacy
npx shipmantis push --branch drop-legacy
MANTIS_BRANCH=drop-legacy npm test
npx shipmantis branch promote drop-legacy # held on main for a person's approval
npx shipmantis branch delete drop-legacyA branch per pull request. Run npx shipmantis ci init to generate a GitHub
Actions workflow that creates or resets pr-<number>, checks schema safety, posts a PR comment,
and deletes the branch on close — or wire the commands yourself:
- run: npx shipmantis pr-check --comment
env:
MANTIS_URL: ${{ secrets.MANTIS_URL }}
MANTIS_SECRET_KEY: ${{ secrets.MANTIS_SECRET_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}Try a data fix on a copy. Run the script against a branch, read the result, then run it on
main, or rewind the branch and try again.
Edge cases
| Case | What happens |
|---|---|
| Writes on the parent while the copy is made | The copy is a snapshot from when it started; later writes stay on the parent. The parent keeps serving queries and keeps every connection open meanwhile. |
| A large parent | The copy takes longer, about as long as dumping and restoring it. |
| The team's data room | A branch's rows count against the plan like main's, so a copy of a 400 MB project uses another 400 MB. Creating a branch past the plan is refused with 402. |
| Rewind on a new branch | Its history starts when it was created; it can't be rewound past that. |
| Promoting rows | Not done: promote moves the schema only. Copy rows with a script if you need them. |
| Promoting a branch made from another branch | Applies to that branch's parent, not to main. |
| A name already taken | 409. |
| A name that isn't a lowercase letter and then lowercase letters, digits and dashes | 422. |
| A request naming a branch that doesn't exist | 404. |
| A deleted branch | Its data is dropped for good: a deleted branch can't be rewound or restored. |