Whenever a writ of habeas corpus shall issue from either the supreme, superior or family court for the production and appearance before it of a prisoner confined in the training school for youth, the writ shall be delivered to the division of sheriffs. Whenever the writ is issued from any other court, it shall be delivered to the division of sheriffs or to any town sergeant or chief of police or police constable who shall duly present it to the superintendent of the training school for youth. The superintendent shall upon receipt of the writ deliver the prisoner to the custody of the officer. The officer shall take and receive the prisoner into his or her custody, shall duly present him or her before the court pursuant to the commands of the writ, and shall keep and hold the prisoner until by order of the court the prisoner shall be recommitted to the institution or otherwise disposed of. Upon the delivery of the custody of the prisoner by the superintendent to the officer, the superintendent shall endorse the delivery upon the writ, and the officer shall receipt on the books of the training school for youth for the custody. The officer, upon the production of the prisoner in court, shall further endorse that fact on the writ and deliver it to the clerk or (if there is no clerk) the presiding justice; but shall, as an officer of the court, maintain safe custody of the prisoner until he or she is, by further order, recommitted or discharged.
R.I. Gen. Laws § 11-25-21