defense-in-depth

Enforce multi-layer validation across API boundaries, services, and test environments.

4|Updated Dec 7, 2020
One-click install
npx skills add https://github.com/charly3pins/dotfiles --skill defense-in-depth-charly3pins
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: defense-in-depth
Source: https://github.com/charly3pins/dotfiles/tree/main/.config/opencode/skills/defense-in-depth
Command: npx skills add https://github.com/charly3pins/dotfiles --skill defense-in-depth-charly3pins

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Fixing bugs caused by invalid data at a single point is often insufficient, as other code paths or future refactors can bypass the check, leading to recurring issues and system fragility.

Core Features & Use Cases

  • Four-Layer Validation: Enforces checks at entry point, business logic, environment guards, and debug instrumentation.
  • Structural Bug Prevention: Makes bugs impossible by validating data at every layer it passes through, ensuring data integrity.
  • Comprehensive Application: Guides tracing data flow, mapping checkpoints, and adding validation at each layer of the system.
  • Use Case: When a bug caused by invalid data reappears despite a previous fix, use this skill to implement robust, multi-layered validation, ensuring the bug cannot be reproduced and the system remains stable.

Quick Start

I found a bug caused by invalid data. Guide me through applying defense-in-depth validation at every layer of the system.

Frequently Asked Questions about defense-in-depth

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

FAQPage Schema
How do I prevent bugs caused by invalid data from recurring in my system?

Defense-in-depth validation prevents invalid data bugs by enforcing checks at multiple layers—entry point, business logic, environment guards, and debug instrumentation—so no code path can bypass protection. This makes bugs structurally impossible rather than fixing them at a single point.

What layers should I validate data across in my application?

Validate data at four layers: entry validation at API boundaries, business logic validation within services, environment guards for runtime context, and debug instrumentation for tracing. Mapping all checkpoints ensures comprehensive coverage across every path data travels.

How do I trace data flow to identify validation gaps?

Trace how data moves through your system—from entry points through business logic to storage and output—and map where validation currently exists. Identifying gaps reveals which layers lack checks, allowing you to insert validation strategically to close every bypass route.

When should I apply multi-layered validation instead of a single fix?

Use multi-layered validation when bugs caused by invalid data reappear despite previous fixes or when refactoring introduces new bypass paths. Single-point checks are fragile; layered validation ensures data integrity remains enforced as code evolves.

Can I apply defense-in-depth validation across microservices?

Yes. Enforce validation at service boundaries, within each service's business logic, and at environment entry points. This approach works across distributed systems, ensuring invalid data cannot bypass protection at API boundaries or between services.

What's the difference between entry validation and business logic validation?

Entry validation filters malformed or out-of-range input at API boundaries; business logic validation enforces domain rules and data consistency within services. Both are necessary—entry validation catches external threats, business logic validation catches internal state violations.