Question: What rule do atoms that tend to combine in such a way that they have eight electrons in their valence shell follow?
About the article "Chemistry", section "Bonding".

Candidate passages:
Atoms sticking together in molecules or crystals are said to be bonded with one another.
A chemical bond may be visualized as the multipole balance between the positive charges in the nuclei and the negative charges oscillating about them.
More than simple attraction and repulsion, the energies and distributions characterize the availability of an electron to bond to another atom.
A chemical bond can be a covalent bond, an ionic bond, a hydrogen bond or just because of Van der Waals force.
Each of these kinds of bonds is ascribed to some potential.
These potentials create the interactions which hold atoms together in molecules or crystals.
In many simple compounds, Valence Bond Theory, the Valence Shell Electron Pair Repulsion model (VSEPR), and the concept of oxidation number can be used to explain molecular structure and composition.
An ionic bond is formed when a metal loses one or more of its electrons, becoming a positively charged cation, and the electrons are then gained by the non-metal atom, becoming a negatively charged anion.
The two oppositely charged ions attract one another, and the ionic bond is the electrostatic force of attraction between them.
For example, sodium (Na), a metal, loses one electron to become an Na+ cation while chlorine (Cl), a non-metal, gains this electron to become Cl-.
The ions are held together due to electrostatic attraction, and that compound sodium chloride (NaCl), or common table salt, is formed.
In a covalent bond, one or more pairs of valence electrons are shared by two atoms: the resulting electrically neutral group of bonded atoms is termed a molecule.
Atoms will share valence electrons in such a way as to create a noble gas electron configuration (eight electrons in their outermost shell) for each atom.
Atoms that tend to combine in such a way that they each have eight electrons in their valence shell are said to follow the octet rule.
However, some elements like hydrogen and lithium need only two electrons in their outermost shell to attain this stable configuration; these atoms are said to follow the "duet rule", and in this way they are reaching the electron configuration of the noble gas helium, which has two electrons in its outer shell.
Similarly, theories from classical physics can be used to predict many ionic structures.
With more complicated compounds, such as metal complexes, valence bond theory is less applicable and alternative approaches, such as the molecular orbital theory, are generally used.
See diagram on electronic orbitals.
The octet rule is a chemical rule of thumb that states that atoms of low (<20) atomic number tend to combine in such a way that they each have eight electrons in their valence shells, giving them the same electronic configuration as a noble gas.
The rule is applicable to the main-group elements, especially carbon, nitrogen, oxygen, and the halogens, but also to metals such as sodium or magnesium.
The valence electrons can be counted using a Lewis electron dot diagram as shown at the right for carbon dioxide.
The electrons shared by the two atoms in a covalent bond are counted twice.
In carbon dioxide each oxygen shares four electrons with the central carbon, two (shown in red) from the oxygen itself and two (shown in black) from the carbon.
All these four electrons are counted in both the carbon octet and the oxygen octet. 
  Octet (computing), a grouping of eight bits  Octet rule, chemical theory stating that atoms tend to combine so they each have eight valence electrons  Octet stream, alternative name for byte stream  Octet truss, type of space frame  
The noble gases are colorless, odorless, tasteless, and nonflammable under standard conditions.
They were once labeled "group 0" in the periodic table because it was believed they had a valence of zero, meaning their atoms cannot combine with those of other elements to form compounds.
However, it was later discovered some do indeed form compounds, causing this label to fall into disuse.
Like other groups, the members of this family show patterns in its electron configuration, especially the outermost shells resulting in trends in chemical behavior:The noble gases have full valence electron shells.
Valence electrons are the outermost electrons of an atom and are normally the only electrons that participate in chemical bonding.
Atoms with full valence electron shells are extremely stable and therefore do not tend to form chemical bonds and have little tendency to gain or lose electrons.
However, heavier noble gases such as radon are held less firmly together by electromagnetic force than lighter noble gases such as helium, making it easier to remove outer electrons from heavy noble gases. 
Counting electrons.
The total number of electrons represented in a Lewis structure is equal to the sum of the numbers of valence electrons on each individual atom.
Non-valence electrons are not represented in Lewis structures.
Once the total number of available electrons has been determined, electrons must be placed into the structure.
They should be placed initially as lone pairs: one pair of dots for each pair of electrons available.
Lone pairs should initially be placed on outer atoms (other than hydrogen) until each outer atom has "eight" electrons in bonding pairs and lone pairs; extra lone pairs may then be placed on the central atom.
When in doubt, lone pairs should be placed on more electronegative atoms first.
Once all lone pairs are placed, atoms - especially the central atoms - may not have an octet of electrons.
In this case, the atoms must form a double bond; a lone pair of electrons is moved to form a second bond between the two atoms.
As the bonding pair is shared between the two atoms, the atom that originally had the lone pair still has an octet; the other atom now has two more electrons in its valence shell.
Lewis structures for polyatomic ions may be drawn by the same method.
When counting electrons, negative ions should have extra electrons placed in their Lewis structures; positive ions should have fewer electrons than an uncharged molecule.
When the Lewis structure of an ion is written, the entire structure is placed in brackets, and the charge is written as a superscript on the upper right, outside the brackets.
A simpler method has been proposed for constructing Lewis structures eliminating the need for electron counting: the atoms are drawn showing the valence electrons; bonds are then formed by pairing up valence electrons of the atoms involved in the bond-making process; and anions and cations are formed by adding or removing electrons to/from the appropriate atoms.
A trick is to count up valence electrons, then count up the number of electrons needed to complete the octet rule (or with hydrogen just 2 electrons), then take the difference of these two numbers and your answer is the number of electrons that make up the bonds.
The rest of the electrons just go to fill all the other atoms' octets.
Another simple and general procedure to write Lewis structures and resonance forms has been proposed.