Allah's Messenger [صلی اللہ علیہ وسلم] said: "When a man dies, his good deeds come to an end except three: ongoing charity, beneficial knowledge and righteous offspring who will pray for him." [Sahih Muslim: 3084]
Al-Nawawi [may Allah have mercy on him] said in Sharh Muslim:
"The scholars said: the meaning of this hadith (above) is that the deeds of the deceased come to an end when he dies, and the renewal of reward ceases for him, except in these three cases, because he is the cause of them: his offspring is counted among his earnings, as is the knowledge that he leaves behind through teaching or writing, and ongoing charity, i.e., a waqf (Islamic endowment)."
The narrations below add further details:
Narrated Abu Hurairah [رضی اللّٰہُ عنہ]: "The Messenger of Allah [صلی اللہ علیہ وسلم] said: "The good deeds that will reach a believer after his death are: knowledge which he learned and then spread; a righteous son whom he leaves behind; a copy of the Qur'an that he leaves as a legacy; a mosque that he built; a house that he built for wayfarers; a canal that he dug; or charity that he gave during his lifetime when he was in good health. These deeds will reach him after his death."
[Ibn Majah: 224]
It was narrated that they slaughtered a sheep at the time of the Prophet [صلی اللہ علیہ وسلم] and gave it in charity except for its shoulder. The Prophet [صلی اللہ علیہ وسلم] asked ‘A'ishah, "What is left of it?" She said: "Nothing is left except the shoulder." He said: "All of it will remain except its shoulder."
[Al-Tirmidhi: 2470]
Consequently, a Muslim must not just persist in doing good deeds while alive, but should also pursue projects that will reap benefit after death. Options for such endeavors are listed below:
- Constantly remembering death: One of the best ways to actively do good deeds and leave behind avenues that will continue to benefit after death, is to remember death itself, often and consistently.
- Invest money in welfare projects: Whether it's a hospital, school, mosque, domestic shelter or a welfare organization that generally helps the needy, a Muslim should invest some money in it, in order to ensure that the rewards for charity will keep coming even after they have died, when the money they invested continues to benefit others in different ways.
- Spread beneficial knowledge through media:
- Educate another person or teach others a skill; contribute in starting a regular Islamic class. The more students you have, the farther your trail of good deeds will extend after you have left this world.
"And We record that which they send before (them), and their traces, and all things We have recorded with numbers (as a record) in a Clear Book."
[Qur'an, Surah Yaseen: 12]

