This Letter presents a model to unify the diverse range of magnetar activity, through the building and release of elastic stress from the crust. A cellular automaton drives both local and global yielding of the crust, leading to braiding of coronal loops and energy release. The model behaves like a real magnetar in many ways: giant flares and small bursts both occur, as well as periods of quiescence whose typical duration is either ≲1 yr or ∼10-30 yr. The burst energy distribution broadly follows an earthquake-like power law over the energy range 10 40-10 45 erg. The local nature of coronal loops allows for the possibility of high-energy and fast radio bursts from the same magnetar. Within this paradigm, magnetar observations can be used to constrain the poorly understood mechanical properties of the neutron-star crust.