How does skin width work in Unity’s CharacterController?

I’m trying to write my own character controller and I want to understand how Unity’s works. I think what it does is this: at each fixed update it takes the smaller collider reduced by the skin width, casts it forward to see where it hits something, then moves the character forward so that the full size collider touches that point. So my first question is is that right, am I missing an important step?

My next question is how does Physics.SphereCast work? What subroutines and geometric algorithms are involved? Every Collider has the methods Raycast, ClosestPoint, and ClosestPointOnBounds, so does Physics.SphereCast just use some combination of those functions for each Collider, or is there more math involved on top of that? And are sphere casting and capsule casting the main geometric algorithms used by the character controller, or are there others I should be aware of?