check-context-communication
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "check-context-communication":https://skillpi.com/zh/skills/deepskill-cf2c871dc84e1ac3a7dc8d8c09d4a021c554e91fe4ea5b0b9bbb7814ad1ad33c。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
审计限界上下文之间的通信模式。检查上下文映射关系(共享内核、ACL、开放主机)、事件与直接调用方式,以及防腐层的使用情况。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 减记
- 实测状态
- 未测试
文件浏览
Frontmatter
name: check-context-communication
description: Audits Bounded Context communication patterns. Checks Context Map relationships (Shared Kernel, ACL, Open Host), event vs direct calls, and anti-corruption layer usage.Context Communication Audit
Analyze PHP code for proper Bounded Context communication following DDD Context Map patterns.
Detection Patterns
1. Direct Cross-Context Dependency
// CRITICAL: Order context directly uses User context internals
namespace App\Order\Application;
use App\User\Domain\User; // Cross-context import!
use App\User\Domain\UserRepository; // Cross-context import!
final readonly class CreateOrderUseCase
{
public function __construct(
private UserRepository $userRepo, // Depends on another context's repository
) {}
public function execute(CreateOrderCommand $command): void
{
$user = $this->userRepo->find($command->userId());
$order = Order::create($user->email(), $user->shippingAddress());
// Tight coupling — if User changes, Order breaks
}
}
// CORRECT: Anti-Corruption Layer
namespace App\Order\Infrastructure\ACL;
final readonly class UserProfileAdapter implements OrderContext\UserProfilePort
{
public function __construct(
private UserContextApi $userApi, // Interface, not concrete
) {}
public function getShippingInfo(UserId $userId): ShippingInfo
{
$userData = $this->userApi->getUserProfile($userId);
return new ShippingInfo( // Map to Order context's own model
address: Address::fromArray($userData['address']),
name: $userData['name'],
);
}
}
2. Shared Kernel Misuse
// ANTIPATTERN: Too much shared between contexts
namespace App\Shared\Domain;
class User { } // Full entity in Shared — too much!
class Order { } // Full entity in Shared — too much!
class Money { } // OK — genuine shared concept
class Currency { } // OK — genuine shared concept
class EventId { } // OK — infrastructure concern
// CORRECT: Minimal Shared Kernel
namespace App\Shared\Domain;
// Only truly shared, stable concepts
final readonly class Money { }
final readonly class Currency { }
final readonly class EventId { }
final readonly class AggregateId { }
3. Synchronous Cross-Context Call
// ANTIPATTERN: Synchronous call between contexts
namespace App\Order\Application;
final readonly class CompleteOrderUseCase
{
public function execute(CompleteOrderCommand $command): void
{
$order = $this->orderRepo->find($command->orderId());
$order->complete();
$this->orderRepo->save($order);
// Synchronous cross-context calls!
$this->inventoryService->reserve($order->items()); // Inventory context
$this->paymentService->capture($order->paymentId()); // Payment context
$this->shippingService->schedule($order->address()); // Shipping context
// If any fails → partial state + coupling
}
}
// CORRECT: Event-driven cross-context communication
final readonly class CompleteOrderUseCase
{
public function execute(CompleteOrderCommand $command): void
{
$order = $this->orderRepo->find($command->orderId());
$order->complete(); // Records OrderCompleted domain event
$this->orderRepo->save($order);
// Events dispatched asynchronously:
// OrderCompleted → InventoryContext (reserve)
// OrderCompleted → PaymentContext (capture)
// OrderCompleted → ShippingContext (schedule)
}
}
4. Missing Anti-Corruption Layer
// ANTIPATTERN: External API model used directly in domain
namespace App\Order\Domain;
use Stripe\PaymentIntent; // External API model in domain!
final class Payment
{
public function __construct(
private PaymentIntent $stripePayment, // Stripe model in domain
) {}
public function isSuccessful(): bool
{
return $this->stripePayment->status === 'succeeded'; // Coupled to Stripe
}
}
// CORRECT: ACL translates external to domain
namespace App\Order\Infrastructure\ACL;
final readonly class StripePaymentAdapter implements PaymentGateway
{
public function charge(Money $amount): PaymentResult
{
$intent = $this->stripe->paymentIntents->create([...]);
return PaymentResult::from( // Domain model
status: $this->mapStatus($intent->status),
transactionId: new TransactionId($intent->id),
);
}
private function mapStatus(string $stripeStatus): PaymentStatus
{
return match ($stripeStatus) {
'succeeded' => PaymentStatus::COMPLETED,
'requires_action' => PaymentStatus::PENDING,
default => PaymentStatus::FAILED,
};
}
}
5. Event Leaking Internal State
// ANTIPATTERN: Domain event exposes aggregate internals
final readonly class OrderCompleted implements DomainEvent
{
public function __construct(
public Order $order, // Full aggregate in event!
// Other contexts can access all internal state
) {}
}
// CORRECT: Event contains only necessary data
final readonly class OrderCompleted implements DomainEvent
{
public function __construct(
public OrderId $orderId,
public UserId $userId,
public Money $total,
public \DateTimeImmutable $occurredAt,
) {}
}
6. No Context Boundary in Namespace
// ANTIPATTERN: Flat structure without context boundaries
src/
├── Entity/
│ ├── User.php
│ ├── Order.php
│ └── Product.php // All entities mixed together!
├── Repository/
│ ├── UserRepository.php
│ └── OrderRepository.php
// CORRECT: Bounded Context boundaries in namespace
src/
├── UserManagement/ // Bounded Context
│ ├── Domain/
│ ├── Application/
│ └── Infrastructure/
├── OrderProcessing/ // Bounded Context
│ ├── Domain/
│ ├── Application/
│ └── Infrastructure/
Grep Patterns
# Cross-context imports
Grep: "use App\\\\[A-Z][a-z]+\\\\Domain" --glob "**/Application/**/*.php"
# Check if import is from different context than file's context
# Direct service calls across contexts
Grep: "Service->|Client->|Api->" --glob "**/Application/**/*UseCase.php"
# External models in domain
Grep: "use Stripe\\\\|use Twilio\\\\|use AWS\\\\|use Google\\\\" --glob "**/Domain/**/*.php"
# Full aggregate in events
Grep: "public.*Entity.*\$|public.*Aggregate.*\$" --glob "**/Domain/**/*Event*.php"
# Shared Kernel size
Glob: **/Shared/Domain/**/*.php
# Count files — if > 10, probably too much shared
# Missing ACL
Grep: "implements.*Port|implements.*Gateway" --glob "**/Infrastructure/ACL/**/*.php"
Severity Classification
| Pattern | Severity |
|---|---|
| Direct cross-context domain dependency | 🔴 Critical |
| External model in domain layer | 🔴 Critical |
| Synchronous cross-context calls | 🟠 Major |
| Oversized Shared Kernel | 🟠 Major |
| Event leaking aggregate internals | 🟠 Major |
| Missing ACL for external service | 🟡 Minor |
Context Map Patterns Reference
| Pattern | When to Use |
|---|---|
| Shared Kernel | Two teams co-own small shared model (Money, EventId) |
| Anti-Corruption Layer | Protect domain from external/legacy models |
| Open Host Service | Provide well-defined API for consumers |
| Published Language | Shared event schema (JSON Schema, Protobuf) |
| Customer/Supplier | Upstream provides, downstream consumes |
| Conformist | Downstream adopts upstream model (not recommended) |
Output Format
### Context Communication: [Description]
**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**Contexts:** [Source Context] → [Target Context]
**Pattern Violated:** [Context Map pattern]
**Issue:**
[Description of the communication violation]
**Impact:**
- Coupling between bounded contexts
- Cannot deploy/evolve contexts independently
**Code:**
```php
// Cross-context violation
Fix:
// Proper context communication
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供完整的 DDD 限界上下文通信审计能力,覆盖 Shared Kernel、ACL、事件驱动等核心模式
- 针对 PHP 开发者,解决微服务架构中的实际耦合问题
亮点
- 触发描述精准完整,覆盖多种上下文通信模式变体,边界清晰
待提升项
-
缺少 When to Use 显式章节 原报告严重程度:轻微
虽有 Context Map Patterns Reference,但未以标准 When to Use 章节命名
改进建议:建议增加显式的 When to Use 章节以提升规范性
亮点
- 结构清晰,Phase/步骤分明,包含多个端到端代码示例
- frontmatter 完整,单文件长度合理
亮点
- 提供具体 grep 命令用于自动化检测,严重性分类明确
- 输出格式标准化,便于集成到 CI/CD 流程
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。