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 in
work-orders/ 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.
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
work-orders/ order files (tracked in the factory repo; FACTORY_ORDERS_DIR relocates it)
night-shift/NIGHT-SHIFT.md the night agent's operating manual
night-shift/QA-SHIFT.md the QA pre-shift reviewer's manual
night-shift/logs/ run reports, QA packets, event streams, morning digest (append-only)
night-shift/sessions.json engine session ids per order (local state, gitignored)
night-shift/locks/ run locks (gitignored)
night-shift/worktrees/ per-run worktrees of target repos (gitignored, removed after each run)
repos/ target repos cloned from git URLs (gitignored)
src/moonlighting/ the library; every workflow is a moonlighting subcommand
bin/ misc scripts (the factory greeting)
docs/work-order-template.md how orders are written
docs/runbook.md shift checklists (morning, handover, forensics)
docs/flow.md mermaid diagrams: the day/night work flow
PLAN.md phased roadmap
tests/ pytest suite for the factory scripts
pyproject.toml uv project; publishes the factory 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
main(squash, viamoonlighting accept ID). Night bookkeeping (order files, run logs) commits straight tomain— but never contains code. Order files live inwork-orders/, tracked.FACTORY_ORDERS_DIRrelocates them. - 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:
repo:frontmatter takes a path or a git URL (URLs are cloned underrepos/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
Three hosts run 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 night-shift/sessions.json |
alias or full model id |
| opencode | opencode run |
host picks the id (ses_...), kept in night-shift/sessions.json |
provider/model#variant |
Pick per run with --engine (or FACTORY_ENGINE). All three run under the
nWave tool-call guard (nwave-ai mode all). Agent commits carry nWave
attribution.
Set the model in three places, most specific first: a model: field,
--model (or FACTORY_MODEL), or the host default. 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 QA pass can run its own model. Use --qa-model (or env
FACTORY_QA_MODEL). Without it, QA uses the order model.
Every run is double-checked by default:
- JSON audit — the engine's full event stream is archived to
night-shift/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.
Several factories, several repos
One factory process per target repo; processes run in parallel:
factory night --repo ~/repos/shop
factory night --repo git@github.com:acme/api.git --engine claude
Locks make collisions visible: one night per target repo, one night per factory checkout. For true parallel nights, clone this factory once per repo and run one process in each:
git clone ~/repos/moonlighting ~/factories/shop-factory
cd ~/factories/shop-factory
factory night --repo ~/repos/shop
# in another terminal, another clone, another repo, same time — no conflict
The morning is still one command per factory:
factory status
Requirements
- git, Python 3.9+, and uv. The factory code
is stdlib-only. 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.1.2
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.1.2.tar.gz | 60.7 kB | Without provenance | Details for moonlighting_factory-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| moonlighting_factory-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for moonlighting_factory-0.1.2-py3-none-any.whl |
Total release size: 94.2 kB
Release files / moonlighting_factory-0.1.2.tar.gz
| Download URL | moonlighting_factory-0.1.2.tar.gz |
|---|---|
| Size | 60.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be950f7c5b89ba395eaf5f80416b388b7ed096183a7e0348dea27f2e38b14da4
|
|
BLAKE2b-256 checksum How to use checksums |
f2cf02915691b3159d1eb1a48a6ecd5f5e5ff1a704e140dbd37d9902fdf0aa41
|
| 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.1.2-py3-none-any.whl
| Download URL | moonlighting_factory-0.1.2-py3-none-any.whl |
|---|---|
| Size | 33.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
987039c4d664281728f2861b43de5c93707b7cb076f79e6d9da6a6ceabc1e37f
|
|
BLAKE2b-256 checksum How to use checksums |
c1897aca742512540a4705444439c7ed9eca07a93b9357535a293453277d59e2
|
| 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.1.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.