Skip to content
Back to skills

Angular Architecture Shared Domain Library Contract

ASecurity

Audits and designs Angular shared domain libraries in Nx monorepos to keep reusable business concepts, entities, and policies isolated from UI, transport, and feature orchestration concerns.

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 2, 2026
businessangularapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned October 2, 2026

npx -y skills add janpereira-dev/ngAutoPilot --skill angular-architecture-shared-domain-library-contract --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Angular Architecture Shared Domain Library Contract?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Angular Architecture Shared Domain Library Contract
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/janpereira-dev-angular-architecture-shared-domain-library-contrac/badge)](https://www.skillsdirectory.com/skills/janpereira-dev-angular-architecture-shared-domain-library-contrac)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: angular-architecture-shared-domain-library-contract
description: "Audits and designs Angular shared domain libraries in Nx monorepos to keep reusable business concepts, entities, and policies isolated from UI, transport, and feature orchestration concerns."
license: MIT
metadata:
  ngautopilot-id: "angular.architecture.shared-domain-library-contract"
  ngautopilot-source: "skills/angular/architecture/shared-domain-library-contract/SKILL.md"
  ngautopilot-version: "0.10.0"
---


# Shared Domain Library Contract

## Purpose

Use this skill to audit or design Angular shared domain libraries in Nx monorepos.

A shared domain library must behave as a reusable source of business concepts, not as a dumping ground for UI helpers, transport adapters, or feature orchestration. It should expose entities, value objects, policies, rules, and domain-level invariants that can be shared across multiple features or data-access layers without leaking infrastructure or presentation concerns.

The core rule is simple:

```txt
Domain libraries define concepts and rules.
Data-access libraries implement transport and persistence.
Feature libraries orchestrate workflows.
UI libraries render and emit intent.
```

## When to Use

Use this skill when:

- creating a reusable `shared/domain` library
- reviewing entities, value objects, policy objects, or business rule modules
- auditing Nx dependency graph leaks in domain libraries
- a domain library imports Angular components, HTTP clients, routing, or feature state
- multiple features need the same stable business concepts
- a model is duplicated between feature and data-access libraries
- you need a clear boundary between business meaning and infrastructure shape

## Do

Keep shared domain pure and stable:

```ts
export interface Product {
  readonly id: string;
  readonly name: string;
  readonly isActive: boolean;
}

export function canArchiveProduct(product: Product): boolean {
  return product.isActive;
}
```

Prefer explicit value objects and rules:

```ts
export class Money {
  constructor(
    readonly amount: number,
    readonly currency: string,
  ) {}

  isSameCurrency(other: Money): boolean {
    return this.currency === other.currency;
  }
}
```

Keep domain contracts independent from Angular UI and transport details.

Example Nx project tags:

```json
{
  "name": "shared-domain",
  "projectType": "library",
  "root": "libs/shared/domain",
  "sourceRoot": "libs/shared/domain/src",
  "tags": ["type:domain", "domain:shared"]
}
```

Example ESLint boundaries:

```js
{
  files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
  rules: {
    '@nx/enforce-module-boundaries': [
      'error',
      {
        allow: [],
        depConstraints: [
          {
            sourceTag: 'type:domain',
            onlyDependOnLibsWithTags: ['type:domain', 'type:util']
          },
          {
            sourceTag: 'type:ui',
            onlyDependOnLibsWithTags: ['type:ui', 'type:util', 'domain:shared']
          },
          {
            sourceTag: 'type:data-access',
            onlyDependOnLibsWithTags: ['type:domain', 'type:util']
          }
        ]
      }
    ]
  }
}
```

## Do Not

Avoid Angular dependencies in domain libraries:

```ts
@Component({
  selector: 'lib-product-name',
  template: `{{ product.name }}`,
})
export class ProductNameComponent {}
```

Avoid HTTP, router, store, or feature orchestration in domain code:

```ts
private readonly http = inject(HttpClient);
this.router.navigate(['/products']);
```

Avoid DTO shape leakage when a stable business concept is needed instead.

## Review Checklist

- [ ] The library contains business concepts, rules, or policies rather than UI or transport logic.
- [ ] The library does not import Angular components or framework orchestration.
- [ ] The library does not depend on HTTP, router, store, or API clients.
- [ ] Domain concepts are stable and reusable across features.
- [ ] Public APIs are explicit and easy to version.
- [ ] Nx tags and boundaries prevent infrastructure or UI dependencies from leaking in.

## Expected Output

1. Classify the library as shared domain, feature, data-access, UI, or mixed.
2. Identify leaked transport or UI concerns.
3. Recommend pure domain abstractions where needed.
4. Separate stable business concepts from infrastructure DTOs.
5. Produce a refactor plan with validation steps and boundary checks.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…