In a Nutshell:
Muslims can avoid the punishment of the grave (azaab al-qabar) through rituals and good deeds. There are a number of ahadith mention specific acts that help in this regarding supplicating against azaab al-qabar, reading Surat al-Mulk, involving oneself in jihad for Allah's sake and performing mandatory rituals, following them with voluntary ones.