Skip to content

Commit cbaa4a9

Browse files
docs: add comprehensive RPI workflow documentation (#153)
## Summary This PR adds a new "why-rpi.md" document explaining the psychology behind constraint-based AI workflows and propagates consistent messaging about the RPI framework across all RPI documentation. The core insight—AI can't distinguish between investigating and implementing, and constraints change the goal—now appears throughout the documentation ecosystem. ## Changes - **docs**(_rpi_): create `why-rpi.md` explaining the psychology of constraint-based AI behavior, quality comparisons between traditional and RPI approaches, and guidance for choosing between strict RPI and rpi-agent - **docs**(_root_): rewrite README.md "Try the RPI Workflow" section with the constraint insight, reorder bullets to lead with "why" before tutorial - **docs**(_rpi_): enhance README.md "Why Use RPI?" section with key benefits (pattern matching, traceability, knowledge transfer) and TIP callout linking to why-rpi.md - **docs**(_rpi_): add NOTE callouts to task-researcher.md, task-planner.md, and task-implementor.md explaining why constraints matter for each mode - **docs**(_rpi_): expand using-together.md with "RPI Agent: When Simplicity Fits" section, quick decision guide table, and escalation path - **docs**(_getting-started_): add IMPORTANT callout to first-workflow.md connecting the tutorial to the underlying constraint insight ## Related Issue Closes #152 📚 - Generated by Copilot
1 parent 5113e3b commit cbaa4a9

8 files changed

Lines changed: 223 additions & 15 deletions

File tree

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,17 @@ For manual setup or alternative installation methods, see the [Getting Started G
6565

6666
### Try the RPI Workflow
6767

68-
Transform complex tasks into working code using Research → Plan → Implement:
68+
AI coding assistants are brilliant at simple tasks. Ask for a function that reverses a string, and you'll get working code in seconds. Ask for a feature that touches twelve files across three services, and you'll get something that looks right, compiles cleanly, and breaks everything it touches.
6969

70-
1. Complete the [Your First RPI Workflow](docs/getting-started/first-workflow.md) tutorial (~15 min)
71-
2. For simple tasks, use [prompts](.github/prompts/README.md) directly without the full workflow
70+
The root cause: AI can't tell the difference between investigating and implementing. When you ask for code, it writes code. It doesn't stop to verify that the patterns it chose match your existing modules. AI generally writes first and thinks never.
71+
72+
HVE Core's RPI (Research → Plan → Implement) framework solves this by separating concerns into distinct phases. When AI knows it cannot implement during research, it stops optimizing for "plausible code" and starts optimizing for "verified truth." The constraint changes the goal.
73+
74+
Get started with RPI:
75+
76+
* [Why the RPI Workflow Works](docs/rpi/why-rpi.md): the psychology behind constraint-based AI workflows
77+
* [Your First RPI Workflow](docs/getting-started/first-workflow.md): 15-minute hands-on tutorial
78+
* [rpi-agent](.github/chatmodes/rpi-agent.chatmode.md): autonomous mode for simpler tasks that don't need strict phase separation
7279

7380
## What's Included
7481

docs/getting-started/first-workflow.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ You'll create:
3131

3232
**Why use RPI for this?** Multiple unknowns: existing script patterns, PowerShell conventions, npm integration, output format. Research first reduces guesswork.
3333

34+
> [!IMPORTANT]
35+
> **Why this matters:** AI can't tell the difference between investigating and implementing. When you ask for code, it writes code—patterns that look plausible but break your conventions. RPI's constraint system changes the goal: when AI knows it cannot implement, it stops optimizing for "plausible code" and starts optimizing for "verified truth." [Learn more about why RPI works](../rpi/why-rpi.md).
36+
3437
## Before You Start
3538

3639
**The `/clear` command** resets Copilot's context between phases. Each RPI phase should start fresh—the artifacts (research doc, plan) carry the context forward, not the chat history.

docs/rpi/README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ The RPI (Research, Plan, Implement) workflow transforms complex coding tasks int
1919
2020
## Why Use RPI?
2121

22-
Traditional AI coding assistants work well for simple tasks but struggle with complex, multi-file changes. Without structure:
22+
AI coding assistants are brilliant at simple tasks and break everything they touch on complex ones. The root cause: AI can't tell the difference between investigating and implementing. When you ask for code, it writes code. It doesn't stop to verify that patterns match your existing modules or that the APIs it's calling actually exist.
2323

24-
* AI makes assumptions instead of investigating
25-
* Context gets polluted with accumulated guesses
26-
* Implementation details contradict earlier decisions
27-
* You spend time correcting rather than building
24+
RPI solves this through a counterintuitive insight: when AI knows it cannot implement, it stops optimizing for "plausible code" and starts optimizing for "verified truth." The constraint changes the goal.
2825

29-
RPI solves this by separating concerns into distinct phases, each with its own specialized chat mode.
26+
**Key benefits:**
27+
28+
* 🔍 **Pattern matching**: uses verified existing patterns instead of inventing plausible ones.
29+
* 📋 **Traceability**: every decision traced to specific files and line numbers.
30+
* 🔄 **Knowledge transfer**: research documents anyone can follow, not tribal knowledge.
31+
32+
> [!TIP]
33+
> **Want the full explanation?** See [Why the RPI Workflow Works](why-rpi.md) for the psychology, quality comparisons, and guidance on choosing between strict RPI and rpi-agent.
34+
35+
RPI separates concerns into distinct phases, each with its own specialized chat mode.
3036

3137
## The Three Phases
3238

docs/rpi/task-implementor.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Use Task Implementor after completing planning when you need:
3232
5. **Verifies** success criteria before marking complete
3333
6. **Pauses** at stop points for your review
3434

35+
> [!NOTE]
36+
> **Why the constraint matters:** Task Implementor has one job: execute the plan using patterns documented in research. No time wasted rediscovering conventions, no "creative" decisions that break existing patterns—just verified facts applied methodically.
37+
3538
## Output Artifacts
3639

3740
Task Implementor creates working code and a changes log:

docs/rpi/task-planner.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Use Task Planner after completing research when you need:
3131
4. **Organizes** tasks into logical phases with dependencies
3232
5. **Generates** an implementation prompt for Task Implementor
3333

34+
> [!NOTE]
35+
> **Why the constraint matters:** Task Planner receives verified research and transforms it into actionable steps. Because it can't implement, it focuses entirely on sequencing, dependencies, and success criteria—the plan becomes a contract that prevents improvisation during implementation.
36+
3437
## Output Artifacts
3538

3639
Task Planner creates three files:

docs/rpi/task-researcher.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Escalate to Task Researcher when your task involves:
3232
4. **Recommends** ONE approach per technical scenario
3333
5. **Outputs** a comprehensive research document
3434

35+
> [!NOTE]
36+
> **Why the constraint matters:** Task Researcher knows it will never write the code. This single constraint transforms its behavior—it searches for existing patterns instead of inventing new ones, cites specific files as evidence, and questions its own assumptions because it can't hide them in implementation.
37+
3538
## Output Artifact
3639

3740
Task Researcher creates a research document at:

docs/rpi/using-together.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,27 @@ RPI artifacts support handoffs:
230230
231231
Remember: **Always `/clear` between phases!**
232232

233-
## RPI Agent
233+
## RPI Agent: When Simplicity Fits
234234

235-
For tasks that don't require strict phase separation, **rpi-agent** provides autonomous execution with subagent delegation. RPI-agent combines research and implementation into a single workflow, making it ideal for:
235+
For tasks that don't require strict phase separation, **rpi-agent** provides autonomous execution with subagent delegation. Use it when the scope is clear and you don't need the deep iterative research that comes from constraint-based separation.
236236

237-
* Straightforward feature implementations
238-
* Bug fixes with clear scope
239-
* Discovery during implementation as deeper research can be handed off to Task Researcher from RPI Agent
237+
### Quick Decision Guide
240238

241-
See [Chat Modes Reference](../../.github/chatmodes/README.md) for rpi-agent details.
239+
| Choose Strict RPI when... | Choose rpi-agent when... |
240+
|------------------------------|------------------------------------|
241+
| Deep research is critical | Scope is clear and straightforward |
242+
| Multi-file pattern discovery | Minimal external research needed |
243+
| Team handoff needed | Quick iteration during development |
244+
| Compliance or security work | Exploratory or prototype work |
245+
246+
### Escalation Path
247+
248+
You don't have to decide upfront. Start with rpi-agent for speed, and if the task reveals hidden complexity, it can hand off to Task Researcher. This hybrid approach gives you speed for simple tasks and the verified truth that comes from constraint-based research when you need it.
249+
250+
> [!TIP]
251+
> For the full explanation of why constraints change AI behavior, see [Why the RPI Workflow Works](why-rpi.md#the-counterintuitive-insight).
252+
253+
See [Chat Modes Reference](../../.github/chatmodes/README.md) for rpi-agent implementation details.
242254

243255
## Related Guides
244256

docs/rpi/why-rpi.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
---
2+
title: Why the RPI Workflow Works
3+
description: The psychology, research, and principles behind the Research-Plan-Implement framework, plus guidance on when to use RPI vs rpi-agent
4+
author: Microsoft
5+
ms.date: 2026-01-05
6+
ms.topic: concept
7+
keywords:
8+
- rpi workflow
9+
- ai constraints
10+
- research first
11+
- hallucination prevention
12+
- ai coding
13+
estimated_reading_time: 8
14+
---
15+
16+
AI coding assistants are brilliant at simple tasks. Ask for a function that reverses a string, and you'll get working code in seconds. Ask for a feature that touches twelve files across three services, and you'll get something that looks right, compiles cleanly, and breaks everything it touches.
17+
18+
If you've spent hours debugging AI-generated code that ignored your project's conventions, used variable names that don't match anything in your codebase, or confidently called APIs that don't exist, you're not alone. The problem isn't that AI is incapable. The problem is that we're asking it to do too many things at once.
19+
20+
## The Real Problem
21+
22+
Here's what took us a while to figure out: AI is doing exactly what it's designed to do. When you ask it to "build a feature," it generates plausible output quickly. The issue is that "plausible" and "correct" aren't the same thing.
23+
24+
> [!WARNING]
25+
> **The failure mode you'll recognize**
26+
>
27+
> You: "Build me a Terraform module for Azure IoT"
28+
>
29+
> AI: *immediately generates 2000 lines of code*
30+
>
31+
> Reality: Missing dependencies, wrong variable names, outdated patterns, breaks existing infrastructure
32+
33+
Why does this happen? Because AI can't tell the difference between investigating and implementing. When you ask for code, it writes code. It doesn't stop to verify that the variable naming convention it chose matches your existing modules. It doesn't check whether the resource it's creating already exists. It doesn't ask itself whether the API it's calling is current or deprecated.
34+
35+
AI writes first and thinks never. Not because it's broken, but because that's the only mode it has when you give it unrestricted access to both research and implementation.
36+
37+
## The Counterintuitive Insight
38+
39+
The solution isn't teaching AI to be smarter. It's preventing AI from doing certain things at certain times.
40+
41+
RPI (Research → Plan → Implement) works by separating AI work into three distinct phases, each handled by a specialized mode:
42+
43+
* [Task Researcher](task-researcher.md): investigates your codebase and external sources, producing verified findings with citations
44+
* [Task Planner](task-planner.md): transforms research into actionable implementation plans with clear success criteria
45+
* [Task Implementor](task-implementor.md): executes plans methodically, following established patterns discovered during research
46+
47+
The magic happens because each phase starts fresh. When you clear context between phases, the implementation session doesn't carry forward the assumptions from research. It only has the documented artifacts: verified findings, explicit decisions, and cited evidence.
48+
49+
### The Difference in Practice
50+
51+
**Without RPI**, AI thinks: "This looks like a reasonable variable name. I'll use `prefix`."
52+
53+
**With RPI**, Task Researcher finds: "12 existing modules in this repository use `resource_prefix`, not `prefix`. See [variables.tf#L47](../infrastructure/modules/base/variables.tf#L47) for the established pattern."
54+
55+
When AI knows it cannot implement during research, it stops optimizing for "plausible code" and starts optimizing for "verified truth." The constraint changes the goal.
56+
57+
## What Happens in Each Phase
58+
59+
Understanding what AI does differently in each phase helps explain why separation works.
60+
61+
### Research Phase: Investigating, Not Guessing
62+
63+
Task Researcher knows it will never write the code. This single constraint transforms its behavior:
64+
65+
* Searches for existing patterns instead of inventing new ones.
66+
* Cites specific files and line numbers as evidence.
67+
* Questions its own assumptions because it can't hide them in implementation.
68+
* Documents dependencies, APIs, and conventions with precision.
69+
70+
The output is a research document that anyone can verify. No tribal knowledge. No "I think this is how it works."
71+
72+
### Planning Phase: Sequencing, Not Improvising
73+
74+
Task Planner receives verified research and transforms it into actionable steps. Because it can't implement, it focuses entirely on:
75+
76+
* Breaking work into logical, sequenced tasks.
77+
* Identifying dependencies between changes.
78+
* Defining clear success criteria for each step.
79+
* Anticipating edge cases before code is written.
80+
81+
The plan becomes a contract. When implementation begins, the AI follows the plan rather than making decisions on the fly.
82+
83+
### Implementation Phase: Following, Not Inventing
84+
85+
Task Implementor has one job: execute the plan using the patterns documented in research. This is where the payoff becomes obvious:
86+
87+
* No time wasted rediscovering conventions.
88+
* No "creative" decisions that break existing patterns.
89+
* No assumptions about how things work, only verified facts.
90+
* Clear accountability when something goes wrong.
91+
92+
## The Quality Difference
93+
94+
RPI produces measurably different outcomes than traditional AI coding:
95+
96+
| Aspect | Traditional Approach | RPI Approach |
97+
|------------------------|----------------------------------------------------|----------------------------------------------|
98+
| **Pattern matching** | Invents plausible patterns | Uses verified existing patterns |
99+
| **Traceability** | "The AI wrote it this way" | "Research document cites lines 47-52" |
100+
| **Knowledge transfer** | Tribal knowledge in your head | Research documents anyone can follow |
101+
| **Rework** | Frequent, after discovering assumptions were wrong | Rare, because assumptions are verified first |
102+
103+
### The Paradigm Shift
104+
105+
Stop asking AI: "Write this code."
106+
107+
Start asking: "Help me research, plan, then implement with evidence."
108+
109+
RPI treats AI as a research partner first, code generator second. The code comes last, after the hard work of understanding is complete.
110+
111+
## The Learning Curve
112+
113+
Let's be honest: your first RPI workflow will feel slower. You're learning a new process, building muscle memory for context clearing, and adjusting to the handoff between phases.
114+
115+
By your third feature, the workflow feels natural. The research phase becomes faster because you know what questions to ask. The planning phase tightens because you recognize what level of detail works for your codebase. Implementation becomes almost mechanical.
116+
117+
The value compounds over time. Research documents accumulate into institutional memory. New team members can read how past decisions were made. Patterns get documented once and referenced forever.
118+
119+
## Choosing Your Workflow: RPI vs rpi-agent
120+
121+
HVE Core provides two workflow options. The right choice depends on the task, not personal preference.
122+
123+
### Strict RPI: When Quality Matters Most
124+
125+
Use the three-phase workflow ([Task Researcher](task-researcher.md)[Task Planner](task-planner.md)[Task Implementor](task-implementor.md)) when:
126+
127+
* 🔍 **Deep research needed**: new frameworks, external APIs, compliance requirements
128+
* 📁 **Multi-file changes**: pattern discovery across the codebase
129+
* 👥 **Team handoff**: artifacts document decisions for others
130+
* 🔧 **Long-term maintenance**: work you'll maintain and evolve over time
131+
132+
**The workflow:**
133+
134+
1. Invoke Task Researcher → produces research document with citations
135+
2. Clear context, invoke Task Planner → produces implementation plan
136+
3. Clear context, invoke Task Implementor → implements following the plan
137+
138+
### rpi-agent: When Simplicity Fits
139+
140+
Use the [autonomous agent](../../.github/chatmodes/rpi-agent.chatmode.md) when:
141+
142+
***Clear scope**: straightforward feature or bug fix
143+
***Minimal research**: codebase-only investigation
144+
***Quick iteration**: active development with fast feedback loops
145+
146+
**The workflow:** Single rpi-agent session that handles research and implementation together.
147+
148+
### Matching Tool to Task
149+
150+
| Factor | Strict RPI | rpi-agent |
151+
|-----------------------|--------------------------------|-----------------------------|
152+
| Research depth | Deep, verified, cited | Moderate, inline |
153+
| Context contamination | Eliminated via `/clear` | Possible |
154+
| Audit trail | Complete artifacts | Summary only |
155+
| Best for | Complex, unfamiliar, team work | Simple, familiar, solo work |
156+
157+
### Escalation Path
158+
159+
rpi-agent can hand off to Task Researcher when it encounters complexity beyond its scope. This hybrid approach gives you speed for simple tasks and depth when needed. You don't have to decide upfront; start with rpi-agent and escalate if the task reveals hidden complexity.
160+
161+
## Next Steps
162+
163+
Ready to try it yourself?
164+
165+
* [Your First RPI Workflow](../getting-started/first-workflow.md): 15-minute hands-on tutorial
166+
* [Using the Modes Together](using-together.md): context management and handoffs
167+
* [RPI Overview](README.md): the three modes explained
168+
169+
---
170+
171+
🤖 *Crafted with precision by ✨Copilot using the RPI workflow*

0 commit comments

Comments
 (0)