عن علي رضي الله عنه عن النبي صلى الله عليه وسلم قال:
«رُفِعَ الْقَلَمُ عن ثلاثة: عن النائم حتى يَسْتَيْقِظَ، وعن الصبي حتى يَحْتَلِمَ، وعن المجنون حتى يَعْقِلَ».
[صحيح] - [رواه أبو داود والترمذي والنسائي في الكبرى وابن ماجه وأحمد] - [سنن أبي داود: 4403]
المزيــد ...
‘Ali (may Allah be pleased with him) reported: The Prophet (may Allah's peace and blessings be upon him) said:
"There are three (people) whose actions are not recorded by the Pen: a sleeping person till he awakes, a boy till he reaches puberty, and a person with an unsound mind till he regains his sanity."
[Authentic hadith] - [Narrated by Abu Daoud & At-Termedhy & Ahmad & Ibn Majah & An-Nasa'i in Major Sunan] - [Sunan Abu Daoud - 4403]
The Prophet (may Allah's peace and blessings be upon him) informed that accountability is binding on all the children of Adam except for these three:
A child till he grows up and reaches puberty.
An insane and crazy person till his mind is restored.
A sleeping person till he wakes up.
Accountability has been lifted from them, and their sinful actions are not recorded against them. However, goodness is recorded for a young boy, but not for the insane or sleeping person, because they are in the category of those who are not capable of valid worship due to the loss of consciousness.