In the past I did the following in order on Stack Overflow at least several times:
- Found a question, couldn't make much sense of it, voted to close it as "Not a real question" (the predecessor to 'unclear what you're asking').
- Read it a few more times, epiphany hit, understood what they were getting at
- Edited the question to be much clearer, left a comment for the author to make sure I preserved their intent
- Answered the question, since I knew the answer
- Felt like a very sad panda because I voted to close an interesting question
This can unfold in different ways but I think making the edit, or doing something else to give others the same sense of value you saw which led you to answer the question is what matters. Sometimes you can pull that off simply by answering and showing others there's more depth to the question than what meets the eye.
The other thing I strongly encourage users to do is answer duplicates in the course of voting to close them as such. Write an answer that pulls in knowledge from the most relevant answer on the duplicate, and explain how it pertains to the problem / code at hand. That gives these 'stubs' that are left much more lasting value to those that find them as folks search for things in a variety of ways.
In other cases, if you still feel that the question should be closed yet feel compelled to answer it, then you probably want to consider making some edits instead. It's not black and white, though - sometimes sending someone off with a better start than they had can be the right thing to do, even if it's not in the process of creating something of lasting value. Maybe you see something in them and want them to come back. It's (as I said) sometimes fuzzy.
Take away - prefer editing and answering if you can over closing if you think you've got a gem that just needs some polish, but don't let 'decision paralysis' prevent you from keeping the site clean or extending a welcoming hand to a new user. Just do what makes sense given what you've got.