DEV Community

CBT Tools
CBT Tools

Posted on

Cognitive Distortions in Code Review: How CBT Helps Debug Your Thinking, Not Just Your Code

Cognitive Distortions in Code Review: How CBT Helps Debug Your Thinking, Not Just Your Code

We've all been there. You open a PR review and your stomach drops. Before you've read a single line of code, the thought hits:

"This code is terrible. They're going to think I'm a bad developer for approving this."

That's not a code review. That's a cognitive distortion — and CBT (Cognitive Behavioral Therapy) has been debugging these exact thought patterns for 50 years.

The 6 Cognitive Distortions That Kill Code Reviews

CBT identifies 11 cognitive distortions — systematic errors in thinking that cause emotional distress. Here are the 6 that show up most in code review:

1. Catastrophizing

The thought: "If this bug gets to production, the company will fail and I'll be fired."
The CBT reframe: "What's the actual probability? We have staging, CI/CD, and rollback. Even if it ships, the blast radius is contained. One bug doesn't end a company."

2. Mind Reading

The thought: "The senior engineer thinks my PR is garbage."
The CBT reframe: "You can't know what they're thinking. They might be busy, tired, or focused on a different concern. Ask for specific feedback instead of assuming."

3. All-or-Nothing Thinking

The thought: "Either this code is perfect or it's worthless."
The CBT reframe: "Code exists on a spectrum. 'Good enough to merge with follow-up issues' is a valid state. Perfect is the enemy of shipped."

4. Personalization

The thought: "They rejected my PR because they don't respect me."
The CBT reframe: "The rejection is about the code, not about you. Maybe the approach doesn't fit the architecture. Maybe there's a simpler way. Separate your identity from your diff."

5. Labeling

The thought: "I'm a fraud. I shouldn't be reviewing anyone's code."
The CBT reframe: "'I made a mistake' is a fact. 'I am a fraud' is a label. Labels are global, permanent, and wrong. Focus on the specific gap and close it."

6. Should Statements

The thought: "I should have caught this bug in my own review. I should be better."
The CBT reframe: "'Should' generates guilt, not improvement. Replace with 'Next time, I'll add a test for this case.' Specific, actionable, forward-looking."

I Built a Tool for This

I built a Cognitive Distortion Detector in 200 lines of vanilla JavaScript. It takes a thought as input and returns:

  • Which distortion(s) you're using
  • Confidence score
  • The evidence it matched
  • A CBT-based reframe
// The core detection logic (simplified)
const DISTORTIONS = {
  catastrophizing: ['fail', 'disaster', 'end', 'over', 'ruined'],
  mind_reading: ['think', 'know they', 'everyone will', "they'll think"],
  all_or_nothing: ['perfect', 'worthless', 'failure', 'useless'],
};

function detectDistortions(thought) {
  const lower = thought.toLowerCase();
  const results = [];
  for (const [name, keywords] of Object.entries(DISTORTIONS)) {
    const matched = keywords.filter(k => lower.includes(k));
    if (matched.length > 0) {
      results.push({
        distortion: name,
        confidence: matched.length / keywords.length,
        evidence: matched,
      });
    }
  }
  return results;
}
Enter fullscreen mode Exit fullscreen mode

No AI. No ML. No API. No backend. Just keyword-pattern matching — because CBT distortions are well-defined categories with recognizable linguistic patterns.

Try It on Your Next Review Thought

Before your next code review, run your anxious thought through the detector:

Thought: "If I approve this and it breaks, everyone will blame me"
Result: Catastrophizing + Mind Reading detected
Reframe: "What evidence do you have that it will break? And even if it does,
'everyone blaming you' is mind reading. Most people understand bugs happen."
Enter fullscreen mode Exit fullscreen mode

The tool is free, runs in your browser, and stores nothing externally. Your thoughts never leave your machine.

Try the Cognitive Distortion Detector

Why This Matters

Code review anxiety is real. A 2023 Stripe study found that 43% of developers avoid contributing to open source because of fear of negative feedback. That's not a skills gap — that's a cognitive distortion.

CBT is the most evidence-based psychotherapy in existence (3000+ RCTs, effective for anxiety, depression, OCD, PTSD). Applying it to code review isn't a stretch — it's using the right tool for the job.

The same distortions that make you miserable in therapy make you miserable in code review. The same reframes that work in therapy work in PR comments. The only difference is the domain.

The Full Toolkit

The distortion detector is one of 36 free mental health tools I built with vanilla JavaScript. All follow the same philosophy:

  • Zero backend — your data never leaves your browser
  • Zero signup — no account, no tracking, no cookies
  • Zero dependencies — just HTML + CSS + JS
  • Evidence-based — grounded in CBT research, not pop psychology

Full toolkit


Build in public. Share everything. Hide nothing.

Top comments (0)