Not to be confused with the Raspberry Pi: in AI-assisted software development, RPI is this three-step workflow for coding agents.
Introduction: The Hidden Problem with AI-Assisted Coding
AI coding tools like GitHub Copilot, Cursor, and Claude Code produce clean code on small greenfield projects but degrade fast in large, legacy codebases — because they lack the surrounding context a senior engineer would use to make the same decision. The fix is the RPI framework: Research the codebase first, Plan the change explicitly, then Implement against that plan, instead of letting the model guess mid-generation.
Many developers report that although code delivery speed has increased, a significant portion of their time is spent fixing bad code that AI wrote last week. This low-quality code, known in the developer community as "Slop", can create significant Technical Debt.
In this article, you'll learn about a scientific and practical approach called Context Engineering and the RPI Framework that helps you solve complex problems in legacy code without producing Slop.
What is Context Engineering?
To understand Context Engineering, we first need to understand how Large Language Models (LLMs) work.
The Stateless Nature of Language Models
Language models are stateless. This means they have no memory of previous conversations, and the only thing that determines output is the input tokens. Everything you put in the Context Window directly affects response quality.
The "Dumb Zone" Concept
In practice, model performance drops noticeably once the Context Window fills past roughly 40 percent; HumanLayer’s context-engineering guide recommends keeping utilization in the 40–60% range. Dex Horthy from HumanLayer calls this phenomenon the "Dumb Zone."
The Cluttered Desk Analogy: Think of the Dumb Zone like a cluttered desk. When your desk is full of scrap paper, old notes, and unnecessary tools, finding what you actually need becomes difficult and your work quality decreases. The AI's Context Window works exactly the same way.
Solution: Smart Compaction
The solution is Smart Compaction. Instead of blindly accumulating information in context, you should:
- Intelligently summarize conversation history
- Only include relevant files in context
- Remove long JSON outputs, logs, and test results
- Use Sub-agents to summarize information
The RPI Framework: A Practical Solution for Slop-Free Coding
To solve complex problems in legacy codebases, you shouldn't immediately start coding. The RPI Framework is a three-stage workflow that prevents Slop production:
1. Research - Compressing Truth
In this stage, the goal is complete system understanding and finding the correct files. You're not writing code yet; you're "Compressing Truth."
Key Techniques:
- Use sub-agents to read large code sections and return only useful summaries
- Identify project structure, architectural patterns, and dependencies
- Understand Entry Points and data flow
2. Plan - Compression of Intent
After understanding the system, write a detailed execution plan. This plan should include:
- Exact file names that need to change
- Actual code snippets to be added or modified
- Order of changes
- Tests that need to be written
This stage is called "Compression of Intent." A good, detailed plan ensures even weaker models make fewer mistakes because ambiguity is minimized.
3. Implement - Final Code Production
Only after completing the previous two stages should you enter the implementation phase. In this stage:
- Execute the plan step by step
- Verify each change with relevant tests
- Keep context clean and remove unnecessary information
RPI vs QRSPI: what changed in 2026
In 2026 Dex Horthy revisited RPI in a talk called "Everything We Got Wrong About Research-Plan-Implement". Experts got good results with the three-step version, but their teams did not, and he traced it to two things. Research came back full of opinions because the agent knew which feature it was building. And the single planning prompt held 85+ instructions, while frontier models follow roughly 150 to 200 instructions reliably once system prompts, tools and MCP definitions are added, so steps like the design discussion were often skipped.
The revised workflow, nicknamed "crispy" (QRSPI), splits the work into smaller stages, each prompt under 40 instructions:
- Questions: turn the ticket into research questions in one context window.
- Research: answer them in a fresh window that never sees the ticket, so the output stays factual.
- Design discussion: a document of about 200 lines with the current state, desired end state, patterns to follow and open questions, reviewed by the engineer.
- Structure outline: phases, signatures and test checkpoints, "like a C header file", built as vertical slices rather than all database work first.
- Plan, work tree, implement, pull request: the plan is spot-checked, and the code itself is read and reviewed.
The last point is a reversal. Horthy now tells teams that own production systems to read the code, and to aim for a 2 to 3x speed-up at near-human quality rather than more output nobody has checked.
The Human Role: Don't Outsource Thinking
One of developers' biggest mistakes is thinking AI can replace thinking. This assumption is dangerous.
AI is an Amplifier, Not a Replacement
AI is an amplifier of your abilities, not a replacement. The most dangerous thing is allowing AI to produce code without reviewing the Plan. This is equivalent to:
- Letting an inexperienced junior make architectural decisions
- Blindly accepting any suggestion without understanding consequences
Mental Alignment
Human review of the plan creates "Mental Alignment" in the team. When someone reviews the AI's plan:
- Logical errors are identified before coding
- Team knowledge increases
- Architectural decisions are documented
What to Focus On
Instead of reading generated code line by line, focus on reviewing "Research" and "Plan". If these two stages are correct, the final code will very likely be correct too.
Context Window Management: Stay in the Smart Zone
For effective AI-assisted coding, you need to learn to stay in the "Smart Zone." This means:
Golden Rules of Context Management
- Under 40%: Always fill less than 40% of the Context Window
- Continuous Compaction: Remove unnecessary information after each stage
- Sub-agents: Use sub-agents for reading large files
- Summarization: Periodically summarize conversation history
Model size is the other lever people reach for, and it isn't always the right one: a 27-million-parameter model beat much larger LLMs on ARC-AGI by reasoning in loops instead of scaling up.
Conclusion: The Future Belongs to Adaptive Teams
Using AI in coding is no longer a choice but a competitive necessity. However, the difference between teams that succeed and teams drowning in technical debt lies in how they use it.
The future belongs to teams that:
- Learn to manage context and stay in the Smart Zone
- Use the RPI Framework (Research, Plan, Implement)
- Don't outsource thinking and review plans
- Adapt their processes to tools that now write most of the code
By implementing Context Engineering principles and the RPI Framework, you can benefit from AI's amazing advantages without falling into the trap of producing low-quality code.
This article is based on practical experiences and research by Dex Horthy from HumanLayer on optimizing AI use in software development.
The same discipline applies outside of coding: agentic AI needs the same guardrails in customer support that RPI enforces in a codebase — a defined process the model has to follow, not free rein.
Part 2: RPI in practice with Claude Code subagents — the day-to-day workflow, ownership rules for parallel agents, and how we verify results.
Frequently asked questions
What does RPI stand for?
Research, Plan, Implement: a three-phase workflow for AI coding agents. The agent first researches how the relevant code works, then writes an explicit plan of the change, and only then implements it, starting each phase with a fresh, compacted context.
What is the "Dumb Zone"?
Dex Horthy of HumanLayer's name for the drop in model performance once the context window fills past roughly 40 percent. Like a cluttered desk, the more irrelevant material in context, the worse the output.
What is smart compaction?
Instead of accumulating everything in context: summarize conversation history, include only relevant files, remove long JSON outputs, logs and test results, and use sub-agents to read and summarize large code sections.
What should a human review when an AI agent writes code?
The Research and the Plan, rather than reading generated code line by line. If those two stages are correct, the final code will very likely be correct too, and logical errors are caught before any code is written.