First and foremost, practice self-defense. Make sure that your client knows beforehand that jumping in at the last minute is indeed a risk to the project, and that you won't lose reputation if things go off poorly.
Depending on the developer, you'll be met with either efflusive thanks or indignant resentment. If you get the latter, then your most important task is getting buy-in from him. Convince him you're on his side.
Next, take a look at the architecture. If it's a piece of crap -- onworkable -- then communicate that to the client as soon as possible. Try hard not to lay the blame at the feet of the developer (hell, it could be me!), but again, you have to defend yourself.
If it's something you can work with, then do some code triage -- fix the big, easy stuff first, then on to the next piece and so on.
In any event, good luck -- you'll need it!