The UK Statutory Residence Test (SRT), set out in FA2013 Schedule 45, determines whether you're UK tax resident for a given tax year. It works through three stages in order: the automatic overseas tests, the automatic UK tests, and — if neither applies — the sufficient ties test, which weighs your UK day count against ties such as family, accommodation, work, the 90-day tie, and (for those leaving the UK) a country tie.
This free tool lets you log UK days individually, by trip (arrival to departure), or as a straight count; works out which automatic tests apply to you; walks through the sufficient ties test for your situation as a UK arriver or leaver; and gives a preliminary residency indication with a full reasoning trail you can download.