home / skills / d-oit / do-novelist-ai / architecture-guardian

architecture-guardian skill

/.opencode/skill/architecture-guardian

This skill helps enforce clean architecture principles, layering rules, and boundary management to improve module decoupling and interface design.

npx playbooks add skill d-oit/do-novelist-ai --skill architecture-guardian

Review the files below or copy the command above to add this skill to your agents.

Files (6)
SKILL.md
2.7 KB
---
name: architecture-guardian
description:
  Enforce clean architecture principles, proper layering rules, dependency flow,
  module boundaries, and interface design. Use when designing new features,
  refactoring code, or reviewing architecture.
---

# Architecture Guardian

Enforce clean architecture principles, proper layer separation, and well-defined
boundaries between architectural layers.

## Quick Reference

- **[Core Guidance](core-guidance.md)** - Detailed methodology and
  implementation
- **[Layering Rules](layering-rules.md)** - Layer separation principles
- **[Dependency Flow](dependency-flow.md)** - Allowed and prohibited
  dependencies
- **[Interface Design](interface-design.md)** - API and interface design
- **[Module Boundaries](module-boundaries.md)** - Module coupling and cohesion

## When to Use

- Designing new feature modules
- Refactoring existing architecture
- Creating new interfaces between layers
- Reviewing code for architectural compliance
- Setting up dependency injection
- Decoupling modules

## Core Methodology

Enforce clean architecture through systematic layering, dependency flow control,
and boundary management.

**Key Principles**:

1. Layer separation (Presentation, Application, Domain, Infrastructure)
2. Upward dependency flow (depends on abstractions, not implementations)
3. Clear module boundaries (bounded contexts)
4. Interface-based design (depend on contracts, not concretions)
5. SOLID principles adherence

**Quality Gates**:

- No circular dependencies
- No layering violations
- Clear public APIs
- Proper dependency directions
- Single responsibility per module

## Integration

- **domain-expert**: Ensures proper domain modeling
- **typescript-guardian**: Type safety in interfaces
- **feature-module-architect**: Structures features correctly
- **tech-stack-specialist**: Framework and tool configuration

## Best Practices

✓ Keep layers strictly separated ✓ Depend on abstractions, not concretions ✓
Define clear public APIs ✓ Use repository interfaces in domain layer ✓ Implement
dependency inversion ✓ Enforce bounded contexts ✓ Design interfaces with
segregation principle ✗ Mix responsibilities across layers ✗ Leak infrastructure
into domain ✗ Create tight coupling between features ✗ Allow circular
dependencies ✗ Make interfaces too large (segregate) ✗ Skip dependency flow
validation

---

## Content Modules

See detailed modules:

- **[Core Guidance](core-guidance.md)** - Implementation details and patterns
- **[Layering Rules](layering-rules.md)** - Layer separation
- **[Dependency Flow](dependency-flow.md)** - Dependency management
- **[Interface Design](interface-design.md)** - API design patterns
- **[Module Boundaries](module-boundaries.md)** - Coupling and cohesion

Overview

This skill enforces clean architecture principles for TypeScript projects, focusing on proper layering, module boundaries, and interface design. It helps teams design new features, guide refactors, and validate architecture during reviews to keep dependencies and responsibilities clear.

How this skill works

The skill inspects project structure, TypeScript types, import graphs, and module APIs to detect layering violations, circular dependencies, and boundary leaks. It reports allowed and prohibited dependency flows, highlights oversized or mixed-responsibility interfaces, and suggests inversion or segregation where needed. Outputs include concrete remediation steps and examples for applying dependency inversion and clearer module contracts.

When to use it

  • Designing a new feature module and defining its public API
  • Refactoring existing code to improve separation of concerns
  • Reviewing pull requests for architectural compliance
  • Establishing or validating dependency injection and wiring
  • Decoupling tightly coupled modules or removing circular imports

Best practices

  • Enforce strict layer separation: Presentation → Application → Domain → Infrastructure
  • Depend on abstractions (interfaces) in higher layers, implement in lower layers
  • Define small, focused public APIs per module and apply interface segregation
  • Detect and eliminate circular dependencies early in the design phase
  • Treat bounded contexts as independent modules with clear contracts

Example use cases

  • Validate a proposed feature's folder layout and imports before implementation
  • Scan a codebase to identify where domain logic depends on infrastructure types
  • Suggest interface extraction for a service that mixes persistence and business rules
  • Generate a migration plan to split a monolith module into bounded contexts
  • Review a pull request to ensure no new layering violations or circular imports

FAQ

Can this skill enforce rules automatically?

It identifies violations and produces concrete fixes, but applying code changes typically stays with developers or CI tooling that integrates suggested changes.

Does it integrate with TypeScript tooling?

Yes. It analyzes TypeScript ASTs, import graphs, and type information to provide accurate guidance aligned with your tsconfig and module resolution.