The writ of habeas corpus is the remedy to be used when any person is restrained in his liberty. In Texas, the state writ of habeas corpus is a legal mechanism that allows individuals to challenge their detention or imprisonment.Let's start with the basics. The Privilege of the Writ of Habeas Corpus shall not be suspended, unless when in Cases of Rebellion or Invasion the public Safety may require it. Texas Constitution Article 1, Section 12: "The writ of habeas corpus is a writ of right, and shall never be suspended. The Court of Criminal Appeals has ruled that a claim of insufficiency of the evidence cannot be raised on a writ of habeas corpus. Prosecutors must show that they have a valid reason for detaining the person. If the detention is illegal, the detainee can be released. The Texas Constitution authorizes -- indeed, requires -- the legislature to devise an effectual system of habeas corpus. The privilege of the writ of habeas corpus shall not be suspended, unless when in Cases of Rebellion or Invasion the public Safety may require it.