Usually, for a number of reasons, I don't cook fish (I know, it was probably ill-judged of me). What with my recently imposed dietary restrictions, I decided to give it another chance to compensate for a lack of meats I could eat. I bought cod, filleted it, put it onto my non-stick grill pan (which turned out to be not as non-stick) and grilled it for just a few minutes on each side. It was tender (so I believe I didn't overdo it), but I could hardly flip it or take it off the pan: it easily disintegrated, fell to pieces. Is it supposed to happen to cod? Was it bad cod (it smelled fishy – not spoiled, mind, but I heard fresh fish doesn't smell at all)? Was it a method of preparation that didn't suit that kind of fish?
That's totally normal for cod, it's a flaky fish. The best way to keep it together is to leave the skin on, if possible.
If the fish is skinless your best bet of keeping it together is to handle it as little and as gently as possible. The way I do it is to flip it once, starting it on the top first, then after a minute flipping it to the bottom, which is where the majority of cooking takes place. There are spatulas for fish which are longer to help support the fish as you turn it and keep it in one piece as you take it out, I actually use a crepe spatula for the same purpose.
If you treat it gently and use the right tools and pans you can keep even flaky fish together.
Ideally, you should avoid turning it more than once or twice, to GdD's point of handling it as little and gently as possible.
You'll also want to use a good spatula (or two) to flip it. Additionally, make sure the heat isn't too high and you use enough fat (e.g. olive oil, butter)/liquid (e.g. white wine, lemon juice) to keep it from sticking to the pan.
You might find this tutorial/recipe helpful: https://www.thekitchn.com/how-to-cook-fish-on-the-stovetop-cooking-lessons-from-the-kitchn-204805
If cod separates in pieces, it is overcooked. The flesh should still be slightly tender and in one piece. As you start cooking with cod, remember: You don't need to move the cod once in the pan. Instead, add some liquid (broth, wine, or just veggies) and the steam will cook it.
The simplest way I'd suggest: sauté leaks, onions and mushroom (or whichever veggies you prefer), then, once they're half cooked, just deposit the cod over them, add wine if you want, or broth if you want it a bit saltier. Let it simmer for 5 to 10 minutes, covered. The steam should bring the cod to the right texture without it separating in flakes.
Buy the thicker cod pieces you can find.
Also, not sure what the policy of this SE is on linking to recipes, but for reference consider: https://www.finedininglovers.com/recipes/cod-la-grenobloise-claude-bosi
The whole recipe is super complex, but the cod cooking part?
Place a saucepan over a medium-high heat filled with around an inch of water. Place a petal steamer inside and line with a piece of parchment. Season the cod with salt, place into the steamer and steam for around 6 minutes.