Muhammad Hanafiyyah used to visit the grave of Imam Hasan (a.s.) and recite the following:
Peace be on you, O son of Amirul Momineen and son of the first Muslim! How can you be anything other than this, for you are the son of the Prophet of guidance, most devoted to piety, and one of the five folks of the cloak. You were fed by the hands of mercy, raised in the lap of Islam, and nursed from the bottom of faith. You were blessed when you were alive and you are blessed after your passing away, except that our souls are miserable in your separation. But we do not have any doubts that you are alive. May Allah’s mercy be on you.
Imams (a.s.) said: When you perform the Ziyarah of the graves of the Imams (a.s.) in Baqi’, stand at the graves facing them with your back to Qibla and recite:
Peace be on you, O Imams of guidance! Peace be on you, O people of devotion and piety! Peace be on you, O the Proofs on the people of the world! Peace be on you, O just custodians of creation! Peace be on you, O chosen ones! Peace be on you, O family of Allah’s Messenger (s.a.w.s.)! Peace be on you, O confidants of Allah! I bear witness that you conveyed Allah’s message, you advised the people and remained patient in the way of Allah. You were belied and insulted, but you forgave. I bear witness that you are the wise Imams, rightly guided; that obeying you is obligatory, and that your words are truth. You called the people to Allah but your call was not answered, and you commanded the people but you were not obeyed. Indeed you are supporters of religion and pillars of the earth. Allah has always watched over you and has transferred you from the loins of purified fathers to wombs of purified mothers. The darkness of paganism did not defile you and afflictions of desires did not affect you. You were blessed and the places in which you were raised were also blessed. Undisputed ruler of religion has bestowed favors upon us through placing you “In houses which Allah has permitted to be exalted and that His name may be remembered in them.” (24:36). Allah has made our invoking blessings on you as mercy on us and penance for our sins. Indeed Allah has chosen you for us. He has purified our creation by bestowing His favors upon us through His Wilayat. We were named by Allah as those who know you and are known as those who acknowledge your Imamate. I am one who committed excess and made mistakes, but one who has surrendered, confessed to his crimes, and hopes to be saved through being here. One who hopes that the savior of the ruined will save him from destruction through you. So please intercede on my behalf, for I have come to you while the people of this world have abandoned you, have mocked the signs of Allah, and have arrogantly turned away from them. O One in charge and one who is never neglectful! O One who is everlasting and never distracted! O One who encompasses all things! You have favored me by giving me the success of knowing my Imams and by keeping me steady on this belief, while Your servants have turned away from it, ignored knowing it, belittled the rights of this belief, and have turned to other paths. Hence the favor is from You to me and to certain peoples for whom You have chosen that which You have chosen for me. Praise be to You for recording for me this position. Do not deprive me of that which I hope for and do not disappoint me in this position by not granting my requests for the sake of Muhammad (s.a.w.s.) and his purified progeny.
Then pray and invoke whatever you like.
Imam Sadiq (a.s.) said, “Recite whatever you want before the grave of Imam Sajjad (a.s.).”
Kamiluz Ziyaraat By: Ibne Quluwayh
Translated by: Sayyid Athar Husain S. H. Rizvi