Sahih Muslim
2234.01

Abdullah reported:We were with Allah's Messenger (ﷺ) in a cave when there was revealed to him (the Sura al-Mursalat, i. e. Sura lxxvii.:" By those sent forth to spread goodness" ) and we had just heard (it) from his lips that there appeared before us a snake. He said: Kill it. We hastened to kill it, but it slipped away from us, thereupon Allah's Messenger (ﷺ) said: Allah saved it from your harm just as he saved you from its evil

2234.02

This hadith has been narrated on the authority of al-A'mash with the same chain of transmitters

2234.03

Abdullah reported:While we were with the Messenger of Allah (ﷺ) in the cave, the rest of the hadith is the same as the one narrated above