The "trick" of expert[^1] programmers is to know the difference, and to slowly expand the base they can build on.
[^1] An expert is merely a person who has learnt from more mistakes. There's nothing magical about it, as much as the cult of the rock star programmer would have us believe otherwise.