ContextliContextli

Developers · Refactor Plan Note

Talk through a refactor before you touch the code.

Who this is for

Developers about to refactor who want a controlled plan, not a half-migrated mess they lose track of partway through.

The moment this saves you

I start a refactor with a clear picture in my head, get three files deep, lose the thread, and end up with a half-migrated mess that's worse than what I started with and risky to ship.

See it work

Messy spoken thought in. A clean, structured artifact out.

What you said

Planning a refactor. The problem is our API routes are all giant functions with the validation, business logic, and database stuff all mixed together, it's untestable and every change is scary. The target is to split each into three layers, a thin route handler, a service layer for logic, and a repository for data access. The safe way to do this, I'll start with the most isolated route, the one with no shared dependencies, prove the pattern there, write tests, then migrate the rest one route at a time, never more than one in flight. The risk is touching the shared user service, that's used everywhere, save that for last and do it carefully. I do not want a big-bang rewrite, incremental only.

refactor-plan-note.md

Refactor plan, June 5, 2026

  • Problem: API routes are giant functions mixing validation, business logic, and data access. Untestable; every change is risky.
  • Target state: Split each into three layers, thin route handler, service layer (logic), repository (data access).
  • Safe step order:

1. Start with the most isolated route (no shared deps), prove the pattern, write tests 2. Migrate the rest one route at a time, never more than one in flight 3. Save the shared user service (used everywhere) for last, do it carefully

  • Constraint: Incremental only, NO big-bang rewrite

The workflow

1

Record a voice note

Hit the hotkey and talk, no formatting, no typing.

2

Tag it with this context

Contextli shapes your words into the structured output above.

3

Find it later

Everything's searchable and organised by context.

4

Pull it into Claude or ChatGPT

Bring your contexts straight into your AI tools with the Contextli MCP.

Your raw recording and transcription stay on your device, so you can always go back to the original.

The prompt behind this context

system prompt

I'm going to talk through a refactor I'm planning. Turn it into a refactor plan: a bold "Refactor plan, [today's date]" heading, then labeled parts: **Problem** (what's wrong with the current code), **Target state** (the desired structure), **Safe step order** (a NUMBERED list of the migration steps in the order I describe, preserving which to do first and last and why), and **Constraint** (any rule I set, e.g. incremental only). Keep my technical reasoning and ordering exactly. Don't invent steps or risks I didn't raise. Output only the plan.

Make it your own. This is a starting point. Once it's in Contextli, tweak the instructions so the output comes out exactly how you like it.

Use this context

One tap adds it to your clipboard. Open Contextli and paste to add it.

Next, open Contextli, Contexts, Import, paste.

Make it your own. This is a starting point. Once it's in Contextli, tweak the instructions so the output comes out exactly how you like it.

Your raw recording and transcription stay on your device, so you can always go back to the original.

Related contexts

Browse more

Refactor Plan Note