A shul and a bais midrash are miniature “mikdash”s. Therefore the mitzvah of awe for He who dwells in them apply. You may not act with kallus rosh: laughter, silliness, idle speech. Eating and drinking, doing crafts and jobs, adorning yourself, and loitering are likewise forbidden. (ShA1 – MB 1, 3)
Idle speech includes necessary topics like parnossa. Unnecessary speech should always be avoided, even outside of shul. (MB 2)
Forbidden speech like lashon hora, insults and curses are even worse when said in shul. And if one disgraces his fellow in front of a sefer Torah, oy! … he forfeits his share in the World to Come. Therefore one who fears Hashem’s word should not speak any mundane speech so he does not come to this. The shul will be for him only for Torah and tefilla. (MB 2)
Do not use the shul for protection from bad weather. If you were involved in a halacha outside of shul and then it began to rain, you are allowed to continue inside. (ShA 1 – MB 4)
The category of prohibition that does not contain kallus rosh (e.g. Eating, drinking, sleeping, doing crafts…) does not apply to those people who learn Torah steadily in that building. If they would have to go home for those activities, they would be idle from their studies. These talmidim must still be sure not to disgrace the bais midrash by using it to escape bad weather or for a short-cut. (ShA 1 – MB 6,7)
People who learn in the bais midrash all day are allowed even to use it to escape the bad weather or any other usage. Even so, they must never behave there with kallus rosh. (Rama 1-BeH “v’yaish)
Do not make calculations in shul even for needs of the public, unless it is for a mitzvah like tzedoka. (ShA1 – BeH “v’ain”)
Do not hold eulogies in shul unless it is for a talmid chocham or a family member of a city official which draws a large crowd. (ShA1 – MB 10)
If you enter for your own needs (e.g. to call someone), enter and say some words of Torah first and then do what you need. Even the mitzvah of staying in the shul a little (the amount of time it takes to walk 8 tefachim) without divray Torah justifies entering. (ShA 1 – MB 11,12,13)
Your study room at home is not made for public Torah learning so it does not have this status of kedushas bais midrash. (ShA 2)
Anyone can take a nap in a bais midrash. (ShA 3 – MB 16)
A talmid chochom who learns in a bais midrash steadily, may lay down to sleep there. (MB 16)
A shul guard is allowed to eat and sleep in the shul. (ShA 4 – MB 17)
You may host a seudas mitzva in shul. If they want to serve liquor at the seuda and there is no space to have it elsewhere, you do not need to protest. (ShA 4 – MB 20)
Do not use a shul for a short cut unless you will learn or delay inside the shul a little bit. Otherwise it is forbidden to enter a shul except for the purpose of a mitzvah. (ShA 5 – BeH “la’asoso”, “l’katzayr”)
Upon leaving a shul it is a mitzvah to exit from a door across from the one that you entered to demonstrate your love for being in shul. (ShA 5 – MB 21)
There are those who hold not to bring a weapon into shul. However, a talmid chochom may use a long knife to cut his food when eating in shul. (ShA 6 – BeH “b’sakkin”)
A man who wears a head covering feels trepidation and seriousness before Hashem. You may not enter shul without this. (ShA 6- BeH “oh”)
You may spit in shul as long as it is not during Shemoneh Esray, it does not disturb other people, and you rub it with your foot so the spit will not be noticable. If you are makpid not to spit in your house it is forbidden to spit in shul. (ShA 7 – MB 24 – ShaH 15)
It is best to wipe off any mud on your legs before entering shul to daaven. You and your clothes should be perfectly clean. (ShA 8)
It is an honor to clean the shul. Rabaynu Yaakov would sweep in front of the Aron Kodesh with his beard. (ShA 9 – BaH 10)
It is an honour to have lights lit in shul. They should be lit before the minyan gathers. (ShA 9 –MB 27)
Before a shul in any country is finished being built, a condition can be made to limit its kedusha. (Some poskim hold that the condition is automatic but it’s best not to be so maykil.) This condition enables the shul to be used for any mundane activity that does not entail any kallus rosh. The shul can even be used once in a while for activities that entail semi-kallus rosh when there is a pressing need. (e.g. meals served with liquor, sleeping). Kallus rosh mamash is never allowed. (e.g. laughter, silliness, idle speech, mathematical calculations). (BeH “avol bishuvo”, “avol b’votay” – MB 31 – ShaH 19,20)
An upper storey of a building built originally as a shul may be used for sleeping and other degrading usages only once in a while. For non-degrading purposes, you may use the upper storey, excluding the room directly above the Aron Kodesh. (ShA 12 – MB 39,40)
Upon the flat roof of such a building you are never allowed to dry out laundry (or any other degrading usage) because everyone can see it. (BeH “yaish”)
Do not move a shul into a building that has an already occupied apartment on top – because of the bathroom that is up there. If the shul is temporarily renting the lower storey, it is okay. (MB 41)