Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)81k · #1616

ddd-validate

Skill này làm gì

Skill này kiểm tra một codebase theo domain-driven design để tìm rò rỉ ranh giới, tức là khi một lĩnh vực nghiệp vụ import file nội bộ của lĩnh vực khác. Nó dành cho nhóm muốn giữ cấu trúc mã gọn gàng.

Khi nào nên dùng

  • ✓Khi bạn muốn kiểm tra codebase xem có rò rỉ giữa các lĩnh vực nghiệp vụ không.
  • ✓Khi bạn sắp hợp nhất một thay đổi chạm vào nhiều lĩnh vực.
  • ✓Khi bạn muốn một kiểm tra tự động bắt sớm các vấn đề về ranh giới.

Liên kết skill

https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-ddd/skills/ddd-validate/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-ddd/skills/ddd-validate/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Hãy kiểm tra codebase của tôi xem có đoạn mã nào chạm vào file nội bộ của lĩnh vực khác không.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill tìm từng lĩnh vực nghiệp vụ, quét các file để tìm import đi vào thư mục nội bộ của lĩnh vực khác, rồi kiểm tra các quy tắc về entity, tên sự kiện và vị trí của repository. Sau đó nó báo cáo từng vấn đề tìm được.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Validate domain boundary integrity across all bounded contexts.

Steps

  1. Discover contexts: Scan src/*/domain/ to find all bounded contexts.

  2. Check cross-boundary violations:

    • For each context, scan all .ts files for import statements
    • Flag any import that reaches into another context's domain/ directory directly
    • Allowed: importing from another context's public index.ts (application layer)
    • Violation: importing from src/<other-context>/domain/entities/... directly
    # Find cross-boundary imports
    for ctx in $(find src -maxdepth 2 -name "domain" -type d | sed 's|src/||;s|/domain||'); do
      grep -rn "from ['\"].*src/" "src/$ctx/" --include="*.ts" | grep -v "src/$ctx/" || true
    done
    
  3. Check aggregate invariant enforcement:

    • Scan aggregate root entities for public setters that bypass validation
    • Flag mutable public properties without invariant checks
    • Verify that child entities are not directly accessible (must go through aggregate root)
  4. Check event naming conventions:

    • Domain events should be past-tense named (e.g., OrderCreated, not CreateOrder)
    • Events should be immutable (no public setters)
    • Events should carry the aggregate ID
  5. Check repository patterns:

    • Repository interfaces should exist in domain/repositories/, not infrastructure/
    • Repository implementations should exist in infrastructure/, not domain/
    • Each aggregate root should have exactly one repository
  6. Report findings:

    • Output a table of violations with file path, line number, violation type, and suggestion
    • Categorize as: BOUNDARY, INVARIANT, EVENT, REPOSITORY
    • Exit with summary: total violations, by category, severity
  7. Store results:

    npx @claude-flow/cli@latest memory store --key "ddd-validation-TIMESTAMP" --value "RESULTS_SUMMARY" --namespace tasks
    npx @claude-flow/cli@latest hooks post-task --task-id "ddd-validate" --success true --store-results true
    
Câu hỏi thường gặp

Thế nào là vi phạm?

Import đi thẳng vào thư mục miền của lĩnh vực khác sẽ bị đánh dấu. Import từ index công khai của lĩnh vực khác thì được phép.

Skill có tự sửa lỗi không?

Các bước tập trung vào việc tìm và báo cáo vấn đề, nên bạn hãy xem báo cáo và quyết định cần sửa gì.

Quy tắc đặt tên nào áp dụng cho sự kiện?

Sự kiện miền nên đặt ở thì quá khứ, ví dụ OrderCreated thay vì CreateOrder.

Chi tiết

Mô tả gốc của tác giả

Validate domain boundaries -- detect cross-context import violations and aggregate invariant issues. Use when auditing a DDD codebase for leaks between bounded contexts, before merging cross-cutting changes, or as a CI gate to catch boundary erosion early.

repo: ruvnet/ruflo

Độ phổ biến

Sao GitHub
81k
Vị trí xếp hạng
#1616
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự