This is the "fix the bug once, then make it structurally impossible" pattern. Instead of adding validation at just the entry point, you add checks at every layer data flows through: API boundaries, business logic, environment guards, and debug instrumentation. The original example is pretty telling: a test passed an empty project directory that caused git init to run in the source code directory. One validation check would have caught that instance, but four layers made it impossible through any code path, including mocks and refactorings. The insight is that each layer catches different failure modes that the others miss. It's more work upfront but you're trading a few extra conditionals for entire categories of bugs that can't happen.
npx skills add https://github.com/secondsky/claude-skills --skill defense-in-depth-validation