secondsky avatar

Defense In Depth Validation

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.

skills.sh installs
430
GitHub stars
248
last updated
Aug 21, 2026

Install

$ npx -y skills add secondsky/claude-skills --skill defense-in-depth-validation --agent claude-code

Installs into .claude/skills of the current project.

Files

Defense-in-Depth Validation

Overview

When you fix a bug caused by invalid data, adding validation at one place feels sufficient. But that single check can be bypassed by different code paths, refactoring, or mocks.

Core principle: Validate at EVERY layer data passes through. Make the bug structurally impossible.

Why Multiple Layers

Single validation: "We fixed the bug" Multiple layers: "We made the bug impossible"

Different layers catch different cases:

  • Entry validation catches most bugs
  • Business logic catches edge cases
  • Environment guards prevent context-specific dangers
  • Debug logging helps when other layers fail

The Four Layers

Layer 1: Entry Point Validation

Purpose: Reject obviously invalid input at API boundary

Sponsors

Details

Repository
github.com/secondsky/claude-skills
First seen
Jun 3, 2026

More from secondsky/claude-skills

All 146

Recommended

1juliusbrussee avatarcavemanjuliusbrussee/cavemanUltra-compressed communication mode. Cuts output tokens 65% (measured) by speaking like caveman while keeping full technical accuracy. Supports intensity levels618.3Kskills.sh installs
2mattpocock avatargrill-memattpocock/skillsA relentless interview to sharpen a plan or design.1.5Mskills.sh installs
3shadcn avatarimproveshadcn/improveSurvey any codebase as a senior advisor and produce prioritized, self-contained implementation plans for OTHER models/agents to execute. Strictly read-only on s40Kskills.sh installs
4obra avatarsystematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes326.7Kskills.sh installs
5forrestchang avatarkarpathy-guidelinesforrestchang/andrej-karpathy-skillsBehavioral guidelines to reduce common LLM coding mistakes through explicit assumptions, simplicity, and verifiable success criteria.17.9Kskills.sh installs
6vercel-labs avatarfind-skillsvercel-labs/skillsHelps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express int4.3Mskills.sh installs