If you have transactional sex periodically how can you protect yourself against an accusation

later down the road for rape or sexual assault aside from NOT assaulting or raping anyone. I am talking about having consensual sex and being accused later on of it NOT being consensual. It seems it could happen at any time.