I searched in vain for a command that would purge all unused constraints in an assembly. Because in an assembly that I used to test a lot of things, I have a lot of light gray constraints in my creation tree. Some because I deleted the component or they are in the deleted state.
In short, it's a bit of a jungle and I would have liked to clean up all at once. But I haven't seen such an order in SW
Look at HERE, there is a macro that allows you to list the constraints from which 1 reference is removed, all that remains is to add the delete function.