The Shulchan Aruch · Orach Chayim
אורח חיים ל״טOrach Chayim 39
Siman 39 of 697 in Orach Chayim — 10 se'ifim
הלכות תפיליןLaws of Tefillin· siman 39
Se’if 1א׳
תְּפִלִּין שֶׁכְּתָבָן עֶבֶד, אוֹ אִשָּׁה, אוֹ קָטָן, אֲפִלּוּ הִגִּיעַ לְחִנּוּךְ, אוֹ גּוֹי, אוֹ כּוּתִי, אוֹ יִשְׂרָאֵל מוּמָר, אוֹ מוֹסֵר, פְּסוּלִים, מִשּׁוּם דִּכְתִּיב וּקְשַׁרְתָּם וּכְתַבְתָּם. כָּל שֶׁאֵינוֹ בִּקְשִׁירָה, אוֹ אֵינוֹ מַאֲמִין בָּהּ, אֵינוֹ בִּכְתִיבָה.
תפילין that were written by a slave, or a woman, or a minor - even if he reached [the age of] training [in mitzvot], (or a non-Jew), or a Samaritan, or a transgressor/apostate who served idols, or an informer are invalid because [of what] is written "And you shall bind them as a sign on your hand… and you shall write them on the doorposts of your house" (Deuteronomy 6:8–9): [which is expounded to mean] - All that are not [commanded] in binding or do not believe in it, are not [suitable] for writing.
Se’if 2ב׳
כָּל שֶׁפָּסוּל לְכָתְבָן, פָּסוּל בְּכָל תִּקּוּן עֲשִׂיָּתָן.
All that are invalid to write them, are invalid in all [aspects of] making/fixing them.
Se’if 3ג׳
גֵּר שֶׁחָזַר לְדָתוֹ מֵחֲמַת יִרְאָה, כָּשֵׁר לִכְתֹּב תְּפִלִּין.
A [Jewish] convert that returned to his [previous] religion because of fear is valid to write תפילין.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0