My 3 yr old male neutered cat will occasionally pee outside the litter box immediately after pooping inside the box? There are 2 boxes no other animals. Urine analysis showed slightly alkaline urine and cat was started on cranberry supplements per vet. He does pee in the litter boxes at other times.
As one of the comments indicated, breaking litter box discipline can indicate that kitty has some health issue that is interfering.
Watch him to see if he shows any signs of distress. Look for changes in his daily pattern. If he is in pain he may stop doing stuff he previously did. Or he may want to be warm much more, or much less. Or he may want to be petted much more or less than previously. You get the idea.
Does he seem to have trouble in the litter box? False starts?
Check him thoroughly for lumps and bumps. Maybe he took a bad tumble. Check for ticks and such. Is his fur normal? Are his eyes normal?
Basically, look for any changes other than the litter box.
And praise him when he does it right. Maybe he's just bored.
Also, my cat occasionally just mis-judges where the edges of the litterbox are. It doesn't seem to be illness or age or anything else treatable; like many of us, she's just clumsy sometimes. Clean up, keep an absorbent pad in front of the litterbox for a while in case she misses again or is really saying she's uncomfortable, after a few weeks without a repetition put the absorbent pad aside again. A year or so later, lather/rinse/repeat. Still beats having to go out in the rain for an hour to walk a dog.