The Gemara (Yoma 47a) states: “Our Sages taught: Kimchit had seven sons, all of whom served as Kohanim Gedolim (High Priests). The Sages asked her, ‘What have you done to merit this?’ She replied, ‘The beams of my house have never seen the braids of my hair.’” Rashi, in his commentary on this Gemara, quotes the words of the Talmud Yerushalmi which expounds the verse in Tehillim (45, 14) as follows: “All honor [awaits] the king’s daughter who is within; her raiment is superior to settings of gold”- A modest woman deserves to have a son who shall be a Kohen Gadol dressed in golden settings.
This means that Kimchit was so careful about her modesty that she had never even revealed her hair in front of the beams of her home! This was a result of her extraordinary modesty before Hashem, whose glory fills the entire world.
Maran Ha’Shulchan Aruch (Chapter 2) writes: “One should not wear one’s robe while sitting; rather, one should insert one’s head and arms into one’s robe while lying down and by doing so, when one gets up, one will be covered.” We see that one must be modest even in a place where there are no other people present, for Hashem’s presence fills the entire world and just as it is improper to reveal themselves immodestly in front of one another, it is likewise improper for one to reveal himself immodestly before Hashem besides for when this is necessary, such as, when one is bathing since there is no other way to do so and this poses no concern whatsoever.
Let us now explain if this is an actual law and how much one must be careful in this regard.
The Gemara (Shabbat 118b) states that Rabbi Yose would exclaim about himself that the beams of his home never saw the lining of his robe (meaning that he would never reveal himself immodestly even when he was alone in his own home). The fact that Rabbi Yose praised himself about this shows that it is not an actual law; rather, it is merely a pious behavior.
Nevertheless, Hagaon Harav Menashe Klein zt”l writes in his Responsa Mishneh Halachot (Volume 6, Chapter 2) that the fact that the Talmud, Poskim, and Maran Ha’Shulchan Aruch write that one must not reveal himself within his own home proves that this is indeed a complete law and obligation. The reason why Rabbi Yose praised himself is not because this is a lofty level of piety; rather, this was because most people were not careful regarding this law and Rabbi Yose was proud that he was. He proceeds to prove this from the incident of Kimchit as well.
However, the above opinion is quite difficult to understand, for it is improbable that most people in the times of Rabbi Yose disregarded an explicit law and Rabbi Yose praised himself because of the fact that he merely observed this law. Regarding Hagaon Harav Klein’s proof from Kimchit, it seems that, on the contrary, Kimchit observed an extraordinary level of piety. Indeed, the great Menorat Ha’Maor writes that the Gemara exaggerated here, for it is impossible that the beams of Kimchit’s house never saw her hair since she did shower and comb her hair; rather, this is just meant as an overstatement because she possessed such a high level of modesty.
Thus, halachically speaking, although this is not a halachic obligation, it is good and worthy custom for one to act as modestly as possible even within the privacy of one’s home where no one else can see him. Similarly, Maran Rabbeinu Ovadia Yosef zt”l writes that this is not a complete halachic obligation and the above Halacha which we quoted from Maran Ha’Shulchan Aruch is meant only as an excellent custom which one should adopt as much as possible. By doing so, one will likewise come to the realization that even when one is alone, there is always someone looking, listening, and writing down one’s actions. One will therefore grow in fear of Heaven and be spared from sinning, even when no one sees him.