Suppose that my AC is normally 12, and with Mage Armor it is 15. I cast Contingency, with Mage armor as the contingent spell and a trigger of "when I cast a Shield spell". Later, an attacker fires an arrow at me, rolling a 19 to hit, and I cast Shield as a reaction. Does the mage armor take effect at the same time as the shield, causing my AC to become 20 for that attack (and hence causing the attack to miss)? Or does the mage armor only take effect after the attack is finished resolving?
Mage Armor and Shield take effect before the attack
the contingent spell doesn't come into effect. Instead, it takes effect when a certain circumstance occurs. [...] The contingent spell takes effect immediately after the circumstance is met for the first time
The keyword is immediately. Because Shield interrupts the attack and the contingent Mage Armor takes effect immediately after the Shield is cast, then your AC become 20 and the attack will miss.
Therefore, here is what will happen:
- You are attacked
- You cast Shield
- Mage Armor takes effect
- Shield takes effect
- Attack resolves