This article is from the Problem Behaviors in Cats FAQ, posted to rec.pets.cats newsgroup. Maintained by Cindy Tittle Moore with numerous contributions by others.
Give a sharp, plantative yowl, like the sound a hurt cat will make. Pull your hand back (or if that would score furrows down your hand, let it go completely limp), turn your back on it, and ignore it for a few minutes. People are divided on the issue of whether to allow hand attacks at all or to allow limited hand attacks. You can train the cat to do either with the same method. For the former, always wail when attacked and then offer a toy to play with instead; for the latter, wail whenever the claws come out, but allow attack of the hand up to that point. Be aware that a cat trained not to use a person as a toy at all will be more trustworthy around a new baby (see A New Baby). You may try hissing at a cat that persistently attacks you.