Skip to main content

moonlighting

A software factory where people work the day shift and agents work the night shift. People decide. Agents type. The workforce is the engine you select for the run: pi, Claude Code or opencode.

How it works

Work moves through the factory as work orders — small markdown files whose status: line is the contract between the shifts. Marking an order approved is a standing instruction: tonight, an agent executes it autonomously. In the morning it sits at review — with a report, a branch, and a diff, waiting for a human decision.

day shift (people)                     night shift (selected engine)
decide what problems matter  ──────►   implement approved orders
review branches & reports    ◄──────   flip orders to review/blocked
merge, block, or reject               never merge, never touch main

The whole lifecycle is one binary, moonlighting, with a subcommand per workflow:

moonlighting new-order "Title"      create an order; it asks, then offers to approve
moonlighting status                 see every order: approved, blocked, review, draft, done
moonlighting approve ID             approve a draft
moonlighting night                  run the queue (--repo, --engine, --model, --max-orders)
moonlighting remove ID              delete an order file (a done order's record stays in the logs)
moonlighting accept ID              push the branch and open a PR. Merge it on GitHub
moonlighting reply ID "text"        one reply: parks a review, answers a blocked order
moonlighting lint-orders            check every order before spending tokens
moonlighting rotate-logs --days 90  gzip old logs (never deletes)
moonlighting schedule install       nightly cron at 00:01 (remove and status too)

uv runs everything under the hood. Commands work through uv run moonlighting ... inside a factory checkout, or globally after uv tool install moonlighting-factory.

Layout

The binary works globally out of the box. Config lives at ~/.config/moonlighting/config.toml. State — orders, logs, locks, sessions, cloned target repos — lives under ~/.local/share/moonlighting/. The night and QA manuals and the order template ship inside the package. No git checkout is needed anywhere.

Config

Every user keeps a config at ~/.config/moonlighting/config.toml on their own machine (MOONLIGHTING_CONFIG moves it). The file sets the engine, models and orders directory, and binds repo names to paths and identities through named profiles. Precedence: flags beat env vars beat the config file. Copy docs/config-sample.toml and fill in your own names, repos and profiles. A commented sample lives at docs/config-sample.toml.

Layout

src/moonlighting/       the package: factory model, workflows, engines,
                        manuals/ (NIGHT-SHIFT.md, QA-SHIFT.md),
                        templates/ (work-order-template.md)
tests/                  fake-based pytest suite (no git repos needed)
docs/runbook.md         shift checklists (morning, handover, forensics)
docs/flow.md            mermaid diagrams: the day/night work flow
docs/config-sample.toml every config key, commented
docs/work-order-template.md  how orders are written (reference copy)
PLAN.md                 phased roadmap
pyproject.toml          uv project; publishes the moonlighting command
AGENTS.md               standing instructions for any agent in this repo

The rules

  • The night shift executes only approved orders, each on its own branch (wo/<id>).
  • The day shift never merges locally. moonlighting accept ID pushes a review branch to origin and opens a PR. You merge it on GitHub. Run reports, QA packets and order status flips land under the data directory, never in anyone's repo.
  • A blocked or ambiguous order stops the agent. It asks; it never guesses.
  • The night shift produces options, not answers: when the problem is unknown, an order asks for variants, and the day shift decides among them.
  • Orders can target other repos. The repo: frontmatter takes a config binding name, a path, or a git URL. URLs are cloned under the data directory and refreshed each night. Night work happens in a throwaway git worktree of the target repo — your working copies are never switched or touched. The day shift never merges locally. moonlighting accept ID pushes the branch and opens a PR.

Engines

Every harness runs the same work orders through the same flow:

engine headless invocation sessions model syntax
pi (default) pi --print deterministic: wo-<id> provider/id, optional :thinking
claude claude -p uuid per order, kept in the data dir's sessions.json alias or full model id
opencode opencode run host picks the id (ses_...), kept in the data dir's sessions.json provider/model#variant
codex codex exec --json fresh context each pass plain model string

Need another host? Add a [harness.NAME] row in the config file. Set binary, run, system, session, stdin, audit and extract. No code changes.

Pick per run with --engine (or FACTORY_ENGINE). Every harness runs under the nWave tool-call guard (nwave-ai mode all). Agent commits carry nWave attribution.

Set the model in four places, most specific first: a model: field, --model (or FACTORY_MODEL), the target repo's binding, or the [factory] section. The string passes verbatim to the selected engine. Write it in that engine's syntax from the table. Each run header records the model that ran. The same chain picks the harness: an engine: field, then --engine (or FACTORY_ENGINE), then the repo binding, then [factory], then pi. A qa-model: field follows the same chain for the QA pass, and a plan-model: field does it for the planning pass.

The QA pass can run its own model. Use --qa-model (or env FACTORY_QA_MODEL). Without it, QA uses the order model.

The night can also run a planning pass before the builder. Set plan-model the same way (--plan-model, FACTORY_PLAN_MODEL, a repo binding or [factory]). The planner writes the approach, the files and the risks, and the builder follows that plan. FACTORY_PLAN=0 turns the pass off.

Every run is double-checked by default:

  • JSON audit — the engine's full event stream is archived to the data dir's logs/*.events.jsonl. The final report is extracted from it. Opt out with FACTORY_JSON_AUDIT=0.
  • QA pre-shift — a second agent pass reviews the night's diff against the acceptance criteria and writes a verdict (SHIP/BLOCK/UNSURE) into the order file, so the morning decision takes minutes. Opt out with FACTORY_QA=0.
  • Planning pass — set a plan-model and a separate agent writes the approach before the builder starts. Off until a plan-model resolves anywhere in the chain. Opt out with FACTORY_PLAN=0.

Parallel nights

One night process runs per target repo. Processes run in parallel:

moonlighting night --repo ~/repos/shop
moonlighting night --repo git@github.com:acme/api.git --engine claude

Locks make collisions visible. One lock guards each target repo, plus one global night lock. Run the processes side by side from the same install. No extra checkouts, no conflicts.

Requirements

  • git, Python 3.11+, and uv. The package depends only on rich and typer. uv runs everything: uv sync installs the moonlighting command into the checkout, uv run pytest runs the suite. Publish to PyPI with uv build and uv publish.
  • the host CLI for your selected engine, logged in. Pick pi (pi → /login once), Claude Code (claude installed and logged in) and/or opencode (opencode auth login once). Or point PI_BIN, CLAUDE_BIN or OPENCODE_BIN at a compatible binary
  • for self-running nights: crontab (install with moonlighting schedule install)

First night

  1. moonlighting new-order "My task" — answer the prompts, then approve
  2. moonlighting night
  3. Tomorrow: moonlighting status shows the verdicts. Review the diff. Then moonlighting accept ID ships a PR. moonlighting reply ID "..." answers a blocked order or parks a review.
  4. Optional: moonlighting schedule install runs the night daily at 00:01

The full shift checklists live in docs/runbook.md.

Metadata

Release files for moonlighting-factory 0.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moonlighting-factory 0.9.2
File Size Uploaded Provenance Actions
moonlighting_factory-0.9.2.tar.gz 100.4 kB Without provenance Details for moonlighting_factory-0.9.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for moonlighting-factory 0.9.2
File Interpreter ABI Platform Actions
moonlighting_factory-0.9.2-py3-none-any.whl Python 3 none any Details for moonlighting_factory-0.9.2-py3-none-any.whl

Total release size: 145.1 kB

Release files / moonlighting_factory-0.9.2.tar.gz

Download URL moonlighting_factory-0.9.2.tar.gz
Size 100.4 kB
Tags Source
SHA-256 checksum
How to use checksums
405152918d09fa2488ab67c6f257fc3346d10c6cdf55af7130723b6e993dceea
BLAKE2b-256 checksum
How to use checksums
fcf5ee1dcac976a2a7b67da7445723042cb689986249bb25398e54fd6e0805ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / moonlighting_factory-0.9.2-py3-none-any.whl

Download URL moonlighting_factory-0.9.2-py3-none-any.whl
Size 44.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08602cccf07bf918c83528c6928d1f311f434a7914710f4d7535e856d61fd81e
BLAKE2b-256 checksum
How to use checksums
f47861f257c9e74e4a8b9b20756021b6e22d483225782e808ca11bb018d5bc53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for moonlighting-factory 0.9.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page