Skip to content
Research, Plan, Implement

Research, Plan, Implement

Research, Plan, Implement (RPI) is a suggested workflow for making non-trivial changes with Claude Code. It isn’t mandatory, but it’s the most practical way we know to follow the rule in AI at Safetybits: never ship anything you don’t understand.

The idea is simple: don’t ask the agent to write code straight away. First understand the code, then agree on a plan, and only then write the code. A human reviews the research and the plan, because that’s where review pays off most: one wrong line in a plan turns into hundreds of wrong lines of code.

When to use it

  • New features and changes that touch several components (sensor, backend, frontend).
  • Bugs in code you don’t know well.
  • Anything where you couldn’t explain the change before starting.

Skip it for trivial changes: typos, dependency upgrades, one-line fixes.

Research

Understand how the code works today, before deciding anything.

  1. Start a fresh Claude Code session.
  2. Ask it to explore and describe the relevant code: files, data flows, existing patterns, tests and anything surprising. Facts only, no solution yet. It works better without the issue in front of it, so it describes the code as it is instead of jumping to an answer.
  3. Read the result, and check the important claims against the code yourself.
  4. Post the research as a comment on the GitHub issue.

Example prompt:

Research how discovered devices flow from the sensor to the backend inventory.
List the files, functions and data structures involved, the existing tests,
and any patterns or conventions the code follows. Describe what exists today;
don't propose changes.

Plan

Decide what to change and how, in writing.

  1. Start a fresh session with the research and the issue.
  2. Ask for a step-by-step implementation plan that includes:
    • the steps, in order, each small enough to review and merge on its own;
    • the files to change;
    • the tests to write first for each step (see Testing);
    • how to verify it end to end, on real hardware when it touches the sensor;
    • what’s out of scope.
  3. Review and edit the plan until you’d be happy to defend it. Push back on anything you don’t understand or that doesn’t follow our patterns.
  4. Post the plan as a comment on the GitHub issue. For larger changes, ask a teammate to review it before any code is written.

Example prompt:

Using the research above and issue #1234, write an implementation plan.
Split it into small steps that each leave main working, list the files to
change and the tests to write first for each step, explain how we'll verify
it end to end, and state what's out of scope.

Implement

Follow the plan, one step at a time.

  1. Start a fresh session with the plan.
  2. For each step: write the tests first, implement, run them, and check CI passes locally.
  3. Tick off steps in the plan on the issue as you go, and note any change to the plan and why.
  4. Open a small pull request per step or group of steps, merged to main as you go (trunk-based development). Summarize the plan in the PR description and link the issue.
  5. Read every line of the diff before asking for review. You must be able to explain all of it.

If implementation shows the plan was wrong, stop, fix the plan on the issue, and continue from there.

Keep the context small

  • A fresh session for each phase. Long conversations drift, and old mistakes keep influencing new answers.
  • Pass documents forward, not conversations. The research and the plan on the issue are the hand-off between phases.
  • Keep it focused. Point the agent at the parts of the code that matter instead of the whole repository.

Without AI

The same three steps are just good engineering. Understanding the code before changing it, and agreeing on a plan before writing it, work just as well when you do all of it yourself.

Further reading