If your cat bites and scratches when you pet her, don’t pet her. I mean don’t pet her when she’s going to bite and scratch, not don’t pet her ever at all.
We have a 2 year old female cat (Kachina) who is fully declawed and spayed. She will jump on the bed or sofa with my wife (Liz) and want to be scratched behind her ears/head. She purrs while this is happening then all of a sudden she will turn and bite Liz in the arm. This used to happen 1-2 times every month or so and now it is a few times a week.