Skip to content
MyDSHMy DSH Field Notes
中文
Independently maintained; not affiliated with DeepSeek. No association with mydsh.dev or other MyDSH sites.

All categories/Code and debugging

Debugging · Level Advanced · Debugging Legacy Refactor

Legacy rewrite: wrap or rebuild

A five-year-old system needs work, and the team argues rewrite versus evolve.

Prompt

You never edit code first. You establish when it reproduces and when it does not, then test one hypothesis with the smallest possible change, one thing at a time.

Task: A five-year-old system needs work, and the team argues rewrite versus evolve.

[Before you start, do three things]
1. Restate the goal in one sentence: who reads the output, and what decision it serves.
2. If I have not given you the following, ask me. Do not assume:
   - system size and maintenance cost
   - behaviour that must not change
   - how well the team knows it
3. Say how you plan to do it (at most 5 steps) and wait for my go-ahead.

[Go through each of these]
- name three concrete problems, not 'the code is bad'
- define the boundary: what gets wrapped, what gets rebuilt
- state hidden rewrite costs: migration, parallel run, regression
- one first step with a visible result in two months

[Process]
1. Restate the symptom: action, input, observed, expected
2. Three hypotheses by likelihood, each with a prediction
3. Design the smallest test: one command, one log line, one throwaway test
4. Eliminate or confirm, never change several things at once
5. Explain why the bug could be written, not just which line

[Output]
Symptom, hypotheses with predictions, minimal test, conclusion, next step.

[Do not]
- No conclusion without logs or a reproduction
- Never change three things at once
- 'Try it and see' is not verification
- Say when you are unsure, and how to check

What to state before it starts

Leave these unsaid and the model fills them with an assumption. Most 'wrong answers' start here.

  • system size and maintenance cost
  • behaviour that must not change
  • how well the team knows it

Go through each of these

Where this kind of work most often goes wrong. Already in the prompt, so you do not have to remember it.

  • name three concrete problems, not 'the code is bad'
  • define the boundary: what gets wrapped, what gets rebuilt
  • state hidden rewrite costs: migration, parallel run, regression
  • one first step with a visible result in two months