At work, we all actually joke openly about this and I think it helps to know that everybody feels that insecurity to some degree or other.
All week long you'll hear self-deprecating remarks like:
"Oops, I suppose that bug exposes me as the mediocre hack that I am, haha"
"...but unfortunately I forgot to uncomment that section, because I am a complete idiot..."
In a way it helps keep your confidence up, because you're modeling the behavior of confident people. (Joking openly about one's own shortcomings)