Coding
Refactor without changing behaviour
Smallest safe steps, each one verifiable.
- refactoring
- safety
- incremental
The prompt
I want to refactor the code below. Goal: {{goal}}
Give me a sequence of steps small enough that each one can be committed and
verified on its own. For each step: what changes, and what would prove it did not
change behaviour. Say which steps are pure moves and which actually alter logic —
those are the ones that need a test first.
If the refactor is not worth doing, say so.
{{code}} What to fill in
- {{goal}}
- What you want to end up with — e.g. the wipe-and-retry logic in one testable place
- {{code}}
- The code — e.g. Paste the file or function
What it produces
1. Move the open-else-wipe block into PersistentStore.load(at:)
verbatim. Pure move — same behaviour, callers unchanged.
Verify: existing tests pass untouched.
2. Have both controllers call it. Pure move.
Verify: launch both apps, store opens.
3. Change the wipe to a move-aside. Behaviour change — needs
a test first: corrupt a store, assert the backup exists. 117 prompts, in the app you already paste from
The whole library, searchable, with your own prompts alongside it. Free to browse here; Pro to keep them a keystroke away on every device.