Defense-in-Depth Validation

Implements four-layer validation across entry, logic, environment, and instrumentation points.

Updated Sep 16, 2023
One-click install
npx skills add https://github.com/paopp2/dotfiles --skill defense-in-depth-validation-paopp2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Defense-in-Depth Validation
Source: https://github.com/paopp2/dotfiles/tree/main/.claude/skills/debugging/defense-in-depth
Command: npx skills add https://github.com/paopp2/dotfiles --skill defense-in-depth-validation-paopp2

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? This skill prevents recurring bugs by ensuring invalid data is caught at every system layer, making issues structurally impossible rather than just patched.

Core Features & Use Cases:

  • Four-Layer Validation Model: Guides you to implement validation at entry points, business logic, environment guards, and debug instrumentation.
  • Structural Bug Prevention: Ensures that invalid data is caught at multiple stages, making the bug structurally impossible rather than just patched.
  • Comprehensive Example: Illustrates how to apply the pattern to a real-world bug, demonstrating the necessity and effectiveness of each validation layer.

Quick Start: I've fixed a bug caused by invalid data. Use the Defense-in-Depth Validation skill to guide me on where to add multiple layers of validation.

Frequently Asked Questions about Defense-in-Depth Validation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I validate data at multiple layers to prevent bugs?

Validation across multiple layers catches invalid data structurally impossible to miss. Implement checks at entry points (API input), business logic (consistency rules), environment guards (runtime context), and diagnostic instrumentation (logging) to intercept invalid data during ingestion, transformation, and execution.

Why is data validation important at every system layer?

Single-layer validation leaves gaps where invalid data propagates downstream. Defense-in-depth validation ensures bugs are prevented structurally rather than patched reactively by catching errors at entry, logic, environment, and diagnostic stages.

What does the four-layer validation model cover?

Four-layer validation includes entry-point checks (input sanitization), business logic verification (consistency rules), environment guards (context-aware conditions), and diagnostic instrumentation (structured logging). Each layer targets a different ingestion or execution path.

How do I add validation to an existing bug fix?

After fixing a bug caused by invalid data, add validation at all four layers: validate at API entry, add guards in business logic, check environment prerequisites, and instrument diagnostics. This prevents the same bug class from recurring.

Can validation layers work together in a single system?

Yes. Layered validation works synergistically across data ingestion, transformation, and execution paths. Entry validation blocks malformed data, logic validation ensures consistency, environment guards enforce preconditions, and diagnostics reveal where checks fail.