(In criminal law, "justice delayed is justice denied" and clarifications of constitutional or treaty requirements for speedy trials also can be tidied up by the legislature in a statute of limitations).
Statute (legislation) is a superior source of law to contract law, and so there is generally no way to contract to avoid being statute barred if a claim for breach of contract (or specific performance, etc.) is made beyond the statutory deadline.
Typically there are carve outs enacted in a statute of limitations that allow a claim to be brought out-of-time if the defendant has acted in a dishonest way that prevented a claim from being filed in time, for certain classes of litigant, or for certain types of claim. (And in criminal law, for certain offences - serious crimes will tend to have a longer, or no, limit on how long after the crime the prosecution is begun).
A statute of limitations typically does not extinguish defences based on the lapse of too much time; but such defences in some jurisdictions may be contracted away, leaving the statutory limit as the hard deadline.