As the source you link to explains:
The Uniform Code of Military Justice (UCMJ, 64 Stat. 109, 10 U.S.C. §§
801–946), is the foundation of military law in the United States. It
was established by the United States Congress in accordance with the
authority given by the United States Constitution in Article I,
Section 8, which provides that "The Congress shall have Power....To
make Rules for the Government and Regulation of the land and naval
A bill that applies only to the military is passed like any other Congressional legislation and the only way to know who it applies to (i.e. military or civilian) is to read the text of the adopted law.
Right now, military law in the United States is set forth in a law enacted by Congress in statutes that are located in Title 10 of the United States Code form Sections 801 to 946.
Who Is Subject To The UCMJ?
Section 802 of Title 10, set forth in the block quote below expressly states who is subject to the Uniform Code of Military Justice.
Mostly, the UCMJ applies to members of the U.S. military, broadly defined, with some of the potentially close cases described with specificity. A lot of the detail in this definition goes to the issue of when non-active duty military personnel (1) are subject to the UCMJ, (2) are subject to state versions of the UMCJ in lieu of the UCMJ, or (3) are not subject to the UCMJ at all.
The UCMJ also applies to some civilians and people who belong to other military forces, most of which involve (1) people who are civilian employees of the military or civilian military contractors, (2) civilians and members of foreign militaries who are traveling with the military or present on military bases, and (3) prisoners of war broadly defined. These exception cases are emphasized in bold in the blockquote setting forth 10 USC § 802 below.
(a) The following persons are subject to this chapter:
(1) Members of a regular component of the armed forces, including
those awaiting discharge after expiration of their terms of
enlistment; volunteers from the time of their muster or acceptance
into the armed forces; inductees from the time of their actual
induction into the armed forces; and other persons lawfully called or
ordered into, or to duty in or for training in, the armed forces, from
the dates when they are required by the terms of the call or order to
(2) Cadets, aviation cadets, and midshipmen.
(3) Members of a reserve component while on inactive-duty training,
but in the case of members of the Army National Guard of the United
States or the Air National Guard of the United States only when in
(4) Retired members of a regular component of the armed forces who are
entitled to pay.
(5) Retired members of a reserve component who are receiving
hospitalization from an armed force.
(6) Members of the Fleet Reserve and Fleet Marine Corps Reserve.
(7) Persons in custody of the armed forces serving a sentence imposed
by a court-martial.
(8) Members of the National Oceanic and Atmospheric Administration,
Public Health Service, and other organizations, when assigned to and
serving with the armed forces.
(9) Prisoners of war in custody of the armed forces.
(10) In time of declared war or a contingency operation, persons
serving with or accompanying an armed force in the field.
(11) Subject to any treaty or agreement to which the United States is
or may be a party or to any accepted rule of international law,
persons serving with, employed by, or accompanying the armed forces outside the United States and outside the Commonwealth of Puerto Rico,
Guam, and the Virgin Islands.
(12) Subject to any treaty or agreement to which the United States is
or may be a party or to any accepted rule of international law,
persons within an area leased by or otherwise reserved or acquired for the use of the United States which is under the control of the
Secretary concerned and which is outside the United States and outside
the Commonwealth of Puerto Rico, Guam, and the Virgin Islands.
(13) Individuals belonging to one of the eight categories enumerated
in Article 4 of the Convention Relative to the Treatment of Prisoners
of War, done at Geneva August 12, 1949 (6 UST 3316), who violate the
law of war.
(b) The voluntary enlistment of any person who has the capacity to
understand the significance of enlisting in the armed forces shall be
valid for purposes of jurisdiction under subsection (a) and a change
of status from civilian to member of the armed forces shall be
effective upon the taking of the oath of enlistment.
(c) Notwithstanding any other provision of law, a person serving with
an armed force who—
(1) submitted voluntarily to military authority;
(2) met the mental competency and minimum age qualifications of
sections 504 and 505 of this title at the time of voluntary submission
to military authority;
(3) received military pay or allowances; and
(4) performed military duties;
is subject to this chapter until such person’s active service has been
terminated in accordance with law or regulations promulgated by the
(d)(1) A member of a reserve component who is not on active duty and
who is made the subject of proceedings under section 815 (article 15)
or section 830 (article 30) with respect to an offense against this
chapter may be ordered to active duty involuntarily for the purpose
(A) a preliminary hearing under section 832 of this title (article
(B) trial by court-martial; or
(C) nonjudicial punishment under section 815 of this title (article
(2) A member of a reserve component may not be ordered to active duty
under paragraph (1) except with respect to an offense committed while
the member was—
(A) on active duty; or
(B) on inactive-duty training, but in the case of members of the Army
National Guard of the United States or the Air National Guard of the
United States only when in Federal service.
(3) Authority to order a member to active duty under paragraph (1)
shall be exercised under regulations prescribed by the President.
(4) A member may be ordered to active duty under paragraph (1) only by
a person empowered to convene general courts-martial in a regular
component of the armed forces.
(5) A member ordered to active duty under paragraph (1), unless the
order to active duty was approved by the Secretary concerned, may not—
(A) be sentenced to confinement; or
(B) be required to serve a punishment consisting of any restriction on
liberty during a period other than a period of inactive-duty training
or active duty (other than active duty ordered under paragraph (1)).
(e) The provisions of this section are subject to section 876b(d)(2)
of this title (article 76b(d)(2))
There have been times in the past when statutes merely authorized (or impliedly authorized) the military to adopt its own military law rules, and this approach isn't uncommon abroad. But, this is not the current state of the law in the United States.
Regulation of the discipline of people who are not U.S. military personnel who are in the custody of the military, and of prisoners of war, has not always been consolidated in a single statute as it is today.
Note also that the UCMJ does not apply to Military Tribunals such as those at Guantanamo Bay. Instead, the UCMJ deals with how to treat misconduct by POWs once they are in custody. But, the UCMJ does not comprehensively regulate how one becomes and ceases to be a POW, and the UCMJ does not cover Military Tribunals imposed to met out justice during times when martial law is imposed on civilian populations who have no special relationship with the U.S. military, nor does the UCMJ cover Military Tribunals imposed to met out justice upon enemy combatants for conduct of those enemy combatants prior to their capture by the military. Those matters are covered by other legislation, treaties and case law.