defense-in-depth

Validate data across four execution layers to prevent invalid input bugs.

Updated Nov 3, 2025
One-click install
npx skills add https://github.com/ayourtch/kimichat --skill defense-in-depth-ayourtch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: defense-in-depth
Source: https://github.com/ayourtch/kimichat/tree/main/skills/defense-in-depth
Command: npx skills add https://github.com/ayourtch/kimichat --skill defense-in-depth-ayourtch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents bugs caused by invalid data by implementing validation at every layer data passes through, making the bug structurally impossible to reproduce.

Core Features & Use Cases

  • Four Layers of Validation: Guides adding checks at entry point, business logic, environment guards, and debug instrumentation.
  • Structural Bug Prevention: Ensures that even if one validation is bypassed, other layers catch the invalid data.
  • Comprehensive Protection: Catches different types of issues (obvious input errors, business rule violations, dangerous context-specific operations).
  • Use Case: After fixing a bug where an empty projectDir caused git init in the source code, use this skill to add validation at the Project.create() entry, WorkspaceManager business logic, and WorktreeManager environment guard layers.

Quick Start

I'm using the defense-in-depth skill to add robust validation for the file_path parameter in the file-upload service.

Frequently Asked Questions about defense-in-depth

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

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

Multi-layer validation catches invalid data at entry points, business logic, environment guards, and debug instrumentation. This structural approach makes bugs impossible to reproduce even if one validation layer is bypassed, ensuring data integrity across your entire system architecture.

What are the four layers of validation in a multi-layer architecture?

The four validation layers are: entry validation at API or function boundaries, business logic checks enforcing domain rules, environment guards preventing context-specific violations, and debug instrumentation for tracing data flow. Each layer independently validates before passing data forward.

When should I add validation to API input handling?

Add validation immediately at API entry points to reject invalid input before it reaches business logic. Combined with validation at business logic and environment guard layers, this prevents empty parameters, malformed requests, and dangerous operations from propagating through your system.

Can I use defense-in-depth validation for project initialization and workspace setup?

Yes. Apply the four-layer validation pattern to initialization workflows: validate configuration at entry, enforce workspace rules in initialization logic, add environment guards for workspace context, and instrument data flow tracing. This prevents initialization bugs like invalid project directories.

What happens if one validation layer fails in a defense-in-depth system?

In defense-in-depth architecture, failing one validation layer does not expose invalid data because other layers provide independent checks. Consistent error reporting and data-flow tracing across all layers ensure bugs surface immediately with clear context, making root causes traceable.