B J Fogg, who gets brief mention in this article, teaches his students to cause behaviour by making the behaviour easy and then delivering timely triggers [1]. If you find yourself behaving in ways you don't reflectively endorse, your basic approach should be to flip the Fogg model upside down – avoid triggers and make it harder.
In my own case, that's meant disabling notifications and blocking websites and apps. I also hacked a Chrome extension which applies the "avoid triggers and make it harder" idea to Gmail [2]. The extension has several thousand users, many of whom reclaim 30-60 minutes of focussed work each week which would otherwise be lost to compulsive inbox processing.