Agent skill

Defense In Depth Validation

by secondsky in secondsky/claude-skills

Validate at every layer data passes through to make bugs impossible.

MITAuto-check passedSecurity

Install Defense In Depth Validation

skills CLI
$ npx skills add secondsky/claude-skills --skill defense-in-depth-validation -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install secondsky/claude-skills defense-in-depth-validation --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/secondsky/claude-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/defense-in-depth-validation/skills/defense-in-depth-validation .claude/skills/defense-in-depth-validation && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
defense-in-depth-validation
GitHub stars
227
Token cost
~1.3k tokens
SKILL.md length
447 words
Files
1
Skills in repo
169
Repo updated
First seen
Licence
MIT

At a glance

Validate at every layer data passes through to make bugs impossible.

  • Works in 4 steps: Trace the data flow - Where does bad… → Map all checkpoints - List every point… → Add validation at each layer - Entry,… → …
  • Invalid data causes failures deep in execution
  • SKILL.md covers Overview, Why Multiple Layers, The Four Layers and Applying the Pattern, plus 3 more sections
  • Calls git

What it does

Defense In Depth Validation is an agent skill from secondsky/claude-skills. Validate at every layer data passes through to make bugs impossible. Use when invalid data causes failures deep in execution, requiring validation at multiple system layers.

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Security, covering Secure coding. It works with Git. The repository describes itself as: Production-ready skills for Claude Code CLI - Cloudflare, React, Tailwind v4, and AI integrations. The licence is MIT.

When your agent uses it

  • Invalid data causes failures deep in execution
  • Requiring validation at multiple system layers

Example prompts

  • “/defense-in-depth-validation”

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Trace the data flow - Where does bad value originate? Where used?
  2. Map all checkpoints - List every point data passes through
  3. Add validation at each layer - Entry, business, environment, debug
  4. Test each layer - Try to bypass layer 1, verify layer 2 catches it

What it can do on your machine

Read from SKILL.md and the folder at commit 8837836. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Defense In Depth Validation loads about 1.3k tokens when it runs. Until then it costs about 50 tokens; SKILL.md has 447 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~50
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from secondsky/claude-skills at commit 8837836, republished under its MIT licence (© secondsky). 447 words, ~1,329 tokens.

Download SKILL.mdSave it as .claude/skills/defense-in-depth-validation/SKILL.md (or your agent's skills folder).
name
defense-in-depth-validation
description
Validate at every layer data passes through to make bugs impossible. Use when invalid data causes failures deep in execution, requiring validation at multiple system layers.
metadata.version
1.1.0
license
MIT

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

typescript
function createProject(name: string, workingDirectory: string) {
  if (!workingDirectory || workingDirectory.trim() === '') {
    throw new Error('workingDirectory cannot be empty');
  }
  if (!existsSync(workingDirectory)) {
    throw new Error(`workingDirectory does not exist: ${workingDirectory}`);
  }
  if (!statSync(workingDirectory).isDirectory()) {
    throw new Error(`workingDirectory is not a directory: ${workingDirectory}`);
  }
  // ... proceed
}
Layer 2: Business Logic Validation

Purpose: Ensure data makes sense for this operation

typescript
function initializeWorkspace(projectDir: string, sessionId: string) {
  if (!projectDir) {
    throw new Error('projectDir required for workspace initialization');
  }
  // ... proceed
}
Layer 3: Environment Guards

Purpose: Prevent dangerous operations in specific contexts

typescript
async function gitInit(directory: string) {
  // In tests, refuse git init outside temp directories
  if (process.env.NODE_ENV === 'test') {
    const normalized = normalize(resolve(directory));
    const tmpDir = normalize(resolve(tmpdir()));

    if (!normalized.startsWith(tmpDir)) {
      throw new Error(
        `Refusing git init outside temp dir during tests: ${directory}`
      );
    }
  }
  // ... proceed
}
Layer 4: Debug Instrumentation

Purpose: Capture context for forensics

typescript
async function gitInit(directory: string) {
  const stack = new Error().stack;
  logger.debug('About to git init', {
    directory,
    cwd: process.cwd(),
    stack,
  });
  // ... proceed
}

Applying the Pattern

When you find a bug:

  1. Trace the data flow - Where does bad value originate? Where used?
  2. Map all checkpoints - List every point data passes through
  3. Add validation at each layer - Entry, business, environment, debug
  4. Test each layer - Try to bypass layer 1, verify layer 2 catches it

Example from Session

Bug: Empty projectDir caused git init in source code

Data flow:

  1. Test setup → empty string
  2. Project.create(name, '')
  3. WorkspaceManager.createWorkspace('')
  4. git init runs in process.cwd()

Four layers added:

  • Layer 1: Project.create() validates not empty/exists/writable
  • Layer 2: WorkspaceManager validates projectDir not empty
  • Layer 3: WorktreeManager refuses git init outside tmpdir in tests
  • Layer 4: Stack trace logging before git init

Result: All 1847 tests passed, bug impossible to reproduce

Show full SKILL.md (182 more words)Show less

Key Insight

All four layers were necessary. During testing, each layer caught bugs the others missed:

  • Different code paths bypassed entry validation
  • Mocks bypassed business logic checks
  • Edge cases on different platforms needed environment guards
  • Debug logging identified structural misuse

Don't stop at one validation point. Add checks at every layer.

Security defense-in-depth

The same layered approach is the standard pattern for security controls: trust is never granted at a single point, so that a bug or bypass in any one layer cannot by itself compromise the system. Each request is checked independently at the edge, in the handler, and at the data layer.

  • Layer 1 (edge): rate-limit and filter at the edge (CDN/WAF such as Cloudflare or AWS WAF) so abusive traffic never reaches the origin.
  • Layer 2 (handler): re-derive authorization server-side from the session — never trust a client-supplied claim like a userId in the body.
  • Layer 3 (data): enforce the ownership invariant in the database query so that even a handler bug cannot cross tenant boundaries.
javascript
// Layer 2 — re-derive authz server-side, never trust client claims
app.put('/docs/:id', async (req, res) => {
  const user = await verifySession(req.cookies.session); // throws if invalid
  // Layer 3 — DB clause re-checks ownership; a handler bug still can't cross tenants
  const updated = await db.query(
    'UPDATE docs SET title = $1 WHERE id = $2 AND owner_id = $3 RETURNING *',
    [req.body.title, req.params.id, user.id]
  );
  if (!updated.rowCount) return res.status(403).send('Not allowed');
  res.json(updated.rows[0]);
});

Defense in depth means no single layer's failure is sufficient to compromise the system.

© secondsky, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/defense-in-depth-validation/skills/defense-in-depth-validation of secondsky/claude-skills.

Open the folder on GitHubat commit 8837836

Compare with similar skills

Defense In Depth Validation next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Defense In Depth Validation compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Defense In Depth Validation this skillsecondsky/claude-skills227—~1.3kAutomated safety check: PassMIT
Defense In Depthsandgardenhq/sgai1373 repos~970Automated safety check: PassCustom licence
Thorough Code Reviewpretend1111/claude-desktop-app4941 repos~502Automated safety check: PassCustom licence
Security AuditTheDecipherist/claude-code-mastery550—~1.3kAutomated safety check: NotesMIT
Humble Header Report Analystrfc-st/humble379—~3.7kAutomated safety check: PassMIT
Pre-Commit Security Scanzereight/gitlab-mcp2k1 repos~859Automated safety check: NotesMIT

Similar skills

  • Defense In Depth

    sandgardenhq/sgai

    A skill your agent uses when invalid data causes failures deep in execution, requiring validation at multiple system layers - validates at every layer data passes through to make bugs structurally…

    137 GitHub starsUsed in 3 repos~970 tokens
    SecurityAuto-check passed
  • Thorough Code Review

    pretend1111/claude-desktop-app

    Reviews code or recent changes for bugs, security issues, performance problems and maintainability, reporting findings by severity with the reason and a fix.

    494 GitHub starsUsed in 1 repo~502 tokens
    DevelopmentAuto-check passed
  • Security Audit

    TheDecipherist/claude-code-mastery

    Checks a codebase for hardcoded secrets, vulnerable dependencies, weak input handling, weak authentication and unsafe transport settings before deployment or merge.

    550 GitHub stars~1.3k tokensUpdated 5 mo ago
    SecurityAuto-check: notes
  • Parses reports from the humble HTTP security header analyzer and explains each finding with remediation steps for DevOps teams.

    379 GitHub stars~3.7k tokensUpdated today
    SecurityAuto-check passed
  • Pre-Commit Security Scan

    zereight/gitlab-mcp

    Runs a fast security sweep of recent code changes before a commit or PR, checking for leaked secrets, vulnerable dependencies, unsafe input handling and auth gaps.

    2k GitHub starsUsed in 1 repo~859 tokens
    SecurityAuto-check: notes
  • Checks each shell command for destructive patterns such as recursive deletes, force pushes and dropped tables, and asks before letting them run.

    136k GitHub stars~931 tokensUpdated today
    SecurityAuto-check: notes

More from secondsky/claude-skills

All 169 skills in this repo
  • Tanstack AI

    secondsky/claude-skills

    TanStack AI (alpha) provider-agnostic type-safe chat with streaming for OpenAI, Anthropic, Gemini, Ollama.

    227 GitHub starsUsed in 1 repo~3.6k tokens
    Auto-check: notes
  • Auto Animate

    secondsky/claude-skills

    AutoAnimate (@formkit/auto-animate) zero-config animations for React.

    227 GitHub stars~2.9k tokensUpdated 10 days ago
    Auto-check passed
  • Base UI React

    secondsky/claude-skills

    MUI Base UI unstyled React components with Floating UI. An agent skill from secondsky/claude-skills.

    227 GitHub stars~1.9k tokensUpdated 10 days ago
    Auto-check passed
  • Cloudflare Images

    secondsky/claude-skills

    This skill should be used when the user asks to "upload images to Cloudflare", "implement direct creator upload", "configure image transformations", "optimize WebP/AVIF", "create image variants"…

    227 GitHub stars~3.6k tokensUpdated 10 days ago
    Auto-check: notes
  • Cloudflare Nextjs

    secondsky/claude-skills

    Deploy Next.js to Cloudflare Workers via the OpenNext adapter (@opennextjs/cloudflare).

    227 GitHub stars~5.3k tokensUpdated 10 days ago
    Auto-check: notes
  • Cloudflare Sandbox

    secondsky/claude-skills

    Cloudflare Sandboxes SDK for secure code execution in Linux containers at edge.

    227 GitHub stars~4.5k tokensUpdated 10 days ago
    Auto-check passed

Works with

Categories

Questions about Defense In Depth Validation

What does Defense In Depth Validation do?

Validate at every layer data passes through to make bugs impossible. Defense In Depth Validation is an agent skill from secondsky/claude-skills. Validate at every layer data passes through to make bugs impossible.

When should I use Defense In Depth Validation?

Defense In Depth Validation fits situations like: invalid data causes failures deep in execution; requiring validation at multiple system layers.

How do I install Defense In Depth Validation in Claude Code?

Run `npx skills add secondsky/claude-skills --skill defense-in-depth-validation -a claude-code`. Or copy the skill folder (plugins/defense-in-depth-validation/skills/defense-in-depth-validation in secondsky/claude-skills) into .claude/skills/defense-in-depth-validation in your project. Claude Code loads it when a task matches its description.

How do I install Defense In Depth Validation in Codex?

Run `npx skills add secondsky/claude-skills --skill defense-in-depth-validation -a codex`. Or copy the skill folder (plugins/defense-in-depth-validation/skills/defense-in-depth-validation in secondsky/claude-skills) into .agents/skills/defense-in-depth-validation in your project. Codex loads it when a task matches its description.

Can I use Defense In Depth Validation in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add secondsky/claude-skills --skill defense-in-depth-validation -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/defense-in-depth-validation, .gemini/skills/defense-in-depth-validation, .github/skills/defense-in-depth-validation and .opencode/skills/defense-in-depth-validation in your project.

What does Defense In Depth Validation need to run?

Going by SKILL.md and its folder, Defense In Depth Validation needs the command-line tools its instructions call (git).

Does Defense In Depth Validation access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Defense In Depth Validation safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Defense In Depth Validation use?

Defense In Depth Validation is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Defense In Depth Validation use?

About 1.3k tokens (SKILL.md is roughly 5.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Defense In Depth Validation?

Skills that share tags, products or a category with Defense In Depth Validation: Defense In Depth (sandgardenhq/sgai, 137 stars), Thorough Code Review (pretend1111/claude-desktop-app, 494 stars), Security Audit (TheDecipherist/claude-code-mastery, 550 stars) and Humble Header Report Analyst (rfc-st/humble, 379 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Defense In Depth Validation?

secondsky (a GitHub user) maintains it in secondsky/claude-skills, which has 227 GitHub stars. The repository holds 169 skills in this directory. The repository was last updated on September 28, 2026.

Source: secondsky/claude-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.