Shared with you
This episode begins with an 'awake' Clara beginning her day, only she's actually imprisoned inside of a Zygon pod. This is very similar to the first time the Doctor met Clara (Oswin) in Asylum of the Daleks (2012); she was encased within a Dalek body, but, her mind believed she was in a crashed spaceship, baking soufflés.
Kate describes how she escaped from a Zygon by saying "Five rounds, rapid." This phrase was first used by her (Doctor Who-universe) father, The Brigadier, in The Dæmons: Episode Five (1971) and the name of the actor's memoir: "Five Rounds Rapid! The Autobiography of Nicholas Courtney - Doctor Who's Brigadier."
In the original script, Kate learned of a missing police officer named Bonnie Carter, who was identical in appearance to Clara and had departed with the Zygons. The first death amongst the Zygon community in Truth or Consequences was called Clyde Orson, and was a duplicate of Danny Pink. The Doctor and Osgood used the TARDIS to travel to the past and follow the Zygons as they resettled in New Mexico. They learned that the Zygon leaders, the schoolgirls Claudette and Jemima, had executed Clyde Orson because the death of Danny Pink had caused him to believe himself to actually be the original human; this was their attempt to preserve the peace treaty. However, when Bonnie was called to investigate the murder, it exacerbated the tension she was already sensing between the Americans and the "British" expatriates, leading to her radicalisation. In the present day, three Doctors were active simultaneously, two of them being Zygon allies, while Kate was rescued from Truth or Consequences by American marines. The United Kingdom was being isolated by the international community as it became increasingly dominated by the Zygons; scenes would have depicted politicians and even the cast of EastEnders (1985) engaged in replacing authentic humans with Zygon duplicates. However, the Doctor discovered that the splinter Zygons were being manipulated by a human cabal who intended to wipe them out and take over Great Britain. He brought a recalcitrant Bonnie and the United Nations Security Council together to forge a lasting peace treaty. Bonnie then sacrificed her physical form, allowing Clara to take control of it as her real body succumbed to its injuries.
Osgood has now worn the 12th Doctor's sonic sunglasses, continuing her tradition of wearing items from the various Doctors.
According to Peter Harness, the Doctor's de-escalation speech originally included several additional sections. These were cut out of the final draft of the script, mostly for pacing reasons. One of the sections included the Doctor asking Bonnie about whether everyone will be forced to grow and eat beetroot. During a convention appearance in New Zealand a few weeks after the episode aired, Peter Capaldi performed a version of the complete speech.
UNIT's Black Archive, first seen in The Day of the Doctor (2013) and containing items from several past episodes, currently has a Mire battle helmet first seen in The Girl Who Died (2015).