koi
Stories

Harvest Engineering

Every week the finance team adds up the previous week’s sales. Today someone copies orders from the store into a spreadsheet, one page at a time.

I want to hand that whole change to an agent: pick a week, download its orders, total the sales. And I don’t want to sit watching the chat while it works.

The way I’ve found has the rhythm of a field. I call it Harvest Engineering:

  • I prepare and plant. The team and I agree on the outcome, the limits and the checks.
  • The field grows on its own. The agent works phase by phase, and each phase proves itself before the next one starts.
  • I harvest. I try the result and find out whether it solves the problem for the people who’ll use it.
One delivery cycle
Plan with the agent The phases run on their own Try the result If something is missing, add a phase and let it run ↓ Result accepted Consolidate

I can hand off this much at once because the checks were agreed up front. The agent never needs me to say “keep going.”

Prepare the ground

A rabbit in a straw hat hoes the soil of a terraced rice field. A row of stakes marks the plot.

Before planning, I get the project to a state another developer or agent can reproduce:

  1. Open the project.
  2. Place a test order.
  3. Find the command that runs the existing tests.

On a new project, getting this far can be a piece of work in its own right.

Find the question that matters

By the light of a paper lantern, a rabbit studies a field map. Small paper flags mark the planting rows.

A good question before the plan saves a fix after it. I ask the person who uses the spreadsheet:

What happens when the week’s orders span two pages?

Their answer changes what we need to test.

Which orders belong in the file?
  1. The filter findsThree orders for the week: A, B, and C.
  2. The screen splitsA and B on the first page. C on the second.
  3. The CSV includesA, B, and C in one file, whichever page is open.

I don’t always have to ask:

  • If the answer is already documented, I go straight to planning.
  • If the open question is about the code, I use /junji research, for example to find where the date filter is applied.

Plan in phases

An otter plants rice seedlings in rows while a rabbit checks their order against an unrolled scroll.

First, the boundary. This cycle exports every order in the selected date range as a CSV. Scheduling a weekly email can wait.

Then, the phases. With Junji, that’s three commands:

  • begin surveys the repository.
  • plan chooses an approach.
  • refine breaks the work into phases.

Each phase carries the check that proves it:

Phase How we’ll know it works
P1. Fetch the orders in the date range Given three orders inside the range and one outside, the query returns exactly the expected three, even across page boundaries.
P2. Generate the CSV A test reads the generated file back and recovers the original values, including a name containing a comma.
P3. Connect the export to the orders page With a date filter applied, clicking export downloads a file containing the orders for that period.

This is where I save the most time. If I spot the pagination gap now, I fix one line of the plan. Once everything is built, the same oversight means reworking the query, the file and the tests.

None of these phases is gated, because nothing in the export is hard to undo. A migration on production data would be different: I’d mark that phase gated, and the run would stop there until I approved it.

Let it run

At night, a fox watches the young rice plants. Behind it, a rabbit writes at a low desk in an open pavilion.

Once the plan is approved, I hand off the phases. There are two ways.

In my agent’s chat, it’s one line:

/junji goal --until P3

The agent runs each phase in a fresh subagent and reads the board again before it starts the next.

Outside the chat, for longer runs, I start Yokai in a terminal, on a server or in CI:

yokai --headless --max-cost 10

Yokai adds three things:

  • a judge that reviews each change;
  • recovery when a phase misses its checks;
  • a ceiling on what the run may spend.

Either way, I go and do something else. If a test finds only the orders from the first page, the phase stays open and the agent keeps working on the query without me. If I want to work in the same project meanwhile, I use a separate worktree.

Who is in the loop
Your time and Koi’s time across one cycle A timeline of one cycle in two rows, you and Koi. You and Koi plan together. Then Koi runs phases P1 to P3 on its own while you are free for other work. When the delivery is ready, Koi calls you and you try it. You find a problem, and Koi runs the fix, P4, on its own. Finally you and Koi consolidate the run together. time → You Koi free for other work P1 → P2 → P3 P4 plan phases run try fix consolidate

Koi doesn’t send me notifications. When it needs me, it stops and says why. Three things bring me back:

  • A gated phase. The run waits for my approval before it starts that phase.
  • A halt. A check stays red, or the run reaches its cost ceiling. /junji goal reports the reason in the chat. Headless Yokai prints it and exits with code 2, which I wire to a notification of my own.
  • A delivery ready to try. No phase is left, and Koi points at /junji consolidate. It never runs that step on its own.

Harvest and check

A rabbit inspects a rice sheaf grain by grain beside a stack of sheaves with paper tags.

This time I’m called in because the export is ready. I do what the finance team would do:

  1. Ask for a summary with /junji brief.
  2. Filter a week and download the file.
  3. Open it in the spreadsheet application the team uses.

Suppose every check passed but the amounts come through as text. The orders are all there, yet someone still has to convert the entire column before adding up sales.

No test caught it, because no test opened the file in the team’s spreadsheet. The discovery belongs to the same cycle, so I describe it as a new phase:

/junji iterate When I open the CSV in the team's spreadsheet, the amounts
come through as text. I need to sum the sales column without converting it by hand.

From there:

  1. I send /junji goal again, and the fix runs on its own like the other phases.
  2. I open the new file and try the sum again.
  3. Once I accept the result, I run /junji consolidate myself.

That last step always needs a person. Junji records the deliverable in the project’s documentation and closes the current run.

Carry the lesson forward

A rabbit repairs an irrigation gate with a wooden mallet. An open notebook rests on a stone nearby.

Every cycle leaves something for the next. From this one I’d keep:

  • a small reference file;
  • a note on how the team imports the amounts.

Next time someone changes an export, we’ll know what to check. On another project, the useful change might be a more representative test or a missing setup instruction.

To budget a cycle, I put my time and the machine’s time side by side:

Your time and the machine’s time by stage
Investigate
You0–½
Koi0–1
Plan
You1
Koi1
Run the phases
You0
Koi2
Try and fix
You1
Koi½

How to read it:

  • Running the phases is the biggest share of the cycle, but it’s machine time. I step in only if a gated phase or a halt calls me.
  • Planning and trying are my shares. That’s where the question the tests can’t answer lives: can the team add up sales in the spreadsheet?
  • Investigating earns a share only when an open question could change the plan.
  • Preparing the environment and tending the project between cycles sit outside the budget.

To try a first cycle, pick a small change whose outcome you can check yourself. The getting-started guide walks you through the first phase and then lets the rest run on its own.