Mass. Gen. Laws ch. 276, § 58A
(2) Upon the appearance before a superior court or district court judge of an individual charged with an offense listed in subsection (1) and upon the motion of the commonwealth, the judicial officer shall hold a hearing pursuant to subsection (4) issue an order that, pending trial, the individual shall either be released on personal recognizance without surety; released on conditions of release as set forth herein; or detained under subsection (3).
(B) subject to the least restrictive further condition, or combination of conditions, that such judicial officer determines will reasonably assure the appearance of the person as required and the safety of any other person and the community that the person—
(xiv) satisfy any other condition that is reasonably necessary to assure the appearance of the person as required and to assure the safety of any other person and the community.
The judicial officer may not impose a financial condition that results in the pretrial detention of the person.
The judicial officer may at any time amend the order to impose additional or different conditions of release.
Participation in a community corrections program pursuant to chapter 211F may be ordered by the court or as a condition of release; provided, however, that the defendant shall consent to such participation.
If the judicial officer determines that personal recognizance will not reasonably assure the appearance of the person as required or will endanger the safety of any other person or the community, such judicial officer shall order the pretrial release of the person—
(4) When a person is held under arrest for an offense listed in subsection (1) and upon a motion by the commonwealth, the judge shall hold a hearing to determine whether conditions of release will reasonably assure the safety of any other person or the community.
The hearing shall be held immediately upon the person's first appearance before the court unless that person, or the attorney for the commonwealth, seeks a continuance. Except for good cause, a continuance on motion of the person may not exceed seven days, and a continuance on motion of the attorney for the commonwealth may not exceed three business days. During a continuance, the individual shall be detained upon a showing that there existed probable cause to arrest the person. At the hearing, such person shall have the right to be represented by counsel, and, if financially unable to retain adequate representation, to have counsel appointed. The person shall be afforded an opportunity to testify, to present witnesses, to cross-examine witnesses who appear at the hearing, and to present information. Prior to the summons of an alleged victim, or a member of the alleged victim's family, to appear as a witness at the hearing, the person shall demonstrate to the court a good faith basis for the person's reasonable belief that the testimony from the witness will be material and relevant to support a conclusion that there are conditions of release that will reasonably assure the safety of any other person or the community. The rules concerning admissibility of evidence in criminal trials shall not apply to the presentation and consideration of information at the hearing and the judge shall consider hearsay contained in a police report or the statement of an alleged victim or witness. The facts the judge uses to support findings pursuant to subsection (3), that no conditions will reasonably assure the safety of any other person or the community, shall be supported by clear and convincing evidence. In a detention order issued pursuant to the provisions of said subsection (3) the judge shall (a) include written findings of fact and a written statement of the reasons for the detention; (b) direct that the person be committed to custody or confinement in a corrections facility separate, to the extent practicable, from persons awaiting or serving sentence or being held in custody pending appeal; and (c) direct that the person be afforded reasonable opportunity for private consultation with his counsel. The person may be detained pending completion of the hearing. The hearing may be reopened by the judge, at any time before trial, or upon a motion of the commonwealth or the person detained if the judge finds that: (i) information exists that was not known at the time of the hearing or that there has been a change in circumstances and (ii) that such information or change in circumstances has a material bearing on the issue of whether there are conditions of release that will reasonably assure the safety of any other person or the community.
(7) A person aggrieved by the denial of a district court justice to admit him to bail on his personal recognizance with or without surety may petition the superior court for a review of the order of the recognizance and the justice of the district court shall thereupon immediately notify such person of his right to file a petition for review in the superior court. When a petition for review is filed in the district court or with the detaining authority subsequent to petitioner's district court appearance, the clerk of the district court or the detaining authority, as the case may be, shall immediately notify by telephone, the clerk and probation officer of the district court, the district attorney for the district in which the district court is located, the prosecuting officer, the petitioner's counsel, if any, and the clerk of courts of the county to which the petition is to be transmitted. The clerk of the district court, upon the filing of a petition for review, either in the district court or with the detaining authority, shall forthwith transmit the petition for review, a copy of the complaint and the record of the court, including the appearance of the attorney, if any is entered, and a summary of the court's reasons for denying the release of the defendant on his personal recognizance with or without surety to the superior court for the county in which the district court is located, if a justice thereof is then sitting, or to the superior court of the nearest county in which a justice is then sitting; the probation officer of the district court shall transmit forthwith to the probation officer of the superior court, copies of all records of the probation office of said district court pertaining to the petitioner, including the petitioner's record of prior convictions, if any, as currently verified by inquiry of the commissioner of probation. The district court or the detaining authority, as the case may be, shall cause any petitioner in its custody to be brought before the said superior court within two business days of the petition having been filed. The district court is authorized to order any officer authorized to execute criminal process to transfer the petitioner and any papers herein above described from the district court or the detaining authority to the superior court, and to coordinate the transfer of the petitioner and the papers by such officer. The petition for review shall constitute authority in the person or officer having custody of the petitioner to transport the petitioner to said superior court without the issuance of any writ or other legal process; provided, however, that any district or superior court is authorized to issue a writ of habeas corpus for the appearance forthwith of the petitioner before the superior court.
The superior court shall in accordance with the standards set forth in section fifty-eight A, hear the petition for review under section fifty-eight A as speedily as practicable and in any event within five business days of the filing of the petition. The justice of the superior court hearing the review may consider the record below which the commonwealth and the person may supplement. The justice of the superior court may, after a hearing on the petition for review, order that the petitioner be released on bail on his personal recognizance without surety, or, in his discretion, to reasonably assure the effective administration of justice, make any other order of bail or recognizance or remand the petitioner in accordance with the terms of the process by which he was ordered committed by the district court.
(8) If after a hearing under subsection (4) detention under subsection (3) is ordered or pretrial release subject to conditions under subsection (2) is ordered, then: