This prompt is for domain architects and engineering leads planning a refactor of aggregates, bounded contexts, or domain events. It produces a structured impact map that identifies affected contexts, APIs, events, data migrations, and downstream consumers. Use it before committing to a refactoring plan to surface hidden coupling, sequencing risks, and migration complexity that might otherwise surface mid-implementation.
Prompt
Domain Model Refactoring Impact Analysis Prompt

When to Use This Prompt
Understand the job-to-be-done, ideal user, required context, and when not to use this prompt.
This is a design-time analysis tool, not a runtime migration executor. It assumes you have a documented or well-understood current-state domain model. If your model exists only in tribal knowledge, run a context map or glossary extraction prompt first. The prompt works best when you provide concrete artifacts: existing context maps, event schemas, API contracts, aggregate definitions, and known integration points. Vague inputs produce vague impact maps. For high-risk refactors in regulated domains, always pair the output with human architecture review before committing to implementation.
Do not use this prompt for greenfield design where no current-state model exists, for runtime data migration scripting, or for performance profiling of existing systems. It is not a replacement for static analysis tools that inspect code dependencies. If you need to discover bounded contexts from legacy code, use the Bounded Context Discovery from Legacy Code prompt instead. If you need to validate a specific aggregate design, use the Aggregate Root Design Validation Prompt. This prompt is specifically for understanding the blast radius of a planned change before you make it.
Use Case Fit
Where this prompt works and where it does not.
Good Fit: Planned Aggregate Refactors
Use when: the team has identified a specific aggregate boundary change and needs a structured impact map before implementation. Guardrail: feed the prompt the current aggregate design, the proposed change, and a bounded context map to ground the analysis in real artifacts.
Bad Fit: Greenfield Domain Discovery
Avoid when: no existing domain model or codebase exists. This prompt analyzes refactoring impact, not initial domain discovery. Guardrail: use a bounded context discovery or subdomain classification prompt for greenfield work, then return to this prompt once a baseline model exists.
Required Inputs
What you must provide: current aggregate design with entities and value objects, proposed refactoring target, context map showing integration relationships, and known domain events. Guardrail: missing context maps cause the model to hallucinate integration impacts. Validate context map completeness before running the prompt.
Operational Risk: False Confidence in Sequencing
What to watch: the model may produce a plausible-looking migration sequence that ignores deployment ordering constraints or team capacity. Guardrail: treat the generated sequence as a starting hypothesis. Review with the team that owns the affected contexts and validate against CI/CD pipeline constraints.
Operational Risk: Missed Downstream Consumers
What to watch: the impact analysis may miss event consumers, reporting systems, or external integrations not documented in the provided context map. Guardrail: cross-reference the generated impact list against API gateway logs, event bus subscribers, and data warehouse ingestion pipelines before committing to the refactor scope.
When to Escalate to Human Review
What to watch: risk scores above medium, impacts spanning more than three bounded contexts, or data migration steps involving financial or PII data. Guardrail: flag these outputs for architecture review board approval. The prompt identifies impact; humans decide acceptable risk.
Copy-Ready Prompt Template
A copy-ready prompt template for generating a domain model refactoring impact analysis, ready to paste into your AI harness.
This prompt template is designed to be dropped directly into your AI orchestration layer. It instructs the model to act as a domain architect and produce a structured impact analysis for a planned refactoring. The template uses square-bracket placeholders for all dynamic inputs, such as the model to refactor, the reason for the change, and the system's current context map. Before using it, ensure you have gathered the necessary source materials: your current bounded context definitions, aggregate designs, and a catalog of known domain events and API contracts. The quality of the output depends heavily on the specificity of the inputs you provide.
textYou are a domain architect specializing in Domain-Driven Design (DDD). Your task is to perform a rigorous impact analysis for a proposed domain model refactoring. You will be given the current state of the model, the proposed change, and the system's context map. Your analysis must be precise, actionable, and identify all downstream consequences. **INPUTS** - **Refactoring Target:** [TARGET_AGGREGATE_OR_CONTEXT] - **Refactoring Intent:** [REFACTORING_DESCRIPTION] (e.g., "Split the Customer aggregate into Customer and CustomerBillingProfile to reduce contention.") - **Current Model Snapshot:** [CURRENT_DOMAIN_MODEL_DESCRIPTION] - **Context Map:** [CONTEXT_MAP_DESCRIPTION] - **Known Domain Events:** [LIST_OF_DOMAIN_EVENTS] - **Known API Contracts:** [LIST_OF_API_CONTRACTS] **CONSTRAINTS** - [CONSTRAINTS] (e.g., "Must maintain backward compatibility for the GET /customers/{id} endpoint.") **OUTPUT_SCHEMA** Produce a JSON object with the following structure. Do not include any text outside the JSON object. { "impact_map": { "affected_contexts": [ { "context_name": "string", "impact_type": "BREAKING_CHANGE | ADAPTATION_REQUIRED | NO_IMPACT", "rationale": "string", "required_changes": ["string"] } ], "affected_apis": [ { "api_identifier": "string", "impact_type": "BREAKING_CHANGE | DEPRECATION | NO_IMPACT", "migration_notes": "string" } ], "affected_events": [ { "event_name": "string", "impact_type": "SCHEMA_CHANGE | PAYLOAD_CHANGE | DEPRECATION | NO_IMPACT", "new_schema_suggestion": "string" } ], "data_migrations": [ { "source": "string", "target": "string", "migration_type": "SCRIPT | ETL | EVENT_REPLAY", "complexity": "LOW | MEDIUM | HIGH", "description": "string" } ] }, "risk_assessment": { "overall_risk_score": "LOW | MEDIUM | HIGH | CRITICAL", "key_risks": ["string"], "rollback_complexity": "SIMPLE | COMPLEX | IMPOSSIBLE" }, "sequencing_guidance": { "recommended_phases": [ { "phase": "number", "description": "string", "contexts_involved": ["string"], "validation_criteria": "string" } ], "parallelizable_work": ["string"] } } **RISK_LEVEL:** [RISK_LEVEL] (e.g., HIGH - This is a core domain refactor in a financial system. Flag any risk of data inconsistency or double-billing.)
To adapt this template, start by replacing the placeholders in the INPUTS and CONSTRAINTS sections with your specific details. The OUTPUT_SCHEMA is designed to be parsed by your application code, so resist the urge to simplify it into free text unless you are only doing a one-off analysis. For high-risk domains, as indicated by the [RISK_LEVEL] placeholder, you should add a post-processing step in your harness that flags any CRITICAL overall risk score or IMPOSSIBLE rollback complexity for immediate human review before the analysis is shared with the team. The sequencing_guidance is the most valuable part for planning; ensure your evaluation tests check that the phases are logically ordered and have clear, testable validation criteria.
Prompt Variables
Placeholders required by the Domain Model Refactoring Impact Analysis Prompt. Each variable must be populated before the prompt is assembled and sent to the model. Missing or malformed inputs cause the impact analysis to skip affected contexts or produce false-negative risk scores.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[CURRENT_DOMAIN_MODEL] | The existing domain model definition, including aggregates, entities, value objects, and their relationships | Aggregate: Order (root), entities: OrderLine, value objects: Money, Address. Invariants: Order total must equal sum of line totals. | Must contain at least one aggregate definition with invariants. Parse check: model elements must be named and typed. Null not allowed. |
[PROPOSED_REFACTORING] | Description of the planned refactoring change, including which aggregates, entities, or contexts are being modified, split, merged, or removed | Split Order aggregate into Order and Fulfillment aggregates. Move ShippingAddress from Order to Fulfillment context. | Must specify at least one structural change to the domain model. Parse check: change must reference elements present in [CURRENT_DOMAIN_MODEL]. Null not allowed. |
[CONTEXT_MAP] | The current bounded context map showing contexts, their relationships, integration patterns, and translation layers | Contexts: Sales, Fulfillment, Billing. Sales->Fulfillment: Customer/Supplier with ACL. Fulfillment->Billing: Published Language via OrderFulfilled event. | Must define at least two bounded contexts with named relationships. Schema check: each relationship must have a source context, target context, and pattern type. Null allowed if no cross-context dependencies exist. |
[EVENT_CATALOG] | Catalog of domain events currently published or consumed, including schema, publisher context, and consumer contexts | Event: OrderPlaced {orderId, customerId, lineItems, total}. Publisher: Sales. Consumers: Fulfillment, Billing. | Each event must have a name, payload schema, and at least one publisher. Schema check: event payload fields must be typed. Null allowed if system has no events. |
[API_CONTRACTS] | API endpoints or service interfaces that expose domain model operations, including request/response schemas and versioning | POST /orders {customerId, lineItems} returns {orderId, status}. GET /orders/{orderId} returns Order aggregate projection. | Each contract must specify method, path, and response schema. Parse check: contracts must reference domain concepts from [CURRENT_DOMAIN_MODEL]. Null allowed for purely internal refactors. |
[DATA_STORE_SCHEMA] | Current database schemas, table structures, or persistence models backing the domain aggregates | Table: orders (id, customer_id, status, total, created_at). Table: order_lines (id, order_id, product_id, quantity, unit_price). | Must map to aggregates in [CURRENT_DOMAIN_MODEL]. Schema check: tables must have named columns with types. Null allowed if persistence layer is out of scope. |
[RISK_THRESHOLD] | The risk score threshold above which a refactoring impact requires explicit mitigation planning | 0.7 | Must be a float between 0.0 and 1.0. Default: 0.5. Validation: parse as float and clamp to range. Null allowed, defaults to 0.5. |
Implementation Harness Notes
How to wire the Domain Model Refactoring Impact Analysis Prompt into a reliable application workflow with validation, retries, and human review gates.
This prompt is designed to be called programmatically as part of a refactoring planning pipeline, not as a one-off chat interaction. The implementation harness should treat the prompt as a deterministic analysis function: provide the structured inputs, parse the structured output, validate it against the expected schema, and route the result to the appropriate review queue. Because the output includes risk scores and migration sequencing, downstream automation (such as ticket creation or CI pipeline gating) depends on correct parsing. The harness must handle both successful analyses and failure modes where the model returns incomplete impact maps, hallucinated context names, or confidence scores that don't match the evidence provided.
Wire the prompt into an application using a typed function signature. Accept a RefactoringProposal input object containing the target aggregate or context name, the proposed change description, a current context map (as structured JSON or a textual description), and a list of known domain events and integration points. Call the LLM with the prompt template, passing these fields into the [INPUT] placeholder. Parse the response into an ImpactAnalysis schema that includes: an array of affected contexts with coupling type and risk score, an array of affected APIs with breaking-change flags, an array of affected domain events with migration notes, a data migration checklist, a sequenced refactoring order, and an overall risk level. Use a schema validation library (such as Pydantic or Zod) to enforce field types, required fields, and enum constraints on risk levels (LOW, MEDIUM, HIGH, CRITICAL). If validation fails, retry once with the validation errors appended to the prompt as [CONSTRAINTS] feedback. If the second attempt also fails, escalate to a human architect for manual review rather than looping indefinitely.
For high-risk refactorings where the output risk level is HIGH or CRITICAL, route the impact analysis to a human approval queue before any automated actions are taken. Log every invocation with the input proposal, the raw model response, the parsed output, validation results, and the final disposition (accepted, retried, escalated). Store these logs in a refactoring decision record for auditability. Choose a model with strong structured output capabilities and a context window large enough to hold the full context map plus the analysis output. Avoid using this prompt with small or instruction-untuned models that are likely to hallucinate context names or skip required sections. If your context map is too large for a single prompt, preprocess it by extracting only the contexts within two hops of the target aggregate and summarizing distant contexts before passing them to the model.
Expected Output Contract
Defines the structure, types, and validation rules for the impact analysis output. Use this contract to parse, validate, and store the model response before downstream processing.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
impact_map | Array of objects | Must be a non-empty array. Each element must conform to the affected_context schema. | |
affected_context.context_name | String | Must match a bounded context name provided in [CURRENT_CONTEXT_MAP]. Non-empty string. | |
affected_context.impact_type | Enum: [AGGREGATE, API, EVENT, DATA_MIGRATION, UPSTREAM, DOWNSTREAM] | Must be one of the specified enum values. Case-sensitive. | |
affected_context.impact_description | String | Must be a non-empty string between 20 and 500 characters. Must reference a specific model element from [PROPOSED_REFACTOR]. | |
affected_context.risk_score | Integer | Must be an integer between 1 and 5 inclusive. 1 = negligible impact, 5 = breaking change without mitigation. | |
affected_context.mitigation_hint | String or null | If risk_score > 3, this field must be a non-empty string. Otherwise, null is allowed. | |
sequencing_plan | Array of strings | Must be a non-empty array of unique strings. Each string must reference a context_name from the impact_map. Order implies recommended sequence. | |
unaffected_contexts | Array of strings | If provided, each string must match a context name in [CURRENT_CONTEXT_MAP] that is not present in the impact_map. No duplicates allowed. |
Common Failure Modes
When a domain model refactoring impact analysis prompt fails, the cost is not just a bad output—it's a missed migration risk that can cause data corruption, broken contracts, or cascading production incidents. These are the most common failure modes and how to guard against them.
Hallucinated Dependencies
What to watch: The model invents coupling between contexts that does not exist in the codebase, or asserts that a context depends on an API that was never integrated. This happens when the prompt relies on the model's internal knowledge of common patterns rather than grounding it in provided source artifacts. Guardrail: Require the prompt to cite specific evidence (class names, import paths, event types, API endpoints) for every claimed dependency. Add a validation step that cross-references the output against a static dependency graph or architecture model before accepting the impact map.
Silent Omission of Downstream Event Consumers
What to watch: The impact analysis lists direct API callers but misses asynchronous event consumers subscribed to the refactored domain's event streams. This is the most dangerous failure mode because event-driven coupling is often invisible in code imports. Guardrail: Include an explicit instruction to enumerate all published domain events from the target aggregate or context, then trace each event type to its known consumers. If the prompt cannot access a live event registry, flag missing consumer data as a high-risk gap and require human confirmation.
Overconfident Risk Scoring Without Evidence Weighting
What to watch: The model assigns risk scores (High/Medium/Low) based on surface-level heuristics—like the number of affected files—without considering the blast radius of each change. A single breaking schema change to a core event can be catastrophic even if it touches few files. Guardrail: Require the prompt to decompose risk into explicit factors: data contract changes, consumer count, rollback difficulty, and observability coverage. Output a confidence qualifier for each risk score and flag any score derived without direct source evidence.
Migration Sequencing That Ignores Deployment Ordering Constraints
What to watch: The prompt suggests a refactoring sequence that is logically correct in isolation but impossible to execute safely in production because it requires simultaneous deployment of multiple services, or it breaks backward compatibility during the migration window. Guardrail: Add a constraint that the sequencing plan must include explicit deployment phases with compatibility checkpoints. Require the output to identify which changes can be deployed independently and which require coordinated releases, with a rollback plan for each phase.
Data Migration Blind Spots
What to watch: The impact analysis covers API and event contract changes but omits the data migration implications—existing records that need transformation, foreign key relationships that break, or read models that must be rebuilt. This happens when the prompt treats the domain model as pure logic rather than a structure backed by persistent state. Guardrail: Include a dedicated section in the output schema for data migration impact, requiring the model to enumerate affected tables, collections, or event streams. If the prompt lacks access to the data schema, require it to output explicit questions for the team rather than assuming no migration is needed.
Context Boundary Leakage in the Analysis Itself
What to watch: The model conflates concepts from different bounded contexts when analyzing impact, treating similarly-named entities as identical. For example, an Order in the Sales context may be treated as the same concept as an Order in the Fulfillment context, producing a false-positive impact chain. Guardrail: Require the prompt to qualify every entity reference with its owning bounded context. Add a validation rule that flags any cross-context relationship that is not explicitly justified by an integration pattern (ACL, Open Host, Published Language).
Evaluation Rubric
Use this rubric to evaluate the quality of the Domain Model Refactoring Impact Analysis output before integrating it into your planning workflow. Each criterion targets a specific failure mode common to architecture analysis prompts.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Context Completeness | Every bounded context listed in [CURRENT_STATE_MODEL] appears in the impact map with a non-null assessment | A context from the input is missing from the output or marked 'No Impact' without justification | Diff input context names against output context names; assert set equality |
Artifact Traceability | Each affected artifact references a specific API endpoint, event type, or data schema from [ARTIFACT_INVENTORY] | Vague references like 'related APIs' or 'some events' without concrete identifiers | Regex scan for artifact IDs from the inventory; flag any impact row missing a recognized artifact reference |
Risk Score Calibration | Risk scores use the defined scale from [RISK_SCORING_RUBRIC] with explicit rationale per score | All items scored 'Medium' without differentiation or scores contradicting the described blast radius | Sample 3 risk scores; verify each has a rationale sentence and matches the rubric definition for that level |
Migration Sequencing Logic | Sequencing recommendations include explicit predecessor dependencies, not just a flat ordered list | Sequencing is a simple numbered list with no dependency graph or 'can be parallelized' notes | Parse sequencing section for dependency keywords (requires, depends on, after, before); assert at least one explicit dependency per migration group |
Data Migration Coverage | Every aggregate with a schema change in [PROPOSED_REFACTOR] has a corresponding data migration note | Schema changes mentioned in the refactor plan but absent from the data migration section | Cross-reference aggregate names in proposed changes with migration section; assert no orphaned schema changes |
Rollback Consideration | At least one rollback or roll-forward strategy is described for each phase of the migration | No mention of rollback, revert, or forward recovery for any migration step | Keyword search for rollback, revert, roll-forward, backout; assert presence in each migration phase |
Confidence Flagging | Low-confidence assessments are explicitly marked with a confidence indicator and recommended verification step | All assessments presented with equal certainty; no uncertainty language anywhere in the output | Scan for confidence markers (low confidence, uncertain, needs verification, TBD); assert at least one flag if the input contains ambiguous or incomplete context |
Output Schema Validity | Output strictly conforms to [OUTPUT_SCHEMA] with all required fields present and correctly typed | Missing required fields, extra undocumented fields, or type mismatches (e.g., string where array expected) | Validate output against [OUTPUT_SCHEMA] using a JSON Schema validator; assert zero validation errors |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single aggregate or bounded context as [TARGET_DOMAIN_MODEL]. Replace [CURRENT_MODEL_ARTIFACTS] with a code snippet or diagram description rather than full repository context. Drop the risk scoring section and focus on producing a plain-text impact list. Accept markdown output without strict schema enforcement.
Prompt modification
Remove [OUTPUT_SCHEMA] and replace with: Return a bulleted list of affected contexts, APIs, events, and data migrations. Reduce [CONSTRAINTS] to: Focus on direct dependencies only. Skip confidence scores.
Watch for
- Missing indirect dependencies that only surface in integration tests
- Overly broad impact claims without evidence from the provided artifacts
- Skipping data migration impacts entirely when only code is provided

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us