Inferensys

Prompt

Domain Model Consistency Check Prompt

A practical prompt playbook for using the Domain Model Consistency Check Prompt in production AI workflows to identify conflicting rules, duplicate concepts, and invariant violations across domain boundaries.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the job-to-be-done, required inputs, and boundaries for the Domain Model Consistency Check Prompt.

Domain architects and engineering leads use this prompt to validate that domain models remain consistent across multiple aggregates and bounded contexts before implementation diverges. The job-to-be-done is a structured design-time review that catches conflicting business rules, duplicate concepts, and invariant violations that would otherwise surface as production incidents, integration failures, or contradictory service behavior. This prompt assumes you have documented aggregate definitions, business rules, invariants, and context boundaries—it does not infer these from code or runtime traces.

Use this prompt when teams report conflicting behavior between services, when merging bounded contexts, when conducting a pre-implementation design review for a new feature that spans contexts, or when auditing an existing system for domain model drift. The prompt works best with concrete artifacts: aggregate root definitions, method signatures with preconditions and postconditions, context map diagrams, domain event schemas, and explicit invariant statements. Without these inputs, the model will generate plausible but ungrounded analysis that may miss real conflicts or flag false positives.

Do not use this prompt for runtime data validation, code-level linting, single-aggregate design reviews, or database schema consistency checks. It is not a substitute for integration tests, contract tests, or static analysis tools. The output is a structured consistency report that flags conflicts, duplicates, and invariant violations with severity ratings and remediation guidance—but it requires human review before acting on high-severity findings. For regulated domains, always pair this prompt with a manual architecture review and document the evidence sources used in the analysis.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Domain Model Consistency Check prompt delivers high-signal findings and where it creates noise or false confidence.

01

Good Fit: Multi-Context Refactors

Use when: you are planning a refactor that spans multiple bounded contexts or aggregates and need to surface conflicting rules before code changes begin. Guardrail: run the check against the proposed target model, not just the current state, to catch migration-incompatible invariants.

02

Good Fit: Pre-ADR Consistency Audit

Use when: an architecture decision record proposes a new aggregate, event, or context relationship. Guardrail: attach the ADR draft and the affected context definitions as input so the prompt can flag contradictions between the decision rationale and existing model rules.

03

Bad Fit: Single-Aggregate Micro-Optimization

Avoid when: the scope is a single aggregate with no cross-boundary invariants. The prompt will over-report trivial naming differences as conflicts. Guardrail: use the Aggregate Root Design Validation prompt instead for single-aggregate reviews.

04

Bad Fit: Undocumented Legacy Systems

Avoid when: no canonical domain model artifacts exist and the prompt must infer rules from code comments or tribal knowledge. Guardrail: run the Bounded Context Discovery from Legacy Code prompt first to produce structured context definitions, then feed those into this consistency check.

05

Required Inputs

Risk: incomplete or stale context definitions produce false positives and missed invariant violations. Guardrail: require at minimum a bounded context map, aggregate definitions with invariants, and domain event schemas for all contexts in scope. Reject runs with placeholder or auto-generated artifacts.

06

Operational Risk: False Consensus

Risk: the prompt reports consistency where teams have aligned on the same wrong abstraction, masking deeper modeling errors. Guardrail: pair the consistency report with a human-facilitated domain walkthrough. Never treat a clean consistency score as proof of correctness.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A ready-to-use prompt that instructs the model to produce a structured domain model consistency report identifying conflicts, duplicates, and invariant violations across aggregates and bounded contexts.

The following prompt template is designed to be copied directly into your AI workflow. It expects you to provide your domain artifacts—such as aggregate definitions, context maps, domain event schemas, and business rules—in the designated placeholders. The model will analyze these artifacts and produce a structured consistency report that flags conflicting rules, duplicate concepts, and invariant violations that cross aggregate or context boundaries. This report serves as a pre-implementation design review artifact, catching misaligned mental models before they become incompatible code.

text
You are a domain architecture reviewer specializing in Domain-Driven Design consistency analysis. Your task is to examine the provided domain artifacts and produce a structured consistency report.

## INPUT ARTIFACTS

### Aggregate Definitions
[Aggregate definitions with root entities, child entities, value objects, and invariants for each aggregate]

### Bounded Context Map
[Context map showing bounded contexts, their relationships, translation layers, and integration patterns]

### Domain Event Schemas
[Domain event definitions including event names, payloads, producers, consumers, and versioning information]

### Business Rules and Invariants
[Cross-aggregate and cross-context business rules, consistency requirements, and transactional boundaries]

### Ubiquitous Language Glossary
[Canonical terms, definitions, synonyms, and deprecated terms across all contexts]

## OUTPUT SCHEMA

Produce a JSON object with the following structure:

{
  "report_summary": {
    "total_conflicts": <number>,
    "total_duplicates": <number>,
    "total_invariant_violations": <number>,
    "overall_severity": "LOW" | "MEDIUM" | "HIGH" | "CRITICAL",
    "review_recommendation": "PROCEED" | "REVIEW_REQUIRED" | "BLOCKED"
  },
  "conflicts": [
    {
      "id": "CONF-<number>",
      "severity": "LOW" | "MEDIUM" | "HIGH" | "CRITICAL",
      "description": "<clear description of the conflict>",
      "affected_artifacts": ["<artifact name and location>"],
      "conflicting_rules": ["<rule A>", "<rule B>"],
      "impact": "<what breaks if this conflict is not resolved>",
      "resolution_suggestion": "<actionable recommendation>"
    }
  ],
  "duplicates": [
    {
      "id": "DUP-<number>",
      "severity": "LOW" | "MEDIUM" | "HIGH",
      "concept_name": "<the duplicated concept>",
      "locations": ["<context or aggregate where it appears>"],
      "differences": "<how the definitions diverge>",
      "canonical_source": "<which location should be authoritative>",
      "resolution_suggestion": "<how to consolidate>"
    }
  ],
  "invariant_violations": [
    {
      "id": "INV-<number>",
      "severity": "LOW" | "MEDIUM" | "HIGH" | "CRITICAL",
      "invariant": "<the invariant being violated>",
      "owning_aggregate": "<aggregate responsible for the invariant>",
      "violation_path": "<how the invariant can be broken across boundaries>",
      "affected_contexts": ["<context names>"],
      "resolution_suggestion": "<how to protect the invariant>"
    }
  ],
  "terminology_issues": [
    {
      "id": "TERM-<number>",
      "term": "<the ambiguous term>",
      "contexts": ["<contexts where it appears with different meanings>"],
      "meanings": ["<meaning in context A>", "<meaning in context B>"],
      "risk": "<what misunderstanding this causes>",
      "resolution_suggestion": "<disambiguation strategy>"
    }
  ],
  "integration_gaps": [
    {
      "id": "GAP-<number>",
      "severity": "LOW" | "MEDIUM" | "HIGH" | "CRITICAL",
      "contexts_involved": ["<context A>", "<context B>"],
      "missing_integration": "<what integration pattern or translation is absent>",
      "data_consistency_risk": "<what data becomes stale or inconsistent>",
      "resolution_suggestion": "<recommended integration pattern>"
    }
  ]
}

## CONSTRAINTS

- Only report issues you can trace to specific artifacts provided in the input. Do not invent problems.
- For each finding, cite the specific artifact, rule, or definition that supports the finding.
- If no issues are found in a category, return an empty array for that category.
- Severity ratings: LOW (cosmetic or documentation-only), MEDIUM (operational friction but no data corruption), HIGH (potential data inconsistency or incorrect behavior), CRITICAL (guaranteed data corruption or system failure).
- If the input artifacts are insufficient to complete the analysis, return a partial report and include a `limitations` array explaining what is missing.

## EXAMPLES

### Example Conflict
{
  "id": "CONF-001",
  "severity": "HIGH",
  "description": "Order aggregate requires PaymentConfirmed event before shipping, but Shipping context ships on OrderPlaced event without checking payment status.",
  "affected_artifacts": ["Order aggregate invariants", "Shipping context event handler"],
  "conflicting_rules": ["Orders must not ship before payment confirmation", "Shipping processes all OrderPlaced events immediately"],
  "impact": "Unpaid orders can be shipped, causing revenue loss and reconciliation overhead.",
  "resolution_suggestion": "Add PaymentConfirmed event as a precondition in the Shipping context's ship-order policy, or introduce a Saga that coordinates the full order-to-shipment flow."
}

### Example Duplicate
{
  "id": "DUP-001",
  "severity": "MEDIUM",
  "concept_name": "Customer Credit Limit",
  "locations": ["Billing context - Customer aggregate", "Ordering context - Buyer aggregate"],
  "differences": "Billing calculates credit limit from payment history; Ordering stores a static credit_limit field that is manually updated.",
  "canonical_source": "Billing context - Customer aggregate",
  "resolution_suggestion": "Remove the static credit_limit field from Ordering. Ordering should query Billing via an Anti-Corruption Layer or consume CreditLimitUpdated events."
}

## RISK LEVEL
[RISK_LEVEL: LOW | MEDIUM | HIGH | CRITICAL]

If RISK_LEVEL is HIGH or CRITICAL, flag all findings for human review and include a `human_review_required` boolean in the report_summary set to true.

To adapt this prompt for your domain, replace each square-bracket placeholder with your actual artifacts. The [Aggregate definitions] placeholder should contain your aggregate root definitions, child entities, value objects, and the invariants each aggregate enforces. The [Bounded Context Map] placeholder expects your context map showing relationships, translation layers, and integration patterns between contexts. For [Domain Event Schemas], include event names, payload structures, producer contexts, consumer contexts, and any versioning information. The [Business Rules and Invariants] placeholder should capture cross-aggregate and cross-context rules that span boundaries. The [Ubiquitous Language Glossary] should list canonical terms alongside any known synonyms or deprecated terms. Finally, set [RISK_LEVEL] to reflect the operational risk of your domain—use HIGH or CRITICAL for financial, healthcare, or safety-critical systems to ensure findings are flagged for mandatory human review.

Before integrating this prompt into a production pipeline, validate the output against the expected JSON schema. A common failure mode is the model producing findings without citing specific artifacts—if the affected_artifacts or locations fields are empty or vague, treat the finding as low-confidence and flag it for human verification. Another failure mode is severity inflation, where the model marks every issue as HIGH or CRITICAL. Calibrate severity by spot-checking a sample of findings against your team's actual operational experience. For high-risk domains, always require a domain expert to review the consistency report before acting on its recommendations. The prompt is a design review accelerator, not a replacement for architectural judgment.

IMPLEMENTATION TABLE

Prompt Variables

Each placeholder required for the Domain Model Consistency Check Prompt. Validate these inputs before execution to prevent hallucinated model analysis.

PlaceholderPurposeExampleValidation Notes

[AGGREGATE_DEFINITIONS]

Structured list of aggregates with their entities, value objects, invariants, and root identifiers

Order (root: OrderId) with invariants: Total = sum(LineItem totals), Status transitions: Pending -> Confirmed -> Shipped

Schema check: each aggregate must have a root identifier, at least one invariant, and a list of child entities or value objects. Reject if empty or missing root.

[BOUNDED_CONTEXT_MAP]

Relationships between bounded contexts including partnership, customer-supplier, conformist, ACL, open host, or published language

Ordering Context -> Inventory Context: Customer-Supplier (upstream: Inventory). ACL present for InventoryItem translation.

Schema check: each relationship must specify upstream and downstream contexts, relationship type from DDD taxonomy, and whether an ACL exists. Reject if relationship type is unrecognized.

[DOMAIN_EVENT_CATALOG]

All domain events published across contexts with their schemas, producers, consumers, and ordering guarantees

OrderPlaced {orderId, customerId, lineItems, timestamp} produced by Ordering Context, consumed by Fulfillment and Billing contexts. At-least-once delivery.

Schema check: each event must have a name, producer context, at least one consumer context, and a payload schema. Flag events with no consumers as potential dead events.

[UBIQUITOUS_LANGUAGE_GLOSSARY]

Canonical terms with definitions, synonyms, deprecated terms, and owning context for each domain concept

Customer: in Ordering Context means a registered buyer with payment method. In Support Context means any person with a support ticket. Synonym: Buyer (deprecated in Ordering).

Schema check: each term must have a definition and owning context. Flag terms with conflicting definitions across contexts as high-priority review targets. Null allowed if glossary is incomplete.

[INVARIANT_RULES]

Explicit business rules that must hold true across one or more aggregates, with scope and enforcement context

An Order cannot be Confirmed if any LineItem references a Product marked as Discontinued. Scope: Ordering Context. Enforced in Order.Confirm().

Schema check: each rule must have a condition statement and scope (single aggregate or cross-aggregate). Flag rules without enforcement location as implementation gaps. Reject if no rules provided.

[CONTEXT_BOUNDARY_ARTIFACTS]

Integration contracts, ACL implementations, shared kernel definitions, and translation layers between contexts

InventoryItemDTO {sku, name, availableQuantity} exposed by Inventory Context. Ordering Context ACL maps to ProductAvailability value object.

Schema check: each artifact must specify source context, target context, and translation or contract type. Flag artifacts with bidirectional dependencies as coupling risks. Null allowed if no integration artifacts exist.

[MODEL_ARTIFACT_SOURCES]

References to source documents, code files, diagrams, or meeting notes that ground the model definitions

order-aggregate.ts lines 45-120, domain-model-workshop-2024-03-15.md, inventory-acl-design.md

Citation check: each source reference must be resolvable (file path, document ID, or URL). Flag placeholder references like 'team discussion' without date or artifact. Reject if no sources provided to prevent ungrounded analysis.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Domain Model Consistency Check Prompt into an application or design review workflow.

This prompt is designed to be integrated into a structured design review pipeline, not used as a one-off chat interaction. The implementation harness should treat the prompt as a stateless function that accepts a structured domain model specification and returns a structured consistency report. Because the output drives architectural decisions, the harness must enforce validation, handle model non-determinism, and route findings to the right human reviewers. The prompt is not a replacement for a domain architect's judgment; it is a consistency scanner that surfaces conflicts a human might miss when reviewing large models across multiple aggregates and bounded contexts.

Wire the prompt into an application by building a pre-processing layer that assembles the [DOMAIN_MODEL_SPEC] from source artifacts: event schemas, aggregate definitions, context maps, and ubiquitous language glossaries. The spec should be a structured JSON or YAML document containing aggregates, their invariants, entities, value objects, domain events, and cross-context references. After the model responds, a post-processing validator must parse the output against the [OUTPUT_SCHEMA]—a JSON schema defining the consistency report structure with fields for conflicting_rules, duplicate_concepts, invariant_violations, and boundary_misalignments. If parsing fails, retry once with a repair prompt that includes the raw output and the schema. If the second attempt fails, log the failure and escalate to a human reviewer. For high-risk domains (finance, healthcare, safety-critical systems), always require human approval before accepting any flagged inconsistency as a confirmed issue. Log every run with the model version, input spec hash, output report, and reviewer decision for auditability.

Model choice matters here. Use a model with strong reasoning capabilities (GPT-4o, Claude 3.5 Sonnet, or equivalent) because consistency checking requires cross-referencing rules across a large context window. Do not use a small or fast model for this task; false negatives (missed inconsistencies) are more dangerous than false positives. If the domain model is too large for a single context window, split it by bounded context cluster and run the prompt per cluster, then run a cross-cluster consistency pass that takes the per-cluster reports as input. Implement a confidence threshold: if the model expresses low confidence or flags an issue with hedging language, route that finding to a separate review queue rather than treating it as a confirmed defect. Avoid wiring this prompt into a fully automated CI/CD pipeline that blocks merges; the output is advisory and requires architectural judgment to interpret trade-offs between consistency and pragmatic coupling.

For teams using event-driven architectures, integrate this prompt after domain event schema changes. When a new event version is proposed, run the consistency check against the updated model to catch invariant violations before the event reaches production. Store the consistency report alongside the event schema in the schema registry. For teams practicing continuous architecture review, schedule this prompt to run weekly against the living domain model documentation, surfacing drift between documented and implemented models. The next step after receiving a consistency report is to triage findings: conflicting rules require a design decision meeting, duplicate concepts need glossary reconciliation, and invariant violations demand aggregate redesign. Do not treat all findings as equal priority; the harness should include a severity classifier that routes critical violations to the architecture team and low-severity notes to the domain model backlog.

IMPLEMENTATION TABLE

Expected Output Contract

Validation rules for the consistency report output. Use this contract to build a parser, validator, or retry guard before the report enters a downstream workflow.

Field or ElementType or FormatRequiredValidation Rule

consistency_report_id

string (UUID v4)

Must parse as valid UUID v4. Reject if missing or malformed.

generated_at

string (ISO 8601 UTC)

Must parse as valid ISO 8601 datetime in UTC. Reject if timezone offset is present.

bounded_contexts_analyzed

array of strings

Must be non-empty array. Each element must match a context name from [CONTEXT_LIST]. Duplicates not allowed.

findings

array of objects

Must be present. Empty array allowed only if no issues found. Each object must conform to finding_object schema.

findings[].id

string

Must be unique within the findings array. Non-empty string.

findings[].severity

enum: CRITICAL, HIGH, MEDIUM, LOW, INFO

Must be one of the five allowed values. Case-sensitive.

findings[].category

enum: CONFLICTING_RULE, DUPLICATE_CONCEPT, INVARIANT_VIOLATION, BOUNDARY_LEAK, TERMINOLOGY_MISMATCH

Must be one of the five allowed values. Case-sensitive.

findings[].source_evidence

array of objects with fields: context (string), artifact (string), excerpt (string)

Must contain at least one evidence object per finding. excerpt must be a direct quote from [SOURCE_ARTIFACTS] or null if inferred.

PRACTICAL GUARDRAILS

Common Failure Modes

Domain model consistency checks fail in predictable ways. These cards cover the most common failure modes, why they happen, and how to guard against them before you ship the prompt into a design review workflow.

01

Hallucinated Invariants

What to watch: The model invents business rules or constraints that don't exist in the provided source material, presenting them as discovered violations. This happens when the prompt doesn't anchor analysis strictly to supplied artifacts. Guardrail: Require every flagged invariant violation to cite a specific source document, section, or code reference. Add a post-processing check that rejects findings without citations.

02

False Equivalence Across Contexts

What to watch: The model treats identically named concepts in different bounded contexts as the same thing, flagging false inconsistencies where none exist. 'Customer' in billing vs. 'Customer' in CRM often have different meanings. Guardrail: Include explicit context-boundary definitions in the prompt input. Instruct the model to treat each context's terminology as independent unless an explicit mapping is provided.

03

Over-Reporting Trivial Naming Differences

What to watch: The model floods the report with low-value findings about field name variations (e.g., userId vs. user_id) while missing structural conflicts. Guardrail: Add severity tiers to the output schema. Instruct the model to classify findings as Critical, Warning, or Informational. Set a minimum severity threshold for inclusion in the summary.

04

Missing Cross-Aggregate Invariant Violations

What to watch: The model analyzes each aggregate in isolation and fails to detect rules that span aggregate boundaries, such as 'total order amount cannot exceed customer credit limit.' Guardrail: Explicitly list known cross-aggregate invariants in the prompt input. Require the model to check each one and report a status, even if the status is 'No violation found.'

05

Ignoring Temporal Consistency Rules

What to watch: The model checks structural consistency but ignores time-based rules like 'a shipment cannot be created before the order is confirmed' or 'a refund must occur within 90 days of purchase.' Guardrail: Include a dedicated section in the prompt for temporal invariants. Require the model to reason about event ordering and timestamps explicitly in its analysis.

06

Confidence Inflation on Ambiguous Models

What to watch: When the domain model is incomplete or the source artifacts are sparse, the model still produces a high-confidence report rather than flagging uncertainty. Guardrail: Require a confidence score per finding. Add a prompt instruction: 'If source evidence is insufficient to confirm or deny a rule, mark it as Uncertain and explain what information is missing.'

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Domain Model Consistency Check Prompt before integrating it into a design review workflow. Each criterion targets a specific failure mode that breaks trust in automated consistency reports.

CriterionPass StandardFailure SignalTest Method

Invariant Conflict Detection

Report identifies at least 80% of seeded invariant conflicts across aggregate boundaries

Output misses cross-aggregate rule violations or reports false conflicts without evidence

Seed a test model with 5 known invariant violations and verify detection recall

Duplicate Concept Flagging

Report flags synonymous entities with different names and provides source locations

Output treats identical concepts as distinct or merges semantically different concepts

Inject 3 synonym pairs and 2 homonym traps; check precision and recall

Boundary Rule Attribution

Each consistency issue cites the specific bounded context and aggregate where the rule is defined

Issues lack source attribution or attribute rules to wrong contexts

Parse output for [CONTEXT] and [AGGREGATE] fields; verify against ground truth

False Positive Rate

Fewer than 10% of reported issues are false positives

Report contains invented conflicts not present in the input model artifacts

Manual review of a 20-issue sample; flag any unsupported claims

Schema Compliance

Output matches the [OUTPUT_SCHEMA] exactly with all required fields present

Missing required fields, extra fields, or wrong types in the consistency report

Validate output against JSON Schema; reject on any schema violation

Cross-Context Traceability

Each finding includes a trace path showing how the conflict spans contexts

Findings state a conflict exists but provide no path or evidence chain

Check that every finding includes at least one source reference per affected context

Severity Classification Accuracy

Severity labels match a pre-defined rubric: Critical, High, Medium, Low

All issues marked Critical or severity is inconsistent with impact description

Compare severity labels against a golden set of 10 pre-classified issues

Abstention on Ambiguous Cases

Prompt returns 'Insufficient Evidence' for genuinely ambiguous model overlaps

Prompt hallucinates a resolution or assigns high confidence to guesses

Include 2 ambiguous model elements; verify abstention or low-confidence flag

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single aggregate or bounded context pair. Skip formal schema validation and accept free-text consistency observations. Replace [OUTPUT_SCHEMA] with a simple markdown structure: ## Conflicts, ## Duplicates, ## Invariant Violations. Run against a small, known-clean domain model first to calibrate expectations.

Watch for

  • The model inventing conflicts that don't exist when given sparse context
  • Overly broad invariant checks that flag design choices rather than actual violations
  • Missing explicit instruction to cite the specific rule or aggregate where a conflict was found
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.