Scarlett is the first player to join Stanford's football team as a graduate transfer.
In 18 games over four seasons at Cal, Scarlett recorded 54 tackles, nine tackles for loss, three forced fumbles and 4.5 sacks.
Scarlett dealt with multiple injuries during his time with the Golden Bears, including a partially torn ACL that limited him to only five games in 2014.
Scarlett, who has been admitted to Stanford's management science and engineering graduate program, will be eligible to play right away.
Scarlett's brother, Cameron, is a four-star all-purpose back set to join the Cardinal as a freshman in the fall.
Stanford opens the season on Sept. 5 at Northwestern.