I don't know about you folks out there, but I didn't learn what a query letter was until after I wrote my first book and revised it a few times. Somehow I got it in my head that a query letter could only be written in the weeks before you sent your book out to agents or publishers. If your book wasn't written, polished, and ready to go, you couldn't write that query letter.
How wrong I was...
Earlier this year, I won a query critique from an agent in a random Twitter giveaway. I was a couple weeks away from finishing the first draft of my MS, so of course I hadn't already written my query letter.
Now, to be fair, I've gotten a lot better at query letters over the past few years, so writing this particular query letter wasn't as soul-crushing as previous ones have been. I came up with a rough draft, workshopped it with my Facebook writing group, polished it up, sent it to a CP with notoriously quick turnaround time, then sent it on to the agent who gave me a thumbs up and a request for pages. I let her know (sheepishly) that the book wasn't finished yet, but that I'd send the pages on eventually.
The thing that astonished me most, however, was that in the process of writing the query letter, I discovered that the conflict and stakes of my manuscript were weak. So I made something up that my writing group agreed was much stronger. Then, when I went back to do my first revision on my novel, I was able to add the key scenes that I needed to increase the conflict and therefore the stakes.
Now I recommend to everyone that they write a query letter for their novels somewhere between the beginning of the first draft and the start of the first revision. That way, if the query letter reveals that an aspect of the book needs work, you are in the perfect position to fix it.
When do you write your query letter? Have you tried this before? Let me know in the comments!