We stay 12 miles off any country that we don't particularly like. Inside that is fine in shipping
lanes or areas where you sail around a point, headland etc, something thats normal and obvious as a route
. If ships go through then you are fine
Coming up the Gulf of Aden we were less than 12 miles off the coast of Yemen. I thought that was pretty stupid as the good guys navy's are not allowed to come and rescue
you inside yemeni waters. I, of course, didn't have a say in it as we were in a convoy. One boat was pulled over by the Yemini Coast Guard - they wanted to board him at night. We took off over into international waters.
Inside 12 miles in the USA I would NOT go unless cleared in. They are sticklers for security
and its just silly not respecting their problems.
If transiting look like you are transiting. Its just not worth trying to explain to some 3rd world idiot who hates whities and can't talk English
why you are sailing between the resort islands and the mainland and you don't want to pay him a bribe.
Apart from all that you don't need to have your yellow flag up unless you are heading into clear in. then we put ours up at the 12 mile limit.