You are correct that if you're a U.S. taxpayer working remotely from another country, it is extremely important to constantly keep an eye on how many days you spend working there.
Additionally, you need to meticulously maintain great records of where you live, your travel dates, and all your foreign income. Why? This evidence is critical for passing the Physical Presence Test or proving you have a solid tax home outside the U.S.
To stay on the right side of the law while ensuring you take advantage of every tax break and avoid being taxed twice, you should absolutely consult a CPA who truly understands expat taxes!