He had companionship with the Prophet. When Ali came to Basra, he sent for him and asked, "What prevents you from following me?"He replied, "My dear friend and your cousin instructed me. He said, 'There will be division and discord, so break your sword, take a sword of wood, and stay in your house until a wrongful hand reaches you or a decreed death overtakes you.' So I did what the Messenger of Allah ﷺ commanded me. If you can, Ali, avoid being that wrongful hand."
حدثنا مؤمل قال حدثنا حماد يعني ابن سلمة قال حدثنا شيخ يقال له أبو عمرو
وكانت له صحبة أن عليا لما قدم البصرة بعث إليه فقال ما يمنعك أن تتبعني فقال أوصاني خليلي وابن عمك فقال إنه سيكون فرقة واختلاف فاكسر سيفك واتخذ سيفا من خشب واقعد في بيتك حتى تأتيك يد خاطئة أو منية قاضية ففعلت ما أمرني رسول الله ﷺ فإن استطعت يا علي أن لا تكون تلك اليد الخاطئة فافعل
Its isnad is hasan, because of Abu Amr Qasmali, who is also called Abu Isa, and this is more correct, his name being Isa bin Sinan. The hadith has occurred previously at 20549, so see our comment there.