/lightsout:implement
Build a finished plan unattended — agents write the code and tests, and the repo’s own checks must pass at every step before the run moves on.
When to reach for it
Run it when a plan is graded and you want the work done unattended. Every step is gated by the repo’s own tests, lint, types and coverage, and the run parks rather than pushing past a gate it cannot satisfy. A plan folder missing from this machine is restored from the ticket’s attachments, and a plan its work order’s record does not let run — a lower plan unfinished, say, or the plan already implemented — is refused in one sentence naming what is in the way. The run’s records sit in the primary checkout, in its run folder: .lightsout/work-orders/<work-order>/runs/<id>/ for a plan of a work order, .lightsout/implement/runs/<id>/ otherwise.
How to run it
lightsout implement --plan <path>- folder: overview.md runs all phases, else plan.md
lightsout implement --plan <folder>
- --plan <path>
- The plan file to implement.Required
- --overview <path>
- The overview this plan is one phase of, so the run reads the wider intent.Left out: The plan is implemented on its own.
- --packages <a,b>
- Comma-separated package names the gates are scoped to.Left out: The packages the run actually changed files in.
- --plan <folder>
- A plan workspace folder — overview.md runs every phase as a child run, plan.md runs the one.Required
- --start-phase <n>
- The phase number a phased run begins at.Left out: The first phase that has not already passed.
- --cwd <path>
- Repository to implement in.Left out: The process working directory.
- --skip-refactor
- Skip the refactor step at the end of the run.Left out: off
- --worktree
- Build in a fresh git worktree of this repository, on a branch named after the plan’s ticket folder.Left out: The
implement.worktreeconfig key, which defaults to on. - --no-worktree
- Build in the checkout this was launched from rather than a worktree of its own. The run commits everything in that checkout, so it refuses to start while the checkout holds uncommitted changes and lists them; a phased plan checks again before each phase, not counting
generatedpaths.Left out: off - --ship
- Ship the branch after the run passes: open or adopt the PR, wait for checks, merge, clean up.Left out: off
- --no-ship
- End on the run result even when the config’s
ship.after-implementasks to chain into ship.Left out: off - --detach
- Run in a background engine process that outlives this terminal or session. The command returns once the run has started and prints its id; the engine’s output goes to the run’s launch log in the launches folder of the shared state dir (.lightsout/launches/<id>.log in the primary checkout). It needs macOS or Linux.Left out: The run happens in the foreground, printing as it goes, and Ctrl-C stops it.
What happens
- 1
START THE RUN
the engine- Hand the finished plan to
/implement - Resolve settings from the config
- Snapshot existing worktree changes and create a run ID
- Create a repository lock so other lightsout runs cannot clash
Isolates the agent’s changes and makes the run safely resumable
Files written
<run folder>/manifest.json.lightsout/lock.json - Hand the finished plan to
- 2
VERIFY THE REPO STARTS GREEN
the engine- Run lint, type checks, tests, build, and coverage before implementation begins
- Stop immediately if any gate is already failing
- Record files touched by setup or gates in the manifest
Proves any later failure was introduced by this run, not inherited from the repository
Files written
manifest.json<run folder>/commands.jsonl - 3
WRITE THE ACCEPTANCE TESTS
the agent- Write the tests the plan names as its acceptance tests, before any code
- Later changes may correct a test the plan made stale, but never weaken or drop one
- Skip this step when the plan names no acceptance tests
Fixes what done means before the code that has to meet it exists
Files written
<run folder>/agents/stream-NN-write-ledger-tests.jsonl - 4
IMPLEMENT THE PLAN
the agent- The implementation agent follows the finished spec
- It writes the code and returns a structured report
- It can run only commands explicitly allowed in the config
Executes the finished spec without reopening settled decisions
Files written
<run folder>/agents/stream-NN-implement.jsonlrejected-*.txt - 5
VERIFY THE IMPLEMENTATION
the engine- Run the configured formatter, then re-run lint, type checks, tests, build, and coverage
- Try up to two lightweight repairs if a gate fails
- If the gates remain red, park the run with all evidence
Prevents a broken implementation from moving forward
Files written
manifest.json.lightsout/friction.jsonl - 6
WRITE THE TESTS
the agent- Spawn a test-writing agent for each source file that changed
- Add tests until coverage meets the configured threshold
- Skip this step when no eligible source files changed
Makes sure the new behavior is covered by tests
Files written
<run folder>/agents/stream-NN-write-tests.jsonl - 7
VERIFY THE TESTS
the engine- Run the configured formatter, then re-run lint, type checks, tests, build, and coverage
- Check that every acceptance test ran and passed
- Try up to two lightweight repairs if a gate fails
Confirms the new tests pass and coverage meets the configured threshold
Files written
manifest.json.lightsout/friction.jsonl - 8
REFACTOR
the agent- Review changed code for duplication and structural issues
- Reuse existing helpers or extract shared abstractions
- Refactor to your code standards without changing behavior
- Skip this step when requested or when nothing changed
Removes duplication and keeps agent-written code aligned with your code standards
Files written
<run folder>/agents/stream-NN-refactor.jsonl - 9
VERIFY THE REFACTOR
the engine- Run the configured formatter, then re-run lint, type checks, tests, build, and coverage
- Try up to two lightweight repairs if a gate fails
Confirms the refactor preserved behavior and passes every gate
Files written
manifest.json.lightsout/friction.jsonl - 10
COMMIT AND REPORT
the engine- Commit each unit that passed — a phase, or the whole run — as
<ticket>: <summary>, naming the plan and the run in the body - Fail the run when its agents changed no files
- Record the final status, steps, retries, rejected reports, token cost, and friction in the run folder
Leaves the verified work in git history and an inspectable record of why the run passed or failed
Files written
<run folder>/ - Commit each unit that passed — a phase, or the whole run — as
- 11
SHIP THE BRANCH
the engine- Only when asked: with
--ship, or when the config setsship.after-implement - Bring in the latest main and re-run the gates
- Push, open the pull request, wait for its checks, then merge and clean up
Takes a passed run all the way to merged without a second command
Files written
.lightsout/work-orders/<name>/ship.json - Only when asked: with