The hostile reaction last year of unions, local authorities and opposition parties to the public demolition by HMI of Musselburgh Grammar led on Wednesday to a significant Scottish Executive climbdown during the latest committee stage of the education Bill.
The legislation already recommends a code of practice for inspections of local authorities but ministers were forced to accept a similar arrangement for schools after an all-party ambush, the first major concession in the Bill.
Nicola Sturgeon, SNP shadow education minister, said: "There is consistent concern about the way HMI operate and this will lead to a healing of the relationship between HMI and the teaching profession."
The EducationalInstitute of Scotland last Christmas launched a stinging criticism of the Inspectorate, emphasising a breakdown in trust between inspectors and teachers, a claim subsequently disputed by Douglas Osler, HM senior chief inspector.
Karen Gillon, Labour's vice-convener of the education, culture and sport committee, said ministers had spoken of openness and transparency but "the one group that is not open and transparent is HMI". She insisted: "If there is a code of practice for (inspecting) education authorities, there should be a code of practice for schools."
Brian Monteith, the Conservative spokesman, said: "If HMI is to operate in a way that commands the confidence of the teaching profession and the public, then there is nothing to fear from a code of practice."
Peter Peacock, Deputy Children and Education Minister, said the code should help erase misconceptions about HMI's role.