This sounds like OCD to me. I have had similar obsessions. Please be careful especially of obsessing about eating, because I obsessed about eating for a while and became underweight, developing health issues that are still affecting me several years later. It is really important to maintain a healthy body, because that has a direct impact on your mental health.
Jaimie Eckert has written some blog posts about these kinds of obsessions...
How to Avoid Gluttony Without Being Fanatical - Scrupulosity.com
Idolatry Obsessions: Another Intersect Between Faith and OCD - Scrupulosity.com
She has a lot of other posts on her blog as well!
These are some other OCD resources that I recommend...
OCD and Scrupulosity - ACCFS
Mark DeJesus
Christianity and Anxiety Disorders (private support group)
I have also found the following books to be helpful...
Breaking Free of OCD: My Battle With Mental Pain and How God Rescued Me by Jeff Wells, and
Strivings Within - The OCD Christian: Overcoming Doubt in the Storm of Anxiety by Mitzi VanCleve.
Feel free to message if you have any questions!
Hi! Mark DeJesus specifically talks about compulsive fasting - very similar to what you are going through - see link:
Obsessive Compulsive FASTING
I once heard him mention he was helping a man who was about to start a 40 day fast and had done 2 of them previously!
Also, I wrote a book called "Waging War Against OCD - A Christian Approach to Victory." You may enjoy Chapter 8 which talks about how God speaks to us as His children. Which can be confusing when compulsions seem like the right thing to do. But God has given us a lot of wisdom on this.
I love how these verses directly speak to this issue:
“But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, self-control; against such things there is no law.” (Galatians 5:22-23)
But wisdom from above is first pure, then peaceable, gentle, reasonable, full of mercy and good fruit, unwavering, without hypocrisy.
—James 3:17
Not that we are adequate in ourselves to consider anything as coming from ourselves, but our adequacy is from God, who also made us adequate as servants of a new covenant, not of the letter but of the Spirit; for the letter kills, but the Spirit gives life.
—2 Corinthians 3:5–6
These 3 verses show us a picture of what it looks like when God speaks. It is full of love, peaceable gentle, reasonable, full of mercy, and not of the letter but of the Spirit. Do the thoughts sound like an exact and precise action that has to be done - like pray 47 times in an exact way at an exact time with just the right amount of genuineness, etc. Or is it more like "I love you child, come and spend time with me."
Jaimie Eckert interviewed me about the book. You can see the interview here: