There is a LOT of hard work going into games like Assassin's Creed to make it work. The animation system and character animations are among the most complex (if not the most complex) in the industry.
I the general case, however, there are many different ways to solve this.
One is to add an additional hitbox to the character and one near ledges, test when those intersect, and then grab the edge info from the efge's hitbox.
Another is to simply use ray casting and test for collisions at roughly the height of the chafacters's arms while testing for a lack of collisions at the character's head height (L4D uses a system similar to this for making zombies climb things... Which is why you sometimes see them climb over light posts instead of simply running around them).
You could add a surface flag to walls below ledges and check when the players capsule collides with it. You could a plane extending from the ledge and check when the top of the player collides with that. You could attach ledges to navigation nodes and check for collision there.
A lot of this data and be automatically created by post-processing the level geometry (especially low or mid LOD levels). It can also be produced manually if designers are worried about players being able to climb willy nilly over any obstacles.
The hard part is animating it all. You need relatively fancy animation blending to do it in 3D. Simpler 2D games after just directly switch to a grab ledge frame of animation, but this requires more precise detection of when the character is in a position to grab a ledge.
In most cases I've seen, the hitbox around ledges approach is taken. If the player collides with one of them and is falling, he can grab the ledge. Some extra work to check that the collision is near the players hands and that the player is facing the ledge makes it feel an look better. Aside from that, te animation system has to be able to be given positions to attach the hands and to meld that with the existing falling ankmstion and the climbing animations.