I feel a moderately able deal with this in my friends. I don't think you people are idiots or jerks even when you do idiotic or jerky things, because you aren't what you do, and the small cases just aren't the bulk of what makes you up. So I can say, "You're not an idiot!" or "I know the feeling!" and that's that. Though I don't always do that, because I often feel like acknowledging these statements, which are usually conversational asides, makes them bigger than they were intended to be, and I almost don't want to give the sentiment that attention. That said, I, in general, think it's better (for me) to at least express my disagreement with the sentiment.
I'm running into it a bit, though, in my work life, and it feels trickier to address it with my direct reports. It has all the same challenges of encountering it with a friend, plus the complication of "I'm your boss." I'm not really excited about letting it go, even if it's casual self-talk, because the people who work for me are, like my friends, GREAT people, who sometimes make mistakes, and also because some of them are women, for whom that kind of verbalization can be VERY detrimental in a professional setting, so I feel like it's part of my job as a good boss and mentor to help them rein it in, both internally and externally.
But it feels trickier to call them on it than a friend, because we don't have the same kind of casualness in our interactions. And because, yes, I'm their boss, and I know that sometimes, if you're in a ditch, it brings you lower to hear that you're ALSO failing at liking yourself enough, or something like that. (I'm really only worried about that last bit for one of my reports -- the others, I think, it's not so loaded.)
Anyway, so, I'm noodling on this a fair amount, and I'm interested to hear how you deal with it in yourself, your friends, your colleagues. How do you like to be handled in various settings when you're getting down on yourself? What helps?