Code Architecture
Separate concerns; depend in one direction.
Install 安装
curl -sSL https://updating.cc/skills/engineering-team/code-architecture/SKILL.md -o ~/.agents/skills/engineering-team__code-architecture/SKILL.mdSKILL.md Preview 技能内容预览
---
name: Code Architecture
description: Separate concerns; depend in one direction.
---
# Code Architecture
Most architectural problems are coupling problems. Aim for modules that can be reasoned about, tested, and replaced independently.
## Core rules
- **Dependency direction.** Dependencies point one way — toward stable, low-level modules. A cycle means two modules are really one; break it.
- **Separate what changes for different reasons.** Persistence, business logic, and HTTP handling each change at different rates and for different causes. Keep them apart so a change in one doesn't force the others.
- **Ports and adapters.** Define your core logic against interfaces (ports); put databases, queues, and third-party APIs behind adapters. Then you can swap the adapter without touching the core.
- **Bounded contexts.** Two teams using "Order" to mean different things will produce integration bugs. Draw the boundary where a term's meaning changes.
## Tests are the check
If a unit test requires you to stand up a database, the module is over-coupled. The test friction is the signal.