We investigate the formation of hydrogen cyanide (HCN) in the inner circumstellar envelopes of thermally pulsing asymptotic giant branch (TP-AGB) stars. A dynamic model for periodically shocked atmospheres, which includes an extended chemo-kinetic network, is for the first time coupled to detailed evolutionary tracks for the TP-AGB phase computed with the COLIBRI code. We carried out a calibration of the main shock parameters (the shock formation radius and the effective adiabatic index) using the circumstellar HCN abundances recently measured for a populous sample of pulsating TP-AGB stars. Our models recover the range of the observed HCN concentrations as a function of the mass-loss rates, and successfully reproduce the systematic increase of HCN moving along the M-S-C chemical sequence of TP-AGB stars, that traces the increase of the surface C/O ratio. The chemical calibration brings along two important implications: i) the first shock should emerge very close to the photosphere, and ii) shocks are expected to have a dominant isothermal character in the denser region close to the star (within ~ 3-4 R), implying that radiative processes should be quite efficient. Our analysis also suggests that the HCN concentrations in the inner circumstellar envelopes are critically affected by the H-H2 chemistry during the post-shock relaxation stages.