Blue bruising is one of the most famous features of psilocybin containing mushrooms. Blue bruising (along with two other features) provides strong evidence that a particular mushroom is an active psilocybin mushroom. The complete 3-part test for identifying an active psilocybin mushroom is as follows:

The mushroom bruises bluish;

The mushroom deposits a purple-brown spore print; and

The mushroom has a semi-gelatinous separable pellicle.

Blue bruising of psilocybe azurescens – note the blue color on the stem and along the edge of the cap
Although the bluing reaction is widely known and discussed, no one has identified the cause of the bluish color. According to Paul Stamets in Psilocybin Mushrooms of the World, “No one, to date, has been able to pinpoint the chemical structure of the bluing compound.“

Stamets contends that the bluish pigmentation is “a result of a phenomenon paralleling the degradation of unstable psilocin (dephosphorylated psilocybin) to presently unknown compounds by enzymes within the mushroom cells. What this means is that when a Psilocybe or Panaeolus bruises bluish, the color reaction is a co-indicator that psilocin is or was present. Naturally, since the bluing phenomenon appears to be a parallel decomposition sequence, the more the mushrooms are bruised the less potent they become.”

Bluing reaction of Psilocybe cyanescens, an active psilocybin mushroom – note the blue color around the edge of the cap.
Other researchers agree that the bluing has little to do with the overall content of psilocin or psilocybin. See References 1, 2, and 3 below. If the blue color arises from the degradation of active molecules, then it provides (at best) an indicator of how potent the mushroom was – before the bruising.
Notably several mushrooms (e.g., some Boletus species) which do not contain any psilocybin or psilocin have a bluing...