Local government service
During 's ''Linde'' era , Cui Zhiwen became the military advisor to the prefect of Ling Prefecture . At that time, within the boundaries of the prefecture were two nomadic tribes, the Hun and the Huxue , who were submissive to the Tang, but nevertheless were pillaging the residents of the prefecture. As a result, the residents could not spend their time on agriculture, and had to take up riding and archery to defend against Hun and Huxue pillages. Cui proposed that the Hun and the Huxue be moved north of the Yellow River -- a proposal that the Hun and the Huxue were unwilling to agree to, because they did not want to relocate, and the non-Han general Qibi Heli spoke on their behalf, and so Emperor Gaozong initially rejected Cui's proposal. Cui resubmitted the proposal 15 times, and eventually it was approved. When the Hun and the Huxue reached the new location, they found the pastures fertile and appreciated them. On one occasion, when the Huxue chiefs were going to the capital Chang'an to greet Emperor Gaozong, they visited Ling Prefecture and thanked Cui for his proposal, as it in fact benefited the tribes.
At a later time, Cui served as the prefect of Lan Prefecture . On one occasion, Dangxiang forces were attacking Lan Prefecture, and there were few Tang forces within the prefecture capital, causing a great panic. Cui opened up the city gates and acted as if nothing was happening, and this caused the Dangxiang forces to believe that there were troops hidden within, and therefore went past Lan Prefecture. Later, the general Quan Shancai arrived with a relief force and defeated the Dangxiang. Much of the Dangxiang army surrendered, and Quan initially wanted to slaughter them, stopping only after Cui pointed out that it was unfair to slaughter them all and also that this may cause a violent reaction. Quan, thankful for the suggestion, wanted to give 500 of the surrendered households to Cui as personal property, and Cui declined, pointing out that his proposal was for the state's benefit, not personal benefit. Later, because of this, the remaining Dangxiang submitted to Cui.