Defense-in-Depth Validation
Skill27 starsChanged 3 months agoApache-2.0View on GitHub
Validate at every layer data passes through to make bugs impossible
- Reads credentials
3 other projects use a version of this.
Adopted by
Most recently taken up by
- fimoklei/pm-ai-playbookword for word, first seen May 31, 2026
- kapil0x/skillsword for word, first seen Oct 18, 2025
Other versions3 projects use a version of this.
Word for word · 3
- obra/superpowers-skills★ 748100% same
- fimoklei/pm-ai-playbook★ 42100% same
- kapil0x/skills★ 1100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository163 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-memorySkill
- claukitSkill
- mcp-agent-patternsSkill
- multi-agent-orchestrationSkill
- workflow-state-machinesSkill
- ai-multimodalSkill
- geo-fundamentalsSkill
- media-processingSkill
- screenshotSkill
- seo-fundamentalsSkill
- soraSkill
- aestheticSkill
- figma-implement-designSkill
- figmaSkill
- frontend-designSkill
- mobile-designSkill
- tailwind-patternsSkill
- ui-stylingSkill
- agentic-ragSkill
- api-patternsSkill
- app-builderSkill
- architectureSkill
- ask-mattSkill
- aspnet-coreSkill
- backend-developmentSkill
- better-authSkill
- clean-codeSkill
- code-agent-patternsSkill
- codebase-designSkill
- code-review-checklistSkill
- code-reviewSkill
- context-engineeringSkill
- context-optimizationSkill
- database-designSkill
- databasesSkill
- diagnoseSkill
- diagnosing-bugsSkill
- docs-seekerSkill
- domain-modelingSkill
- frontend-dev-guidelinesSkill
- graph-ragSkill
- i18n-localizationSkill
- implementSkill
- improve-codebase-architectureSkill
- lint-and-validateSkill
- llm-evalsSkill
- nextjs-best-practicesSkill
- nodejs-best-practicesSkill
- openai-docsSkill
- performance-profilingSkill
- playwright-interactiveSkill
- playwrightSkill
- prompt-engineeringSkill
- prototypeSkill
- python-patternsSkill
- react-patternsSkill
- render-deploySkill
- repomixSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
When you fix a bug caused by invalid data, adding validation at one place feels sufficient.
- Distinctive: line 49
Purpose: Ensure data makes sense for this operation
- Distinctive: line 97
When you find a bug:
- Distinctive: line 109
Test setup → empty string
- Distinctive: line 120
Result: All 1847 tests passed, bug impossible to reproduce
- Distinctive: line 124
All four layers were necessary.
- Distinctive: line 130
Don't stop at one validation point: Add checks at every layer.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
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
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
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
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
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:
- Trace the data flow - Where does bad value originate? Where used?
- Map all checkpoints - List every point data passes through
- Add validation at each layer - Entry, business, environment, debug
- 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:
- Test setup → empty string
Project.create(name, '')WorkspaceManager.createWorkspace('')git initruns inprocess.cwd()
Four layers added:
- Layer 1:
Project.create()validates not empty/exists/writable - Layer 2:
WorkspaceManagervalidates projectDir not empty - Layer 3:
WorktreeManagerrefuses git init outside tmpdir in tests - Layer 4: Stack trace logging before git init
Result: All 1847 tests passed, bug impossible to reproduce
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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

