Derdziński and Shen's theorem on the restrictions on the Riemann tensor imposed by existence of a Codazzi tensor holds more generally when a Riemann compatible tensor exists. Several properties are shown to remain valid in this broader setting. Riemann compatibility is equivalent to the Bianchi identity for a new "Codazzi deviation tensor", with a geometric significance. The above general properties are studied, with their implications on Pontryagin forms. Examples are given of manifolds with Riemann compatible tensors, in particular those generated by geodesic mappings. Compatibility is extended to generalized curvature tensors, with an application to Weyl's tensor and general relativity.