I don't honestly think we have that much insight into the code itself, but extrapolating from what we do know:
They're motto is "Honor does not preclude tactics, and glory is not won through foolishness" so I would argue there is no "good" in the strictest sense for the Chevaliers. Rather,
1. They are a military branch that is founded with the express purpose of defending the empire of Orlais. Given their defection with Gaspard, I'm going to go on a limb and assume this is the empire as a political entity itself and not the reigning monarch per se. This, taken with their motto, makes them more utilitarian than anything else - their purpose is to serve the empire of Orlais in whatever way they believe is most beneficial to the empire.
2. I think this would most likely be up to the individual Chevalier - Michel de Chevin obviously believed his word to a commoner superseded his allegiance to his Empress, but I believe there are Chevaliers who would argue the opposite. It would most likely be circumstantial as well - but ceteris paribus, I'd argue saving the reigning monarch would indeed trump saving a town simply because a town has a lesser impact on the empire than the death of the emperor/empress.
3. That's actually an unofficial never really sanctioned ritual the Chevaliers get up to themselves, which is why I think it's better viewed as a twisted hazing ritual than actual Chevalier code. You're obliged to do it because of the people around you, not because of any codified rule. In terms of practicality, if I'm going to be completely heartless - Chevaliers aren't supposed to be sentimental, they're supposed to be weapons of the empire or Orlais and as such willing to give their own lives for it. Killing unarmed elves in alienages may be a way to cement that requisite callousness. Like all hazing rituals, participating in a horrific act together builds strong bonds between the graduating class, which will make them more effective as a composite entity in battle/against enemies. The Chevaliers may also have been involved in the Exalted March upon the Dales, in which case it could be a remnant of that period in their history - when they were enemies of the elves and slaying elves was considered something glorious. I think there's also a lot of indication that the Chevaliers and many Orlesians simply don't view elves as people.
Basically I don't think the Chevaliers were ever supposed to stand on any moral grounds - rather they are bound by Honor and Glory, which is quite simply (1) acting upon your word once you give it & (2) doing cool things that go down in history
All right, we're getting somewhere with my little mental exercise, so let's go in depth.
1. So they are a military order, and if we establish that their "good" is to serve the empire of Orlais, we should look at what that means. Before going to the Winter Palace in Inquisition, we are told that the Chevaliers sided with Gaspard despite having sworn an oath to serve the empress, and their reasons for doing so was because they felt Celene was anti-military and that Gaspard would bring back the glorious expansionist days of Drakon.
So, in this context, their "good" is to build up the country, expand its borders and increase its influence. But given Gaspard in TME and how forthright he is in Inquisition, we should expect that a Chevalier's word is their bond as that is part of the Chevalier code. And their oaths given are tossed aside to support Gaspard, who is also a chevalier, because of the belief in a stronger Orlais.
So, we have a conundrum. We know with Michel and Gaspard that honoring your word once it is given is central to the Chevalier's. But we also know that they are a military order meant to fight for and defend Orlais and swear an oath to the reigning monarch as per Cullen said in Inquisition. Normally one does not take away from the other but it is clear that the Chevalier's as a whole feel it does if they choose Gaspard over Celene.
Pretty much it's a conflict of keeping one's word of honor or acting in the interest of expanding Orlais in strength and power for most of them. And all I can do is wonder why so many Chevalier's felt that conflict.
2. It probably would be up to the individual Chevalier, but as I addressed in point one, the civil war has forced most Chevalier's to choose between two aspects of their duty, and nearly all of them have chosen to turn their backs on the reigning monarch in favor or one who is more pro-military.
I wish the Orlesian Civil War was dug into a lot more than it was, and we had more interactions with the soldiers on both sides. It would add so much more to the complexity of the decision in the Winter Palace and understanding the chevalier code in more depth.
I actually think this ties into question number three.
3. As for the alienage itself. I don't think it's an official rite of passage, but we do have two sources of it, and many more of their abuses, that let me know that it may actually be pretty common place. Loghain mother was raped and murdered by Chevalier in front of him and his father, and this happened to many other women across Ferelden, and even in Orlais as we see from that Orlesian perfume merchant in Denerim in Origins.
Add in that one must be of noble birth before they can even be allowed to train as a Chevalier and Michel only got in because he forged a background, and Orlesian nobles are well known for their consideration of people in general, I feel we can safely say that defending the weak is not part of the Chevalier's code. Otherwise their honor would not allow the abuses that are so rampant. I'm sure not every Chevalier is like that, but enough of them are that it does call into serious question where the line of honor starts and ends in regards to which class of people.
So this brings up the question, tying back into the first one.
3b: If the Chevalier's, as a military order is meant and their "good" is to build up Orlais in strength and power, to whom is it for the benefit of? And whom do they fight for in the service of defending their country? For their country itself, for the honor of Orlais, or for the military might of Orlais and less the people themselves?