Let us assume that a phd student has discovered a brilliant idea during his/her phd studies and that the idea has not been published or presented yet. How can that student protect the idea under a patent? What are the right steps to follow and wrong steps to avoid?
As noted, an idea itself is often not patentable, but lets assume for the sake of discussion that you actually do have a patentable process/invention/etc.
The first thing you should do, if this is related to your PIs project, is talk to your PI. It's possible that the IP for anything done in their lab has already been "assigned" - it will depend on the institution, the funding for the project, etc.
Your second stop should be to your institution's intellectual property office - they're sometimes hard to find, but I'd hazard a guess that nearly all institutions have them. They can help you through the process and again there are already likely rules in place for inventions created while a student. It's possible, depending on the idea, institution, etc. that they can take over the cost and complexity of filing at least a provisional patent.
One thing you need to not do is present the idea publicly. Doing so, depending on jurisdiction, can start a clock ticking to file patent protection, invalidate it entirely, or something else.
You should ask yourself why do you want a patent. You should only do if your goal is to commercialize the idea. Because patent is very expensive to file, and also expensive to maintain.
If money is not a problem, filing a patent is extremely simple. Here are some absurd patents. You only need a vague idea, no need implementation, evaluation etc. You don't need to be better than the state-of-the-art, you only need to be "different".
I'm a mediocre researcher who had never published more than 3 papers a year. More than 6 months in my current company, I already submitted 4 patents. Believe me, this is not what I want.
I said it is extremely simple because at my company, there is a team of lawyers that prepare the documents, and they also hire lawyers from another company. All I need to do is to present some slides. However, if I have to prepare these documents myself, I would not be able to do it.