Validate DDD Domain Boundaries

VerifiedCaution

Audit bounded contexts for cross-boundary imports, aggregate invariant violations, and repository pattern defects. Use as a CI gate or pre-merge check.

Sby Skills Guide Bot
DevelopmentIntermediate
8/29/2026
Claude Code
#ddd#bounded-context#architecture-validation#static-analysis#ci-gate

Recommended for

Automated summary

Audits a DDD codebase by detecting imports that cross bounded-context boundaries and flagging aggregate invariant, domain event, and repository issues.

Strengths

  • Concrete cross-context import check with an explicit allowance for a context's public index.ts application-layer entry point
  • Sorts findings into four categories (BOUNDARY, INVARIANT, EVENT, REPOSITORY) and reports a table with file path, line number, and suggestion
  • Emits an exit summary (total violations, per category, severity) that works as a CI gate
  • Persists the validation summary to claude-flow memory for later retrieval

Limitations

  • Assumes a fixed TypeScript layout under src/<context>/domain/; other structures or languages are not covered
  • Detection is grep- and pattern-based with no AST parsing, so re-exports or dynamic imports can produce false positives
  • Requires the claude-flow MCP tools (memory_store, hooks) for the result-storage step
When to use it

Use it to audit a DDD codebase before merging a cross-cutting change or to install an automated guard against boundary erosion.

When not to use it

Avoid it on non-DDD or non-TypeScript projects, or where the layout does not follow the expected src/<context>/domain/ convention.

Security analysis

Caution
Quality score78/100

The skill is fundamentally a read-only audit: it uses Grep/Read/Glob and shell `find`/`grep` loops to detect boundary violations, and never deletes, rewrites, or transmits repository contents. The main risk is the final step invoking `npx @claude-flow/cli@latest`, which executes unpinned remote code and is allowed unrestricted by the broad Bash grant. No secrets are exfiltrated, no destructive commands, no obfuscation. That places it at caution rather than risky.

Findings
  • •Step 7 runs `npx @claude-flow/cli@latest ...`, which downloads and executes an unpinned third-party package at runtime — a supply-chain risk with no version lock or integrity check.
  • •Broad Bash allowance combined with `npx ...@latest` means the executed code can change silently between runs; the skill itself does not constrain it to the memory/hooks subcommands.
  • •MCP memory tools can persist session results to a shared namespace (`tasks`), so any scanned code context stored there persists beyond the run (low sensitivity, but worth noting).
How this analysis is made

Examples

Pre-merge boundary audit
Run ddd-validate over src/ and tell me which bounded contexts have imports reaching directly into another context's domain/ folder before I merge this branch.
CI gate check
Use ddd-validate as a CI gate: categorize every violation as BOUNDARY, INVARIANT, EVENT or REPOSITORY, and give me the totals and severity summary.
Aggregate invariant review
Check our aggregate roots with ddd-validate: flag public setters that bypass validation and any child entities that are reachable without going through the root.

name: ddd-validate description: 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. argument-hint: "" allowed-tools: Bash Read Grep Glob mcp__plugin_ruflo-core_ruflo__memory_store mcp__plugin_ruflo-core_ruflo__memory_search mcp__plugin_ruflo-core_ruflo__hooks_pre-task mcp__plugin_ruflo-core_ruflo__hooks_post-task

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
    

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/validate-ddd-domain-boundaries-mte1lht2/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/validate-ddd-domain-boundaries-mte1lht2' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/validate-ddd-domain-boundaries-mte1lht2/download' --output '.skill-downloads/validate-ddd-domain-boundaries-mte1lht2/SKILL.md.part' && mv '.skill-downloads/validate-ddd-domain-boundaries-mte1lht2/SKILL.md.part' '.skill-downloads/validate-ddd-domain-boundaries-mte1lht2/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Bash Read Grep Glob mcp__plugin_ruflo-core_ruflo__memory_store mcp__plugin_ruflo-core_ruflo__memory_search mcp__plugin_ruflo-core_ruflo__hooks_pre-task mcp__plugin_ruflo-core_ruflo__hooks_post-task

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/validate-ddd-domain-boundaries-mte1lht2/SKILL.md' && test -s '.skill-downloads/validate-ddd-domain-boundaries-mte1lht2/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/ddd-validate' && cp -R '.skill-downloads/validate-ddd-domain-boundaries-mte1lht2' '.claude/skills/ddd-validate'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/validate-ddd-domain-boundaries-mte1lht2'

openskills read 'validate-ddd-domain-boundaries-mte1lht2'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/validate-ddd-domain-boundaries-mte1lht2/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills