Both directions, or neither. The validity rule is stricter than it looks. A clause that blocks creditors but leaves the beneficiary free to assign their interest is not a partly effective spendthrift provision; it is not one at all, because the statute conditions validity on restraining both voluntary and involuntary transfer. The logic is that a beneficiary who can sell their interest can defeat the restraint themselves, so the restraint has to bind both the beneficiary and the people pursuing them.
The protection stops at the moment of receipt, and that is where most misunderstandings live. The operative sentence says a creditor or assignee of the beneficiary "may not reach the interest or a distribution by the trustee before its receipt by the beneficiary." Before receipt, the beneficiary's interest is not an asset a judgment creditor can seize and not a right the beneficiary can pledge. After receipt it is money like any other, subject to garnishment, levy and everything else. A trust paying a fixed monthly amount therefore protects the stream and not the payments, which is one reason discretionary distribution standards are so common in trusts drafted for a beneficiary with real exposure: what the trustee has no obligation to distribute is harder for a creditor to anticipate than a fixed entitlement.
The exception creditors, and why no national list belongs on this page. A state that has enacted the uniform trust code either carries, or omits, a section listing the claimants a spendthrift provision cannot be enforced against, and a state that has not enacted it answers the question its own way. The variation is not theoretical: Montana enacted the validity section and the settlor's-creditors section and left the exceptions section, 72-38-503, as "reserved." Nebraska did enact it. Its section 30-3848, which the state's own code annotates as the uniform section, provides that "a spendthrift provision is unenforceable against: (1) a beneficiary's child, spouse, or former spouse who has a judgment or court order against the beneficiary for support or maintenance; (2) a judgment creditor who has provided services for the protection of a beneficiary's interest in the trust; and (3) a claim of this state or the United States to the extent a statute of this state or federal law so provides." That is Nebraska's list. It is a fair guide to the shape of the question and it is not authority anywhere else, and the honest answer for any particular trust is the statute of the state whose law governs it.
It does nothing for the person who set the trust up. This is the load-bearing consumer point and it is the opposite of what the phrase suggests to most people. Montana's section 72-38-505(1), which most enacting states mirror, opens "whether or not the terms of a trust contain a spendthrift provision" and then provides that "during the lifetime of the settlor, the property of a revocable trust is subject to claims of the settlor's creditors," and that "with respect to an irrevocable trust, a creditor or assignee of the settlor may reach the maximum amount that can be distributed to or for the settlor's benefit." The opening words are doing the work: the settlor's creditors are not affected by the clause. A spendthrift provision is a tool for protecting somebody else, and a settlor who keeps the ability to benefit from the trust keeps the exposure that goes with it. Some states have legislated around that default for trusts a settlor creates for their own benefit, on conditions of their own. Section 166.040 of Nevada's Spendthrift Trust Act permits a spendthrift trust for the benefit of the settlor, but only where the writing "is irrevocable, does not require that any part of the income or principal of the trust be distributed to the settlor, and was not intended to hinder, delay or defraud known creditors." That is a different instrument with its own rules, and it is not what this page describes.
What it is genuinely good for. A beneficiary who cannot manage money, or who is in an occupation or a life stage that attracts claims. A beneficiary with a substance problem or a gambling problem, where the point is to prevent a lump sum being pledged away in advance. A young adult who would otherwise take an outright inheritance. A beneficiary receiving means-tested public benefits, where the design question is broader than the clause and belongs with the material on special needs trusts. In each case the clause is one line in a trust whose distribution standard, trustee choice and duration are doing most of the work.