Skip to content
Back to skills

Clean Architecture Checker

ASecurity

Verifies code follows Clean Architecture principles in Polibase. Activates when creating or modifying src/domain, src/application, src/infrastructure, or src/interfaces files. Checks dependency rules, entity independence, repository patterns, DTO usage, and type safety.

  • 754 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added February 8, 2026
developmentpythongosql

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill clean-architecture-checker --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Clean Architecture Checker?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Clean Architecture Checker
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-clean-architecture-checker/badge)](https://www.skillsdirectory.com/skills/majiayu000-clean-architecture-checker)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: clean-architecture-checker
description: Verifies code follows Clean Architecture principles in Polibase. Activates when creating or modifying src/domain, src/application, src/infrastructure, or src/interfaces files. Checks dependency rules, entity independence, repository patterns, DTO usage, and type safety.
---

# Clean Architecture Checker

## Purpose
Verify that new code follows Clean Architecture principles as defined in the Polibase project.

## When to Activate
This skill activates automatically when:
- Creating or modifying files in `src/domain/`, `src/application/`, `src/infrastructure/`, or `src/interfaces/`
- Reviewing code changes across multiple layers
- Adding entities, repositories, use cases, or services

## Quick Checklist

Before approving code, verify:

- [ ] **Dependency Rule**: Dependencies point inward (Domain ← Application ← Infrastructure ← Interfaces)
- [ ] **Entity Independence**: Domain entities have no framework dependencies (no SQLAlchemy, Streamlit, etc.)
- [ ] **Repository Pattern**: All repos inherit from `BaseRepository[T]` and use async/await
- [ ] **DTO Usage**: DTOs used for layer boundaries, not raw entities
- [ ] **DTO Placement**: DTOは`src/application/dtos/`に配置(UseCaseファイル内に混在させない)
- [ ] **UseCase間依存**: Orchestratorパターンとして許容される場合のみ(抽出ログ統合等)
- [ ] **Type Safety**: Complete type hints with proper `Optional` handling
- [ ] **Tests**: Unit tests for domain services and use cases

## Core Principles

### 1. Dependency Rule
**Dependencies must point inward: Domain ← Application ← Infrastructure ← Interfaces**

✅ Domain imports nothing from outer layers
✅ Application only imports Domain
✅ Infrastructure imports Domain and Application
✅ Interfaces imports all inner layers (but not other Interface modules)

### 2. Entity Independence
**Domain entities must not depend on external frameworks**

✅ Use `@dataclass` or Pydantic `BaseModel`
❌ No SQLAlchemy models in Domain
❌ No UI framework imports in Domain

### 3. Repository Pattern
**All repositories follow async/await with ISessionAdapter**

✅ Interfaces in Domain: `class IRepo(BaseRepository[T])`
✅ Implementations in Infrastructure: `class RepoImpl(BaseRepositoryImpl[T], IRepo)`
✅ All methods are `async def`

### 4. DTO Pattern
**Always use DTOs between layers**

✅ DTOs in `src/application/dtos/`(専用ファイルに配置)
✅ Input DTO → Use Case → Output DTO
❌ Never expose domain entities directly to outer layers
❌ **UseCaseファイル内にDTO定義を混在させない**(Issue #969)

### 5. UseCase間依存(Orchestratorパターン)
**UseCase間依存は条件付きで許容**

✅ Orchestrator UseCase が 子UseCase を呼び出すパターンは許容
✅ 抽出ログ統合(`UpdateEntityFromExtractionUseCase`)への依存は許容(ADR-0005)
❌ UseCase間で循環依存を作らない
❌ Bronze Layer / Gold Layer の保護機構をバイパスしない

### 6. Type Safety
**Leverage Python 3.11+ type hints**

✅ All public methods have type hints
✅ Use `T | None` for nullable types
✅ Explicit `None` checks for Optional values

## Common Violations

See [examples.md](examples.md) for detailed good/bad code examples.

## Detailed Reference

For comprehensive architecture guidelines, see [reference.md](reference.md).

## Templates

Use templates in `templates/` directory for creating new:
- Domain entities
- Repository interfaces and implementations
- Use cases with DTOs
- Domain services

## References

- [CLEAN_ARCHITECTURE_MIGRATION.md](../../../docs/CLEAN_ARCHITECTURE_MIGRATION.md)
- [ARCHITECTURE.md](../../../docs/ARCHITECTURE.md)
- [tmp/clean_architecture_analysis_2025.md](../../../tmp/clean_architecture_analysis_2025.md)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.