Boris Johnson does it while singing Happy Birthday twice. For Jacob Rees-Mogg, it’s the national anthem. And as soap supplies run low, it seems much of Britain is following their example and heeding the official guidance to wash hands thoroughly and often, in order to minimise the spread of the coronavirus.

It is good public health advice, of course. Indeed, one question raised by the rush for soap is just what all those people without any in the house did before. But for some people with obsessive-compulsive disorder (OCD), to be warned they must scrub to protect themselves from an invisible enemy, and to do so in a ritualistic way with internal musical accompaniment, is akin to inviting a demon to come for tea. Some of these people have spent years trying not to wash their hands, often as a prescribed part of their treatment.

“It’s definitely put a lot of the internal OCD dialogue back into my life. It’s being reinforced by outside, authoritative voices,” says Erica (not her real name), a long-term OCD patient. “It’s a lot harder to tell yourself that the urge to wash your hands is irrational when everyone on your Twitter feed or on the news is saying: ‘Wash your hands. Nobody is washing their hands correctly.’”

The worsening outbreak affects people with OCD in other ways, too. Chiefly, the spike in anxiety about the virus can fuel existing obsessive fears of contamination and trigger destructive compulsive actions. For some people with OCD, coronavirus can become all they think about. “I have seen three patients this week whose OCD has started to focus on coronavirus,” says David Veale, a consultant psychiatrist at the Priory hospital in London. “It is a challenging time for people who have OCD.”

As anyone with the condition will know, of course, OCD is challenging all the time. Often portrayed as a behavioural quirk, OCD is in fact a syndrome defined by recurring irrational thoughts. The compulsive actions – often the most visible feature of the illness – are usually only a response to those intrusive thoughts.

The irrational content of those thoughts is limited only by the spectrum of human imagination. Since I published a book on my experiences with OCD, I have met people obsessed with the idea that if they close their eyes, the whole world will change while they are not looking, or that if they hand-write a letter or a number that contains a closed loop, their family will die. But OCD does tend to cluster around a limited number of themes.

Perhaps the biggest of these is contamination – with generic dirt or germs, or with a specific illness or disease. And these contamination fears are heavily influenced by culture, society and shared health scares. Coronavirus is only the latest.

I have OCD that focuses on HIV and Aids, which makes sense because I grew up in the 1980s when global fear of that condition was at its peak. It wasn’t just me. A generation was traumatised. The US psychiatrist Judith Rapoport wrote in her book, The Boy Who Couldn’t Stop Washing, that by 1989 a third of her OCD patients focused on HIV and Aids. The disease, she wrote, appeared “so terrifying, so irrational that it could have been the creation of an obsessive-compulsive’s worst fantasy”.

In the 1920s, doctors in the US reported a surge in what they called syphilis-phobia, which coincided with a campaign to highlight the dangers of the disease. In the 1960s and 70s there was a spike in irrational fears of asbestos, just as the dangers of the material had come to popular attention. In 2012, Australian scientists reported the first cases of OCD in people who fixate on thoughts about climate change – a bogeyman for the new millennium and one that, like HIV in the 1980s, poses an uncertain, universal threat, depicted in lurid detail by the mass media. (Full disclosure: as the former environment correspondent for this newspaper, I used to write those stories.)

If coronavirus continues to spread, experts expect related cases of OCD to spike as well. The disease and the attention it is receiving are “good for business”, one psychiatrist told me with gallows humour.

Exactly what makes some people predisposed to OCD isn’t clear, but genetics and previous experiences seem to play a role. In some cases, Veale says, the coronavirus threat could bring on OCD for the first time. “If someone’s got the right genes and they’ve had all the right experiences to shape them, then this could be a trigger to set the whole thing off.” There is some evidence that simply asking people to wash their hands can make them more anxious about their health. Psychologists have found that students asked to spend a week using hand sanitiser after they touched money, door handles or other possible sources of germs subsequently reported significantly higher signs of hypochondria.

For Kyle MacNeill, a freelance writer, the 2009 swine flu scare initiated a years-long struggle with OCD. He traces it back to a remark from a family member that he wasn’t washing his hands properly. Combined with the warnings about the virus, the comment sparked an obsession with germs. “I’d wash my hands 20 times in a row,” he says. “On my way out I would accidentally brush against the door handle. It’s very exhausting, you know, having to repeat that process again.” MacNeill’s anxieties were eventually successfully treated and he is not overly worried that coronavirus will set them off again.

What about people who do worry they might convert rational coronavirus anxiety to OCD? What should they look out for? Veale says the signs of OCD are clear and different from the “normal” response to the coronavirus. Fretting about the virus and washing hands a lot don’t qualify on their own. An important difference is that someone with OCD will wash until they feel comfortable or “just right”. “The key issue is the function,” he says. “Is it to reduce the risk of spreading of coronavirus, or is it done ritualistically in a specific order with termination criteria?”

The content of the thoughts and the nature of the anxiety are usually different, too. With OCD, the intrusive thoughts are exaggerated and irrational. One of Veale’s patients with coronavirus OCD, for example, has started to fixate on whether they can catch the disease from Chinese food.

It is important to stress that, as long as it is not excessive, handwashing to minimise the risk of coronavirus spread from other people is a rational response to a genuine threat. But OCD just isn’t rational. Although many patients with OCD do wash their hands repeatedly, it is not always because they think they are dirty. In some cases, it is just a way to find comfort, to ease the mental burden of irrational obsessions that a loved one might die, or that something dreadful will happen to them. For some OCD patients, flicking a light on and off a set number of times can bring that relief. So can tapping, or saying a specific word, or shuffling from foot to foot or an infinite number of other nonsensical routines. For me it was seeking reassurance: checking for blood on a piece of glass I stepped on, or asking health professionals if I could catch HIV by doing this and that. In every case, I already knew the answer was no. But I wanted them to say it because for a second or two I believed and the world seemed a brighter place. The reassurance never lasted but it gave me a hit of happiness that became addictive.

That is why OCD is so hard to treat, and why coronavirus and official advice on handwashing pose such a dilemma for some OCD patients and therapists. Treatment for OCD is based on the principle of exposure-and-response prevention. It exposes a patient to what they are afraid of, to spike their anxiety, but stops them performing the compulsive acts they would usually employ to make themselves feel better. For contamination-related OCD, that response prevention frequently involves getting them to not wash their hands, sometimes for days on end. In theory, the anxiety drips away and the patient realises they need not rely on handwashing to feel better. Being told they do need to repeatedly wash their hands after all could interfere with that recovery.

It is a paradox and one that makes health officials jumpy. I spoke with one NHS psychiatrist who wanted to make the point that OCD patients with handwashing issues should follow the government advice on coronavirus, but not take it too far. They were told by their bosses that they shouldn’t say so publicly because: “It may be a very risky strategy, including if a patient actually does catch the virus.”

For some OCD patients, the risky strategy is the correct one, says Jon Abramowitz, an OCD expert and therapist at the University of North Carolina. He is telling some OCD patients to ignore the official US government health advice on coronavirus and to keep on not washing their hands. “It’s a tough call. What I have said to people is that your risk is low and I don’t think you need to take all these kinds of precautions. And given you have OCD, you’re probably better off not.”

David Adam is the author of The Man Who Couldn’t Stop: The Truth About OCD.