How to make the top of character controller( 3D) hitting a roof edge not make my character stutter?

I use the character controller component for my FPS game. Moving the character works fine.

The problem is that the character controller being a capsule lowers itself automatically when you hit the edge of a roof with the concave part of it so it can go below and move forward. The character also stutters a bit and slows down when it contacts the edge. I put the skin width to the lowest value and the stutter is still there.

How would you go about fixing this problem?

image of the problem: https://imgur.com/a/H7xP27J

EDIT : Maybe my explanation wasn't the best. I want my character to stop moving in the direction of the roof edge unless it's highest point can move below the roof edge - basically instead of having a concave top, the character should act as if he has a box the size of the character radius.

And to add to that, if I still try to move the character in that direction it should move along the edge he is hitting. Something like a projected Vector3 of movement direction on the surface it hit.

@korgokorgo you need to add restrictions so that your character will not continue going up. i suggest looking at their colliders as that is the most common solution.