The Chida famously wrote:
Before learning Torah, or doing any mitzvah, it is a good custom to have thoughts of teshuvah (Moreh Be'etzba, Siman 1)
I heard, in addition to what the Chida says, that the Mishnah Berurah wrote it is good to do teshuvah before going to sleep. I did not remember if he wrote that it should be done before, or after Krias Shema.
Does anyone know where the Mishnah Berurah writes this and what the specific reason for this is?