I start with myself. I refactor and clean code I own and take responsibility and initiative. But if a project smells bad and I know I’ll need more sprint time to tidy up, I present a value versus risk plan to my tech lead. We decide if it’s doable now, and if not we put a ticket in the backlog to pull in the next time that project gets touched. When we plan sprints it’s always driven by business need, but a little extra time can be allotted to pull in these refactoring tickets.
As for selling refactoring to the team, if your culture promotes direct ownership of the code by everyone, then your colleagues will want to refactor to clean code to lower their time spent on bugs. +1 for testing here too.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.