Sub topic 1
How a habit works: the cue, routine, reward loop
Prerequisites
This chapter assumes you already know what a habit is in everyday terms: something you do often and almost without deciding. It also assumes you are willing to watch your own behavior for a few days. You do not need any background in psychology. The code example uses basic Python (a class, an f-string), but you can read the chapter without running it.
Why start with the loop
Most advice about changing habits says "stop doing X". That treats the habit as one block of behavior to delete. This tutorial uses a different working model: a habit is a loop with three parts, and you can often change one part while leaving the other two alone.
The three parts are:
- Cue: the trigger that starts the habit. It is a situation, not a decision.
- Routine: the behavior itself. This is the part you notice and usually want to change.
- Reward: the benefit you get, which tells your brain the loop is worth repeating.
The loop model is popular through Charles Duhigg's book The Power of Habit, which built on research on habit formation in the brain and in behavior. Treat it as a practical model, not a complete theory. It is useful because it tells you what to look for and what to change.
The cue: what starts the habit
A cue is whatever reliably comes just before the habit and sets it off. It might be a time of day, a place, a feeling, a person, or an event. The key point is that the cue arrives before you have chosen anything. You do not decide to feel restless at 3 pm. You feel it, and the routine follows.
Because cues are often small and constant, they are hard to see. You have lived with them for so long that they feel like part of the background. Chapter by chapter, this tutorial shows how to catch them by writing down what was true each time the habit happened. For now, remember that a cue is a reliable trigger, and that you can often leave it in place.
The routine: the behavior you want to change
The routine is the visible action: eating the snack, checking the phone, lighting the cigarette. It is what most people mean when they say "my habit".
Two things matter about routines for this tutorial.
- A routine is more specific than you think. "Snacking" is a category. "Walking to the vending machine and buying a candy bar at 3 pm" is a routine. Precise descriptions make it easier to find the cue and to design a replacement.
- A routine is only one way to get a result. The same result can usually be reached by other routines. That is what makes swapping possible.
The reward: what the habit gives you
The reward is what you get at the end of the routine. It is the reason the loop repeats. Your brain notes that the routine in this situation led to something good, and it makes the link stronger.
The tricky part is that the obvious reward is often not the real one. If you buy a snack at 3 pm, you might assume the reward is food. But the real reward might be a break from your desk, a few minutes away from a screen, or contact with another person. The snack is just the routine that happened to deliver it.
Behind the reward sits a craving, a pull toward some outcome. The craving is what you feel between the cue and the routine. It is the motor of the loop. Over many repetitions, the cue alone starts to produce the craving, and the craving pushes you into the routine.
| Part | What it is | Example | Easy to see? |
|---|---|---|---|
| Cue | Trigger that arrives before you choose | Feeling restless at 3 pm | Often hidden |
| Routine | The behavior | Buy a snack from the vending machine | Obvious |
| Reward | What you get, and the craving behind it | A break and some social contact | Often misread |
Why swap instead of delete
Here is the central idea of the whole tutorial. The cue and the reward are the parts that keep the loop alive. If you try to remove the routine and leave a gap, the cue still fires and the craving still builds. Nothing satisfies it. Willpower then has to hold the line every time, and that is tiring.
If you keep the cue and deliver the same reward through a different routine, the loop stays complete. The craving is satisfied, so there is less pressure to go back. You are changing one step instead of fighting the whole structure.
A worked example in code
The following Python class stores the four pieces of a swap. The cue and reward stay fixed. Only the routine changes. The method builds the if-then sentence that you will use later to anchor the new routine to the cue.
from dataclasses import dataclass
@dataclass
class HabitSwap:
cue: str
old_routine: str
new_routine: str
reward: str
def if_then(self) -> str:
return (
f"When {self.cue}, I will {self.new_routine} "
f"instead of {self.old_routine}, so I still get {self.reward}."
)
swap = HabitSwap(
cue="I feel restless at 3 pm",
old_routine="buy a snack from the vending machine",
new_routine="walk around the block and chat with a colleague",
reward="a break and some social contact",
)
print(swap.if_then())Running it prints:
When I feel restless at 3 pm, I will walk around the block and chat with a colleague instead of buy a snack from the vending machine, so I still get a break and some social contact.The grammar of the last phrase is a little awkward ("instead of buy"). That is a small flaw in the template, and you can fix it by writing the old routine as "buying a snack from the vending machine". The point is the structure: the sentence names the cue, the new routine, and the reward you keep.
Common errors when applying the model
Most mistakes come from misreading one of the three parts.
- Naming the routine too loosely. "I snack too much" gives you nothing to work with. Write down the exact action, place and time.
- Assuming the reward is the obvious one. If you assume the reward is food when it is really a break, a replacement such as an apple will not work. You will eat the apple and still feel restless.
- Treating the cue as a decision. If you say "I decide to check my phone", you are describing the routine. Look for what happened just before the decision.
- Changing everything at once. If you change the cue, the routine and the reward together, you have built a new habit from scratch, which is harder than a swap.
- Expecting the loop to be fully logical. Some cues are combinations, such as a time plus a mood plus a place. You may need several days of notes to see the pattern.
What comes next
The remaining chapters take the loop apart in the order you would use it in practice. You will name the routine precisely, isolate the cue, test which reward you are after, design a replacement routine, and tie it to the cue with an if-then plan. After that you will learn to track the swap, shape your environment, and handle slips.
Exercise
A person bites their nails during long video meetings. They decide to "just stop". After a week they say it is not working, because they still feel the urge in every meeting. Using the habit loop, explain why deleting the routine left the urge in place, and describe what a swap would keep and what it would change.
Show answer
The cue (long video meetings, likely with boredom or tension) still fires, and the craving it produces has nothing to satisfy it once the routine is removed. The urge stays, and willpower has to resist it each time. A swap keeps the cue (the meeting) and the reward (for example, something to do with the hands or a release of tension) and changes only the routine, for example squeezing a stress ball or holding a pen under the desk. The reward needs to be tested first, because the real reward might be tension relief, stimulation, or something else.
Exercise
Identify the cue, routine and reward in this sentence: "Every evening when I sit on the sofa after dinner, I open social media and scroll for half an hour, and I feel relaxed and in touch with my friends." Then name one thing you would need to test before choosing a replacement routine.
Show answer
Cue: sitting on the sofa after dinner. Routine: opening social media and scrolling for half an hour. Reward: feeling relaxed and in touch with friends. Before choosing a replacement, test which part of the reward matters most, relaxation or social contact. For example, try a calming activity one evening and a call to a friend on another, then note which one ends the craving.