Debugging Your Brain Part 5
Cognitive Restructuring for Systems Thinkers

In this chapter, you will learn how to identify unhelpful thought patterns and how turn them into helpful ones. This is known as "cognitive restructuring".

This post was a precursor
to Casey's book
"Debugging Your Brain."


You have read about how to enter an introspective state (whoop!), about how to process experiences by putting them into words, and about how to validate those experiences to non-judgmentally accept them as inputs. In this chapter, you will learn how to identify unhelpful thought patterns and how turn them into helpful ones. This is known as “cognitive restructuring”.

Cognitive Restructuring Definition

Cognitive Restructuring is the process of identifying and countering “unhelpful thought patterns”. Unchecked, these lead to downward spirals of negative emotion. They make you feel worse in an unproductive, unhelpful way. They tend to be irrational or exaggerated. Some examples include: all-or-nothing thinking, over-generalization, and magnification.

These unhelpful thought patterns are also known as “maladaptive thought patterns”. Maladaptive means it is unhelpful; it gets in your way. Maladaptive thought patterns are doing a bad job of being adaptive (“mal” = bad, “adaptive” = helpful). A third term for these unhelpful thought patterns is “cognitive distortions”, because they give you a distorted view of reality. In this book we’ll mostly use the term “cognitive distortion”.

Example Scenario

One evening I was excited to attend a tech meetup. It was raining and I was wet and cold. On my way to the event I stepped in a puddle! I heard several thoughts go off in my head. These thoughts made me feel worse, and I really considered not going. I gave myself a “whoop! to introspect a bit, and took stock of my automatic thoughts:

  • “Ugh! Wet shoes are the worst!“.
  • “If I’m running late, I shouldn’t even go!”
  • “Today sucks.”

These thoughts each have some underlying cognitive distortions.

Identifying Cognitive Distortions

There are many cognitive distortions, and this book covers the most common ones. Knowing their names will help you get better at identifying these when they happen to you. Knowing their names makes it easier for you to manipulate them in your mind and also makes it easier for you to describe these to other people. They are grouped here to make them easier to remember but many of these could fit in the other groups as well.

Common Cognitive Distortions

Feelings vs Facts

  • Emotional Reasoning is when you believe something based on a feeling, as opposed to thinking about it and basing it on facts.
  • Post-hoc Rationalization is when you have already made up your mind based on a gut feeling and you defend that gut feeling with facts you come up with afterward. “Post-hoc” means “after the event”.

Generalizing: Needs nuance

  • Overgeneralization is applying a small amount of information to explain a whole situation, inaccurately. Not incorporating enough nuance.
  • Labeling is a subset of overgeneralization. Using a shorthand description that implies a lot. This misses a lot of what makes the person or situation unique.
  • All or nothing thinking is when you think in a binary yes/no or good/bad kind of way. Truth often lies in a gray area between the two extremes.

Focusing: Positive versus negative

  • Magnification is focusing too much on something (often negative), and minimization is focusing too little on something (often positive).
  • Disqualifying the positive is when you convince yourself that certain positive things doesn’t count. This could be completely discounting the positive or partially discounting it, reducing the relative weight of importance you give it.


  • Personalization is believing you have more control or influence over a situation than you actually do. This is often by not taking into account forces external to yourself.
  • Mind reading is believing you know what another person is thinking or feeling without any evidence, often negative.

Outcome Prediction

  • Fortune-telling is believing you know how something will turn out, usually for the worse.
  • Catastrophization is focusing on the worst possible outcome of a situation, especially when it is a less likely outcome.


You can learn even more of these by searching online for “cognitive distortions” or “maladaptive thought patterns”. The Wikipedia article on Cognitive Distortions is a good place to start, and easy to share with friends, too.

Identifying Cognitive Distortions - Example

After I stepped in the puddle on the way to the meetup, I noticed several automatic thoughts:

  • “Ugh! Wet shoes are the worst!“.
  • “If I’m running late, I shouldn’t even go!”
  • “Today sucks.”

Each of these thoughts contain cognitive distortions. They make me feel worse in an unhelpful, unproductive way. Dwelling on these thoughts is not going to be helpful (rumination!). Which cognitive distortions apply to these?

My thought “wet shoes are the worst” is an example of magnification. It blows the problem out of proportion - not only are wet shoes bad, but they’re the WORST. This is emotional reasoning since I am coming up with this based on my mood, and not based on facts. I would not consider this post hoc rationalization since I am not defending this thought with support.

My thought “If I’m running late, I just shouldn’t go!” is an example of all or nothing thinking. By this perspective, going on time is an option and not going is an option, but anything between is not an option. Digging deeper, the implied reason in my mind is “because arriving late will look bad”. That reasoning is an example of mind reading of others and fortune telling that the folks at the event would judge you when you arrive late. This is also disqualifying the positive things that may happen by attending, like learning things and making connections with people.

My thought “today sucks” has a lot going on. This is an example of overgeneralizing the entire day, disqualifying the positive things that happened earlier in the day, and fortune telling that the rest of the day is also going to be bad.

Once you identify what cognitive distortions you are experiencing, take a moment to be proud. Identifying these is no a challenging skill to learn! Even if you don’t know what to do with some of them next, it is worth celebrating that you took a moment to be introspective, that you took stock of automatic thoughts and feelings, and even identified some as cognitive distortions.

Countering Cognitive Distortions

Once you know which cognitive distortions you are experiencing, you can deal with them one at a time. This “three column technique” can help with this (adapted from “Feeling Good: The New Mood Therapy” by David Burns). The left column is for describing your unhelpful “automatic thoughts” and the middle is for brainstorming some “deliberate thoughts”. I bolded the cognitive distortion I think is the most applicable and helpful to counter. Later the right column will be for writing out more adaptive thoughts to counter the automatic thoughts.

Automatic ThoughtCognitive DistortionMore Adaptive Thought
“wet shoes are the worst”magnification, emotional reasoning
“if I’m running late, I just shouldn’t go”all or nothing thinking, mind reading, fortune telling, disqualifying the positive
“today sucks”disqualifying the positive, overgeneralizing, fortune telling

In the left column, write an automatic thought and any maladaptive thoughts that apply. This is descriptive of what’s happening. In the right column, write out any alternative more-adaptive thoughts you can think of.

To start, you might write out the full chart to process a past experience thorougly as you build the skill. This can help you prepare for the future if you have similar automatic thoughts, or it can help improve your general skill at identifying these. As identifying these becomes more automatic, you may visualize this chart in your mind or even skip right over it and identify the cognitive distortions directly.

Countering Cognitive Distortions - Example

In the “wet shoes” example from earlier, I imagined the two column technique in my mind. I ended up thinking of several more-adaptive thoughts for each of my maladaptive ones. I ended up going to the event after all, and I was very glad I did.

My thought “wet shoes are the worst” contains magnification. I can adjust this thought to be more accurate and rational by thinking something more adaptive, like “Wet shoes are not literally the worst, obviously. I am feeling really uncomfortable and cold right now, and these wet shoes are making it worse. It’s really unfortunate this happened.”. This may not be as satisfying to exclaim as “wet shoes are the worst!”, but that’s the point - this defuses you, and prevents you from experiencing a downward spiral of more, even more negative automatic thoughts and emotions.

My thought “If I’m running late, I just shouldn’t go!” contains all or nothing thinking. I could defuse this with something like “The gray area answer is often pretty good, let’s think about it more. Is it really that bad to be late? Will it make you look so bad that it’s literally not worth attending? No! Hmm I thought going was worth it before, and it’s probably still pretty worthwhile. Actually yeah, the topic is great and the people are great and…”

My thought “today sucks” contains disqualifying the positive things that happened earlier in the day and what could still happen. To counter this I might try and come up with a couple of positive things that happened that day like “well brunch was good earlier at least”. I might also think about the positives of being able to attend a meetup at all, like “I’m glad I have the free time and energy to attend meetups at all, even wet. Not everyone has this opportunity.”.

Here is the two-column chart I drew up in my head in the moment I was considering not going:

Automatic ThoughtCognitive DistortionMore Adaptive Thought
“wet shoes are the worst”magnification, emotional reasoning“I am uncomfortable and cold, and that is unfortunate”
“if I’m running late, I just shouldn’t go”all or nothing thinking, mind reading, fortune telling, disqualifying the positive“going late is still valuable, and it won’t actually look that bad”
“today sucks”disqualifying the positive, overgeneralizing, fortune telling“I’m glad I get to go to a meetup at all”

Parallels to Programming

This brain debugging process may feel familiar to you if you have worked with “code smells” and “refactoring techniques” in the past.

In software development, a “code smell” is something you notice about a piece of code that suggests there may be an issue with it. You might not be able to identify what exactly “smells” about the code right away, sometimes you just have a sense something is off. The code smell can cause issues if not addressed. One consequence is “brittle code” where a small change to the code can dramatically break functionality. Another common consequence is hard to read code, for others or for your future self. With practice, you can get good at identifying and naming code smells.

If you can name the code smell that will help you talk about it with other people. You can use the smell names to give more concrete feedback during code review. Naming the code smell also helps you look up how other people have dealt with the smell in other contexts, and give you ideas about what refactoring techniques to use on it.

For an example, imagine a function that is 30 lines long - you might notice this as a code smell called “long function”. You might break this long function down into several smaller functions, using the refactoring technique “extract function”. If this improves readability, that’s a positive change! You might even use the technique “extract class” if there is a class-appropriate concept inside the long function.

For a second example, imagine a function with a name that doesn’t tell you what it is, like “fmt()”, and there is (fortunately) a comment above it explaining what it does. Often code comments are a code smell of their own, compensating for poorly-named functions.

Here is my finished three-column table for these two examples:

CodeCode SmellRefactoring Technique
[30 line long function]long function
[comment above a function]code comment

Even being able to identify the code smells is a step worth celebrating. It is the first step to making it better. For each code smell, there is usually a specific “refactoring technique” associated. A refactoring technique is a way you can edit the code to keep how it works, while getting rid of the code smell. This improves the quality of the code base, and avoids the issues code smells bring. There are many possible refactoring techniques for a given code smell, it’s up to you to choose an appropriate one.

For the “30 line long function” example, you may be able to extract several smaller functions out of the big one, reducing its length, using the “extract function” technique. It might even be appropriate to do an “extract class” refactor if there is a class-like concept in it.

For the “comment above a function” example, you may be able to get rid of the comment by renaming the function to be more self-explanatory, using the technique “rename function” to enable you to remove the comment.

Here is my finished three-column table for these two examples:

CodeCode SmellRefactoring Technique
[30 line long function]long functionextract function, extract class
[comment above a function]code commentrename function, remove comment

Code smells are a lot like cognitive distortions - you may get a sense that something is a cognitive distortion even if you have trouble naming it. Refactoring techniques are a lot like the more-adaptive thoughts you think of to counter cognitive distortions.

To read more about these named code smells and refactoring techniques in the software context, you might like the book “Refactoring” by Martin Fowler, or the website Sourcemaking. To read more about cognitive distortions in the human brain, I recommend “Feeling Good” by David Burns.

FAQ / Other Points

When to let it through

The goal of debugging your brain is to respond to situations in a helpful, adaptive way. These “Debugging Your Brain” techinques are tools you can use to redirect your mental energy where you see fit. Often the most adaptive thing you can do is to focus on a positive, accurate view of a situation. Sometimes, however, it may be more adaptive to lean into an unhappy emotional state to either share it with others or to incite action in yourself. It is up to you to determine what “adaptive” means to you in a given situation.

Why doesn’t everybody already do CBT

CBT takes time, energy, and skill. Most people aren’t aware of these skills you can work on. Many people who do know about these skills probably aren’t sure how to develop them.

You’ll be able to work on these skills gradually, but the rate at which you can work on them is limited. You don’t have infinite time or energy. Try to celebrate each step in the right direction. It’s a long journey.

More Resources

CBT Book

The book “Feeling Good: The New Mood Therapy” covers Cognitive Behavioral Therapy in depth. This is the book that popularized CBT, written by David Burns. This book is intended for you to use at home, even without a therapist. Many friends of mine have read this book, and they rave about it. It has changed many people’s lives for the better. This book covers cognitive distortions very in-depth, with many vivid examples.

You can consider this “bibliotherapy”, therapy via reading. The more motivated you are, the more likely bibliotherapy is to help. If you can also see a therapist, that support can make it significantly more likely you’ll see improvements. If you have a therapist, they may even assign this book as supplemental homework.


You can think of Cognitive Behavioral Therapy as “Training”. Therapists happen to be skilled personal trainers for CBT. Seeing a therapist regularly is the best option for working on these skills, it is the approach most likely to succeed. A therapist will determine how they can best help you, whether they make a formal diagnosis or not.

Many health insurance plans only cover a limited number of therapists that are frequently overbooked. If you can see one of these it may be the most cost effective approach. If not, many other places offer a sliding scale and there are other assistance programs available. If you believe therapy would help you, there’s a way to get it.

Two of the most frequent diagnoses are depression and anxiety. Many folks have undiagnosed “mild depression” and “mild anxiety”. Even these “mild” versions can still affect your life in very significant ways, and can benefit from developing skills like CBT.


The web application “Joyable” helps with one particular issue, social anxiety. It is a great tool to help make sure you regularly work on your CBT homework, and give you some structure around it. It is cheaper than seeing a therapist, but just like the book approach seeing a therapist as well is more effective.

Joyable is great tool for social anxiety. I haven’t yet found an app that helps with CBT more generally, but I really hope to see more things like this!


Meditation has a lot of health benefits. There are many studies showing that it decreases stress, anxiety, and depression. Some doctors even “prescribe” meditation to their patients.

There are many ways to get started with meditation - apps, videos, books, classes. For one specific way to get started, I recommed the app “Headspace”. It breaks down the main concepts of meditation into short sessions with cute videos.

Regular Practice

Regardless of your approach, you’ll have to regularly practice these skills to see progress. Brainstorm with yourself how to get yourself to regularly work on these skills. You might come up with some prompts (calendar event reminders? do it before/after something else?). You might pick one maladaptive thought pattern per week to look out for and work on, or you might set a goal of “whooping” yourself one per day. There are entire books on the psychology of habit formation. Make CBT skills a habit for yourself, however you are able.

Book Summary

When you feel yourself potentially downward spiraling, get yourself into a mindful state. You can use the “whoop!” technique. Once you’re in the mindful state, think about what your “inputs” are. Automatic thoughts, automatic feelings, bodily state, external stimuli. Put these into words. Identify any cognitive distortions you have within these automatic thoughts, and consider what more-adaptive thoughts you can come up with. With these skills together, you’ll be able to choose a response that’s more effective than what you might have originally done.

  1. Whoop! - When you feel yourself potentially downward spiraling, get into a mindful state.
  2. Inputs - In a mindful state, listen to and describe your inputs, especially your automatic thoughts and feelings.
  3. Cognitive Distortions - Identfy any thoughts that are unrealistic or unproductive, and name them.
  4. More Adaptive Thoughts - For each unhelpful thought, think of an alternative thought that is more realistic and helpful.
Liked this?
I also write about:
workplace culture
community building
Casey's headshot

Hi, I'm Casey!

I'm all about helping people be
happy and effective.