The Claude application your team built has grown over six months, and the prompt-handling code has
accumulated duplication and tangled control flow. The functionality is working, but new features are getting
harder to add.
How would you address this?
Show answerHide answer
Correct answer: A Plan a refactoring pass to consolidate duplicated logic, separate concerns, and simplify control flow before adding new features.
Explanation
ExplanationThis is textbook technical debt blocking new work: the code functions, but duplication and tangled control flow make features increasingly hard to add. The recognized remedy is a planned refactoring pass that consolidates duplicated logic, separates concerns, and simplifies control flow. Because the problem is now actively slowing feature delivery, addressing it before piling on more features prevents the debt from compounding and keeps the new features from being built on an unstable base.
A planned, scoped refactor is also safer than ad hoc cleanup: it can be defined, tested (behavior-preserving), reviewed, and validated in one deliberate effort — which is exactly how you refactor safely without changing functionality.
Why the other options are incorrect
- B — "Refactor in small increments as a side effect of each feature ticket": Incremental refactoring can be legitimate, but folding cleanup into feature work tangles two goals: it makes feature changes harder to review, risks scope creep, and doesn't systematically address the duplication and tangled control flow that spans the codebase.
- C — "Keep adding features; refactor after the next two release cycles": Defers the debt while continuing to build on the tangled base — the cost grows, the refactor gets harder, and the "when we have bandwidth" condition rarely arrives. This is how technical debt compounds.
- D — "Move everything into one large function": The opposite of good structure — it worsens coupling and readability, making the code harder to navigate and change, not easier.
References
- Refactoring and technical-debt management best practice — planned, behavior-preserving refactors to reduce duplication and separate concerns.