Small, local, inspectable

What do you want to do?

Pick a task and copy the commands. The current agent becomes the Lead. cmux opens the Builder, Reviewer, and Watchdog tabs.

Make commands ready to copy

Set your project path

The page uses this path and its directory name in every project command.

Task index

I want to…

I want to set up a new machine

Install cmux-factory

Result: the command and agent skill point to one local clone.

  1. Check the prerequisites

    Install cmux, Git, Python 3.11 or later, and at least one agent command.

    cmux version
    git --version
    python3 --version
    command -v codex
    command -v claude
  2. Clone and install

    git clone https://github.com/mullender/cmux-factory.git \
      ~/.local/share/cmux-factory
    cd ~/.local/share/cmux-factory
    ./install
  3. Add the command to your shell

    grep -qxF 'export PATH="$HOME/.local/bin:$PATH"' ~/.zshrc || \
      printf '%s\n' 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
  4. Connect cmux and verify

    cmux hooks setup
    factory version
    factory doctor

    Done when the cmux binary and socket checks report PASS.

I want to add the factory to a project

Create the project brain

Result: the Git root contains a readable .factory directory.

  1. Initialize from any project directory

    cd /path/to/project
    factory init

    A second run preserves project rules and prints READY.

  2. Check the project

    factory doctor --project

    Done when cmux, the project config, worker commands, and ignore rules pass.

I want Codex to be the Lead

Start with Codex

Choose the command for your current location.

From a normal terminal

Open cmux, then start Codex

cmux /path/to/project

In the new cmux terminal:

codex /start-factory

I want Claude to be the Lead

Start with Claude

The worker roles still come from .factory/factory.toml.

From a normal terminal

Open cmux, then start Claude

cmux /path/to/project

In the new cmux terminal:

claude /start-factory
If /start-factory is not available

Give the Lead this prompt:

Run factory doctor --project, then run factory start. You are the Lead.

I want to see what the factory is doing

Inspect status and watchdog events

The output uses exact cmux IDs and readable reasons.

Read status

factory status

Follow watchdog actions

factory events --follow

Get JSON status

factory status --json

Record feedback

factory note "Keep the next change smaller"

Read Lead mail

factory inbox lead
factory inbox lead --archive

Send agent mail

factory mail builder lead \
  "The change is ready" --kind handoff \
  --base BASE_SHA --head HEAD_SHA

I want Reviewer to inspect what Builder committed

Review an exact commit

Builder and Reviewer use separate worktrees. Reviewer never reads Builder's live files.

  1. Assign Builder from its current commit

    factory status
    factory mail lead builder "Make the bounded change" \
      --kind assignment --base BASE_SHA
  2. Receive Builder's committed handoff

    factory inbox lead --archive

    The mail contains full base_sha and head_sha fields.

  3. Assign that range to Reviewer

    factory mail lead reviewer "Review this change only" \
      --kind assignment --base BASE_SHA --head HEAD_SHA

    The factory checks out HEAD_SHA and its recorded submodule commits before it sends the mail.

  4. Inspect the worktrees when needed

    git -C .factory/worktrees/builder status
    git -C .factory/worktrees/reviewer status
    factory status

I want to change instructions for one project

Edit project-owned rules

These changes travel with the project repository.

FilePurpose
.factory/config/OPERATING_RULES.mdRules for all agents
.factory/config/STYLE.mdShared writing style
.factory/roles/lead.mdLead duties and limits
.factory/roles/builder.mdBuilder duties and limits
.factory/roles/reviewer.mdReviewer duties and limits
.factory/agents/<name>/IDENTITY.mdOne agent identity
.factory/factory.tomlNames, commands, and role paths
  1. Edit a rule

    cd /path/to/project
    $EDITOR .factory/config/OPERATING_RULES.md
  2. Review and publish it

    git diff -- .factory/config/OPERATING_RULES.md
    git add .factory/config/OPERATING_RULES.md
    git commit -m "docs: update factory operating rules"
    git push
  3. Restart the factory

    Existing agents keep their original prompt. Start a new session to load the change.

I want to publish a change

Push from Lead only

Builder and Reviewer never push. They hand commits to Lead.

  1. Check the remote branch

    git remote get-url origin
    branch=$(git branch --show-current)
  2. Find open pull requests

    gh search prs --head "$branch" --state open \
      --json repository,number,url

    Verify that a result uses the exact remote repository and branch.

  3. Check repository visibility

    gh pr view URL --json headRefName,headRepository,state,url
    gh repo view OWNER/REPOSITORY --json visibility
  4. Ask before a public update

    If the matching pull request repository is public, Lead shows its URL and asks the user for permission. Permission applies to one push only.

I want to change defaults for future projects

Edit central templates

New projects receive these files when factory init creates their brain.

  1. Open a template

    cd ~/.local/share/cmux-factory
    $EDITOR templates/project/.factory/config/STYLE.md
  2. Test and publish it

    python3 -m unittest discover -s tests -v
    git diff
    git add templates/project/.factory
    git commit -m "docs: update default agent instructions"
    git push
  3. Compare with one existing project

    cd /path/to/project
    diff -u \
      ~/.local/share/cmux-factory/templates/project/.factory/config/STYLE.md \
      .factory/config/STYLE.md

I want to use a different agent command

Change a worker provider

cmux-factory calls commands. It does not depend on a provider SDK.

  1. Edit the project config

    cd /path/to/project
    $EDITOR .factory/factory.toml
  2. Keep {prompt} as a separate argument

    [agents.builder]
    label = "Builder"
    command = ["claude", "{prompt}"]
    role = ".factory/roles/builder.md"
  3. Keep source work separate

    The worker starts in the project root for shared factory state. Its prompt gives it a separate source worktree.

  4. Check the command

    factory doctor --project

I want the latest factory version

Update commands and project rules

The command fast-forwards the clone, verifies links, and safely syncs managed rules.

  1. Run the update from your project

    cd /path/to/project
    factory update

    Use factory update --no-pull while you test local template edits.

  2. Resolve any rule conflicts

    diff -u \
      .factory/roles/reviewer.md \
      .factory/update/roles/reviewer.md.new
    
    # Accept all incoming rules:
    factory update --no-pull --use-upstream

    The command prints exact diff, upstream, and keep-current choices. The project file stays unchanged until you choose.

  3. Verify the update

    factory version
    factory doctor

    Start a new Lead so it loads the updated skill.

I want the factory to learn from a session

Review feedback and improve the rules

The POC keeps this process manual and visible.

  1. Record feedback during the session

    factory note "Keep each assignment small"
    factory note "Require evidence before reporting completion"
  2. Review feedback at the end

    tail -n 50 .factory/brain/FEEDBACK.jsonl
    $EDITOR .factory/brain/LESSONS.md
  3. Move repeated lessons into the right rules

    $EDITOR .factory/config/OPERATING_RULES.md
    $EDITOR .factory/config/STYLE.md
    git diff -- .factory

    Keep one-time facts in the brain. Add only repeated and useful behavior to agent instructions.

  4. Commit the lesson

    git add .factory
    git commit -m "docs: apply factory session lessons"
    git push

I want to end the current session

Stop the factory

The command interrupts workers and the watchdog. It leaves tabs open for inspection.

cd /path/to/project
factory stop

Close the worker and watchdog tabs when you no longer need their output. The worker worktrees remain for inspection and the next start.

Quick reference

Factory commands

factory init [DIR]Create or verify a project brain
factory doctor --projectCheck cmux, config, and agents
factory updateUpdate source, links, and managed rules
factory startLaunch tabs from the Lead
factory status [--json]Show agents and surface health
factory events [--follow]Read watchdog decisions
factory check-in …Record agent state
factory mail FROM TO TEXTWrite agent mail
factory inbox AGENTRead or archive agent mail
factory note TEXTRecord process feedback
factory stopInterrupt workers and watchdog
factory versionShow source and revision
factory watchRun the watchdog loop
Troubleshooting checks

Command not found

ls -l ~/.local/bin/factory
printf '%s\n' "$PATH"

Project or agent failure

factory doctor --project

Pull cannot fast-forward

git status
git log --oneline --decorate --graph --all -20

Old instructions remain

Stop the old session. Start a new Lead and workers.