The Rules as Written are based on the official rule books: the Dungeon Masters Guide, the Monster Manual, and the Players Handbook. The Starter Set is, as you noted, an incomplete presentation of those core rules, as are the Basic Rules (and the SRD) that are freely available on-line. If there is a conflict between them, the core rules (MM, DMG, PHB) will generally take precedence1.
- A caveat to the above is well summarized in paragraph 3 of this
answer. D&D 5e has tried to move toward "rulings over rules"
since the developers are aware of how (regardless of the amount of
effort put into perfecting a rule set) the play of the game is the
most important aspect of an adventure or a campaign.
To get the most out of a RAW reference, the official errata as posted by WoTC on their web page is directed at the Players Handbook, the Dungeon Masters Guide, and the Monster Manual. Official errata, because it corrects and updates the core rule books, need to be accounted for during a RAW discussion. Any reference to a rule that does not take into account the errata will be incomplete. (And quite possibly wrong). A more recent printing (which usually includes errata from a previous release) will typically take precedence over one lacking that update/correction. (@Sh4dowPlyr, thanks for making that point).
Whether or not the Sage Advice compendium meets "rules as written" isn't as clear, since within Sage Advice WoTC points out the three levels of rules: Rules as Written, Rules as Intended, and Rules as Fun. I've noticed that most folks treat it as within RAW, but some folks on the GITP forums (for example) spell out why they don't.
As a caveat, for Adventure League play it is important to check for that season's rules treatment, since certain published material either is or isn't eligible for AL play. A RAW issue in AL must account for a given season's boundaries and limitations. This may include official published material like Princes of the Apocalypse/Elemental Evil, The Curse of Strahd, Sword Coast Adventure Guide, and other officially published material. Draft rules and play test like "Unearthed Arcana" are admitted by WoTC to not be in finished form and as such are least likely to be acceptable as a basis for RAW.
1 At a given table it is similar to the AL case: it is common to see some optional rules included or not included based on a DM's decision. For example, in my first 5e campaign the Variant Human rules, and Feats, were closed down by the DM for character creation. (No feats until 4th level). That was RAW for us, as were selected spells from the published Elemental Evil material from WoTC. In our second campaign, the optional DMG rules for facing/flanking/being surrounded were included. This was made explicitly clear by the DM in both cases and, being published rules, were there for reference in published material in case questions/conflicts came up.