Previous research on achieving the alignment of compression gratings has mainly focused on the parallelism of the gratings. We propose a promising method to achieve parallelism and especially accurately adjust the grating to its optimum working angle to achieve dispersion compensation. A spectrometer and a precisely adjustable mirror pair are cooperatively used to measure the wavelength of the light diffracted by the grating, satisfying the Littrow condition. Meanwhile, the tiny slit of the spectrometer can decrease the grating-tip and in-plane rotation error during the alignment procedure. Using this technique, the residual phase of the compressed pulse is optimized and the compressed pulse duration is 25.4 fs, which is 1.06 times that of the Fourier-transform-limited compressed pulse.