check-bounded-contexts

Analyze bounded context boundaries in a DDD project. Detect cross-context coupling, shared kernel violations, context mapping issues, and ubiquitous language inconsistencies, and generate a context mapping diagram with boundary recommendations.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "check-bounded-contexts" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-db7d5127c843a53e55b594e1e9f0f79b5a1201529cf4c4c569efa13f319017d4. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Analyze bounded context boundaries in a DDD project. Detect cross-context coupling, shared kernel violations, context mapping issues, and ubiquitous language inconsistencies, and generate a context mapping diagram with boundary recommendations.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Analyzes bounded context boundaries in DDD projects. Detects cross-context coupling, shared kernel violations, context mapping issues, and ubiquitous language inconsistencies. Generates context map diagrams and boundary recommendations.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: check-bounded-contexts
description: Analyzes bounded context boundaries in DDD projects. Detects cross-context coupling, shared kernel violations, context mapping issues, and ubiquitous language inconsistencies. Generates context map diagrams and boundary recommendations.

Bounded Contexts Analyzer

Overview

This skill analyzes PHP DDD projects for bounded context boundary issues, cross-context coupling, and context mapping violations.

Bounded Context Concepts

Concept Definition Violation Indicator
Bounded Context Explicit boundary with its own domain model Missing namespace separation
Ubiquitous Language Consistent terminology within context Same term, different meanings
Context Map Relationships between contexts Unclear dependencies
Anti-Corruption Layer Translation between contexts Direct foreign model usage
Shared Kernel Deliberately shared code Unintentional sharing
Published Language Public API contracts Breaking changes

Detection Patterns

Phase 1: Context Discovery

# Identify bounded contexts from directory structure
Glob: **/src/**/Domain/*
Glob: **/src/**/Context/*
Glob: **/src/**/Bounded/*
Glob: **/src/**/Module/*

# Namespace-based contexts
Grep: "namespace.*\\\\Domain\\\\|namespace.*\\\\Context\\\\" --glob "**/*.php"

# Composer autoload namespaces
Read: composer.json (check autoload paths for context namespaces)

Context Indicators:

  • Top-level namespace under src/ (e.g., Order, User, Payment)
  • Explicit Domain/ subfolder per context
  • BoundedContext/ or Context/ folder structure

Phase 2: Cross-Context Coupling Detection

Direct Cross-Context Imports

# Find cross-context imports (most critical)
# Pattern: Context A importing from Context B's Domain layer

# Order context importing User domain
Grep: "use Order\\\\.*\\\\Domain" --glob "**/User/**/*.php"
Grep: "use User\\\\.*\\\\Domain" --glob "**/Order/**/*.php"

# General pattern: Domain layer importing another Domain
Grep: "use [A-Z][a-z]+\\\\Domain\\\\" --glob "**/Domain/**/*.php"

# Direct entity references across contexts
Grep: "use.*\\\\Entity\\\\(?!.*\\\\self)" --glob "**/Domain/**/*.php"

Foreign Aggregate References

# Aggregates referencing foreign entities directly
Grep: "private.*[A-Z][a-z]+Entity\|private readonly [A-Z][a-z]+" --glob "**/Aggregate/**/*.php"

# Should use ID references only
# Good: private UserId $userId
# Bad: private User $user (from another context)

# Detect direct object references vs ID references
Grep: "\\$user[^I]|\\$order[^I]|\\$customer[^I]" --glob "**/Domain/**/*.php"

Shared Repository Usage

# Repository from one context used in another
Grep: "UserRepositoryInterface" --glob "**/Order/**/*.php"
Grep: "OrderRepositoryInterface" --glob "**/User/**/*.php"

# Generic repository pattern violations
Grep: "RepositoryInterface" --glob "**/*.php"
# Check if implementations span contexts

Phase 3: Shared Kernel Analysis

# Identify potential shared kernel (common code between contexts)
Glob: **/Shared/**/*.php
Glob: **/Common/**/*.php
Glob: **/Core/**/*.php
Glob: **/SharedKernel/**/*.php

# Find duplicated Value Objects across contexts
# Same class name in multiple contexts
Glob: **/Domain/**/Email.php
Glob: **/Domain/**/Money.php
Glob: **/Domain/**/Address.php

# Shared events
Grep: "class.*Event.*implements|extends.*Event" --glob "**/Shared/**/*.php"

Shared Kernel Rules:

  • Must be explicitly designated
  • Minimal and stable
  • Changes require agreement from all context owners
  • Should contain only Value Objects, not Entities

Phase 4: Context Map Relationships

Upstream/Downstream Detection

# Event publishers (upstream)
Grep: "EventDispatcher|MessageBus|publish\(" --glob "**/Domain/**/*.php"
Grep: "class.*Event\s*\{|final readonly class.*Event" --glob "**/Domain/**/*.php"

# Event subscribers (downstream)
Grep: "EventSubscriber|MessageHandler|Listener" --glob "**/*.php"
Grep: "function __invoke\(.*Event" --glob "**/*.php"

# Check which context publishes and which subscribes

Customer/Supplier Relationships

# API clients (customer role)
Grep: "ApiClient|HttpClient|RestClient" --glob "**/Infrastructure/**/*.php"

# API providers (supplier role)
Grep: "Controller|Action|Endpoint" --glob "**/Presentation/**/*.php"

Anti-Corruption Layer Detection

# ACL presence
Glob: **/AntiCorruption/**/*.php
Glob: **/ACL/**/*.php
Glob: **/Adapter/**/*.php
Glob: **/Translator/**/*.php

# Missing ACL (direct external model usage)
Grep: "use External\\\\|use ThirdParty\\\\|use Legacy\\\\" --glob "**/Domain/**/*.php"

Phase 5: Ubiquitous Language Analysis

# Find same term with different meanings
# Example: "Account" in User context vs Payment context

# Find class with same name in different contexts
Glob: **/User/**/Account.php
Glob: **/Payment/**/Account.php
Glob: **/Billing/**/Account.php

# Find similar entity names
Glob: **/Domain/**/User.php
Glob: **/Domain/**/Customer.php
Glob: **/Domain/**/Client.php

# Inconsistent naming
Grep: "class Order|class Purchase|class Sale" --glob "**/Domain/**/*.php"

Report Format

# Bounded Context Analysis Report

## Context Map

```mermaid
graph TB
    subgraph "Order Context"
        O_Domain[Domain]
        O_App[Application]
    end

    subgraph "User Context"
        U_Domain[Domain]
        U_App[Application]
    end

    subgraph "Payment Context"
        P_Domain[Domain]
        P_App[Application]
    end

    subgraph "Shared Kernel"
        SK[Money, Currency]
    end

    O_Domain -->|"uses ID only"| U_Domain
    O_Domain -->|"publishes events"| P_Domain
    O_Domain --> SK
    U_Domain --> SK
    P_Domain --> SK

Detected Contexts

Context Location Entities Events Dependencies
Order src/Order/ 5 8 User (ID), Payment (event)
User src/User/ 3 4 None
Payment src/Payment/ 4 6 Order (event)
Shared src/Shared/ 0 0 All contexts

Critical Issues

BC-001: Cross-Context Entity Reference

  • File: src/Order/Domain/Entity/Order.php:15
  • Issue: Direct reference to User entity instead of UserId
  • Code: private User $user (from User context)
  • Expected: private UserId $userId
  • Impact: Tight coupling, breaks context isolation
  • Refactoring: Replace with ID reference, use ACL if needed
  • Skills: create-value-object (for UserId), create-anti-corruption-layer

BC-002: Missing Anti-Corruption Layer

  • File: src/Payment/Infrastructure/Gateway/StripeGateway.php
  • Issue: Stripe models used directly in domain
  • Code: use Stripe\PaymentIntent;
  • Impact: External API changes affect domain
  • Refactoring: Create PaymentIntent adapter/translator
  • Skills: create-anti-corruption-layer

BC-003: Unintended Shared Kernel

  • Files:
    • src/Order/Domain/ValueObject/Address.php
    • src/User/Domain/ValueObject/Address.php
  • Issue: Duplicated Address VO without explicit sharing
  • Impact: Inconsistent behavior, maintenance burden
  • Refactoring: Either consolidate to Shared Kernel or differentiate
  • Skills: create-value-object

Warning Issues

BC-004: Ambiguous Ubiquitous Language

  • Context 1: src/User/ uses Account for user profile
  • Context 2: src/Payment/ uses Account for financial account
  • Issue: Same term, different meanings
  • Refactoring: Rename to UserProfile and PaymentAccount

BC-005: Missing Published Language

  • Context: Order
  • Issue: No explicit contract for inter-context communication
  • Events published: 8
  • Documented: 0
  • Refactoring: Create event schema documentation

BC-006: Upstream Without Events

  • Context: User (upstream)
  • Downstream: Order, Payment (via direct queries)
  • Issue: Downstream contexts query User directly
  • Refactoring: User should publish events, downstreams react

Context Relationship Matrix

From \ To Order User Payment Shared
Order - ID ref Events Uses
User - - - Uses
Payment Queries Queries - Uses
Shared - - - -

Legend:

  • ID ref: References only by ID (good)
  • Events: Async event communication (good)
  • Queries: Direct query (warning)
  • Uses: Shared kernel usage (acceptable)

Recommendations

Immediate Actions

  1. Replace direct entity references with ID Value Objects
  2. Add ACL for external service integrations

Short-term

  1. Document published language (event contracts)
  2. Consolidate or differentiate duplicated VOs

Long-term

  1. Consider event-driven communication between contexts
  2. Review shared kernel scope

Context Integration Patterns

Recommended Patterns

Pattern When to Use Skills
ID Reference Entity association across contexts create-value-object
Domain Events Async communication create-domain-event
ACL External systems, legacy create-anti-corruption-layer
Shared Kernel Common VOs (Money, etc.) create-value-object
Published Language Public contracts Documentation

Anti-patterns

Anti-pattern Issue Remediation
Direct Entity Reference Tight coupling Use ID + resolve via query
Shared Entities Ownership unclear Split or explicit ownership
Cross-Context Repository Boundary violation Use events or ACL
Synchronous Cross-Context Calls Temporal coupling Use async events

Quick Analysis Commands

# Detect bounded contexts
echo "=== Bounded Contexts ===" && \
find src -maxdepth 2 -type d -name "Domain" && \
echo "=== Cross-Context Imports ===" && \
for ctx in $(find src -maxdepth 1 -type d | tail -n +2); do \
  name=$(basename $ctx); \
  grep -rn "use .*\\\\Domain\\\\" --include="*.php" "$ctx" | grep -v "use $name"; \
done && \
echo "=== Shared Kernel ===" && \
find src -type d -name "Shared" -o -name "Common" -o -name "Core"

Integration

Works with:

  • ddd-auditor — Domain model quality
  • structural-auditor — Layer violations
  • ddd-generator — Generate missing components

References

  • "Domain-Driven Design" (Eric Evans) — Chapter 14: Context Mapping
  • "Implementing Domain-Driven Design" (Vaughn Vernon) — Chapter 3: Context Maps
  • Strategic DDD patterns documentation

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value68/100

Highlights

  • 针对 DDD 架构中的限界上下文边界提供专业分析,解决实际工程痛点
  • 功能完整,涵盖上下文发现、耦合检测、共享内核分析、上下文映射和通用语言一致性检查
Trigger Precision92/100

Highlights

  • description 清晰准确,明确说明技能功能和输出(生成上下文映射图和边界建议)
  • 触发词覆盖全面,边界定义清晰,无歧义
Structure and Standards95/100

Highlights

  • 文档结构完整,分阶段(Phase)组织检测逻辑,步骤清晰
  • 包含丰富的代码示例、表格说明和 mermaid 图示,易于理解
  • frontmatter 完整,符合规范
Execution Reliability78/100

Areas to improve

  • 缺少对 shell 命令执行失败的错误处理 Reported severity: Minor

    提供的检测命令(如 grep、find)未处理文件不存在、无匹配结果或权限错误等异常情况

    Recommendation: 建议在文档中补充错误处理说明,或在实际实现中添加 try-catch 或条件检查

Highlights

  • 检测逻辑基于标准 shell 命令和 PHP 项目结构,工具来源明确
  • 覆盖了跨上下文耦合、共享内核违规、上下文映射等核心问题场景
Evidence Verifiability (mean of the first four)83/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.