Tefillin written by a slave or a woman, or a minor even if he has reached the age of chinuch, or even if he has reached the age of years but has not brought signs [of puberty], or a Kutite, or a transgressor of the entire Torah, or an idolater, or one who desecrates Shabbat; or even a transgressor of a single transgression, provided he does so provocatively and even regarding a rabbinic law; or an informer to an oppressor—all of these are invalid. For it is written: "And you shall bind [...] and you shall write," anyone who is included in binding and believes in this is included in writing. And anyone who is not included in binding, such as a woman, a slave, a minor, a deaf-mute, and a deranged person, or does not believe in it like all those we have enumerated—is not included in writing. And a minor, as long as it has not been clarified that he brought two hairs—is invalid, even if he reached the total of his years. For regarding a Torah law we do not say there is a presumption that he brought signs (Magen Avraham subsection 1). And it appears to me that a transgressor regarding tefillin alone, even if it is not provocatively—is invalid. And even though regarding shechitah he is valid—that is when another checks the knife for him, as I wrote in Yoreh Deah siman 2. And if so, regarding tefillin he is not trusted to say that he wrote them according to the halachah, since there is exertion involved in this. And there is one who says that for appetite—he is valid, for he is called "subject to binding," just as in shechitah he is "subject to slaughtering" (Magen Avraham subsection 3). And I wonder: for granted that he is subject to binding, does he not refuse to exert himself? And this is similar to shechitah when an Israelite does not check the knife, for it is forbidden to eat from his slaughtering. And one whose left hand was severed—is valid for writing, for he is "subject to binding" but merely has nothing upon which to bind. (Ibid. subsection 5. And see Taz subsection 1 what he wrote as a reason regarding an informer. And be precise and you will find it easy.)
תפילין שכתבן עבד או אשה, או קטן אפילו הגיע לחינוך, או אפילו הגיע לשנים ולא הביא סימנים, או כותי, או עבריין לכל התורה, או עובד לכוכבים, או מחלל שבת; או אפילו עבריין לעבירה אחת, רק שעושה להכעיס ואפילו בדרבנן; או מלשין לאנס – כל אלו פסולים. דכתיב: "וקשרתם […] וכתבתם", כל שישנו בקשירה ומאמין בזה – ישנו בכתיבה. וכל שאינו בקשירה, כאשה, ועבד, וקטן, וחרש, ושוטה, או אינו מאמין בה ככל הני שחשבנו – אינו בכתיבה. וקטן כל זמן שלא נתברר שהביא שתי שערות – פסול, אפילו הגיע לכלל שניו. דבדאורייתא לא אמרינן חזקה שהביא סימנים (מגן אברהם סעיף קטן א'). ויראה לי דעבריין לתפילין בלבד, אף שאינו להכעיס – פסול. ואף על גב דבשחיטה כשר – זהו כשאחר בודק לו סכין, כמו שכתבתי ביורה דעה סימן ב. ואם כן בתפילין אינו נאמן לומר שכתבן כהלכה, כיון שיש בזה טורח. ויש מי שאומר דלתיאבון – כשר, דמקרי בר קשירה, כבשחיטה בר זביחה (מגן אברהם סעיף קטן ג'). ותמיהני: דנהי דבר קשירה הוא, הא אינו רוצה לטרוח? וזהו דומיא כמו בשחיטה כשאין הישראל בודק הסכין, דאסור לאכול משחיטתו. ומי שנקטעה ידו השמאלית – כשר בכתיבה, ד"בר קשירה" הוא אלא שאין לו על מה לקשור. (שם סעיף קטן ה'. ועיין ט"ז סעיף קטן א' מה שכתב טעם במלשין. ודייק ותמצא קל.)