Skip to content

Refine-Plan-Act-Consolidate (RPAC): A File per Phase, a Fresh Session per Phase

Four phases, each started in a fresh session and closed by a file: refine requirements, plan implementation, act on the plan, consolidate the result.

Contributed by Stefano Borzì (@Helias) via agentpatterns-ai/website#11.

RPAC is a per-task workflow described by Francesco Borzì and Stefanos Lignos in the Engineering in the Age of AI publication (Borzì, RPAC) and implemented by the open-source agent-toolkit skill collection (agent-toolkit docs: Task workflow). A misunderstanding surfaces in a document before any code exists, and a failed attempt restarts from the last file instead of from scratch. It shares its skeleton with Research-Plan-Implement and Discrete Phase Separation: phases run in separate sessions and only a file crosses each boundary, never the chat history. Two choices set it apart. The first phase is Refine, an interview that settles what to build with the human, rather than research into how the code works. And the loop does not stop at working code: a fourth phase, Consolidate, reviews the change with a clean context and writes down what the reviewers need to know.

The phases

flowchart LR
    T["Ticket<br>TICKET.md"] --> R["Refine: the what<br>REQUIREMENTS.md"]
    R --> P["Plan: the how<br>PLAN.md"]
    P --> A["Act<br>code + checks"]
    A --> C["Consolidate<br>review + HANDOVER.md"]

Every phase begins in a new session and reads only the file the previous one wrote, and the human reviews that file before the next phase starts (Borzì, RPAC). It is the "offload to a file, pick up fresh" technique for keeping each session in the early, sharp part of its context window (Borzì, context window).

Ticket: the starting file

The task enters as a self-contained TICKET.md, fetched from the tracker with its attachments and linked tickets, or written by hand when there is no tracker (Borzì, daily workflow). Everything downstream works from this file, so the next phase never needs tracker access.

Refine: agree on what to build

The agent checks the ticket against the actual codebase, then interviews the human one question at a time, each question paired with a recommended answer. Questions the code can answer go to the code; only genuine decisions reach the human (agent-toolkit core philosophy). The interview borrows Matt Pocock's "grilling" technique, and the human is expected to push back and brainstorm rather than just answer (Borzì, daily workflow). The output is REQUIREMENTS.md: the validated "what", with no silent assumptions left in it. Typical catches are a ticket that names a page which no longer exists, or a missing property in a DTO that would block the change (Borzì, RPAC). This is the phase where a wrong reading of the ticket is cheapest to kill: it costs an edit to a document, not a revert of a diff. The interview is close to the technique in Interactive Clarification for Underspecified Tasks.

Plan: decide how to build it

A fresh session studies the code, settles the technical decisions with the human the same way, and writes a self-contained PLAN.md that another fresh session can execute without re-reading the requirements or the ticket (Borzì, daily workflow). The plan is a file rather than a built-in plan mode on purpose: the human can edit it in an IDE, keep it for later and share it (Borzì, RPAC). Two optional steps sit here:

  • Harden the document. Run in a fresh session: a sub-agent with a clean context checks REQUIREMENTS.md or PLAN.md against the ticket, the code, and related tickets. That session then tries to disprove each finding, and the human decides the survivors one at a time: fix, dismiss, or defer (agent-toolkit docs).
  • Split the plan. Break the steps into small tasks, each leaving the build green and the tests passing, grouped into PR-sized batches, with the first batch producing something runnable as early as the plan allows. Each task gets a done check and a suggested commit subject. The plan's own text is left unchanged; the task list is appended. The motivation is reviewability: a whole plan executed in one sweep can land twenty files at once, and a structural mistake found at that point means executing the plan again (S. Borzì, split the plan).

Act: build it

With an unsplit plan, no special tooling is needed: open a fresh session, point it at PLAN.md, and ask it to run the project's checks as well. With a split plan, run one task per fresh session. The agent implements that task and nothing beyond it, runs the task's done check and the project checks, ticks the task off in the plan, and stops so the human reviews and commits before the next one. Any deviation it had to settle along the way goes into a DECISIONS.md next to the plan, with the reason (agent-toolkit docs).

Because the thinking lives in files, a bad attempt is cheap to throw away: discard the changes, tweak PLAN.md and start a fresh session. Once the plan is solid, some practitioners hand execution to a cheaper model (Borzì, RPAC).

Consolidate: review and hand over

Consolidate has two steps.

  1. Fresh-eyes review. A sub-agent with a clean context reviews the changeset. It gets the changes and a summary of the goal, and is free to read the whole codebase, but it never sees the plan, notes or chat history of the authoring session. Handing it the reasoning that produced a bug makes it likely to miss the bug for the same reason (agent-toolkit docs: Fresh eyes review). The practice came from noticing that a session asked to review its own work found far fewer issues than a new session did, even with plenty of context left. Each finding must name a location and a concrete failure, and zero findings is a valid result. The findings go back to the authoring session, which knows the intent and helps the human separate real problems from noise (Borzì, fresh eyes). See Reviewer Independence for what a context reset does and does not buy.
  2. Handover. The agent gathers the decisions made along the way, from the ticket to the session, compares the plan with the actual diff, and writes HANDOVER.md: a paste-ready PR description with the decisions worth knowing, where to look and what is still open. If the repository has a PR template, it fills that in instead (agent-toolkit docs). It never invents a reason: a deviation with no recorded why ships flagged for the reviewer to confirm, and review findings the team chose not to fix go into the known gaps (Lignos, handover; Borzì, RPAC). The motivation is reviewer habituation: as agent PRs pile up, reviewers approve more and inspect less, so the handover points them at the decisions instead of the lines (Lignos, handover).

Why it works

  • Each phase starts at the top of a clean context window. The file replaces the conversation, so the next phase does not inherit the earlier one's dead ends; long multi-turn threads are where models "get lost and do not recover" (Laban et al., arXiv:2505.06120v1).
  • Errors are caught where they are cheapest. A wrong assumption in REQUIREMENTS.md is a paragraph to rewrite; the same assumption in a forty-file diff is a revert (core philosophy). This is the cost asymmetry behind Research-Plan-Implement.
  • The human decides at every boundary. The skills are user-invoked and nothing moves to the next phase on its own; the agent recommends, the human approves (core philosophy).
  • Document phases run in parallel. Refine and Plan only read code and write one markdown file, so several tasks can be refined and planned at once without conflicts; only Act changes source code (Borzì, daily workflow).
  • The files outlive the task. They are plain markdown any colleague or agent can read, so they double as PR descriptions, ticket comments and documentation, whether or not the rest of the team uses agents (core philosophy).

When this backfires

  • Trivial or well-defined changes. When the diff fits in one sentence, the documents restate what everyone already knows. The workflow's own guidance says such tasks may skip phases: the artifacts are a tool, not a ceremony (core philosophy). Its author skips Refine and uses a built-in plan mode for tasks like "rename this method everywhere it's used" (Borzì, RPAC).
  • Fast feedback loops. Where tests run in seconds and failures name their own fix, try-and-fix converges before the requirements file is written — the same limit noted for Research-Plan-Implement.
  • A stale plan. A self-contained PLAN.md is authoritative by design. If requirements move mid-build and nobody updates it, the executing session follows the file, not the new intent. Re-plan rather than patching in chat: the workflow's own recovery is to throw the changes away, fix PLAN.md and run again (Borzì, RPAC).
  • No measurement. The sources report higher quality and fewer wrong assumptions from the authors' own daily use, with no comparison against unstructured delegation (Borzì, RPAC; Borzì, daily workflow). Treat RPAC as a structure to try, not a measured result.

Example

Take ticket 1234, a change to the users feature. All planning files for the task live in one folder, named after the ticket (plans-directory rule). The folder is usually gitignored and named in AGENTS.md, so every session saves its files in the same place (Borzì, project setup):

.agents/plans/1234-users/
├── 1234-users.TICKET.md        # fetched from the tracker
├── 1234-users.REQUIREMENTS.md  # Refine: what to build, decisions settled
├── 1234-users.PLAN.md          # Plan: files, steps, checks; task list appended if split
├── 1234-users.DECISIONS.md     # Act: deviations from the plan, with reasons
└── 1234-users.HANDOVER.md      # Consolidate: paste-ready PR description

Each phase is a new session started with one line, for example "execute task 3 of 1234-users.PLAN.md". If task 3 goes wrong, discard the working-tree changes and run it again from the same file; nothing earlier is lost.

The loop also covers review feedback. When the PR comes back with comments, they can be triaged with the agent into a new REQUIREMENTS.md for the accepted changes, which re-enters the workflow at Plan like a refined ticket (Borzì, PR reviews).

Reference implementation

agent-toolkit ships one single-purpose skill per step, composed into the workflow (Borzì, agentic skills; Borzì, simple skills). They are user-invoked and agent-agnostic, working with Claude Code, Codex, GitHub Copilot, OpenCode and others (core philosophy):

Phase Skill Output
Ticket fetch-ticket TICKET.md
Refine refine-ticket REQUIREMENTS.md
Plan create-implementation-plan, optional harden-artifact and split-plan-tasks PLAN.md
Act plain prompt, or execute-plan-tasks per task code, DECISIONS.md
Consolidate fresh-eyes-review (or self-review), then handover HANDOVER.md

The pattern does not depend on these skills: a prompt that produces the same files at the same boundaries gives the same structure.

Key Takeaways

  • Close every phase with a file and start the next one in a fresh session; never carry the chat history across.
  • Refine the "what" with the human before planning the "how": one question at a time, each with a recommended answer.
  • Make the plan self-contained so execution re-derives nothing, and split it into green-build tasks when one sweep would be too big to review.
  • Add a fourth phase after the code works: a review by a context that never saw the plan, and a handover that records the decisions for reviewers.
  • Skip phases on trivial work; the files are a tool, not a ceremony.

Sources