---
name: service-boundaries
description: Use for service boundaries, bounded capabilities, modular monoliths, microservices, monolith decomposition, data ownership, shared databases, API coupling, anti-corruption layers, and architecture topology decisions.
title: service-boundaries
canonical_url: https://skilld.dev/gh/eralmansouri/skills/service-boundaries
last_updated: 2026-10-07T21:03:15.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install eralmansouri/skills/service-boundaries`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/service-boundaries`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/eralmansouri/skills/service-boundaries) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/service-boundaries`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/service-boundaries --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/service-boundaries --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Service Boundaries

Design logical ownership before physical topology. A service is the authority
over a cohesive set of business capabilities and the data needed to perform
them. Repositories, containers, processes, and databases do not prove that a
useful boundary exists.

## Decision Workflow

1. Name the measurable outcome: release autonomy, failure isolation, security, throughput, team ownership, or cost.
2. Map business capabilities, workflows, language, rules, state transitions, and authoritative decisions.
3. Identify candidate boundaries by cohesion, lifecycle, ownership, and reasons to change.
4. Verify that commands can usually be decided with locally owned data.
5. Map dependencies in both directions and classify their coupling.
6. Test whether a monolith plus ordinary scaling solves the stated constraint.
7. Price distribution: latency, partial failure, contracts, deployment, observability, consistency, and support.
8. Choose monolith, modular monolith, services, or a hybrid per capability.
9. Extract only a boundary with a concrete beneficiary and sufficiently stable ownership.
10. Record the context, alternatives, consequences, and triggers for reconsideration.

## Boundary Rules

- Start with behavior and business decisions, not tables or entity nouns.
- One logical owner controls each state transition and authoritative write.
- Ownership includes meaning, rules, lifecycle, behavior, and supporting data.
- The same identity may have different purpose-specific models in different boundaries.
- Keep logical and physical boundaries separate; several modules may share a deployment or database instance.
- Prevent modules from reading or writing one another's internal schemas by default.
- Enforce module dependency rules with an architecture test or dependency linter, and confirm it fails on a deliberate violation.
- Use public APIs and events as translated contracts, not serialized domain or persistence models.
- Use an anti-corruption layer when external semantics differ from the receiving context.
- Treat all communication styles as forms of coupling with different costs.
- Prefer incremental, reversible extraction over wholesale decomposition.

## Validate A Candidate Boundary

A strong boundary:

- Owns cohesive behavior with a narrow business reason to change.
- Owns its rules, lifecycle, state transitions, and authoritative writes.
- Can decide most commands using local data.
- Exposes explicit contracts rather than its internal schema.
- Can evolve without coordinated changes across many consumers.
- Participates in wider workflows through explicit handoffs.
- Can change deployment topology without redefining its purpose.

Repeated synchronous lookups, shared mutable entities, growing event payloads,
cross-boundary transactions, and coordinated releases are warning signals.

## Topology Heuristic

| Situation | Default |
| --- | --- |
| Small team, uncertain domain, frequent boundary changes | Monolith |
| Clear capability ownership without proven deployment need | Modular monolith |
| Proven independent release, scale, isolation, or ownership need | Independently deployed service |
| Different needs by capability | Hybrid |

## Communication Choices

| Mechanism | Use when | Main cost |
| --- | --- | --- |
| In-process call | Same deployment and immediate result | Technology and behavioral coupling |
| HTTP or gRPC | Immediate answer or external integration | Temporal, latency, availability, and contract coupling |
| Queue command | Deferred directed work or buffering | Delivery, idempotency, failure, and operations |
| Pub/sub event | Independent reactions to a fact | Semantic, schema, broker, and publication coupling |
| Shared database | Deliberately coupled local system | Strong schema and change coupling |

No mechanism removes coupling. Choose the form whose failure and evolution
costs match the business requirement.

## Data And Evolution

For a query, decide among client composition, a backend-for-frontend, owner
APIs, or a purpose-built projection. For a command decision, first try to move
the decision and required data into one ownership and transaction boundary.

Treat replicated state as a cache or projection, never co-authority. Define its
freshness, rebuild path, and failure behavior. A synchronous lookup can still be
stale before the caller commits.

Sharing a physical database is acceptable when schemas have clear owners and
permissions enforce access. Separate databases add value for isolation,
scaling, technology, security, backup, or organizational ownership; they are
not a ceremonial requirement.

Evolve incrementally: discover boundaries in the current deployment, establish
module contracts and owner-only writes, select one capability with a proven
deployment benefit, map dependencies, move communication and data gradually,
and protect old and new semantics through translation. Consolidation is also a
valid architectural evolution.

## Avoid

- One service or module per table/entity.
- A universal customer, product, or employee model.
- Cross-schema joins and writes hidden inside a modular monolith.
- HTTP or a broker used to disguise a distributed dependency graph.
- RPC chains across independently deployed services.
- Copying entire authoritative tables into every consumer.
- Coordinated releases among supposedly autonomous services.
- Infrastructure for hypothetical scale without a named beneficiary.

## Review Checklist

- What measurable outcome does this topology serve?
- Are logical and physical boundaries documented separately?
- What capability, rules, and data does each boundary own?
- Can each command be decided with locally authoritative data?
- Who may read and write each schema?
- Which calls create latency or availability chains?
- What consistency does the business actually require?
- What coupling was removed, and what coupling replaced it?
- Are public events and APIs stable translated contracts?
- Can a capability change without coordinated releases?
- Does independent deployment repay its operational cost?
- Is extraction incremental and reversible?
- What evidence would trigger extraction, consolidation, or redesign?
