Professors often do not have time to write a recommendation letter. Sometimes, they do not know the student well so they ask the students to write a recommendation letter for them. However, universities are aware of this form of "Ghost writing" and they can recognize ghost writing pretty easily. I would suggest to read some recommendation letter online and then try to write one for yourself.
If you are working with your professor for some time, try to write about the project in the recommendation letter. Try to write what you are doing in the project and what is your contribution in the project. Also, try to discuss your differences with other project members (if you have any). If you have taken any course with the professor, then try to discuss the course's interaction from the professor's perspective. If you won any awards, you can also discuss that from the professor's prospective. I guess the best idea is to read about some recommendation letter and then try to write your own.