Knees Cramping When I Bend Them

So I’ve had this issue for a while now and it’s quite hard to explain.

If I’ve been in a position with my legs straightened (quads shortened) for a while and I suddenly bend my knees, I feel like a reflex or cramp and I have to immediately halt the movement and slow it down. It’s almost like I am trying to stretch a tightened muscle.

This sensation is in the inner part of each leg near the knee. It does not manifest in any other place in the leg.

The other day I was in underwear when this happened so I had a chance to look at what it looked like. It looked as if the muscle was spontaneously contracting. I could see like a line following the direction of the muscle. As my quads relaxed it went away. It’s pretty annoying and uncomfortable.

I can’t really find a better way to explain this. Has this ever happened to any of you? What could this be caused by?