1היא שצונו שיהיה כל מלך מאומתנו יושב בכסא המלוכה כותב ספר תורה לו לעצמו לא יפרד ממנו. והוא אמרו והיה כשבתו על כסא ממלכתו וכתב לו את משנה התורה הזאת. וכבר התבאר כלל משפטי מצוה זו בפרק ב' מסנהדרין. (שופטים ושוטרים, אהבה הלכות תפילין ומזוזה וס"ת פרק ז'):
And that is that He commanded us that any king from our nation that sits on the royal throne should write a Torah scroll for himself, and that it not be separated from him. And that is His saying, "When he is seated on his royal throne, he shall have a copy of this Torah written for him" (Deuteronomy 17:18). And all of the regulations of this commandment have already been explained in Chapter 2 of Sanhedrin. (See Parashat Shoftim; Mishneh Torah, Tefillin, Mezuzah and the Torah Scroll 7.)
The Rambam's count of the 613 mitzvos. English: Rabbi Francis Nataf, Sefaria 2021 (CC-BY). Hebrew: Warsaw 1883. Via Sefaria. All the library · Jer’s Torah Page