Write the test before the code, keep changes small, run the full suite on every pull request, and never trust a test that has never failed.
Preventing regressions
Write the test first
If the test does not exist, the feature has no contract. A regression test written before the code is a contract the code cannot break silently.
Keep changes small
A 5,000-line pull request hides the one line that breaks. A 200-line pull request makes it visible.
Run the full suite, not the touched subset
"It only changed one file" is the sentence that precedes every regression discovered in production.
Never trust a test that has never failed
A test that has never failed has never proven it can fail. Break the code on purpose, once, and confirm the test goes red.