Validation Architecture
Relevant source files
The following files were used as context for generating this wiki page:
- cli-tool/src/validation/README.md
- cli-tool/src/validation/BaseValidator.js
- cli-tool/src/validation/ValidationOrchestrator.js
- cli-tool/src/validation/validators/StructuralValidator.js
- cli-tool/src/validation/validators/SemanticValidator.js
- cli-tool/src/validation/validators/IntegrityValidator.js
- cli-tool/src/validation/validators/ReferenceValidator.js
- cli-tool/src/validation/validators/ProvenanceValidator.js
Introduction
The Validation Architecture of the Claude Code Templates project is a comprehensive security and quality assurance system designed to ensure that all components (Agents, Commands, and MCP servers) are safe, trustworthy, and standardized before distribution. It operates based on industry standards such as npm 2025 and the SLSA Framework to detect malicious patterns, prevent tampering, and verify structural integrity.
The system processes components across five distinct validation tiers, ranging from basic file structure to advanced semantic analysis for prompt injection and jailbreak attempts. By providing a trust score (0-100) for every component, the architecture enables automated decision-making in CI/CD pipelines and provides clear feedback to developers regarding security risks and best practices.
Sources: cli-tool/src/validation/README.md:1-25
Validation Tiers
The architecture is organized into five specialized tiers, each handled by a dedicated validator module.
| Tier | Validator | Focus Area |
|---|---|---|
| 1. Structural | StructuralValidator | YAML frontmatter, file size, required metadata fields, and encoding. |
| 2. Integrity | IntegrityValidator | SHA256 hashing and tamper detection against a known registry. |
| 3. Semantic | SemanticValidator | Detection of prompt injection, jailbreaks, and malicious shell commands. |
| 4. Reference | ReferenceValidator | URL protocol validation and SSRF prevention for external links. |
| 5. Provenance | ProvenanceValidator | Verification of authorship, versioning, and Git history metadata. |
Sources: cli-tool/src/validation/README.md:65-135
Validation Process Flow
The following diagram illustrates the sequence from component scanning to final report generation.
The architecture uses an asynchronous, parallel execution model where the ValidationOrchestrator coordinates all tiers simultaneously for maximum efficiency.
Sources: cli-tool/src/validation/README.md:182-205, cli-tool/src/validation/ValidationOrchestrator.js
System Components
Validation Orchestrator
The ValidationOrchestrator serves as the central controller for the security audit system. It is responsible for discovering components, invoking the suite of validators, and aggregating individual scores into a final component metadata object.
Key responsibilities include:
- Coordination of parallel validator execution.
- Calculation of the final
componentScorebased on weighted inputs from each tier. - Generating validation summaries (passed, failed, warnings).
Sources: cli-tool/src/validation/README.md:182-205, cli-tool/src/validation/ValidationOrchestrator.js
Base Validator Logic
All specialized validators extend the BaseValidator abstract class. This ensures a consistent interface for error reporting and result tracking.
// Conceptual structure of a validator extending BaseValidator
class CustomValidator extends BaseValidator {
async validate(component) {
// Tier-specific logic
if (issueFound) {
this.addError('CODE_001', 'Description', metadata);
}
return this.getResults();
}
}
Sources: cli-tool/src/validation/README.md:320-335, cli-tool/src/validation/BaseValidator.js
Security Patterns & Detection
Semantic Validation
The SemanticValidator is the most critical tier for AI safety. It identifies patterns that attempt to bypass the intended behavior of the Claude Code tool.
- Prompt Injection: Detects phrases like "ignore previous instructions" or "disregard all prior directives."
- Jailbreaks: Identifies "you are now a..." or "system prompt" overrides.
- Dangerous Commands: Flags high-risk shell commands such as
rm -rf /, fork bombs, or direct disk manipulation (dd). - Credential Harvesting: Scans for hardcoded API keys and patterns attempting to "fetch" secrets.
Sources: cli-tool/src/validation/README.md:88-114, cli-tool/src/validation/validators/SemanticValidator.js
Reference & SSRF Prevention
The ReferenceValidator protects the system from Server-Side Request Forgery (SSRF) and malicious redirections by analyzing all URLs within a component's markdown.
Scoring & Metadata Architecture
Scoring Algorithm
The final trust score is a weighted average of the results from all five validators.
| Validator | Weight | Criticality |
|---|---|---|
| Semantic | 30% | High |
| Structural | 25% | Medium-High |
| Integrity | 20% | Medium |
| Reference | 15% | Medium-Low |
| Provenance | 10% | Low |
The score for an individual validator is calculated as: max(0, 100 - (errors * 25) - (warnings * 5)).
Sources: cli-tool/src/validation/README.md:208-220
Validation Metadata Output
Once a component is validated, its metadata is integrated into the components.json registry, allowing clients to verify the security status before downloading.
{
"name": "frontend-developer",
"security": {
"validated": true,
"valid": true,
"score": 96,
"errorCount": 0,
"warningCount": 2,
"lastValidated": "2025-10-15T20:07:37.583Z",
"hash": "eb5f9f4978b71ba06f129c73f5573a58...",
"validators": {
"structural": true,
"integrity": true,
"semantic": true,
"references": true,
"provenance": true
}
}
}
Sources: cli-tool/src/validation/README.md:290-315
Conclusion
The Validation Architecture provides a robust defense-in-depth strategy for the Claude Code Templates project. By combining structural checks with deep semantic analysis and integrity tracking, the system ensures that AI agents and development commands remain secure throughout their lifecycle. This automated approach enables the project to scale to hundreds of components while maintaining a high standard of security and trust.
Sources: cli-tool/src/validation/README.md:1-40, cli-tool/src/validation/ARCHITECTURE.md