Morning Beating Up

I often wake up in the morning, like this morning, beating myself up. Generally it will be earlier than my alarm clock, it is dark and I cannot get myself to get out of bed. Then my brain starts: life is shit, you are incapable, you are so useless, you have no purpose or definition.

It is like a dagger in my head. I generally listen for a while, then brush it away. Then I just get up and off I go.
But I am always ever so surprised by the harshness of these early morning thoughts. It is like if my brain was stabbing me to force me to stay in bed to kill my day before I even have a chance to start.

I know it is an old habit but it always takes me by surprise.
How can I get rid of it?