Are you stressed a lot of the time? Do you have some need that is unfilled? You may have a shortness of patience with others because your mind is busy with something else.
I do this same thing, usually when I'm overly focused on something and something else takes my attention. I've found meditation helps as a way to practice breathing before reacting. A good life skill to have, but it takes time to develop.
Best of luck to you. In the meantime you can often balance out bad attitude with a sincere compliment or gratitude.