We coded something which works but is quite terrible. We have planned the refactoring of that piece of code in this sprint but since it doesn't really fit in a user story, how do we add or represent this? Nothing will change at front-end, just back-end.
You have several options, including:
- Add a task to the backlog that covers this (perhaps labelling it as technical debt)
- Add a technical sub-task to a story that is already in your backlog
In the second option, what you are saying is
To complete this story and deliver a quality product to our team's definition of done we should include refactoring this piece of code
What I like about this approach is that it demonstrates that code quality is built-in to your delivery of functionality.