Question

Claude Code runs out of context halfway through a refactor

Solved · 11 views · asked by leo_prompts · edited

Big refactor: rename a concept across 60 files. Around file 35 it starts forgetting the new name and reintroduces the old one.

What I’ve tried

Asked it to "remember the plan". It summarizes and then drifts anyway.

Comment

2 answers

Marked as helpful by the asker
felix_codes · edited

Do not do 60 files in one session. Make the machine do the boring part and the model the judgement:

  1. grep -rl OldName src/ > files.txt, split into batches of 10.
  2. New session per batch. First message: the rule ("OldName → NewName, also in tests and docs") plus the 10 file names.
  3. Commit per batch. If a batch drifts, git checkout . and redo that batch.

A fresh session with a short, exact instruction beats a long session with a fading plan.

Comment
leo_prompts · edited

Marking this one. The batch-per-session approach worked: 6 sessions, zero drift.

Comment