Imam al-Bukhari (may Allah have mercy on him) himself stated that he did not include any hadith in this book until he had taken a ritual bath, performed two units of prayer, and then sought divine guidance (Istikhara) regarding it. He compiled this book at the Sacred House (Ka‘bah), and performed two units of prayer before including each hadith. When he became fully satisfied with the authenticity of a hadith, only then did he record it. He regarded it as a proof for his own salvation and compiled it after selecting from a collection of six hundred thousand hadiths.
Al-Hafiz Ibn ‘Adi reports from a group of his teachers that Imam al-Bukhari used to sit between the Prophet’s Chamber and Minbar in the Prophet’s Mosque to organize the chapter headings (Tarajim al-Abwab) of Al-Jami‘ al-Sahih. For every chapter title, he would perform two units of prayer and seek divine guidance until he attained complete inner peace before writing it down.
His scribe narrated an incident: “I was once with Imam al-Bukhari when he was writing the Book of Tafsir. I observed him during the night wake up fifteen to twenty times. He would strike the fire stone to light a lamp, mark the hadiths, and then lie down again.”
This demonstrates that Imam al-Bukhari was constantly engaged in compiling his book whether he was traveling or residing somewhere. Whenever and wherever he became convinced of a hadith’s authenticity, he would mark it. He reviewed his hadith collection three times in this manner.
Finally, the arrangement and refinement of the chapter titles and the inclusion of hadiths under each chapter were completed—once while sitting in the Sacred Sanctuary (Masjid al-Haram) and again in the Prophet’s Mosque between the Prophet’s Minbar and Mihrab in Madinah. During this process, before writing any hadith under a chapter heading, he would first take a ritual bath and seek divine guidance. In this way, this monumental work was completed over a span of sixteen years.