  We study the cosmic microwave background (CMB) in the framework of the
degenerate higher-order scalar-tensor (DHOST) theory to test gravity theories.
This theoretical framework includes the wide class of dark energy models such
as the Horndeski theory and its extensions as certain limits, and the general
relativity can be also recovered. In this study, to test gravity theories with
CMB, we formulate the linear perturbations of gravity and matter in the theory
and their effective description parameterised by time-dependent effective field
theory (EFT) parameters, $\alpha_i$ $(i=B,K,T,M,H,L)$ and $\beta_i$
$(i=1,2,3)$. Based on the resultant DHOST framework, we develop a numerical
code to solve Boltzmann equations consistently. We then show that the angular
power spectra of the CMB temperature anisotropies, E-mode and lensing potential
as a demonstration and find that the parameter characterising the DHOST theory,
$\beta_1$, provides the larger modifications of the spectra, compared with
other EFT parameters. We also show the results in the case of a specific model
in which the cosmic expansion as well as the EFT parameters are consistently
determined.
