The RPI Framework: A Refresher

The Research, Plan, Implement (RPI) framework for AI coding agents is designed to maximize effectiveness by compartmentalizing tasks. The core idea, as detailed in our previous article, is to maintain clean context for each phase. Research should operate independently, gathering information without cluttering the primary workspace. Planning occurs deliberately in the main conversation, outlining the path forward before any code is touched. Finally, implementation leverages the research and plan to execute changes.

This article moves beyond the theory to detail the practical application of this workflow using Claude code subagents. It’s not about setting benchmark records; it’s about the day-to-day reality of a small team managing a monorepo with around a dozen products. These products span diverse areas, including a helpdesk system, Manufacturing Execution Systems (MES), email hosting, and a university AI assistant. The aim is to provide a working setup, emphasizing the lessons learned from failures, which are often the most valuable insights.

Structuring the Workflow: Research Subagent

The first critical step is isolating the research phase. This subagent runs entirely separate from the main conversational context. Its sole purpose is to gather information relevant to the task at hand. This could involve researching specific libraries, understanding existing codebases, or identifying potential solutions to a technical problem. The output of the research subagent is typically a concise summary or a newly generated file containing the gathered intelligence. By keeping this separate, we prevent the extensive documentation or code snippets from polluting the main thread, which is crucial for maintaining focus during the planning and implementation stages.

For instance, when tasked with integrating a new payment gateway, the research subagent would be prompted to find the most suitable Python libraries, their API documentation, and any common integration pitfalls. The output would be a clean document listing these findings, ready for review. This strict separation ensures that the main conversation remains uncluttered and focused on strategic decision-making.

Claude Code Subagent interface showing focused research output

The Planning Phase: Deliberate and Explicit

Once the research is complete and its findings are presented, the next phase is planning. This is where human oversight and strategic thinking are paramount. The planning phase occurs entirely within the main conversation. It is a deliberate, written process that solidifies the approach before any code is written or modified. This means outlining the specific changes to be made, the order of operations, and any potential edge cases or dependencies.

The team leads the AI through this process, asking clarifying questions and ensuring the plan is robust. It's not enough for the AI to suggest a plan; the human operator must validate it. This often involves a back-and-forth to refine the strategy. For example, if the research identified two viable libraries, the planning phase would involve a discussion about the pros and cons of each in the context of the existing project, leading to a definitive choice and a detailed step-by-step implementation outline. This explicit documentation of the plan serves as a contract for the subsequent implementation phase and provides a clear record for future reference.

Implementation: Iterative Code Generation

The implementation phase is where the AI, guided by the research and the approved plan, generates or modifies code. This phase is iterative. The AI writes code based on the plan, and the human operator reviews it. Feedback is provided, and the AI refines the code accordingly. This loop continues until the implementation meets the requirements outlined in the plan.

A key aspect of this phase is managing context. Claude's context window is substantial, but it's not infinite. The team employs strategies to keep the relevant code and discussion within the active context. This might involve summarizing previous code blocks or explicitly instructing the AI to focus on specific files or functions. When introducing a new feature, for example, the plan might dictate creating a new module. The AI would then generate the initial code for this module. Upon review, if a bug is found or an improvement is suggested, the human would provide feedback, and the AI would regenerate or modify the code. This iterative process, coupled with careful context management, allows for the development of complex features.

Handling Failures: The Most Valuable Lessons

The true value of sharing a workflow lies in acknowledging and dissecting failures. One common pitfall is context pollution. If the research subagent is not strictly confined, its output can overwhelm the main conversation, making planning difficult. Another issue arises when the implementation phase drifts from the plan. Without constant human guidance, the AI might explore alternative solutions or introduce unintended side effects. This is why the explicit, written plan is so critical – it acts as a fixed reference point.

For instance, a failure might occur when a complex refactoring task is attempted. The AI might generate code that looks correct but breaks subtle dependencies elsewhere in the monorepo. The discovery of such a failure requires reverting, re-evaluating the plan, and potentially re-running the research subagent with more specific prompts. The team learned that over-reliance on AI for planning without rigorous human validation is a recipe for disaster. Similarly, expecting the AI to