Ibn Ḥajar, after quoting the aforementioned report of Anas, comments:
"The correct position is that when a Companion says, ‘It is sunnah to do such-and-such,’ his statement is deemed marfūʿ—implicitly traced back to the Prophet. Yet because Anas’s ḥadith did not meet the compiler’s stringent conditions, he merely alluded to it by citing the report of Ibn ʿUmar. Moreover, the general wording of ʿĀ’ishah’s ḥadith indicates that one should start with the right side when leaving the mosque as well. Her phrase ‘whenever he could’ may be understood as excluding situations in which beginning with the right is not legally appropriate—such as entering the lavatory or exiting the mosque—and likewise excludes handling repulsive matters with the right hand, such as istinjāʾ (toilet cleansing) and nose-blowing. ʿĀ’ishah, may Allah be pleased with her, learned of his ﷺ preference either because he told her so directly or through contextual clues."
6 – It is recommended, upon entering the mosque, to say: “Aʿūdhu billāh al-ʿAẓīm, wa bi-wajhihi al-Karīm, wa sulṭānihi al-Qadīm, min al-shayṭān al-rajīm” (I seek refuge in Allah the Mighty, in His Noble Face, and in His Eternal Dominion, from the accursed Satan). The Prophet ﷺ said: “When he says that, Satan remarks, ‘He has been protected from me for the rest of the day.’”
Abū Dāwūd recorded the ḥadith (1/76) through the chain of ʿUqbah ibn Muslim, from ʿAbd Allāh ibn ʿAmr ibn al-ʿĀṣ, that whenever the Prophet ﷺ entered the mosque he would say the above supplication, concluding with the words just quoted: “If he says that…” and so forth.
Its chain is ṣaḥīḥ: all of its narrators are transmitters accepted by the two Shaykhs [al-Bukhārī and Muslim] except for this ʿUqbah ibn Muslim and Ismāʿīl ibn Bishr ibn Manṣūr—the teacher of Abū Dāwūd in this report—and both are trustworthy. Al-Nawawī states in al-Adhkār: “A ḥasan ḥadith with a good chain.”