Markdown Converter
Agent skill for markdown-converter
This skill enforces strict architectural principles and code generation standards to ensure all code follows enterprise-grade patterns. When this skill is active, Claude must generate code that adheres to these principles without exception.
Sign in to like and favorite skills
This skill enforces strict architectural principles and code generation standards to ensure all code follows enterprise-grade patterns. When this skill is active, Claude must generate code that adheres to these principles without exception.
Domain Layer (Core) āāā Entities āāā Value Objects āāā Domain Services āāā Repository Interfaces Application Layer āāā Use Cases āāā DTOs āāā Application Services Infrastructure Layer āāā Database Implementation āāā External Service Adapters āāā Framework-specific Code Presentation Layer āāā Controllers/Handlers āāā View Models āāā UI Components
# ā WRONG - Business logic in repository class UserRepository: def get_active_premium_users(self): users = self.db.query("SELECT * FROM users") # Business logic should NOT be here! return [u for u in users if u.is_active and u.subscription == 'premium'] # ā CORRECT - Business logic in domain service class UserRepository: def get_all_users(self): return self.db.query("SELECT * FROM users") class UserDomainService: def get_active_premium_users(self, repository): users = repository.get_all_users() return [u for u in users if self._is_active_premium(u)] def _is_active_premium(self, user): return user.is_active and user.subscription == 'premium'
# Define ports (interfaces) first from abc import ABC, abstractmethod class PaymentGatewayPort(ABC): @abstractmethod def process_payment(self, amount: float, currency: str) -> PaymentResult: pass class NotificationPort(ABC): @abstractmethod def send_notification(self, recipient: str, message: str) -> bool: pass # Then implement adapters class StripePaymentAdapter(PaymentGatewayPort): def process_payment(self, amount: float, currency: str) -> PaymentResult: # Stripe-specific implementation pass class EmailNotificationAdapter(NotificationPort): def send_notification(self, recipient: str, message: str) -> bool: # Email-specific implementation pass
from dataclasses import dataclass, replace from datetime import datetime from typing import Optional @dataclass(frozen=True) class Order: id: str customer_id: str total_amount: float status: str created_at: datetime def mark_as_paid(self) -> 'Order': # Return new instance instead of mutating return replace(self, status='PAID') def apply_discount(self, percentage: float) -> 'Order': new_amount = self.total_amount * (1 - percentage / 100) return replace(self, total_amount=new_amount)
# Every generated component must include tests # Domain model test class TestOrder: def test_mark_as_paid_creates_new_instance(self): order = Order(id="1", customer_id="C1", total_amount=100.0, status="PENDING", created_at=datetime.now()) paid_order = order.mark_as_paid() assert paid_order.status == "PAID" assert order.status == "PENDING" # Original unchanged assert paid_order is not order # Different instances # Use case test class TestCreateOrderUseCase: def test_create_order_with_valid_data(self): # Arrange repository = Mock(OrderRepositoryPort) use_case = CreateOrderUseCase(repository) # Act result = use_case.execute(customer_id="C1", items=[...]) # Assert repository.save.assert_called_once() assert result.is_success
""" Order Processing Module Architectural Intent: - This module handles order lifecycle management following DDD principles - Order aggregate is the consistency boundary - All state changes go through domain methods to ensure invariants - External payment processing is handled via ports/adapters pattern - Events are published for other bounded contexts to react Key Design Decisions: 1. Orders are immutable to prevent accidental state corruption 2. Payment processing is abstracted behind PaymentGatewayPort 3. Order status transitions are validated in domain model 4. Complex pricing logic is delegated to PricingDomainService """ class OrderAggregate: """ Order Aggregate Root Invariants: - Order total must be positive - Status transitions must follow defined state machine - Cancelled orders cannot be modified """ pass
When generating code, Claude must verify:
Start with the Domain
Define Interfaces
Implement Use Cases
Add Infrastructure
Create Tests
project/ āāā domain/ ā āāā entities/ ā ā āāā order.py ā ā āāā customer.py ā āāā value_objects/ ā ā āāā money.py ā ā āāā address.py ā āāā services/ ā ā āāā pricing_service.py ā āāā ports/ ā āāā repository_ports.py ā āāā external_service_ports.py āāā application/ ā āāā use_cases/ ā ā āāā create_order.py ā ā āāā process_payment.py ā āāā dtos/ ā āāā order_dto.py āāā infrastructure/ ā āāā repositories/ ā ā āāā order_repository.py ā āāā adapters/ ā ā āāā payment_adapter.py ā ā āāā notification_adapter.py ā āāā config/ ā āāā dependency_injection.py āāā presentation/ ā āāā api/ ā ā āāā order_controller.py ā āāā cli/ ā āāā order_commands.py āāā tests/ āāā domain/ āāā application/ āāā infrastructure/ āāā integration/
from abc import ABC from dataclasses import dataclass from datetime import datetime from typing import List @dataclass(frozen=True) class DomainEvent(ABC): aggregate_id: str occurred_at: datetime @dataclass(frozen=True) class OrderPlacedEvent(DomainEvent): order_total: float customer_id: str class EventStore(ABC): @abstractmethod def append(self, events: List[DomainEvent]) -> None: pass
# Command side class CreateOrderCommand: customer_id: str items: List[OrderItem] class CommandHandler: def handle(self, command: CreateOrderCommand) -> None: # Process command, update state pass # Query side class OrderSummaryQuery: customer_id: str date_range: DateRange class QueryHandler: def handle(self, query: OrderSummaryQuery) -> OrderSummaryDTO: # Return read-optimized data pass
When using this skill, Claude should be familiar with:
Code generated with this skill must:
Note: This skill is designed to enforce architectural discipline in AI-generated code. All patterns and principles should be applied pragmatically based on project scale and requirements.