Muhammad ibn Yaqub al-Kulayni worked on Kitab al-Kafi for roughly twenty years, completing it in Baghdad not long before his death in 941 CE, during the early decades of the Minor Occultation, the period in which Twelver Shia Islam's Twelfth Imam was held to be in hiding and communicating only through a series of deputies.
The book divides into three parts. Usul al-Kafi, the largest and most cited, gathers hadith on theology and doctrine: the nature of God, prophecy, the status and authority of the Imams, and the principles by which a believer is meant to reason about faith. Furu al-Kafi turns to practical law, covering ritual purity, prayer, fasting, pilgrimage, marriage, inheritance and commercial transactions in the detailed case-by-case style typical of early Islamic legal literature. Rawdat al-Kafi, the shortest section, is a miscellany of sermons, letters and narrative reports that do not fit neatly under either heading. Across the whole work al-Kulayni assembled something close to sixteen thousand individual hadith, each carried by its own chain of transmission back through earlier narrators to one of the Imams, making Kafi as much a record of how Twelver Shia scholars of his generation understood authoritative transmission as it is a statement of doctrine and law in its own right.