Categorical imperative: Kant's cousin idea to the golden rule - can serve as a means towards virtue (both in defining what virtue means to us and in keeping it central enough to us that we can effectively strive for it). Anticategorical imperative: Likewise. How so?
The categorical imperative is a restatement of "What's good for the goose is good for the gander" - "Act as if by your specific action you will the general" means that we should attempt to make our actions uphold our broad notions of the public good, and be compatible with those standards we would hold for everyone. This acts as a wedge against the base instinct towards greed, and its refined form of giving special treatment to oneself or smaller groups (see also Mozi/Mohist thought). Problem with applying this to one's approach - society needs internal regulation that is not easily placed in the framework of laws. Current real-life approach is for there to be some tension between laws (which are vehicles of useful consistency) and real life instincts - there are many instances where someone or a group might strike out at those who harm society's interest while remaining roughly or entirely within the law - this is a necessary parallel to rule of law. Unfortunately, this is not simply distinguishable from criminal-in-the-hurts-society-sense, and in many cases the "wrong people" are making the judgement. As individual actors with our own senses of morality, the best we can do is hope to only take such steps when it is either societally forgivable (even if illegal) or well worth it from our perspective, because we place our neck way out there when we do so.
I imagine the most common examples of this are when fights start - the person in the wrong is not always necessarily the first person to strike a blow. Whether the public good is normally served by legal intervention depends on the conflict and the framework we use to consider the matter, of course. We certainly would find it difficult to approach some notions of the public good in the law - if we imagined, for example, that there are standards of civility and dignity due to everyone, and had specific content for these notions, how could we hope to make these a basis for a system of law? The current legal system is easier to have in place than one that would attempt to judge these matters, even if we might consider the latter to be necessary for deep justice and were willing to take on the requisite burden of making sure those cultural standards laid out were broadly understood/accepted.
The presence of the law and an individual's adherence to it should not be considered sufficient to make that individual a good member of society, nor should they feel "safe" or "proper" in sticking tightly and solely to those legal codes. Cultivation of empathy, civility, solidarity, and intellectual independence, placed together into an appropriately worked out larger system, are foundations for the growth of virtue.