The stability of geotechnical structures after an earthquake is primarily determined by the residual strength of surrounding soils that have not fully liquefied. This research employs the discrete element method (DEM) to study the undrained post-cyclic shear behaviour of sand under triaxial conditions, focusing on the effect of varying degrees of liquefaction (LD) simulated by subjecting the samples to different lengths of cyclic loading. Different types of cyclic loading, i.e. symmetric (fully reversal), partially reversal, and non-reversal ones, as well as the effect of sample density, have been considered. The results indicate that the samples under fully or partially reversal cyclic loading eventually liquefied, displaying a cyclic mobility failure mode. In contrast, samples under non-reversal cyclic loading develop plastic strain accumulation (PSA) failure without liquefaction. The post-cyclic shear stiffness of the samples is affected by both LD and the type of cyclic loading. For samples under reversal cyclic loading, the post-cyclic shear stiffness decreases as LD increases. Notably, the liquefied samples (LD = 1) initially exhibit near-zero stiffness during post-liquefaction shear until highly anisotropic force chains are formed along the loading direction, with their buckling leading to stiffness recovery. The length of the low-stiffness stage is influenced by the static shear stress and the relative density of the sample, which determines the rate of anisotropy accumulation during cyclic loading. The onset and completion of stiffness recovery are marked by a peak in anisotropy and an abrupt increase in effective anisotropy, respectively. For samples under non-reversal cyclic loading, the post-cyclic shear stiffness initially decreases with the increase in LD but increases at higher LDs due to the significant anisotropy developed during the cyclic loading stage.