https://doi.org/10.1351/goldbook.O04365
Gives the degree of oxidation of an atom in terms of counting electrons. The higher the oxidation state (OS) of a given atom, the greater is its degree of @O04362@. Definition:

OS of an atom is the charge of this atom after ionic approximation of its heteronuclear bonds.

The underlying principle is that the ionic sign in an AB molecule is deduced from the electron allegiance in a LCAO-MO model: The bond’s electrons are assigned to its main atomic contributor. Homonuclear AA bonds are divided equally. In practical use, the ionic-approximation sign follows Allen electronegativities (see Source). There are two general algorithms to calculate OS:
  1. Algorithm of assigning bonds, which works on a @L03513@ showing all valence electrons in a molecule: OS equals the charge of an atom after its heteronuclear bonds have been assigned to the more electronegative partner (except when that partner is a reversibly bonded Lewis-acid ligand) and homonuclear bonds have been divided equally:
    O04365-1.png
  2. Algorithm of summing bond orders: Heteronuclear-bond orders are summed at the atom as positive if that atom is the electropositive partner in a particular bond and as negative if not, and the atom’s formal charge (if any) is added to that sum, yielding the OS. This algorithm works on Lewis formulas and on bond graphs of atom connectivities for an extended solid:
    O04365-2.png
Notes:
  1. Specific uses may require modified OS values: Electrochemical OS is nominally adjusted to represent a redox-active molecule or ion in Latimer or Frost diagrams. Nominal OS values may also be chosen from close alternatives for systematic-chemistry descriptions.
  2. Some OS may be ambiguous, typically when two or more redox-prone atoms enter bonding compromises and nearest integer values have to be chosen for the OS.
  3. The caveat of reversibly bonded Lewis-acid ligands originates from the simplifying use of electronegativity instead of the MO-based electron allegiance to decide the ionic sign. Typical examples are the transition-metal complexes with so called Z ligands in the CBC ligand-classification scheme (see Source).
  4. When used in chemical nomenclature as a symbol, the OS value is in roman numerals.
  5. At the introductory teaching level, prior to the bonding-based definition and algorithms: OS for an element in a chemical formula is calculated from the overall charge and postulated OS values for all the other atoms. For example, postulating OS = +1 for H and -2 for O yields correct OS in oxides, hydroxides, and acids like H2SO4; with coverage extended to H2O2 via decreasing priority along the sequence of the two postulates. Additional postulates may expand the range of compounds to fit a textbook's scope.
Sources:
PAC, 2014, 86, 1017. (Toward a Comprehensive Definition of Oxidation State) [Terms] [Paper]
PAC, 2016, 88, 831. (Comprehensive definition of oxidation state) [Terms] [Paper]
Red Book, 3rd ed., p. 34 [Terms] [Book]