I work on an agile project using Scrum.
Sprints have come and gone and we have fulfilled milestones successfully. The system works well enough to meet the current customer requirements.
However, we are left with a system in serious need of refactoring, as much of the development was performed with little eye on the future (instead the focus was on the sprint at hand).
How best to deal with this? Sprint(s) dedicated to refactoring?
Yes, the occasional one of those is sometimes not a bad thing. But if you’re agile using Scrum, then you are presumably trying to follow Test-Driven Development (TDD), and it is important that you remember that the sequence is red-green-refactor, not just red-green. Bad quality code is not the output of agile development, but of poor agile development.