Inferensys

Prompt

Service Merge Candidate Identification Prompt

A practical prompt playbook for identifying over-decomposed services that should be merged, with coupling evidence, shared data ownership analysis, and cognitive load reduction estimates.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
PROMPT PLAYBOOK

When to Use This Prompt

Identify when to deploy the Service Merge Candidate Identification Prompt to reverse nano-service sprawl and reduce coordination overhead.

This prompt is designed for architects and engineering leads who are actively managing a system that has been over-decomposed into too many services. The primary job-to-be-done is to reverse 'nano-service sprawl' by identifying specific services that should be merged back together. You should use this prompt when your teams report that simple feature changes require coordinated pull requests across three or more services, when deployment synchronization meetings are a recurring calendar fixture, or when the cognitive load of tracking inter-service dependencies exceeds the value of independent deployability. The ideal user has access to a concrete service inventory, a dependency graph, and recent deployment history—this is not a greenfield design exercise.

Before running this prompt, you must assemble the required context: a list of services with their primary data stores, a mapping of shared database tables or event streams, and a record of coordinated deployments over the last quarter. The prompt analyzes coupling evidence, shared data ownership, coordinated deployment frequency, and cognitive load to produce a ranked merge candidate list. It will flag services that always change together, services that share a database despite being separate deployments, and services whose domain logic is so intertwined that separating them creates more problems than it solves. Do not use this prompt for greenfield service boundary design, for systems that are still largely monolithic, or when you lack empirical dependency data—the output will be speculative rather than evidence-based.

The output is a ranked list of merge candidates with specific evidence for each recommendation, estimated consolidation benefits, and a risk assessment for the merge operation. Use this as input to an architecture review meeting, not as a final decision. The prompt identifies candidates; your team must validate the findings against business context, team topology, and future roadmap. If the prompt returns an empty or low-confidence list, that is a valid signal that your current decomposition may be appropriate, and you should investigate whether coordination overhead stems from team structure rather than service boundaries.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Service Merge Candidate Identification Prompt delivers value and where it introduces risk. Use these cards to decide whether this prompt fits your current architecture review workflow.

01

Good Fit: Over-Decomposed Systems

Use when: your system has services that share a database, deploy together, or require coordinated changes for every feature. Guardrail: Provide the prompt with a service dependency graph and deployment history so it can ground its merge recommendations in coupling evidence rather than naming conventions.

02

Bad Fit: Greenfield Design

Avoid when: you are designing a new system from scratch with no runtime data. Risk: The prompt will hallucinate coupling patterns and recommend merges based on hypothetical boundaries. Guardrail: Use the Service Boundary Candidate Identification Prompt instead for greenfield decomposition work.

03

Required Inputs

What you must provide: a service inventory with ownership metadata, a dependency graph or interaction map, shared data store references, and deployment frequency data. Guardrail: Missing inputs cause the prompt to rely on naming similarity heuristics, which produce false positives for services that happen to share prefixes but are correctly separated.

04

Operational Risk: Merge Without Migration Plan

Risk: The prompt identifies merge candidates but does not produce a safe migration sequence. Teams that act on the output without a rollback plan risk data inconsistency during consolidation. Guardrail: Always pair this prompt's output with the Database per Service Migration Planning Prompt or a human-authored migration runbook before executing any merge.

05

Team Topology Blind Spot

Risk: The prompt evaluates technical coupling but does not consider team structures, cognitive load, or ownership boundaries. A technically sound merge may create an unmanageable team scope. Guardrail: Cross-reference merge candidates with the Conway's Law Boundary Validation Prompt to catch organizational mismatches before committing to a merge decision.

06

Nano-Service Detection Threshold

Use when: you suspect services are too small to justify independent operation. Guardrail: Set an explicit threshold for nano-service classification (e.g., fewer than 3 endpoints, single-table ownership, zero independent deployments in 90 days) and include it in the prompt's [CONSTRAINTS] block to prevent subjective granularity judgments.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for identifying service merge candidates in an over-decomposed system.

This prompt is designed to be copied directly into your AI harness, IDE, or orchestration layer. It uses square-bracket placeholders for all dynamic inputs, ensuring you can adapt it to your specific system context without modifying the core instruction structure. The template expects a description of your current service landscape, coupling evidence, and any known pain points. Replace each placeholder with data from your architecture review, dependency graphs, or team surveys before sending the prompt to the model.

text
You are a senior software architect specializing in microservice decomposition and consolidation. Your task is to analyze a potentially over-decomposed system and identify services that are strong candidates for merging.

## SYSTEM CONTEXT
[SYSTEM_DESCRIPTION]

## SERVICE INVENTORY
[SERVICE_LIST_WITH_RESPONSIBILITIES]

## COUPLING EVIDENCE
[COUPLING_DATA]

## DEPLOYMENT COORDINATION DATA
[DEPLOYMENT_FREQUENCY_AND_COORDINATION_PATTERNS]

## TEAM COGNITIVE LOAD ASSESSMENT
[TEAM_FEEDBACK_AND_COGNITIVE_LOAD_INDICATORS]

## CONSTRAINTS
[CONSTRAINTS]

## OUTPUT SCHEMA
Return a JSON object with the following structure:
{
  "merge_candidates": [
    {
      "services_to_merge": ["service-a", "service-b"],
      "merge_rationale": "string",
      "coupling_evidence": {
        "shared_data_ownership": ["entity-x", "entity-y"],
        "coordinated_deployment_frequency": "string",
        "chatty_communication_paths": ["path-1", "path-2"],
        "shared_business_capability": "string"
      },
      "cognitive_load_reduction_estimate": "high|medium|low",
      "merged_service_name_suggestion": "string",
      "merged_responsibility_statement": "string",
      "risk_assessment": {
        "migration_complexity": "high|medium|low",
        "rollback_safety": "high|medium|low",
        "team_impact": "string"
      },
      "nano_service_detection": {
        "is_nano_service": true|false,
        "nano_service_indicators": ["string"]
      }
    }
  ],
  "analysis_summary": "string",
  "recommended_merge_sequence": ["string"]
}

## INSTRUCTIONS
1. Review the service inventory and identify services that share the same data entities, require coordinated deployments, or exhibit excessive inter-service communication.
2. Flag any nano-services—services with a single responsibility that could be a module within a larger service.
3. For each merge candidate, provide specific coupling evidence and a clear rationale.
4. Estimate the cognitive load reduction for the owning team if the merge were completed.
5. Assess migration complexity and rollback safety for each candidate.
6. Recommend a merge sequence that minimizes blast radius and respects dependency ordering.
7. If no strong merge candidates exist, return an empty `merge_candidates` array and explain why in `analysis_summary`.

## RISK LEVEL
[RISK_LEVEL]

After copying the template, replace each placeholder with concrete data. For [SYSTEM_DESCRIPTION], include a brief overview of the system's domain and architecture style. [SERVICE_LIST_WITH_RESPONSIBILITIES] should be a structured list of service names and their stated responsibilities. [COUPLING_DATA] can include dependency graph outputs, shared database tables, or API call frequency metrics. [DEPLOYMENT_FREQUENCY_AND_COORDINATION_PATTERNS] should capture how often services are deployed together. [TEAM_FEEDBACK_AND_COGNITIVE_LOAD_INDICATORS] can include survey results or on-call rotation data. [CONSTRAINTS] should list any non-negotiable requirements, such as regulatory boundaries or team topology constraints. [RISK_LEVEL] should be set to high, medium, or low to calibrate the model's caution. For high-risk environments, always route the output through a human architecture review before any merge work begins. Validate the JSON output against the schema before processing downstream, and log the prompt version, inputs, and outputs for auditability.

IMPLEMENTATION TABLE

Prompt Variables

Each variable must be populated with accurate, current data before the prompt is executed. Missing or stale inputs produce unreliable merge recommendations. Validate every field against live system telemetry, not architectural diagrams alone.

PlaceholderPurposeExampleValidation Notes

[SERVICE_INVENTORY]

Complete list of candidate services with ownership, runtime, and deployment metadata

payment-gateway-v2, order-fulfillment, shipping-label-gen, invoice-renderer, tax-calc-us, tax-calc-eu

Parse check: must be a JSON array of service names. Cross-reference against service registry. Reject if fewer than 3 services or if any service name appears in both active and deprecated registries.

[DEPENDENCY_GRAPH]

Directed graph of service-to-service calls, message subscriptions, and shared resource access

{ "payment-gateway-v2": ["tax-calc-us", "tax-calc-eu", "invoice-renderer"], ... }

Schema check: adjacency list format. Validate every target service exists in [SERVICE_INVENTORY]. Null allowed only for fully isolated services. Must be generated from runtime traces or service mesh data within the last 7 days.

[DATA_OWNERSHIP_MAP]

Mapping of database tables, event streams, and blob stores to their owning service

{ "orders_table": "order-fulfillment", "tax_rates_cache": "tax-calc-us", ... }

Schema check: flat key-value object. Every key must be a canonical resource identifier. Reject if any resource has multiple owners. Validate against schema registry and last-write timestamps. Stale data older than 30 days triggers a retry condition.

[DEPLOYMENT_FREQUENCY_LOG]

Per-service deployment count and coordinated deployment pairs over the last 90 days

{ "payment-gateway-v2": 47, "tax-calc-us": 44, "coordinated_pairs": [["tax-calc-us", "tax-calc-eu", 41], ...] }

Schema check: object with integer values and a coordinated_pairs array of [serviceA, serviceB, count] tuples. Counts must be non-negative. Null allowed if CI/CD data is unavailable, but merge confidence will degrade. Validate against deployment pipeline logs.

[TEAM_OWNERSHIP_MAP]

Mapping of each service to its owning team and team size

{ "payment-gateway-v2": { "team": "payments-squad", "size": 4 }, ... }

Schema check: object where each value has string team and integer size fields. Size must be positive. Cross-reference against org chart or team API. Reject if a single team owns more than 8 services, as this indicates an organizational bottleneck rather than a technical merge candidate.

[COGNITIVE_LOAD_THRESHOLD]

Maximum number of services a single team should own before merge is strongly recommended

5

Type check: positive integer. Default is 5 if not specified. Values below 3 or above 10 require explicit justification in [CONSTRAINTS]. This threshold drives the urgency scoring in the merge candidate output.

[CONSTRAINTS]

Business or regulatory constraints that prohibit specific merges regardless of technical evidence

{ "do_not_merge": [["tax-calc-us", "tax-calc-eu"]], "reason": "Regulatory separation required for GDPR and US tax code compliance" }

Schema check: object with do_not_merge array of service pairs and a reason string. Null allowed. Every pair listed here will be excluded from merge recommendations. Validate with legal or compliance lead before running the prompt. Approval required for any override.

[OUTPUT_SCHEMA]

Expected JSON schema for the merge candidate list output

{ "merge_candidates": [{ "services": ["..."], "rationale": "...", "coupling_score": 0.0, "shared_data": ["..."], "coordinated_deployments": 0, "cognitive_load_reduction": 0 }] }

Schema check: valid JSON Schema draft. Must include required fields: services, rationale, coupling_score, shared_data, coordinated_deployments, cognitive_load_reduction. Reject output that omits any required field. Use this schema for programmatic validation after generation.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Service Merge Candidate Identification Prompt into an architecture review workflow or automated analysis pipeline.

This prompt is designed to operate as a structured analysis step within a broader architecture review workflow, not as a standalone chatbot interaction. The implementation harness should treat the prompt as a deterministic function: it receives a structured service inventory and returns a scored merge candidate list. Because the output directly influences refactoring decisions that carry operational risk, the harness must enforce validation, human review gates, and audit trail capture before any merge recommendation reaches an implementation backlog.

Wire the prompt into an application by first assembling the required inputs: a service inventory with ownership, data store mappings, deployment frequency, and dependency graph data. These inputs should be pulled from your service catalog, CI/CD pipelines, and infrastructure-as-code repositories rather than manually compiled. Before invoking the model, validate that the input payload conforms to the expected schema—missing fields like deployment_frequency or shared_data_stores will degrade the quality of coupling evidence. On invocation, use a model with strong structured output support (GPT-4o or Claude 3.5 Sonnet with JSON mode enabled) and set temperature to 0 or near-zero to maximize consistency across runs. Capture the raw model response, the validated merge candidate list, and the input snapshot in an audit log so that architecture decisions remain traceable.

Post-generation validation is critical. Implement a validator that checks each merge candidate for required fields: services_to_merge, coupling_evidence, shared_data_ownership, coordinated_deployment_frequency, and cognitive_load_reduction_estimate. Reject any candidate where the coupling evidence is purely syntactic (e.g., 'they share a name prefix') without concrete data or deployment coupling. Flag candidates where the cognitive load reduction estimate is implausible—merging two services with five engineers each should not claim a reduction to one engineer. If validation fails, retry once with the validation errors appended to the prompt as feedback. If the retry also fails, escalate the candidate to a human architect for manual review rather than silently accepting a weak recommendation.

The output should feed into a review queue, not directly into a refactoring backlog. Each merge candidate must be reviewed by at least one architect who can assess organizational context—team topology, Conway's Law alignment, and migration cost—that the model cannot see. The harness should present each candidate with its evidence, scores, and a link to the raw dependency data so reviewers can verify claims. After human approval, merge candidates can be promoted to implementation planning with a clear audit trail showing the model's recommendation, the validator's checks, and the human reviewer's sign-off. Avoid the temptation to automate the entire pipeline end-to-end; the cost of a bad merge far exceeds the cost of a human review step.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the structure, types, and validation rules for the model response. Use this contract to parse the output programmatically and to build automated validation checks before the result enters downstream systems.

Field or ElementType or FormatRequiredValidation Rule

merge_candidates

Array of objects

Must be a non-empty JSON array. If no candidates are found, return an empty array [].

merge_candidates[].service_pair

Array of two strings

Must contain exactly two service names. Both names must appear in the [SERVICE_INVENTORY] input.

merge_candidates[].merge_score

Number (0.0 - 1.0)

Must be a float between 0.0 and 1.0. Higher scores indicate stronger merge justification. Validate range.

merge_candidates[].coupling_evidence

Array of strings

Each string must describe a specific coupling pattern observed (e.g., 'shared database table X', 'coordinated deployment required'). Minimum 1 item.

merge_candidates[].shared_data_ownership

Array of strings

If present, each string must name a specific data entity or store shared between the pair. Null or empty array allowed.

merge_candidates[].coordinated_deployment_frequency

String enum

Must be one of: 'always', 'frequently', 'rarely', 'never'. Describes how often the pair must be deployed together.

merge_candidates[].cognitive_load_reduction

String

A brief justification of how merging reduces cognitive load. Must not be empty. Max 280 characters.

merge_candidates[].risk_notes

String

Any risks or downsides of merging this pair. Null allowed if no risks identified. Max 500 characters.

PRACTICAL GUARDRAILS

Common Failure Modes

When identifying service merge candidates, these failures surface most often in production. Each card explains what breaks and how to prevent it before the merge proposal reaches an architecture review.

01

Nano-Service False Negatives

What to watch: The model misses merge candidates because it treats each microservice as independently justified, ignoring services with fewer than 3 endpoints or single-entity ownership. Guardrail: Pre-filter the service inventory by endpoint count, data ownership breadth, and independent deployability before prompting. Require the model to justify why any service under the granularity threshold should remain separate.

02

Shared Database Blindness

What to watch: The model proposes merging services based on API coupling alone while ignoring that both services write to the same database tables, creating a hidden distributed monolith. Guardrail: Supply a data ownership matrix as a required input. Add an explicit instruction to flag any service pair sharing write access to the same tables, regardless of API-level decoupling.

03

Coordinated Deployment Overfitting

What to watch: The model recommends merging services solely because they deploy together, without distinguishing between true coupling and coincidental release cadence driven by team process. Guardrail: Require deployment frequency evidence to be paired with API coupling scores. Add a constraint that coordinated deploys alone are insufficient evidence—cross-service data access or chatty communication must also be present.

04

Cognitive Load Overestimation

What to watch: The model inflates cognitive load reduction estimates by assuming all merged services become simpler, ignoring that merging two poorly understood services creates one larger poorly understood service. Guardrail: Require the model to estimate pre-merge and post-merge cognitive load separately, with explicit reasoning about domain alignment. Flag any merge where the combined domain scope spans more than one bounded context.

05

Missing Anti-Corruption Layer Dependencies

What to watch: The model recommends merging services that sit behind an anti-corruption layer without accounting for the translation logic that would need to be unwound or internalized. Guardrail: Supply the ACL inventory as input context. Add a constraint that any merge involving an ACL-protected service must include an ACL removal or internalization plan with translation complexity assessment.

06

Team Topology Mismatch

What to watch: The model produces a technically sound merge recommendation that assigns the combined service to a team that lacks domain expertise, capacity, or organizational mandate. Guardrail: Include current team ownership and capacity as required inputs. Add a post-processing rule that flags any merge where the proposed owning team differs from both original service owners, requiring explicit team assignment before the recommendation is accepted.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the quality of the Service Merge Candidate Identification Prompt's output before integrating it into your architecture review workflow. Each criterion targets a specific failure mode common to merge analysis.

CriterionPass StandardFailure SignalTest Method

Merge Justification Completeness

Each merge candidate includes at least two distinct evidence types (e.g., shared data ownership, coordinated deployment frequency, chatty communication)

Candidates listed with only a single generic reason like 'high coupling' or no evidence at all

Parse output JSON. For each candidate in the merge_candidates array, count unique evidence_type values. Fail if any candidate has fewer than 2.

Nano-Service Detection

Output explicitly flags services with fewer than 3 distinct business capabilities or endpoints as nano-service candidates

Services with a single endpoint or trivial function are not identified or are recommended for extraction instead of merge

Scan the nano_service_candidates field. Verify that any service with <=2 endpoints in the input inventory appears in this list with a merge recommendation.

Distributed Monolith Risk Flagging

Merge proposal includes a risk assessment that identifies whether merging would create or worsen a distributed monolith pattern

Merge recommendation ignores shared database dependencies or tight synchronous coupling that would persist after merge

Check the risk_assessment field within each merge proposal. Fail if shared_database_risk is null or false when the input shows both services accessing the same schema.

Cognitive Load Reduction Estimate

Each merge candidate includes a quantified or ordinal cognitive load reduction estimate (e.g., 'reduces from 4 services to 1, eliminating 3 API contracts to maintain')

Cognitive load estimate is missing, vague ('reduces complexity'), or purely qualitative without reference to contracts, endpoints, or team context

Parse the cognitive_load_reduction field. Fail if it is empty, null, or contains no numeric or ordinal reference to eliminated artifacts.

Coordinated Deployment Evidence

Output identifies services that are always deployed together and cites deployment frequency data or release coordination patterns

Deployment coupling is mentioned without specific frequency data, or services deployed independently are incorrectly flagged as coordinated

Check the coordinated_deployment field. Fail if is_coordinated is true but deployment_frequency_match is null or if the justification field is empty.

Data Ownership Conflict Resolution

Output proposes a clear data ownership model for the merged service, identifying which entities become owned, shared kernel, or require an anti-corruption layer

Data ownership recommendation is absent, or the output suggests merging services that own conflicting entities without resolving the conflict

Parse the data_ownership field in the merge proposal. Fail if owned_entities, shared_kernel_entities, and acl_required_entities are all empty or null.

Migration Sequencing Guidance

Output includes a recommended merge sequence with dependency ordering and a rollback safety gate for each merge step

Merge candidates are listed without sequencing, or the sequence violates dependency order (e.g., merging a consumer before its provider)

Validate the migration_sequence array. Fail if steps are empty, if step_order values are not sequential, or if a consumer service appears before its provider in the dependency graph.

False Positive Rate Control

Output does not recommend merging services that have distinct business capabilities, separate team ownership, and independent deployment cycles

Services with clearly different bounded contexts, separate databases, and independent roadmaps are recommended for merge

Maintain a golden test set of 5 known independent service pairs. Run the prompt against each pair. Fail if any pair receives a merge recommendation with confidence above 0.3.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet) and a single service catalog input. Skip strict schema validation. Accept a markdown table or bulleted list as output. Focus on the top 3-5 merge candidates only.

Prompt modification

  • Remove the [OUTPUT_SCHEMA] section and replace with: Return a markdown table with columns: Service Pair, Merge Rationale, Shared Data, Risk Level.
  • Add: Limit analysis to the 5 most obvious merge candidates.
  • Remove coordinated deployment frequency and cognitive load reduction estimate requirements.

Watch for

  • Overly broad merge suggestions that ignore bounded context boundaries
  • Missing evidence for shared data ownership claims
  • Nano-service consolidation suggestions that don't account for independent deployability needs
  • No distinction between merge and strangler-fig extraction candidates
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.