How do I apply to graduate school?

If you've decided to apply to graduate school, you need to (1) have a list of schools you want to apply, (2) an application dossier, and (3) funds for the applications. You should start thinking about applications a year ahead of time at least, researching the schools you want to attend (what are their job placement rates, how involved are the profs, etc.) and taking relevant standardized tests & compiling documents.

An excellent how-to can be found at Eric Schwitzgebel's site, which breaks down the process step-by-step.

Letters and writing samples are two key parts of your application and both require time and preparation.

Letters. Make sure your letter-writers are people who can speak to your abilities (it's best if they are ones you have taken more than one class with) and while you do want to consider things like rank and prestige here, you also want professors who can write the best letters. Also, you need to give your professor the best information possible for them to write a letter for you--they don't know about all of your other coursework or extracurricular activities, or the details of the program you're applying to.

Writing sample. This needs to be a paper which has been read by a few people and gone through several drafts. Take a look at what Schwitzgebel has to say about them on his link above. I’m happy to look at papers and give you an honest evaluation of whether I think a paper would be a good candidate, but be prepared for different opinions among professors (we have different styles and things we look for). Still, you should be able to find some overlap in our evaluation.

Note that students often apply to 20 programs, because of the extreme competitiveness involved. That means you probably need to start planning financially for the application cost--which is good practice for budgeting when in graduate school, a time which is financially challenging for many students.