> For AI agents: read the machine-readable documentation index at [https://corpuslaw.us/llms.txt](https://corpuslaw.us/llms.txt) or the single-file full reference at [https://corpuslaw.us/llms-full.txt](https://corpuslaw.us/llms-full.txt).

# Va. Code Ann. § 37.2-847 — Duty of attorney for Commonwealth

- **Citation**: Va. Code Ann. § 37.2-847
- **Node Type**: section
- **Jurisdiction**: Virginia (state)
- **Code Body**: Code of Virginia (Aug. 2026 snapshot) (Va. Code Ann.)
- **Official Source**: [https://law.lis.virginia.gov/vacode/37.2-847/](https://law.lis.virginia.gov/vacode/37.2-847/)
- **Canonical URL**: [https://corpuslaw.us/codes/virginia/title-37-2/chapter-8/section-37-2-847](https://corpuslaw.us/codes/virginia/title-37-2/chapter-8/section-37-2-847)
- **Semantic URL**: [https://corpuslaw.us/codes/virginia/title-37-2/chapter-8/section-37-2-847](https://corpuslaw.us/codes/virginia/title-37-2/chapter-8/section-37-2-847)

## Hierarchy

Title 37.2 > Chapter 8

## Text

In any case to test the legality of the detention of a person pursuant to this article, whether by habeas corpus or otherwise, the attorney for the Commonwealth of the county or city in which the hearing is held shall, on request of the director of the facility or other institution having or claiming custody of the person, represent the Commonwealth in opposition to any such petition, appeal, or procedure for the discharge of the person from custody.

Code 1950, § 37-125; 1950, p. 916; 1968, c. 477, § 37.1-104.2; 1972, c. 639; 2005, c. 716 .
