From stenswf
Guide architectural decision-making for new projects or significant code changes. Use when starting a new project, choosing a design pattern, evaluating architecture for a large refactor, or when the user asks which architecture pattern to use.
How this skill is triggered — by the user, by Claude, or both
Slash command
/stenswf:architectureThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Based on research across academic literature, practitioner consensus (Mark Richards, Simon Brown, Gregor Hohpe), and Matt Pocock's codebase improvement methodology. This skill operationalizes those insights into a structured decision process.
Based on research across academic literature, practitioner consensus (Mark Richards, Simon Brown, Gregor Hohpe), and Matt Pocock's codebase improvement methodology. This skill operationalizes those insights into a structured decision process.
Use this skill when:
Do not use this skill when:
"Everything in software architecture is a trade-off." — First Law of Software Architecture
A senior architect's job is not to find the one correct pattern — it is to make trade-offs explicit, document them, and choose the option that best satisfies the system's quality attributes.
Before choosing any pattern, identify what the system must achieve beyond its functional requirements. Ask the user (or infer from context):
| Attribute | Question to ask |
|---|---|
| Scalability | Will load grow? Must it scale horizontally? |
| Maintainability | How often will it change? How large is the team? |
| Testability | Must individual behaviors be verified in isolation? |
| Observability | Do we need to infer internal state from outputs? |
| Security | Is the attack surface or data sensitivity a concern? |
| Reliability | What happens when a dependency fails? |
| Deployability | How fast and safely must changes reach production? |
Output: A ranked shortlist of the 2–4 quality attributes that matter most for this system. Everything else flows from this prioritization.
If the quality attributes are unclear, surface them before proceeding by interviewing me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer. If a question can be answered by exploring the codebase, explore the codebase instead.
Architecture choices differ fundamentally by what is being built. Classify the artifact:
SPAs manage routing, state, caching, domain logic, and real-time updates on the client. Key decisions:
useState/useContext/useReducer for most SPAs. Adopt centralized stores (Redux, Zustand) only when shared state is genuinely complex and frequently updated.CLIs are developer-facing, pipe-composable, and embedded in automation. Their API is their flags and subcommands — treat them like a versioned public interface.
tool [noun] [verb] (e.g., git branch list). Use it as functionality grows.Libraries are the most API-sensitive artifact — the interface is the product.
For applications with significant business logic, proceed to Step 3 to select a structural pattern.
Apply the tier system below. Start with Tier 1 options; move to Tier 2 only when the quality attributes require it; use Tier 3 only when the use case is explicit.
| Pattern | Best fit | Key trade-off |
|---|---|---|
| Layered (N-Tier) | Default starting point; maps to most frameworks | Cheap to start; cross-layer changes at scale → Big Ball of Mud |
| Hexagonal (Ports & Adapters) | Significant business logic; testability is top priority | Maximally testable core; requires explicit port/adapter discipline |
| Clean Architecture | Rich, evolving business rules; long-term flexibility | Strong testability; upfront abstraction overhead |
| Event-Driven (EDA) | Loose coupling; async workflows; audit trails | Hard to debug and test; eventual consistency complexity |
Hexagonal Architecture is the single most important structural pattern for applications with meaningful business logic. It isolates the domain from all external systems (HTTP, DB, queues) via ports (interfaces) and adapters (implementations).
Clean Architecture is the domain-centric extreme: dependencies flow strictly inward through Entities → Use Cases → Interface Adapters → Frameworks. The core never knows about HTTP or databases. Use for products where domain rules are the primary complexity driver.
| Pattern | When it pays off | Why to skip otherwise |
|---|---|---|
| Modular Monolith | Medium-sized products; deployment independence not yet needed | Gets 80% of microservices' benefits at 20% of the operational cost |
| Vertical Slice Architecture (VSA) | CRUD-heavy APIs; fast-moving teams; feature-aligned delivery | Reduced cross-feature coupling; can coexist with Clean Architecture within slices |
| CQRS | High read/write asymmetry; event-sourced systems; analytics | Pure overhead for simple CRUD |
| Microservices | Proven need for team autonomy and independent deployability | On a single machine, a monolith outperforms its microservice equivalent; distributed systems cost is substantial |
Default recommendation for new backend applications: Start with a Modular Monolith. Extract microservices only when deployment independence is a proven and funded requirement.
Use only when the specific use case demands it:
| Pattern | Use case | Default stance |
|---|---|---|
| Microkernel (Plugin) | Products with genuine extension points (IDEs, CMS, build tools) | Overkill without real extensibility needs |
| Space-Based | Extreme high-concurrency, low-latency (trading systems) | High infrastructure cost |
| Serverless | Event-triggered, sporadically-used workloads | Cold starts, vendor lock-in, difficult local testing |
| Reactive | High-throughput streams, IoT sensor ingestion | Paradigm shift; steep learning curve |
Freedom demands discipline. The primary risk is over-engineering.
Decisions are constrained by live systems, team knowledge, and existing consumers. The key principle is incremental, validated change.
| Scenario | Strategy |
|---|---|
| Good core logic, poor structure | Module Deepening (Pocock approach) |
| Need to migrate monolith to services | Strangler Fig Pattern |
| New code must interact with legacy models | Anti-Corruption Layer (ACL) |
| Critical security/compliance gap | Greenfield rebuild |
| Sprawling spaghetti, low test coverage | Strangler Fig for key domains; leave stable parts |
Strangler Fig: Build new functionality alongside the monolith. A routing layer intercepts requests and gradually redirects to new services. The monolith is strangled incrementally — no big-bang rewrites.
Anti-Corruption Layer (ACL): Translate between the old system's model and the new domain model. Prevents legacy design decisions from contaminating modern services — it is a semantic and technical firewall.
Module Deepening (Pocock Approach): Converts shallow modules into deep modules by merging tightly-coupled small files into coherent units with thin public interfaces. Safe, incremental, no external behavior change.
A deep module has a small interface hiding a large implementation. The opposite — shallow modules where the interface is nearly as complex as the implementation — creates a codebase that is hard to test, hard to navigate, and hard to reason about (Ousterhout, A Philosophy of Software Design).
"What you really want to avoid are lots of little shallow modules... really hard to navigate and really hard to keep in your head." — Matt Pocock
Module deepening process:
/design-an-interface skill)For every significant architectural decision, create a short ADR capturing:
ADRs prevent future teams from unknowingly reversing past decisions and create a living audit trail of the system's evolution.
Use Simon Brown's C4 model to communicate architecture at four levels:
C4 is notation-independent and tool-independent. Logical components are the building blocks of software architecture — the structural units the architect is responsible for.
After working through the steps above, produce a structured recommendation:
## Architecture Recommendation
**Artifact type:** [SPA | CLI | Library | Backend]
**Project type:** [Greenfield | Brownfield]
**Quality attributes (ranked):**
1. [Most important]
2. [Second]
3. [Third]
**Recommended pattern:** [Pattern name]
**Why this fits:** [1–3 sentences tied to the quality attributes]
**Key trade-offs accepted:** [What this pattern costs]
**Starting point:** [Concrete first step]
**Patterns explicitly rejected:**
- [Pattern]: [Why it doesn't fit here]
**ADR topics to document immediately:**
- [Decision 1]
- [Decision 2]
Then ask: "Does this match your constraints? Are there quality attributes I'm missing?"
Apply these at the component and module level regardless of which architecture is chosen:
When the domain is complex, align structure with business reality:
DDD provides the semantic layer; Hexagonal/Clean Architecture provides the structural enforcement.
npx claudepluginhub stevenengland/sten-agent-skills --plugin stenswfGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.