Our Sages teach us in Pirkei Avot (Chapter 4, Mishnah 11): “Rabbi Eliezer ben Yaakov says when one performs one Mitzvah, one acquires for himself one advocate and when one performs one sin, one acquires for himself one prosecutor.”
The simple understanding of this is that “advocate” and “prosecutor” refer to the angel created by one’s actions. Similarly, the holy Zohar states explicitly (Volume 3, Page 307b) that there is an angel that corresponds to every single Mitzvah. This corresponds to the teaching of our Sages (Sotah 3b) that when one performs a Mitzvah, this Mitzvah will come out to greet him in the World to Come, as the verse states, “And your righteousness shall go before you” which refers to the angel who goes before the individual and announces, “Make way!”
Maran Rabbeinu Ovadia Yosef zt”l writes that one who goes out of his way to fulfill the Halacha according to the Rishonim and to rule on halachic matters in accordance with their view, when he passes away and reaches to the World of Truth, these Poskim will come out to greet him. Similarly, the Gemara (Baba Kama 111b) tells us, “Rava said, ‘When I pass away, Rav Oshaya shall come out to greet me for I have made the words of the Mishnah compatible with his opinion.”
Furthermore, Maran zt”l writes that one who defends the opinions of Maran Ha’Shulchan Aruch (from those who disagree with him occasionally) and rules on halachic matters according to his words, there is no doubt that Maran will come out to greet him in the World to Come. Additionally, Maran will act as an awesome advocate on one’s behalf, like none other. We must add that this does not necessarily only apply to Torah scholars who rule on Halacha in accordance with the opinion of Maran Ha’Shulchan Aruch; rather, anyone who benefits the public by teaching them how to properly conduct themselves according to the Halacha and according to the opinions of the saintly Maran Rabbeinu Yosef Karo in any aspect of Halacha known to him, whether it be from what he has heard in Torah lectures, saw in books, or learned in his set learning schedule, shall merit having powerful advocates who will come to his aid on one’s Day of Judgment.
A similar incident is recorded in the Sefer Maginei Shlomo, authored by the grandfather of the Penei Yehoshua, Hagaon Harav Yehoshua, head of Cracow’s Bet Din (Rabbinical Court) approximately four hundred years ago. The entire Sefer is dedicated to defending the saintly Rashi’s opinions throughout the Talmud after being questioned in many places by the various authors of the Tosafot. The author’s grandson writes in the introduction to the Sefer that the author recounted to his students that Rashi had appeared to him in a dream and told him with great joy, “Because you trouble yourself to save me from [the questions of] the mighty and sharp lions, the Tosafists, I shall come out to greet you in World to Come together with all of my students.” So did it transpire; on the day the author would later expire, a half-hour before a light of Israel would extinguish, many leaders of the Jewish nation were at his bedside. He told them, “Make way for our great Rabbi, the light of our eyes, Rabbeinu Shlomo Yitzchaki (Rashi), for he has come to me together with his entire holy entourage and he has greeted me joyously to show me the way of the Tree of Life since I have always been at his right side to resolve the questions posed by the Tosafists on his commentary.”