All of the "thus says the Lord" passages in Exodus have so far articulated God's care for Israel and Egypt, and it's important to keep that in mind when considering its occurrence in the final Exodus passage. Exodus 32:27 says, "And he said to them, 'Thus says the LORD God of Israel: "Let every man put his sword on his side, and go in and out from entrance to entrance throughout the camp, and let every man kill his brother, every man his companion, and every man his neighbor"'" (NKJV).
I'm just going to acknowledge it: this is a dark passage. However, its darkness is not found in a death sentence, but in its plethora of damaged and broken relationships. Exodus 32 is the famous "golden calf" chapter, which describes how Israel got tired (or maybe scared?) of waiting for Moses to descend Mount Sinai, and instead asked Aaron to make a golden image for them to follow. This whole chapter, in fact, is a nightmarish repetition of Genesis 3: the people seem to pressure Aaron to abandon his relationship with his brother Moses (verse 1); everyone seems to fight with each other about who they're worshiping (verses 4-5); God seems to feel betrayed by Israel (verses 7-10); and Moses seems to feel betrayed by God, Israel, and his brother Aaron at different times (verses 11-26). But with all this hurt and betrayal, why would death be the best way for God to address and even heal these wounds?
The clue is in verse 25. When it says Moses saw that the people were "unrestrained" in Exodus 32:25, the Hebrew word used there is "phara" - which means "loose," but sounds like "pharaoh." For Moses, the people are acting like Pharaoh, who was unrestrained in ignoring, hating, and actively fighting against God. Consequently, Exodus 32:27 is not about God angrily ordering peoples' deaths, but about God making very clear to Israel that their interpersonal relationships have been destroyed and that death might be the only reprieve for people who hate God as much as Pharaoh did.
Friends, God doesn't want a relationship with you like Pharaoh, he wants you to enjoy being loved by him - because "thus says the Lord."