Be mindful of your authority and the power dynamics within the team, such as employee versus contractor status. Publicly refactoring someone's work can be perceived as a personal attack, undermining trust and psychological safety. A private, collaborative approach is often more effective for mentoring and fostering change.
Examples
A tech lead publicly refactored a contractor's code to demonstrate better practices to the whole team. The contractor felt shamed and quit, forcing the lead to apologize and reconsider his approach to mentorship.


