The practicing a habit example is great, it has been nearly impossible to quit cracking my knuckles because, like the author, I would only notice when it was too late. Practicing by fake-starting to do the bad habit and then doing a replacement seems like a great way to get around that
It reminds me of what a friend called the "Pavlovian alarm clock training".
Set an alarm clock for five minutes, jumps onto the bed pretending to sleep, and when the alarm goes off, immediately get up and walk around. Do this several times every day and for a few days, and you'll have an easier time getting up to the alarm in the morning. And it worked for me.
It's fortunate that I don't have to resort to this anymore (plenty of sleeping time, now). But it was pretty useful when I during middle school, especially at the end of long vacations.
These are typical recommendations for fighting obsessive-compulsive behaviors. It's been a long time but I recall reading something like this in The Mind and the Brain: Neuroplasticity and the Power of Mental Force (2003) by J.M. Schwartz - seems like he has some more recent books out that specifically prescribe remedies (I assume are along these lines).
biased i am, but you can use pavlok to #1 automate awareness with a vibration, based on hand motion, and #2 snap out and reduce automatic habits with the electric shock. Usually takes about 3-5 days for our knuckle cracking users (and smokers) to quit for good