Sub topic 1
How a habit works: cue, routine, reward
Prerequisites
This chapter assumes you have two things:
- A basic idea of what a habit or routine is, such as brushing your teeth or checking your phone when you wake up.
- Experience keeping at least one regular routine for a while, such as exercise, a sleep schedule, or study time.
You do not need any background in psychology. The short Python examples use only lists, functions, and print.
Why start with the loop
Later chapters in this tutorial cover how a move, a new job, a new baby, an illness, or a breakup can break habits. To repair a habit, you first need a working model of what it is made of. This chapter gives you that model: the habit loop of cue, routine, and reward. It also covers the common ways people misread their own habits.
The three parts of the loop
A habit is a behavior that you start with little deliberate thought because a situation has triggered it many times before. The habit loop describes this as three parts.
| Part | What it is | Example: reaching for your phone | Example: evening walk |
|---|---|---|---|
| Cue | A signal that starts the behavior | The phone buzzes, or you feel bored | Finishing dinner |
| Routine | The behavior itself | Pick it up and scroll | Put on shoes and walk around the block |
| Reward | The result that makes the behavior worth repeating | Novelty, relief from boredom | Feeling calmer, the sense of closing the day |
Each part has a job.
- The cue is what happens just before the behavior. It can be a time, a place, a person, a preceding action, an emotional state, or an object in view.
- The routine is what you do. It can be physical, mental, or emotional.
- The reward is the outcome that your brain registers as useful. Over repeated rounds, it teaches you that this cue is worth responding to.
The arrow from reward back to cue is what makes this a loop. Each repetition that ends in a reward makes the next response to the cue a little more likely and a little less effortful.
From effortful to automatic
When you start a new behavior, you decide to do it each time. You must remember it, choose it over alternatives, and push yourself to begin. This takes attention and willpower.
After many repetitions in a similar situation, the link between cue and routine strengthens. The cue starts to prompt the behavior without a decision. This is what people mean when they call a habit automatic. Automatic does not mean you cannot stop the behavior. It means starting it takes little effort and little thought.
Two consequences matter for rebuilding:
- Repetition in a consistent situation is what builds the link. A behavior you do once a week in a different place each time has few chances to attach to a cue.
- The link belongs to the cue and the routine together. If the cue disappears, the routine loses its trigger, even though you still know how to do it and still want to.
The second point is the reason this tutorial exists. Chapter 2 develops it in detail.
Rewards: immediate beats distant
The reward in the loop is not the same as your long-term goal. "Being healthier in five years" is a goal. The reward that reinforces a habit is something you experience soon after the routine.
This explains a common pattern. Habits with an immediate payoff, like scrolling or a snack, form easily. Habits whose payoff is far away, like saving money or stretching, are harder to form because nothing in the moment reinforces them.
Rewards can be:
- Sensory: the taste of coffee, the feeling of warm water.
- Emotional: relief, calm, a sense of pride.
- Social: a friend's approval, a shared moment.
- Informational: seeing a checkmark, seeing progress.
When you rebuild a habit, ask what the reward actually was in your old life. Often it is not what you would have said. A person who ran every morning may say the reward was fitness. The real reward may have been the quiet twenty minutes alone before work. If your new life has no quiet time, running may not feel rewarding anymore, and you will not know why.
Cravings: the link between reward and cue
Over time, the cue starts to produce an anticipation of the reward. You feel a pull before you act. A familiar smell of coffee can create a desire for coffee before you have taken a sip. This anticipation is part of why habits feel like urges.
This has a practical effect. A strong cue plus a reliable reward produces a pull that does much of the work for you. A weak cue or an unreliable reward produces no pull, and you are back to relying on deliberate effort.
A worked example: decoding one habit
Suppose you used to read for twenty minutes every night. You moved to a smaller apartment, and you now read about once a week. To understand why, write the loop as it worked before.
- Cue: You got into bed in your old bedroom, where a book sat on the nightstand.
- Routine: You picked up the book and read.
- Reward: You felt your mind slow down, and you fell asleep more easily.
Now write the new situation.
- Cue: In the new apartment you work and sleep in one room. When you get into bed, you often have your laptop on the bed beside you, and the book is in a box.
- Routine: You open the laptop for "one last thing."
- Reward: Mild stimulation, which does not help you sleep.
Notice what changed. You did not lose the desire to read. The cue (bed plus visible book) changed, a competing routine took over, and the reward is different. Each of these is a separate thing you can repair. Without the loop model you might conclude "I have lost my discipline," which points to no specific fix.
You can sketch this as a small data structure. The code below stores a habit as a cue, a routine, and a reward, then reports which part differs between two situations.
def compare_loops(before, after):
"""Return the parts of a habit loop that differ between two situations."""
changed = []
for part in ("cue", "routine", "reward"):
if before[part] != after[part]:
changed.append(part)
return changed
before = {
"cue": "get into bed, book on nightstand",
"routine": "read for 20 minutes",
"reward": "mind slows down, easier sleep",
}
after = {
"cue": "get into bed, laptop within reach",
"routine": "open laptop for one last thing",
"reward": "mild stimulation",
}
print(compare_loops(before, after)) # ['cue', 'routine', 'reward']When all three parts differ, as here, you do not have a habit that "got weaker." You have a different habit. Rebuilding then means deliberately constructing the old behavior's loop in the new setting.
Common errors when reading your own habits
Intermediate learners usually have the vocabulary of the loop but misapply it. These are the errors to watch for.
Naming a vague cue
"Evening" is not a cue. A cue is something specific you can notice: "I finish washing the dinner dishes." If you cannot point to the moment the habit starts, you have not found the cue yet. Test it by asking, "What exactly happened right before?"
Confusing the goal with the reward
"Losing weight" is not what reinforces a gym visit. The reinforcing reward may be music, the shower afterward, or time away from the house. If you design a plan around the goal and ignore the reward, the habit stays effortful.
Treating a habit as one thing
Many habits are chains. "Go to the gym" includes packing a bag, driving, changing clothes, and exercising. The chain can break at any link. After a life change, the break often occurs at the first link (packing the bag), long before the workout itself. Look for the link that stopped.
Assuming every repeated behavior is a habit
Some behaviors you repeat are still deliberate. If you must decide each time and feel resistance, the behavior is not yet automatic. That is normal for new routines and tells you to expect effort, not to conclude that you are failing.
Ignoring a competing routine
A cue can trigger more than one routine. If the same cue now triggers a stronger or easier behavior, the old one loses. In the example above, the laptop beat the book because it was within reach and had a quick reward.
Checking the loop with a simple log
You will track habits more systematically in later chapters. For now, a minimal log shows how a loop might be recorded. This function counts how often a routine followed a given cue, which is a rough measure of how automatic the link is.
def cue_response_rate(events, cue):
"""events: list of (cue, did_routine) pairs. Returns the share of times
the routine followed the given cue, or None if the cue never appeared."""
outcomes = [did for c, did in events if c == cue]
if not outcomes:
return None
return sum(outcomes) / len(outcomes)
events = [
("finish dinner", True),
("finish dinner", True),
("finish dinner", False),
("finish dinner", True),
("get into bed", False),
("get into bed", False),
]
print(cue_response_rate(events, "finish dinner")) # 0.75
print(cue_response_rate(events, "get into bed")) # 0.0
print(cue_response_rate(events, "wake up")) # NoneThe result 0.75 for "finish dinner" suggests that cue still works for the routine. The 0.0 for "get into bed" suggests that cue no longer triggers it. The None case matters too. A cue that never appears in your new life cannot trigger anything, which is a common situation after a move or job change.
Key points to carry forward
- A habit has three parts: a cue, a routine, and a reward. All three can change when your life changes.
- Automaticity comes from repeating the routine after the same cue, with a reward, many times.
- The reward that matters is the immediate one you feel, which may differ from your stated goal.
- Habits can be chains, and they can break at any link.
- A cue can trigger competing routines, and the easier or quicker one tends to win.
- When a habit fails, diagnose which part of the loop changed before deciding the problem is motivation.
Exercise
You used to drink a glass of water first thing each morning. After starting a night shift, you almost never do. Write the loop for your old situation, then name two different parts of the loop that the new schedule could have changed.
Show answer
Old loop. Cue: waking up and walking into the kitchen, where a glass sat by the sink. Routine: fill the glass and drink it. Reward: a feeling of freshness, plus the sense of starting the day well. Two parts the night shift could have changed: (1) the cue, because you now wake at a different time, perhaps in the afternoon, and the "first thing in the morning" moment no longer exists or happens at an irregular time; (2) the reward, because the freshness and fresh-start feeling may not occur at a time you associate with starting the day. A third possibility is a competing routine, such as grabbing coffee or checking your phone at the new wake-up time. A good answer names specific parts and gives a reason for each, rather than saying "I lost motivation."
Exercise
Using cue_response_rate, what value does it return for the cue "after lunch" with these events: [("after lunch", True), ("after lunch", False), ("after lunch", False), ("after lunch", True)]? What does the value tell you?
Show answer
It returns 0.5, because the routine followed the cue in 2 of 4 occurrences. This means the cue works about half the time. The link is partly formed but not reliable. The next step is to look at what differs between the occasions when it worked and the ones when it did not, such as location, time pressure, or whether a competing routine was available.