Apply mergegate's architecture (domain ownership, ports and adapters, dependency boundaries) when adding or changing code, crates, adapters, or dependencies. Use before deciding where code lives or what it may depend on.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Architecture?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/damian-kolasinski-architecture)
---
name: architecture
description: Apply mergegate's architecture (domain ownership, ports and adapters, dependency boundaries) when adding or changing code, crates, adapters, or dependencies. Use before deciding where code lives or what it may depend on.
---
# Architecture
mergegate is one Rust binary, `mg` (hub daemon and CLI), with a web UI embedded in it. `mergegate` is `mg` under a name nothing else takes, for PATHs where macOS's `/usr/bin/mg` editor comes first: a release ships it as a copy of `mg`, and a source build gets `crates/cli/src/bin/mergegate.rs`, which runs the `mg` beside it. Code is organized as ports and adapters, and the crate graph enforces the boundaries.
## Rules
- Domain logic goes in `core`. `core` has no I/O: no async runtime, network, filesystem, subprocess, database or git crates.
- `core` depends on no other workspace crate, `api` included, and has no serde: it doesn't know the wire format.
- `core` reaches every external system through a port trait it defines. Check the existing ports before adding one; a new external system means a new port or an extension of an existing one.
- Define ports from the perspective of the domain logic. Do not reshape domain logic to fit an adapter.
- Adapters depend on `core` and `api` only, never on each other. Wiring happens only in `hub` and `cli`.
- Wire types live in `api`. TypeScript types are generated from them; never hand-write API types in `ui/`. A type the UI reads gets `#[cfg_attr(feature = "ts", derive(ts_rs::TS), ts(export))]`.
- The edge maps domain to wire: `core` defines its own types, and the `hub` route module or `cli` command that serves them converts to and from `api`.
- Adapters are chosen per project through config, optional ones sit behind cargo features, and third-party extensions run out of process (JSON over stdio).
- Expensive work runs when data arrives and is cached; request paths only read.
- Build a new slice the way existing slices are built.
- Web features own their behavior; the application shell wires features without owning them. Styling uses the shared design system.
- Edit colors and typography in `appearance/tokens.json` and syntax colors in `appearance/syntax.json`, then run `python3 appearance/generate.py` to regenerate the web's tokens.
## Dependencies
Choose for runtime speed and correctness, not human ergonomics. Before adding a crate or package, check that it is maintained, that it doesn't pull I/O into `core`, and that it doesn't add work to the CLI's startup path.
## Before finishing
- The code lives in the slice that owns the behaviour.
- `core` gained no I/O dependency and no `api` import; no adapter imports another adapter. `crates/testkit/tests/boundaries.rs` checks the crate graph.
- This skill reflects any change to the architectural rules above.