The Shulchan Aruch · Orach Chayim
אורח חיים תר״מOrach Chayim 640
Siman 640 of 697 in Orach Chayim — 10 se'ifim
הלכות סוכהLaws of Sukkot· siman 640
Se’if 1א׳
נָשִׁים, וַעֲבָדִים, וּקְטַנִּים פְּטוּרִים מִן הַסֻכָּה; טֻמְטוּם וְאַנְדְּרוֹגִינוּס, חַיָּבִים מִסָפֵק; וְכֵן מִי שֶׁחֶצְיוֹ עֶבֶד וְחֶצְיוֹ בֶּן חוֹרִין, חַיָּב.
1. Who is exempt from dwelling in the Sukkah, and in it is 10 paragraphs. Women, slaves, minors are exempt from the (mitzvah of) Sukkah. A tumtum (one has genitalia that are covered, unable to be recognized) or an androgynous is obligated out of doubt (perhaps they are male). And similarly one who is a half slave, half free person is obligated.
Se’if 2ב׳
קָטָן שֶׁאֵינוֹ צָרִיךְ לְאִמּוֹ, שֶׁהוּא כְּבֶן חָמֵשׁ, כְּבֶן שֵׁשׁ, חַיָּב בְּסֻכָּה מִדִּבְרֵי סוֹפְרִים, כְּדֵי לְחַנְּכוֹ בְּמִצְוֹת.
2. A minor that does not need his mother (when sleeping), when he is about a boy of 5 or a boy of 6, is obligated in (the Mitzvah of) Sukkah from Divrei Sofrim (words of the scribes, Rabbinical) in order to train him in the Mitzvos.
Se’if 3ג׳
חוֹלִים וּמְשַׁמְּשֵׁיהֶן פְּטוּרִים מִן הַסֻכָּה; וְלֹא חוֹלֶה שֶׁיֵּשׁ בּוֹ סַכָּנָה, אֶלָּא אֲפִלּוּ חָשׁ בְּרֹאשׁוֹ, (אוֹ) חָשׁ בְּעֵינָיו; וְיֵשׁ מִי שֶׁאוֹמֵר שֶׁאֵין הַמְשַׁמְּשִׁים פְּטוּרִים אֶלָּא בְּשָׁעָה שֶׁהַחוֹלֶה צָרִיךְ לָהֶם וּמִי שֶׁמַּקִּיז דָּם חַיָּב בְּסֻכָּה (אוֹר זָרוּעַ וְהַגָּהוֹת אֲשֵׁרִ"י פ' הַיָּשֵׁן).
3. Sick people and those attending to them are exempt from the (Mitzvah of) Sukkah. And not just a sick person who is endangered; rather, even if he has head pain or eye pain. There is one who says that the attendants are exempt only at the time the sick person needs them. Parentheses (Rema): And one who is bloodletting is obligated in the (Mitzvah of) Sukkah [Ohr Zarua and the Haagos Ashiri Chapter HaYashan (2nd chapter of Tractate Sukkah)].
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0