Moed Katan3: 4
אֵין כּוֹתְבִין שְׁטָרֵי חוֹב בַּמּוֹעֵד. וְאִם אֵינוֹ מַאֲמִינוֹ, אוֹ שֶׁאֵין לוֹ מַה יֹּאכַל — הֲרֵי זֶה יִכְתֹּב.  אֵין כּוֹתְבִין סְפָרִים, תְּפִלִּין וּמְזוּזוֹת בַּמּוֹעֵד, וְאֵין מַגִּיהִין אוֹת אַחַת, אֲפִלּוּ בְסֵפֶר (עֶזְרָא) [הָעֲזָרָה]. רַבִּי יְהוּדָה אוֹמֵר: כּוֹתֵב אָדָם תְּפִלִּין וּמְזוּזוֹת לְעַצְמוֹ, וְטֹוֶה עַל יְרֵכוֹ תְּכֵלֶת לְצִיצִיתוֹ.
We may not write loan contracts during [Chol] HaMoed. However, if he does not trust him, or if he has nothing to eat, then he may write.  We may not write Books [of Scripture], nor tefillin, nor mezuzos during [Chol] HaMoed. We may not correct a single letter even in the [Torah] scroll of the Temple court. R' Yehudah says: A person may write tefillin or mezuzos for his personal use; and he may spin the blue thread for his tzitzis, on his thigh.