What worked for us is getting cat locked on a kitchen for some 5-10 minutes if it misbehaves, alongside the already mentioned loudly make noise to show that it hurts.
Like, you make pain = we are not playing with you. It didn't take long for her to learn to hide her claws and stop eating electric cables.