Start at the wall, not the shelf. Pull the old thermostat off its base and photograph the wires before you touch anything. That photo is the record you will compare against every new model you consider.
Read the terminal letters
Each wire lands on a lettered terminal. R carries the low voltage from the equipment. C is the common wire. W, Y, and G call for heat, cooling, and fan. O or B switches the reversing valve on a heat pump. An auxiliary or emergency terminal, often labeled AUX or E, calls the backup heat. Match each wire on the old base to its letter, then confirm the new model has a terminal for every letter you use.
Check the common wire
Many thermostats with screens and Wi-Fi need a common wire to run without batteries. If your wall has no C wire, look at the new model's power options before you buy. Some models draw power another way. Others need a trade to run a new cable. Ask which option applies to your wall, and write the answer down.
Match the stage count to the equipment
Stage count is how many heating and cooling steps the thermostat controls. The equipment label or installation sheet lists the stages. A heat pump with backup heat needs a thermostat that can run the reversing valve and the backup heat through their own terminals. A gas furnace or boiler with a plain heat call and a cooling call needs a simpler setup. Do not assume that a model that fits the wall also fits the equipment.
Compare the terminal map
Each thermostat maker publishes a terminal map and a compatibility list. Lay that list beside your photo. Mark every wire that has a match, then mark every wire that has no match. A wire with no match is a question for the installer, not a reason to force a connection.
Questions to ask before you buy
Ask whether the model supports your heat source type, your stage count, and the backup heat setting you use. Ask whether a C wire is required, and if it is not, how the model powers itself. Ask whether the model needs a configuration step after installation. Write each answer next to the model name so you can compare the answers across the models you consider.
Before any wire moves
Turn the power off at the breaker before you loosen any terminal. If you are unsure which breaker feeds the furnace or air handler, leave the work to a licensed trade. If the thermostat change is also a sign that the heat source is near the end of its planning window, the heat pump page on this site lists typical service life and planning notes: Heat Pump: typical service life and when to plan.