Analysis of the texts shows that Sufism as a recognised movement, which began to be consolidated under the Sunni Shafi'i Junayd al-Baghdadi, started to take shape during the minor occultation. Even the earliest famous Sufis, such as Sahl al-Tustari (from Shushtar, Iran) and Bayazid Bastami, were from this era. The time of the Minor Occultation and beyond saw an explosion and proliferation of occult (hidden) and mystical movements. The Isma'ili movement also started during this time.
Many Sufi doctrines were copied and pasted from Imami Shi'ism, such as the concept of the walayah of the saint/wali of God (borrowed almost word-for-word from the concept of the walayah of the Imam). In addition to concepts and practices arising from Imami (Twelver) Shi'ism, other concepts also most likely entered Sufi culture, such as that of fana' fi-llah (ecstatic annihiliation in God). This could come from the Greek concept of henosis, which existed in the Neoplatonic tradition.
Most of the well-known Sufis were technically Sunni (even if people claim that Sufism has no madhhab. You can test that out by asking anyone who considers themselves Sufi what they think of the first three khulafa). The question arises therefore, from a Shi'i perspective: why did these 'great Sufis' not recognise the imamate of the Imam of their time? Why did they choose an alternative route? Why do Sufi orders focus on the adhkar and practices of their founders, but not on those of the Imams?
Some strains of Sufism, such as that of Mansur al-Hallaj (executed during the Minor Occultation), also play around with theology; for example, Hallaj championed Iblis and Pharoah, claiming that they were in fact true monotheists, and were simply 'annihilated in God' and were therefore victims of their perfect love for God. This directly contradicts what the Qur'an says about Iblis and Pharaoh, and what the Imams have said also. This kind of Sufism challenged the 'conventional' ideas of tawhid and espoused the idea that true tawhid is when it is realised that there is no difference between the Lover (the human) and the Beloved (God). There is no evidence in the teachings of the Ahl al-Bayt (as) to support this. In the School of Ahl al-Bayt (as), of course love and intimacy with God are encouraged, but the idea of merging the identity with God's identity most likely originates from India, or, as I said, from the Neoplatonic tradition.
With regard to the tariqas themselves, close scrutiny of their chains up to the time of their eponymous founders during the early medieval period (12th-13th centuries CE) reveals inconsistencies and illogicalities, which indicate that they have been fabricated. Sufis were under intense pressure from the authorities to justify their beliefs and practices, and most likely borrowed the idea of a chain of saints from the Imami Shi'i school - or else from many of the other spiritual movements of the region that also had chains of initiation as a way of trying to prove their legitimacy.
The Naqshbandi Order's chain effectively espouses the idea that Imam al-Sadiq (as) 'inherited' knowledge from Abu Bakr. (Does that really make sense, when al-Sadiq's (as) forefather was Imam Ali (as)?) It also claims that Bayazid Bastami was Imam al-Sadiq's (as) water carrier and inherited knowledge from Imam al-Sadiq (as), but Imam al-Sadiq (as) had already passed away 150 years before Bayazid Bastami lived. The Chishti Order claims that Hasan al-Basri inherited knowledge from Imam 'Ali (as), but if you read the book 'Between Myth and History' by Suleiman Ali Mourad, you can see the extent to which the person of Hasan al-Basri was fabricated by different schools of thought. Who he really was, we don't know. He worked for the Umayyads, and never supported Imam Ali (as) once Imam Ali (as) had departed for Kufa. Many Sufis also had close ties to the governments of their time, such as 'Abd al-Qadir Jilani (Gilani), who taught in Baghdad.
The best thing to do is to study Sufism and the orders while bearing in mind the historical, social and political context of the era. Overall, Sufi Orders are Sunni and go as far as denouncing the Shi'a. One order, the Kubrawiyya, did split, and one branch became Shi'a, hence why texts from the Kubrawiyya Order are taught as part of the 'irfani tradition in Iran. Nevertheless, the roots of the Kubrawiyya are technically Sunni.