In conventional wellbore-integrity analysis, the cement sheath’s initial state of stress and transient thermoporoelastic effects are often neglected. However, the initial state of stress is prerequisite information for accurately predicting the safe operating conditions that prevent a cemented well from being damaged. In addition, transient thermoporoelastic effects can have a profound effect on when damage will occur. In this paper, we propose a model that includes these effects to predict the safe operating pressures and temperatures that will prevent cement-sheath failure. For the initial state of stress, we proposed an empirical model using measurements. Subsequent stress changes are evaluated by a fully coupled transient thermoporoelastic model to analyze the mechanical behavior of the cement sheath. We predict the safe operating envelope (SOE) for shear, tensile, and debonding cement-sheath failures caused by pressure and temperature perturbations after the cement sets. Our model predicts that pore pressure is a key factor for cement failure, especially for rapid temperature changes. If the formation is low permeability, the transient pore pressures are amplified, causing the risk of damage to increase. Compared with conventional thermoelastic models, the thermoporoelastic model predicts a smaller SOE when heating the internal casing fluid and a larger envelope when cooling the internal casing fluid. Finally, the heating rate was considered with respect to field applications. The heating rate was also considered, and slower heating/cooling rates can prevent damage to the cement sheath. Finally, the thermoporoelastic model was applied to explain several laboratory and field experiments and achieved good matches.