architecture-validate-layer-boundaries
Validates Clean Architecture layer boundaries by detecting import violations across domain, application, infrastructure, and interfaces layers using grep-based analysis. Use when asked to "validate architecture", "check layer boundaries", "verify Clean Architecture", "validate my changes follow Clean Architecture", or before committing architectural changes. layer, interfaces layer, dependency rules, architectural validation. Works with Python files in layered architecture projects (domain/, application/, infrastructure/, interfaces/ directories).
What this skill does
Key terms: Clean Architecture, layer boundaries, domain layer, application layer, infrastructure # Validate Clean Architecture Layer Boundaries ## Purpose Validates that all layers respect Clean Architecture dependency rules by checking that domain has no external imports, application doesn't import from interfaces, and infrastructure implements repository interfaces correctly. Ensures architectural integrity before commits and during quality gates. ## Table of Contents ### Core Sections - [Purpose](#purpose) - What this skill validates - [When to Use This Skill](#when-to-use-this-skill) - Triggers and use cases - [Triggers](#triggers) - Explicit trigger phrases - [What This Skill Does](#what-this-skill-does) - Layer dependency rules and validation process - [Quick Start](#quick-start) - Immediate validation workflow - [Usage Examples](#usage-examples) - Real-world scenarios - [Supporting Files](#supporting-files) - References, examples, and scripts ### Detailed Sections - [Validation Process](#validation-process) - Step-by-step validation workflow - [Expected Outcomes](#expected-outcomes) - Success and failure scenarios - [Detection Patterns](#detection-patterns) - Grep patterns for violations - [Integration Points](#integration-points) - Hooks, quality gates, and agents - [Expected Benefits](#expected-benefits) - Performance metrics - [Success Metrics](#success-metrics) - Measurement criteria ## When to Use This Skill Use this skill when: - Making changes to files in domain/application/infrastructure/interface layers - Adding new dependencies to any layer - Reviewing code for architecture compliance - Running pre-commit quality gates - User asks "Does this follow Clean Architecture?" ## Triggers Trigger with phrases like: - "validate architecture" - "check layer boundaries" - "verify Clean Architecture" - "does this follow Clean Architecture?" - "validate my changes follow Clean Architecture" - "check architectural compliance" - "are my layer dependencies correct?" - "validate domain layer imports" ## What This Skill Does Validates that all layers respect Clean Architecture dependency rules: ### Layer Dependency Rules **Domain Layer** (`src/project_watch_mcp/domain/`) - ❌ CANNOT import from: `infrastructure`, `interfaces`, `application` - ✅ CAN import from: `domain` only - **Rationale:** Domain is innermost layer, pure business logic **Application Layer** (`src/project_watch_mcp/application/`) - ❌ CANNOT import from: `interfaces` - ✅ CAN import from: `domain`, `application` - **Rationale:** Application orchestrates domain, but doesn't know about interfaces **Infrastructure Layer** (`src/project_watch_mcp/infrastructure/`) - ✅ CAN import from: any layer - ✅ CAN import external dependencies (Neo4j, etc.) - **Must:** Implement domain repository interfaces - **Rationale:** Infrastructure is outermost layer, connects to external systems **Interface Layer** (`src/project_watch_mcp/interfaces/`) - ❌ CANNOT import from: `infrastructure`, `domain` directly - ✅ CAN import from: `application` - **Rationale:** Interfaces depend on application use cases only ## Validation Process 1. **Identify Layer:** Determine which layer the file belongs to based on path 2. **Extract Imports:** Parse all `import` and `from ... import` statements 3. **Check Rules:** Validate imports against layer-specific rules 4. **Report Violations:** List violations with file:line references ## Quick Start **User:** "Validate my architecture changes" **What happens:** 1. Skill identifies which layer each file belongs to 2. Checks imports against Clean Architecture rules 3. Reports violations with specific fixes **Result:** ✅ Pass (boundaries respected) or ❌ Fail (violations with fixes) **Example output:** Success: All files respect boundaries with 0 violations detected. Failure: Specific violations reported with file location, issue description, and fix guidance. See [examples/examples.md](./examples/examples.md) for detailed output examples. ## Supporting Files - [references/layer-rules.md](./references/layer-rules.md) - Complete layer dependency matrix with examples - [references/violation-fixes.md](./references/violation-fixes.md) - Common violations and how to fix them - [examples/examples.md](./examples/examples.md) - Detailed validation scenarios and expected outputs - [scripts/validate.sh](./scripts/validate.sh) - Executable validation script for Clean Architecture layer boundaries ## Usage Examples ### Example 1: Validate Single File User: "Is this domain model valid?" Claude invokes skill by reading file and checking imports: - Identify layer from path - Extract all imports using Grep - Check each import against layer rules - Report violations See [examples/examples.md](./examples/examples.md#example-6-validating-single-file) for detailed output. ### Example 2: Validate All Changes User: "Check if my changes follow Clean Architecture" Claude invokes skill for all modified files: 1. Run: git diff --name-only 2. Filter Python files 3. Validate each file's imports 4. Report summary of violations See [examples/examples.md](./examples/examples.md#example-4-multiple-violations) for detailed output. ### Example 3: Pre-Commit Gate Invoked automatically by pre-commit hook: 1. Get staged files 2. Validate layer boundaries 3. Block commit if violations found See [examples/examples.md](./examples/examples.md#example-7-integration-with-pre-commit-hook) for implementation details. ## Expected Outcomes ### Success (No Violations) All files checked with 0 violations detected. Layer boundaries are respected across all layers. ### Failure (Violations Found) Violations reported with: - File path and line number - Issue description (which layer rule violated) - Offending code line - Specific fix guidance See [examples/examples.md](./examples/examples.md#example-2-domain-layer-violation) for detailed violation output examples. ## Detection Patterns The skill uses Grep patterns to detect violations across layers: - **Domain layer violations:** Detects imports from application/infrastructure/interfaces - **Application layer violations:** Detects imports from interfaces - **Interface layer violations:** Detects direct imports from domain or infrastructure See [scripts/validate.sh](./scripts/validate.sh) for the exact grep patterns and validation logic used. ## Integration Points ### With Pre-Flight Validation Hook The pre-flight validation hook in `.claude/scripts/pre_flight_validation.py` can invoke this skill to validate architectural boundaries before allowing tool execution. ### With Quality Gates Quality gate scripts in `./scripts/check_all.sh` can run the validation script to ensure Clean Architecture compliance as part of CI/CD. ### With @architecture-guardian The architecture guardian agent can delegate boundary validation to this skill rather than implementing validation inline, reducing context load by 96%. ## Expected Benefits | Metric | Baseline | With Skill | Improvement | |--------|----------|------------|-------------| | Context Load | 50KB (@architecture-guardian) | 2KB (SKILL.md) | 96% reduction | | Execution Time | 2-3s (agent) | 0.5s (skill) | 6x faster | | Reusability | Low (agent-specific) | High (hooks, commands, agents) | 5x | | Error Clarity | Good | Excellent (skill-specific) | +30% | ## Success Metrics After implementation, measure: - **Invocation Rate:** Skill invoked in 80%+ of architecture validation tasks - **Context Reduction:** 90%+ reduction vs agent approach - **Violation Detection:** 95%+ recall (catches all major violations) - **False Positives:** <5% (no incorrect violations)
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.