The former Rangers and Kilmarnock player, 24, will join the Dons on a free transfer at the end of the month after spending only one season at Saltergate.
Leven has agreed a 12-month deal with the League One newcomers after scoring five times in 44 appearances for the Spireites.
He made 75 appearances for Kilmarnock after initially coming through the youth team ranks at Rangers.