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 merge a reviewed order into its target repo
moonlighting answer ID "text" answer a blocked order; it re-approves for tonight
moonlighting feedback ID "text" send a review back with feedback; it goes to blocked
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
approvedorders, each on its own branch (wo/<id>). - Only the day shift merges code into a target repo's
main(squash, viamoonlighting accept ID). The factory never pushes. 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. Only the day shift merges there, and the factory never pushes.
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 withFACTORY_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-modeland a separate agent writes the approach before the builder starts. Off until aplan-modelresolves anywhere in the chain. Opt out withFACTORY_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
richandtyper. uv runs everything:uv syncinstalls themoonlightingcommand into the checkout,uv run pytestruns the suite. Publish to PyPI withuv buildanduv publish. - the host CLI for your selected engine, logged in. Pick pi
(
pi→/loginonce), Claude Code (claudeinstalled and logged in) and/or opencode (opencode auth loginonce). Or pointPI_BIN,CLAUDE_BINorOPENCODE_BINat a compatible binary - for self-running nights:
crontab(install withmoonlighting schedule install)
First night
moonlighting new-order "My task"— answer the prompts, then approvemoonlighting night- Tomorrow:
moonlighting statusshows the verdicts. Review the diff, thenmoonlighting accept ID,moonlighting feedback ID "..."ormoonlighting answer ID "..." - Optional:
moonlighting schedule installruns the night daily at 00:01
The full shift checklists live in docs/runbook.md.
Metadata
Release files for moonlighting-factory 0.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| moonlighting_factory-0.8.1.tar.gz | 95.0 kB | Without provenance | Details for moonlighting_factory-0.8.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| moonlighting_factory-0.8.1-py3-none-any.whl | Python 3 | none | any | Details for moonlighting_factory-0.8.1-py3-none-any.whl |
Total release size: 139.3 kB
Release files / moonlighting_factory-0.8.1.tar.gz
| Download URL | moonlighting_factory-0.8.1.tar.gz |
|---|---|
| Size | 95.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
500e21318963020a041a5331573de13e99069eee5d3c7e78574d8e30e495b52b
|
|
BLAKE2b-256 checksum How to use checksums |
404c8b24918c37c77c9757945b311022902a7a3c3ebbaadcd3a96f7d17e0a173
|
| 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.8.1-py3-none-any.whl
| Download URL | moonlighting_factory-0.8.1-py3-none-any.whl |
|---|---|
| Size | 44.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
89373fb9734af74964d5fcef90aa989b41764cf3336b92db46028ca159f3b1c7
|
|
BLAKE2b-256 checksum How to use checksums |
ce7c90193160dd5879438f4dcd2f36002ce7cfe7f2ebe91c0dbae4ee619381b5
|
| 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.8.1
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.