.claude/skills/sagerstack-software-engineering/SKILL.md
Python code architecture with Vertical Slice + DDD and Clean Architecture. Use when designing Python projects, structuring code, creating domain models, defining bounded contexts, or reviewing architecture. Enforces strict domain purity, CamelCase naming, and proper layer separation.
npx skillsauth add sagerstack/agentic-sdlc sagerstack:software-engineeringInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
<essential_principles>
These principles ALWAYS apply when designing Python code.
Organize by feature/bounded context, not technical layer. Each slice owns its full stack.
src/
├── shared/ # Cross-cutting concerns only
│ ├── domain/ # Shared Value Objects (Money, Email)
│ └── infrastructure/ # Config, DB, event bus
├── orders/ # Feature slice
│ ├── domain/ # Entities, Aggregates, Repository ABC
│ ├── application/ # Commands, Queries, Handlers
│ ├── infrastructure/ # Repository impl, external APIs
│ └── api/ # Routes, schemas
├── customers/ # Another slice
└── payments/ # Another slice
Domain layer has ZERO external dependencies:
# ✅ Domain entity - pure Python
@dataclass
class Order:
id: OrderId
customerId: CustomerId
lines: list[OrderLine]
def place(self) -> None:
if not self.lines:
raise EmptyOrderError()
# ❌ WRONG - framework types in domain
@dataclass
class Order:
id: UUID # Should be OrderId Value Object
data: BaseModel # Framework type!
Inner layers NEVER import from outer layers. Dependencies point inward.
API → Application → Domain ← Infrastructure
↑
(Domain defines interfaces,
Infrastructure implements)
# Classes
class OrderService:
pass
# Functions and methods
def placeOrder(self, orderId: str) -> None:
pass
# Variables
orderId = "123"
customerName = "John"
# Even in tests
def testPlaceOrderWithEmptyCart(self):
pass
Direct service calls allowed. Slices can call each other's application services.
# ✅ Allowed - calling another slice's service
from src.customers.application.getCustomer import GetCustomerHandler
class PlaceOrderHandler:
def __init__(self, customerHandler: GetCustomerHandler):
self.customerHandler = customerHandler
Also supported: Domain events for async communication when appropriate.
.env.local # Local dev secrets (gitignored)
.env.tests # Test secrets (gitignored)
.env.example # Template (committed)
Production uses AWS Secrets Manager.
# Custom exceptions in domain
class OrderNotFoundError(DomainError):
def __init__(self, orderId: str):
super().__init__(f"Order {orderId} not found")
# Result pattern for operations that can fail
@dataclass
class Result[T]:
value: T | None
error: str | None
@property
def isSuccess(self) -> bool:
return self.error is None
Format: [yyyymmdd-HH24:MM:ss] [PID] [CorrelationID] [Class] [Function] [Level] message
import structlog
logger = structlog.getLogger()
logger.info("Order placed", orderId=orderId, customerId=customerId)
Do NOT auto-generate docstrings, README files, or documentation unless explicitly requested.
Write failing test -> Write minimum code to pass -> Refactor -> Repeat
Never write production code without a test first.
# Step 1: Write failing test
def testCalculateTotalReturnsSum():
order = Order(id=OrderId("1"), customerId=CustomerId("c1"))
order.addLine("prod-1", quantity=2, unitPrice=Money(1000))
total = order.calculateTotal()
assert total == Money(2000)
# Step 2: Write minimum code to make it pass
def calculateTotal(self) -> Money:
return Money(sum(line.subtotal().amount for line in self.lines))
# Step 3: Refactor if needed
# Step 4: Next test
See workflows/tdd-workflow.md for the detailed red-green-refactor process.
No exceptions. Configure in pyproject.toml:
[tool.pytest.ini_options]
addopts = "--cov=src --cov-report=term-missing --cov-fail-under=90"
If coverage drops below 90%, the test suite fails. This ensures comprehensive test coverage as a non-negotiable quality standard.
</essential_principles>
<intake> **What would you like to do?**Wait for response, then read the matching workflow. </intake>
<routing> | Response | Workflow | |----------|----------| | 1, "new", "design", "feature", "create" | `workflows/design-new-feature.md` | | 2, "review", "audit", "check" | `workflows/review-architecture.md` | | 3, "refactor", "migrate", "clean" | `workflows/refactor-to-clean-arch.md` | | 4, "add slice", "bounded context", "new slice" | `workflows/add-bounded-context.md` | | 5, "domain", "entity", "aggregate", "value object" | `workflows/design-domain-model.md` | | 6, other | Clarify, then select workflow or references | </routing><reference_index>
All in references/:
Architecture:
DDD Patterns:
Code Style:
Configuration:
Testing:
<workflows_index>
All in workflows/:
| File | Purpose | |------|---------| | design-new-feature.md | Design a feature from scratch with DDD | | review-architecture.md | Audit existing code structure | | refactor-to-clean-arch.md | Migrate code to Clean Architecture | | add-bounded-context.md | Add new slice to existing project | | design-domain-model.md | Create Entities, VOs, Aggregates | </workflows_index>
<verification> ## After Every Design DecisionVerify:
poetry run pytest --cov)
</verification>
development
Interactive UAT verification skill. Walks the user through acceptance criteria one at a time, records pass/fail/skip results, generates UAT report, and routes remediation gaps to /sagerstack:builder. Solo skill (no agent team).
data-ai
SDLC planning skill that spawns a 4-member agent team to plan one epic at a time from project-context.md. Produces epics, user stories with FR/TR/AC, implementation plans, and critical analyses. Use when planning an epic for full SDLC execution with agent teams.
testing
Testing infrastructure, local environment simulation, and deployment scripts. Use when setting up pytest fixtures, Docker Compose, LocalStack, mocking external services, or creating local deployment scripts. Focuses on HOW to test and run locally, not coding principles (TDD is in software-engineering).
testing
AWS infrastructure deployment with Terraform. Use when deploying to AWS, writing Terraform configurations, setting up CI/CD with GitHub Actions, or managing AWS resources (EKS, Lambda, S3, SNS, SQS, Secrets Manager).