/mitosis:mitosisfrom mitosis
Use when one repository holds two or more changes that touch different files, or a document whose sections each become code, and the work should ship as separately reviewable pull requests built in parallel. Splits the work, builds each part on its own branch, checks that each Step's named acceptance tests pass against the finished work, opens one pull request per part, and never merges.
Ships in mitosis. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
mitosis takes work that one agent would grind through serially, splits it so several agents run at once, and produces pull requests a human can merge without discovering that the parallelism broke something. A model may produce anything; a model may judge nothing. Every gate in mitosis is a program.
--help describes every flag.
Reach for mitosis when all three hold:
Do not reach for it when:
--plan-only when unsure; the report shows
the Lane count before anything spawns.--feature-branch and never see uncommitted work. Commit first.mitosis names no model, holds no key and links no SDK. Every model call is a subprocess built from a command template the caller passes. Each template is split into argv before its placeholders are substituted, so a task containing quotes or newlines lands as one argument and is never reinterpreted by a shell.
| Flag | Spawns | Placeholders |
|---|---|---|
--dispatch-command | one Worker session per Lane, in its own clone | listed under --help |
--acceptance-command | one acceptance property, in a worktree | file, test, worktree |
--pr-command | one pull request per MSP; optional, refused with --no-push | listed under --help |
--render-command | render --fields, per MSP at start and ship | none |
--pr-type --pr-scope --pr-subject --pr-why --pr-impact --pr-blast-radius | nothing; they are facts handed to render | none |
--decompose-command | the structure pass that turns a document into Steps, each with its task | prompt, model, document, session_id, schema |
--reask-command | the same session once more, for a reply failing its owned schema; required to call a model | prompt, session_id, schema, model |
--worker-sandbox | each Worker, gate and lock-stage run under sandbox-exec, writing only its clone or checkout, temp, transcript and --worker-write paths and signalling only its own sandbox; exit 3 without it | none |
--worker-write | nothing; one more sandbox-writable path; repeatable; exit 3 if it overlaps the run directory, repository or its git directory | none |
--gate-classes | nothing; a JSON {test, class, reason} list classing properties | none |
A Worker's prompt is its whole brief. Dispatch and decompose templates
must carry {schema}, the call schema as JSON text, and {session_id}, or
mitosis exits 3; the runs below show them with the re-ask template. A reply is read
only from the structured_output of the JSON object printed; one failing its
owned schema is re-asked once in that session, then fails its call. Every
hand-off mitosis writes is checked against contracts/ first; a state, result
or lock record that fails exits 15.
A brief holds a Task line and JSON leaves inside the Lane header and
the clone, referee and return lines. --prompt-template replaces a build
Lane's brief after its Lane line, filling cluster, spec, tier and contract.
--no-briefs drops the briefs, only with --plan-only; else exit 2.
Tiers are labels; with {model} in the template, map every tier the plan
assigns, or mitosis refuses to start:
--tier-model top=claude-opus-5 --tier-model cheap=claude-sonnet-5
The acceptance template exits 0 on a pass, 1 on a fail and anything else when it could not run, so the gate tells a broken build from a failing test:
--acceptance-command "python3 -m pytest {file} -k {test} -q"
pytest exits 5 when it collects nothing, so a misspelled test reads as inconclusive. Wrap another runner to map its exit codes to those three.
At the lock stage the new modules do not exist yet, so the wrapper exits 1 when an import fails on a missing module; any other load error stays inconclusive.
Two more things every run needs: --feature-branch, which must exist and is
what every MSP branches from, and the repository root as the working
directory, since every path is relative to it, or mitosis refuses to run.
--timeout is deprecated and ignored, mitosis has no wall-clock limit: a command's exit ends every wait, and every
process gets no input.
mitosis writes no pull-request text: at ship it writes each MSP's facts file,
runs pull-request render --fields on it and uses the printed title and body
unchanged; a refusal ends the MSP ship-failed, never retried. It needs
pull-request 0.3.0 or later on PATH or named with --render-command. Naming --pr-type and --pr-subject, even
with --no-push, needs --pr-impact or --pr-blast-radius,
and probes render before any Worker spawns. Pushing also needs --pr-why;
without --pr-command each MSP branch is pushed and ends pushed.
Both converge on one list of Steps and one pipeline. Pass one, never both.
--items takes a JSON array meeting schemas/mitosis-items.schema.json, or
exit 3; spec_ref, a Step's document sections, and source, the document's
absolute path and SHA-256, are optional. A validator, then its flag:
[
{"name": "validate-manifest",
"task": "Add validate_manifest(path) to app/manifest.py, returning one error per missing key.",
"files": ["app/manifest.py", "tests/test_manifest.py"],
"source": {"path": "/work/app/docs/manifest.md", "sha256": "4bc2c86cd92744fbb47c8f13e04a42d78fec19f8c032ab091e4a8255720346c8"},
"acceptance": [{"file": "tests/test_manifest.py", "test": "a_missing_key_is_reported_by_name"}],
"spec_ref": ["1.1"]},
{"name": "validate-flag",
"task": "Add --validate to app/cli.py, printing those errors and exiting 1 if any.",
"files": ["app/cli.py", "tests/test_cli.py"],
"source": {"path": "/work/app/docs/manifest.md", "sha256": "4bc2c86cd92744fbb47c8f13e04a42d78fec19f8c032ab091e4a8255720346c8"},
"acceptance": [{"file": "tests/test_cli.py", "test": "validate_exits_one_on_a_bad_manifest"}],
"spec_ref": ["1.2"], "after": ["validate-manifest"]}
]
after orders the second behind the first; with disjoint write-sets they
become two MSPs, the second stacking its pull request on the first.
Steps sharing a contract_group are halves of one interface, built in sequence by one
Lane in one MSP. To build them in parallel, give one "type": "contract"
and make the others wait on it through after. One msp tag ships Steps
together.
Plan first; this validates, schedules and writes the plan, spawning nothing:
python3 "${CLAUDE_PLUGIN_ROOT}/mitosis.py" --items plan.json --plan-only
An after naming no Step is fatal; a write-set path not yet made, an empty
acceptance and a non-empty assumptions are counted, not fatal. When the
Lanes and tiers look right, run:
python3 "${CLAUDE_PLUGIN_ROOT}/mitosis.py" --items plan.json \
--charter docs/CHARTER.md \
--feature-branch main \
--dispatch-command "claude -p {task} --model {model} --session-id {session_id} --output-format json --json-schema {schema} --permission-mode bypassPermissions" \
--reask-command "claude -p {prompt} --resume {session_id} --model {model} --output-format json --json-schema {schema} --permission-mode bypassPermissions" \
--acceptance-command "python3 -m pytest {file} -k {test} -q" \
--pr-command "gh pr create --head {branch} --base {base} --title {title} --body {body}" \
--pr-type feat --pr-subject "validate manifests from the command line" \
--pr-why "A bad manifest should fail before it ships." \
--pr-impact "Bad manifests stop at validation." \
--tier-model top=claude-opus-5 --tier-model cheap=claude-sonnet-5 \
--concurrency 4
The pull-request template's last stdout line, an http or https URL, is recorded as the pull request.
--spec takes a document in any format and reaches the plan in stages, so you
can read its split before any Worker is paid for.
--plan-only runs one structure dispatch over the whole document, because the
two fields that join its distant parts, after and contract_group, cannot
be seen from one section. The stage needs --decompose-command, and its
prompt is large, so let it arrive on stdin. No Step returned here carries a
task yet:
python3 "${CLAUDE_PLUGIN_ROOT}/mitosis.py" --spec docs/specs/search.md --plan-only \
--decompose-command "claude -p --model {model} --session-id {session_id} --output-format json --json-schema {schema} --permission-mode bypassPermissions" \
--reask-command "claude -p {prompt} --resume {session_id} --model {model} --output-format json --json-schema {schema} --permission-mode bypassPermissions" \
--tier-model top=claude-opus-5
It persists its Steps and reports the Split shape findings, scalars, unclaimed sections and assumptions.
No finding stops a run; each is printed, put in its pull request and given an exit code.
An assumption you would decide differently goes into the decisions file,
--decisions PATH (default: <document without extension>.decisions.md when
it exists), which binds every later structure dispatch.
--structure-samples N runs N structure dispatches, ranks them and shows
where they disagree; the best is persisted, or the Kth with --pick K.
Add --revise to the same --plan-only command to revise the structure: one
small dispatch returns a delta, carrying whole Steps only for those it touches.
When the plan reads right, run it with --resume, the items run's flags with
--spec in place of --items; it plans the persisted Steps and builds.
The report's drift section says whether the document source names changed
since the Steps were cut.
Validate, schedule, one worktree and branch per MSP under the run directory,
one Worker session per Lane, producers merged in first, then
per MSP: land, commit, gate, reconcile, push, open a pull request stacked on its single
predecessor when --pr-command is given, report.
Every Lane is one Worker session, which builds its Steps in Step order on its
MSP's branch and lands one commit: subject <type>(<scope>): <steps> (chore,
no scope, if absent), body each Step's task's first sentence. Steps share a
Lane exactly when they share a file, bar a test file each one's acceptance
names, which mitosis joins as each Lane lands. On --spec and --asks each
Step writes its own tests, whose files join its write-set unless the charter
locks them.
Each session builds in its own clone of the MSP branch under the run
directory's clones folder, never in the MSP worktree.
--concurrency Workers, four by default, run at once; the same number caps
the tests a gate runs at once. mitosis reads a
finished Lane's write-set from the clone's files, never running git there,
and lands only those paths as one commit. A finished Lane is held until no
Worker runs in its MSP, and a resume lands it without paying again. A write
outside the write-set is judged by reconcile only, exit 6, or reverted as a
referee write, exit 9; the gate never sees it. A new file there that no
reply names is left out. JSON sandbox is
sandbox-exec or off. Each git call
drops the diff, pathspec, repository and object variables. Producer merges and Lane commits run no hooks; a git command meeting
another process's lock is retried. A later change to a file whose Lane already
committed is kept in its own commit and named in the pull request, attention
and the exit code.
mitosis orders no Steps itself: Lanes sharing a risk marker, a recorded
regression, a migration folder or an import run in parallel and are named in
attention; add an after edge if one needs the other.
mitosis exits 3 when git has no commit identity. A failed Lane is retried once with the reason; a refused commit fails that Lane alone.
The gate runs each acceptance property once, against the finished work.
pass: it exited 0 there. inconclusive: the
acceptance command could not judge it. not-applicable: the Step declared none or
changed no implementation. Implementation is derived: the MSP's
write-set minus the files its acceptance properties name.
A property exiting 1 with the work present gets its Lane one repair per fresh
gate verdict; still failing, it holds its MSP gate-failed, exit 21:
committed, never pushed; a gate that could not run holds it too. Every
other verdict ships and is named in the pull request's Testing table. A
failed repair's notes are in the MSP's repair list.
--trajectory gets one outcome entry per acceptance test after
every gate.
--gate-classes classes a property <file>::<name>
not-applicable, covered-elsewhere or removed with a reason, judged
without a run and kept out of the plan id, so --resume rebuilds nothing; an
entry naming no property is refused.
mitosis writes no check-author Step. One an items file declares, a Step with
"role": "check-author", is folded: each Step whose acceptance names its file
writes that file, and no lock stage runs. Only a --plan-file plan saved with
check-authors runs the lock stage: each locks its tests on its MSP's branch from its own
clone at the feature base. Each test must exit 0 with its uncommitted probe
and each Step hold one that exits 1 there; the locked files alone are the
MSP's first commit. Its record is the MSP's lock in JSON
msps; refused twice, the MSP is built and held gate-failed, exit 21,
finding lock-failed; no resume locks it again.
The referee is what judges the work, and no Worker writes it: the charter's
- Locked: lines, plus built-in markers for test configuration, snapshots,
baselines, allowlists and skip lists. Planning refuses a Step whose files hold
a referee path, exit 3. A committed write to one is reverted; it, or an
acceptance run's write, holds the MSP back referee-reverted, exit 9. The JSON
result's referee object names the locked paths, their receipt lock and
commit. A real run exits 3 on a - Locked: path the feature branch lacks, or
a - Locked: line that is empty, absolute or contains ...
Every gate and acceptance run uses a clean checkout of the commit,
not a git repository, reset to raw blobs before each run; files the commit
lacks never reach it; ignored lists them. A gate runs its tests several at
a time, each in its own checkout, the first alone; one that does not pass
beside others runs again alone, in a checkout made for it, and that run
judges it when it exits 0 or 1, its first log kept as
<n>-with-work.beside.log. --gate-setup keeps one checkout.
Dependencies are the root's node_modules and venvs, a real node_modules folder an
acceptance run installs, which stays for the gate's later runs and is cloned into
its other checkouts, or --gate-setup, run
once per gate with {worktree}; its output survives only at top-level names
the commit lacks, such as the .git a git-running test needs. A top-level referee
file or folder it makes, such as conftest.py, is fatal, exit 9. A Git LFS file stays
pointer text and eol attributes may not apply; a test reading real content
fails. A refused pre-gate commit, a pre-commit hook refusing the whole MSP or
a failed gate setup holds it back gate-failed, exit 21. Ship
refuses any head but the gated one, ship-failed, exit 22.
An unreadable base submodule whose gitlink the branch changed cannot be judged, exit 21; a committed referee write inside one is reverted by resetting its gitlink to the base's, exit 9.
Reconcile compares what the git log says changed against what the Steps declared. A write outside the declaration is a finding; a declared path never written is one only when the MSP changed nothing. A write into a file another MSP owns is the serious one: merging both pull requests as they stand overwrites one with the other. The pull request that made the write names it under Trade-offs and open problems, and it sets the exit code. A repair on a caller-proved head that reaches a file of an MSP stacked with this one is reported with the merge order instead, unless an MSP built on this one is already pushed.
The exit code is zero only when every MSP reached shipped, pushed,
unchanged or committed and nothing in the JSON result's findings list set
one. Otherwise it is the most severe entry, printed with its meaning on the
report's last line.
Each Lane ends ok, failed, blocked, merge-blocked or parked-limit;
each MSP ends shipped, pushed, unchanged, committed, ship-failed,
blocked, referee-reverted, gate-failed or parked. An MSP is
unchanged when its branch adds nothing to its pull request's base, so
nothing is pushed or opened, and a dependant's pull request stacks on that
base instead. Of the two Lane states that block dependents, merge-blocked
wants a conflict resolved and blocked a predecessor fixed.
The last line of mitosis's output is one JSON object: the exit code and
its meaning, every Lane with its state, reason, notes and log paths, every MSP
with its branch, base, pull request, title, body, gate verdict and reconcile
findings, and an attention list of what to look at. An agent that dispatched mitosis reads that line, not the report.
The run directory holds the plan, the state, the Steps, every Worker's output, and the worktrees, which survive a failure. Read a Lane's log there; its return is a claim, and the git log is the record.
A Worker stopped at a usage limit parks its Lane parked-limit and its MSP
parked, exit 13; --resume after the reset runs every Lane not ok.
Pass --resume with the same input and run directory. Lanes already ok and
MSPs already shipped or pushed are skipped, as is an MSP unchanged whose
producers all finished. An MSP that did not ship keeps its recorded gate
result, passing or failing, at an unchanged HEAD and is gated again otherwise,
without rebuilding its Lanes. A
producer whose branch was deleted after its pull request merged is found
through its recorded commit on the feature branch. A plan that differs from the run's is refused, naming what differs.
Pass --no-push to build, gate and reconcile every MSP and publish nothing:
each ends committed on its local branch, or unchanged when it adds nothing
to its base, and --pr-command is refused. Run the project's own checks on
those branches; --resume without --no-push ships what was held, and with
it leaves a committed MSP where it is.
--proven-head <MSP label>=<commit>, repeatable, ships a caller-proved HEAD
ungated when its recorded gate did not block and it was not held back; a
Proven head row in Testing names both commits. A malformed value or label
exits 2.
Each invocation is one run in the metrics store, ~/.plugin-metrics or
PLUGIN_METRICS_DIR, with one summary of split, gates, MSP states and spend.
Each model call's fresh {session_id} names the transcript it is priced
from. Every command mitosis starts gets PLUGIN_METRICS_PARENT naming the run.
--version prints the installed plugin's version, and its tests ship with it:
python3 "${CLAUDE_PLUGIN_ROOT}/mitosis.py" --version
python3 -m unittest discover "${CLAUDE_PLUGIN_ROOT}/tests"
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub satanshumishra/mitosis --plugin mitosis2 skills in this plugin