Some secondary school rules are utterly ridiculous, particularly around uniform.
DD's school listened to the children and parents and made big changes to the uniform policy which has directly contributed to improved behaviour, less time spent by teachers on policing arbitrary rules and more time teaching as a result.
The changes, along with clear behaviour codes in class mean that where DD used to come home with stories about most lessons being disrupted, it is only occasional now and usually where the teacher does not stick to the behaviour code.
If kids feel respected, they will give respect back.
@greengreytrue - If your son was only getting detentions for stupid things the I would say ignore them, but as you are working on other behaviour issues, I don't think you can pick and choose - he needs a consistent message.
However, I would talk to the school if any of the rules seem particularly arbitrary and teach your son how to fight for rule changes while obeying the ones that are in place - I got rules at both school and work changed that way.
Ignore the 'rules are rules' brigade - those people would have chastised people like Rosa Parkes, the Suffragettes and Ghandi for 'breaking the rules'.
Arbitrary school rules are not on the same level as segregation or suffrage, but they are a good tool for teaching children how to make change through discussion, compromise and civil disobedience and when each action is appropriate and necessary.