Take a long walk and a few days or weeks away from writing.
Then I sit down and try and figure out what I've lost confidence about. And why that's happened. (FREX: my plots feel stale OR didn't I just write these same characters OR my dialog suddenly feels forced. And I'm feeling that way because I'm not selling work like I did a year ago OR I just read this other author's work and it just seemed so much better OR someone I think is less skilled at the craft is selling more than I am so maybe I'm just delusional.)
Solutions are not always easy. Leveling up usually means recognizing you've plateaued as a writer. And that, invariably, brings a shit ton of angst and doubt. Depending on your personality and work methods you might just take a break, read some good books, come back to it once you don't feel so stabby. Or work to push through. Challenge yourself to do something different (even if the different is actually crap because trying new things). Write something silly or super-serious. Mimic your favorite author. Reread old work and compare it to where you are now and look for what has improved and what hasn't.
A break is rarely a bad idea. The things you love will draw you back. And if they don't then it's probably time to move on. And I don't mean that in a snotty way. But if writing is something you really need and want to do, then you can take a break and come back to it refreshed, with the creative well refilled and it will be great. And if you take a break and then try to come back and it's still just a horrible struggle and you don't love it at all because it feels like everything you write is crap then maybe you need a longer break and a different activity for a while.
I've had some serious doubts about my writing skills throughout the years, but I've only had a couple of times where I just couldn't write anything. Because even when I felt like I was writing crap, I could still write something stupid and enjoy it. Even if it was only meant for me. Obviously, YMMV in this regard. But you would be amazed at what a conscious week long break can do for you. (And I mean, setting it aside deliberately. Not the "I keep sitting down to write and not much happens and it's been X amount of time." Take a deliberate vacation where you don't write for seven days and see where you are.)