Best Practice Preventing Player to go off map

I have terrain in which the player can roam around.The player has colliders, controllers, and eveything. I already created mountains on the terrain yet the player manages to climb very steep slopes. My question is is there a best way to limit the user from going somewhere he shouldn’t?

You can clamp the player like this

transform.position = new Vector3(Mathf.Clamp(transform.position.x, -xPos, xPos), transform.position.y, transform.position.z);

But I prefer just setting up box colliders myself. That way you can assign a ‘Wall’ tag to all of those colliders and you’ll know when a player has hit a wall through code.