I first heard the term "refactor mercilessly" from the person responsible for hand-holding and inducting me into the Agile process. It was originally coined as part of eXtreme Programming (XP), which is one of the several popular Agile processes that involve very short iterations, continuous releases, and paired-programming. After spending more than a decade with these processes, I can undoubtedly say that there is no way to refactor other than mercilessly. You can't do it half-heartedly or incompletely, as it accumulates as tech debt, but at some stage there is no other way but to do a big bang refactoring exercise. If you have been using Agile previously then you would know how easy it is to ignore refactoring and then end up going through a massive refactoring story to clear up the technical debt.
It is always recommended that you take into account the refactoring effort as part of the story estimation process.
Refactoring is the last straw in our test-driven cycle (Red...