How do I know if a developer isn’t goofing off if I’m not watching them all the time?
If that is how you feel, why did you bring that person on board?
You should vigorously screen for culture fit when interviewing candidates. This should not be a problem if you bring on the right people.
That said, sometimes people become disengaged over time if they are not feeling tightly engaged. Engage them by sharing the broader business context so they always know how their own work ties in to the big picture.