How to deal with leftover developer time in sprint
Sprint Goal is a sacred thing in scrum - it's the main priority of the sprint, and all developers shuold work together towards achieving it. Failing to achieve it is bad, and shouldn't be allowed to happen.
What should happen however when that is assured and there is still spare dev power in the team? That is a possibly common occurrence (given you would err on the side of achieving Sprint Goal while planning), and I couldn't find anything in scrum guide detailing what to do.
- You could add a new task they pick up to the sprint - but that is scope change, one that carries a serious risk of becoming a spillover
- You could let the developer just pick up a story that's not part of sprint - but than how do you track the work, that story does not show up on the sprint board, has no bounds on when it should be achieved and generally seems to be outside the system
- you could only let devs pick stories that can be finished in the sprint goal - at the risk that last one-two days of the sprint there will be no such stories.
If, during the Sprint, after selecting enough Product Backlog Items for the full Sprint, the team has met the Sprint Goal and all of the selected Product Backlog Items are Done, it's up to the team to decide what to do.
I'd be hesitant to pull more work from the Product Backlog. The ordering of the Product Backlog may change as a result of the Sprint Review, which would make any unfinished work not only "spillover", but also waste if it's not done. If this is selected, the Product Owner can help pick something that is likely to still be at the top of the Product Backlog at the next Sprint.
I'd focus on things that can help the team's performance. Refining work in the Product Backlog. Process improvements that need the Developers' attention. Identifying and quantifying technical debt that may be too big to just fix. Finding ways to improve the Definition of Done, which may require some kind of technical enablement to make it efficient. Learning new skills to become more cross-functional.