WRITING OF WILL BEFORE DEATH
The Holy Prophet (s) is reported to have said, “Whoever fails to write his will sensibly before his death, lacks reason and manliness.” He (s) was asked, “How should excellent writing of one’s will be, Allah’s Messenger?” He (s) instructed: In the last hours of his lifetime and when people gather around him, he must say:

The Holy Prophet (s) then added, “This is the covenant of the moribund when he makes his will, which is obligatory upon each Muslim individual.”
Commenting on this, Imam al-Sadiq (‘a) is reported to have said: Certifying this fact, Allah the All-blessed and All-exalted says in Surah Maryam:
"They shall not control intercession, save he who has made a covenant with the Beneficent Allah"
The Holy Prophet (s) then instructed Imam ‘Ali (‘a) to learn this covenant and advise the members of his household and his adherents (i.e. Shi’ah) to learn it. He (s) added, “I have been taught this by Archangel Gabriel.”