How do you keep dirt from under your nails.
trim them and wash your hands.
Wash your hands often (including the nails).
Is that even possible
don't play in dirt
Trim and wash underneath them
Trim your nails
Keep them trimmed, and if you work in an environment where it is inevitable, buy a separate toothbrush, only for the following use..when you wash your hands, brush under your nails too.