Say the when the person listening can already tell which one you mean. Say a when they cannot yet, and say nothing at all when the thing is not being counted in the first place.
That makes the article a report on somebody else's knowledge rather than a description of the noun. The noun does not change: I bought a car yesterday, and the car is red is one car, equally particular in both halves of the sentence. What changed between the two halves is that the listener now knows which car is being talked about, and the second article says so.
Eight rules, and where they actually bite
The article is chosen by whether the listener can identify the thing, and by the sound of the next word rather than its spelling.
- a bus, an hour, a university. The choice follows the sound: hour begins with a vowel sound and university begins with a y sound.
- the sun, the first, the same. Unique things, ordinals and words meaning identical always take the.
- I play the piano and I play football. Instruments take the article and sports do not, which is arbitrary and learned as a pair.
- she is a doctor. English requires an article before a singular job title, which most European languages do not, and this is the commonest article error Spanish and French speakers make.
- I like music. No article at all for uncountables and plurals meaning things in general, and adding one narrows it to a specific instance.
- the poor, meaning poor people in general. The plus an adjective makes a plural group noun.
- go to school and go to the school. Without the article it means as a pupil; with it, the building. Prison, hospital and church behave the same way.
- a friend of mine, not a my friend. English refuses to stack an article and a possessive, so it uses this construction instead.
The four ways a listener gets to identify something
There are only four, and every correct the in English is one of them. It is physically present, so pass me the salt works at a table and nowhere else. It was mentioned a moment ago, which is the car above. There is only one of it in the situation, which covers the sun, the manager and the kitchen in a house with one kitchen. Or the words after the noun narrow it down, as in the book I lent you, where the identifying is done by the clause rather than by anything shared beforehand.
Run a doubtful sentence past those four. If none of them applies, the listener cannot pick the thing out, and the is wrong however particular the thing is in your own head.
Where it stops: the rule you were taught
Most learners are given the for specific and a for general in the first month, and that rule is right often enough to survive a decade. It handles concrete countable nouns, which is what beginner exercises are made of, and it fails silently everywhere else. Because it keeps working, nothing prompts a learner to replace it, and the stall is not a missing rule but a working one that has quietly stopped covering the ground.
It breaks first on nouns that are not counted. Advice, information, furniture, news and research take no a and no plural, and no meaning predicts which nouns behave this way: advice is uncountable and suggestion is countable, and they are close to the same idea. This is where she gave me an advice and I need the information come from, and both survive for years because both are perfectly clear.
The label that settles half of it
Countability is written down, and almost no learner looks at it. Every entry in the Cambridge Dictionary is marked [C] or [U] for countable or uncountable, sense by sense, which matters because a noun can be one in one meaning and the other in another. It is free and it replaced the printed learner's dictionary, which carried the same labels and was never in the room at the moment you needed it.
Be clear about what that label does not do. It tells you whether a noun can take a at all. It cannot tell you whether the person you are speaking to can identify which one you mean, and that is the question behind almost every wrong the, so the dictionary settles the smaller half and is silent on the larger one.
What it looks like when it goes wrong
The audible failure is a missing article: I went to shop, he is teacher. It is caught quickly, because it sounds incomplete to anyone listening and somebody usually repairs it.
The failure that lasts is the opposite one, a the that should not be there. I like the music said about music in general, or the life is hard, are both understood on the first pass, so nobody stops you, and they place you as a second-language speaker in five words. Institution names run the same way: go to school means attend as a pupil and go to the school means walk to the building, which is a difference of meaning rather than of correctness, and no one will ask you which you meant.
Because nothing corrects them, these belong with the errors that survive years of study, and why they stick, and they behave like the other unstressed words that come attached to something rather than chosen, which is in, on, at, and the ones no rule explains. Both are governed by the rules that decide what a sentence is allowed to mean.
The open question is what to do about an error you cannot hear yourself make. Speech gives nobody time to check four conditions, so the place to repair this is on the page, where the reader has all the time in the world to notice the article that is not there: emails, essays and reports that read like a native wrote them.