Tahdhib al-Ahkam began life as a commentary. Shaykh al-Tusi set out to explain, hadith by hadith, the short legal work Al-Muqni'a written by his own teacher, al-Shaykh al-Mufid, and the explanation grew until it became a substantial collection in its own right, organized by the standard divisions of Islamic law rather than by the structure of the book it had started from: ritual purity, prayer, fasting, pilgrimage, marriage, divorce, inheritance and commercial transactions, moving through each in turn with the relevant hadith gathered underneath.
Al-Tusi worked in the eleventh century CE, after the Twelver Shia community had lived for well over a century without direct access to a living Imam, and one of his stated purposes was reconciling the apparent contradictions that had accumulated among the hadith different local traditions had preserved, a problem earlier compilers had mostly left for the reader to sort out. Tahdhib became, by sheer volume of hadith gathered and explained, the largest of the eventual Four Books, and its commentary structure meant it doubled as a training text for later students learning how a jurist was expected to reason from a raw hadith to a working legal ruling.