Inferensys

Prompt

Service Extraction Candidate Scoring Prompt

A practical prompt playbook for using the Service Extraction Candidate Scoring Prompt in production AI workflows. This playbook helps architects prioritize which monolith modules to extract first by producing a scored, ranked list with dependency ordering constraints.
Wide-angle shot of a modern WeWork open floor plan with creative walls covered in AI system architecture diagrams, product team collaborating in standing desk area with industrial lighting.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job-to-be-done, ideal user, required context, and limitations for the Service Extraction Candidate Scoring Prompt.

This prompt is for architects and engineering leads who need to prioritize monolith modules for extraction into separate services. It is designed for the planning phase of a modernization or microservice migration initiative, after you have identified candidate modules but before you commit to an extraction sequence. The prompt forces structured reasoning across multiple dimensions including business criticality, change frequency, team readiness, coupling isolation, and risk level. Use this when you have a list of candidate modules and need a defensible, scored extraction order that accounts for dependency constraints.

The ideal user has already completed a domain analysis or bounded context discovery exercise and has a concrete list of modules with known dependencies. You should have data on each module's change frequency from version control history, business criticality from stakeholder interviews, and coupling characteristics from static analysis or architecture review. The prompt works best when you can populate the [MODULE_LIST] placeholder with structured data including module names, dependency lists, and known risk factors. Without this data, the model will generate plausible but ungrounded scores that could lead to a flawed extraction sequence.

Do not use this prompt for greenfield service design, for evaluating services that already exist, or when you lack sufficient data about module boundaries and dependencies. It is not a replacement for a bounded context discovery workshop or a domain-driven design review. The prompt produces a scored ranking, not a detailed migration plan—for that, use the Strangler Fig Migration Step Planning Prompt. If your primary concern is detecting distributed monolith risks in an existing decomposition plan, use the Distributed Monolith Risk Detection Prompt instead. Always review the output with the team that will own the extracted services, as team readiness and organizational constraints may override the model's scoring.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Use these cards to decide if the Service Extraction Candidate Scoring Prompt fits your current architecture decision.

01

Good Fit: Pre-Migration Prioritization

Use when: you have a known monolith and need to sequence extraction candidates before any code is split. Guardrail: the prompt assumes you can provide a module inventory with coupling and change-frequency data. Do not use it if you lack a current-state dependency map.

02

Good Fit: Architecture Review Gates

Use when: an architecture review board needs a repeatable, evidence-based scoring method for extraction proposals. Guardrail: pair the scored output with a human-reviewed Architecture Decision Record. The prompt provides a recommendation, not a binding order.

03

Bad Fit: Greenfield Service Design

Avoid when: you are designing new services from scratch with no existing monolith. This prompt scores extraction candidates from a running system. Guardrail: for greenfield work, use the Bounded Context Discovery Prompt or Service Boundary Candidate Identification Prompt instead.

04

Bad Fit: Single-Team Microservices

Avoid when: a single team owns all candidate services and there is no organizational boundary pressure. The scoring rubric includes team readiness and Conway's Law alignment, which lose meaning when one team owns everything. Guardrail: validate that organizational boundaries exist before trusting the team-readiness scores.

05

Required Inputs: Module Inventory

Risk: garbage scores from incomplete or outdated module lists. The prompt needs a current module inventory with coupling relationships, change frequency, business criticality, and team ownership. Guardrail: run a dependency graph analysis first and feed the output into this prompt. Do not estimate module coupling from memory.

06

Operational Risk: Dependency Ordering Gaps

Risk: the prompt produces a ranked extraction sequence, but hidden runtime dependencies can invalidate the order. A module scored as low-risk may still block extraction of higher-priority modules. Guardrail: always validate the recommended sequence against a runtime dependency graph. Use the Change Propagation Risk Analysis Prompt as a follow-up check.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for scoring and ranking monolith modules as service extraction candidates, with square-bracket placeholders for your system-specific data.

The prompt below is designed to be copied directly into your AI harness, IDE, or orchestration layer. Every square-bracket placeholder must be replaced with your actual data before sending the prompt to the model. The template expects a structured description of your monolith modules, the scoring criteria you care about, and the output format you need. Do not leave any placeholder unresolved—doing so will produce unreliable rankings or hallucinated module names.

text
You are a senior software architect evaluating a monolith for service extraction. Your task is to score each candidate module against the provided criteria and produce a ranked extraction sequence with dependency ordering constraints.

## INPUT MODULES
[MODULE_LIST]

## SCORING CRITERIA
Score each module from 1 (low) to 5 (high) on the following dimensions. Provide a one-sentence justification for each score.

1. **Business Criticality**: How critical is this module to revenue, user experience, or core business operations? Higher criticality means extraction risk is higher, but isolation benefit may also be higher.
2. **Change Frequency**: How often does this module change relative to the rest of the system? High-change modules benefit more from independent deployability.
3. **Coupling Isolation**: How cleanly can this module be separated? Consider database dependencies, shared libraries, in-process calls, and implicit contracts. High isolation means lower extraction cost.
4. **Team Readiness**: Does a dedicated team with domain expertise exist for this module? High readiness reduces post-extraction ownership risk.
5. **Extraction Risk**: How likely is extraction to cause production incidents, data inconsistencies, or performance regressions? Lower risk means safer to extract early.

## CONSTRAINTS
[CONSTRAINTS]

## OUTPUT SCHEMA
Return a JSON object with the following structure:
{
  "scored_candidates": [
    {
      "module_name": "string",
      "scores": {
        "business_criticality": { "value": number, "justification": "string" },
        "change_frequency": { "value": number, "justification": "string" },
        "coupling_isolation": { "value": number, "justification": "string" },
        "team_readiness": { "value": number, "justification": "string" },
        "extraction_risk": { "value": number, "justification": "string" }
      },
      "composite_score": number,
      "extraction_order": number,
      "prerequisites": ["string"]
    }
  ],
  "extraction_phases": [
    {
      "phase": number,
      "modules": ["string"],
      "rationale": "string",
      "dependency_gate": "string"
    }
  ],
  "high_risk_items": [
    {
      "module_name": "string",
      "risk_description": "string",
      "mitigation": "string"
    }
  ]
}

## INSTRUCTIONS
- Score every module in [MODULE_LIST] against all five criteria.
- Compute composite_score as the weighted average: (business_criticality * 0.15) + (change_frequency * 0.25) + (coupling_isolation * 0.30) + (team_readiness * 0.15) + ((6 - extraction_risk) * 0.15). Invert extraction_risk so that lower risk yields a higher contribution.
- Assign extraction_order starting from 1, respecting dependency prerequisites. A module cannot be extracted before its prerequisites.
- Group modules into extraction_phases where all modules in a phase can be extracted in parallel without violating dependencies.
- Flag any module with extraction_risk >= 4 or coupling_isolation <= 2 in high_risk_items with specific mitigation recommendations.
- If [CONSTRAINTS] specifies a maximum phase size, do not exceed it.
- Do not invent modules. Only score modules present in [MODULE_LIST].

To adapt this template, replace [MODULE_LIST] with a structured description of each candidate module—include the module name, its primary responsibility, known dependencies, database ownership, and the team currently maintaining it. Replace [CONSTRAINTS] with any organization-specific rules such as maximum modules per phase, regulatory boundaries that cannot be crossed, or modules that must be extracted together. If you have no additional constraints, replace [CONSTRAINTS] with the string "None". The weighted scoring formula in the instructions can be adjusted by modifying the coefficients to match your organization's priorities—for example, increase coupling_isolation weight if your primary goal is avoiding distributed monoliths. Before running this prompt in production, validate the output against your actual module inventory to catch hallucinations, and run a dependency graph check to ensure the extraction order does not violate known prerequisites.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the prompt needs to work reliably. Each variable must be populated with accurate data to produce a useful scoring output.

PlaceholderPurposeExampleValidation Notes

[MODULE_LIST]

Array of candidate modules from the monolith to evaluate for extraction

["UserAuth", "PaymentProcessor", "NotificationEngine", "ReportingDashboard"]

Must be a non-empty JSON array of strings. Reject if null, empty, or contains duplicate module names.

[BUSINESS_CRITICALITY_MAP]

Mapping of each module to its business criticality rating (1-5)

{"UserAuth": 5, "PaymentProcessor": 5, "NotificationEngine": 2, "ReportingDashboard": 3}

Must be a valid JSON object with keys matching every entry in [MODULE_LIST]. Values must be integers between 1 and 5. Reject if any module is missing or value is out of range.

[CHANGE_FREQUENCY_DATA]

Deployment or commit frequency per module over the last quarter

{"UserAuth": "weekly", "PaymentProcessor": "daily", "NotificationEngine": "monthly", "ReportingDashboard": "weekly"}

Must be a valid JSON object with keys matching [MODULE_LIST]. Values must be one of: daily, weekly, biweekly, monthly, quarterly. Reject if unknown frequency string is used.

[COUPLING_SCORES]

Afferent and efferent coupling metrics per module

{"UserAuth": {"afferent": 12, "efferent": 2}, "PaymentProcessor": {"afferent": 8, "efferent": 5}}

Must be a valid JSON object with keys matching [MODULE_LIST]. Each value must contain integer afferent and efferent fields. Reject if negative values or missing fields.

[TEAM_READINESS_LEVELS]

Team capability and context ownership rating per module (1-5)

{"UserAuth": 4, "PaymentProcessor": 5, "NotificationEngine": 2, "ReportingDashboard": 3}

Must be a valid JSON object with keys matching [MODULE_LIST]. Values must be integers between 1 and 5. Reject if any module is missing or value is out of range.

[DEPENDENCY_GRAPH]

Directed adjacency list showing which modules depend on which other modules

{"UserAuth": [], "PaymentProcessor": ["UserAuth"], "NotificationEngine": ["UserAuth"], "ReportingDashboard": ["PaymentProcessor", "UserAuth"]}

Must be a valid JSON object with keys matching [MODULE_LIST]. Each value must be an array of strings referencing other modules. Reject if any referenced module is not in [MODULE_LIST] or if self-references exist.

[EXTRACTION_CONSTRAINTS]

Known constraints that limit extraction order or feasibility

["PaymentProcessor requires PCI compliance isolation", "UserAuth must be extracted before any consumer due to token issuance"]

Must be a valid JSON array of strings. Can be empty but not null. Each constraint should be a human-readable sentence describing a real architectural or compliance limitation.

PROMPT PLAYBOOK

Implementation Harness Notes

Wire the scoring prompt into an application with validation, retries, and human review gates.

The Service Extraction Candidate Scoring Prompt is designed to be called from an application or CI/CD pipeline, not just used in a chat interface. The prompt expects a structured input payload containing the monolith module inventory, coupling data, business criticality ratings, team readiness scores, and change frequency metrics. The application layer is responsible for assembling this context from internal systems (code analysis tools, issue trackers, deployment logs, team surveys) before invoking the model. The prompt returns a scored and ranked JSON array, which the harness must validate before the results are presented to architects or fed into downstream planning tools.

API call structure: Use a standard chat completions endpoint with response_format set to json_object (or the equivalent structured output mode for your model provider). The system message contains the full prompt template. The user message contains the serialized [MODULE_DATA] array and [CONSTRAINTS] object. Set temperature to 0.1 or lower to minimize ranking instability across runs. Validation layer: After receiving the response, validate the JSON against a schema that checks: (1) every module in the input appears exactly once in the output, (2) all scores are integers within the defined ranges, (3) the extraction_sequence field respects dependency_constraints (no module appears before its dependencies), and (4) no duplicate rank values exist. If validation fails, retry once with the validation errors appended to the user message as [CORRECTION_FEEDBACK]. If the second attempt also fails, log the failure and route to a human review queue rather than silently accepting a malformed ranking.

Retry and fallback logic: Implement a two-strike retry policy. First failure: append the schema violation details and re-invoke. Second failure: escalate. Do not loop beyond two retries, as repeated failures often indicate a fundamental input quality problem (missing coupling data, contradictory constraints) that the model cannot resolve. Human review gate: Even when validation passes, flag outputs for human review when: (1) the top-ranked candidate has a composite score below a configurable threshold (suggesting no extraction is clearly justified), (2) any two candidates have scores within 5% of each other at rank boundaries (indicating ranking ambiguity), or (3) the risk_level for the top candidate is high. These gates prevent the team from acting on low-confidence or high-risk recommendations without architect oversight. Logging: Record the full prompt, response, validation result, scores, and reviewer decision for auditability. This trace is essential for retrospective analysis when extraction outcomes differ from predictions.

Model choice: This prompt benefits from models with strong reasoning and structured output capabilities. GPT-4o, Claude 3.5 Sonnet, and Gemini 1.5 Pro are suitable. Avoid smaller or older models that may struggle with the multi-criteria ranking and dependency ordering constraints. Tool use and RAG: This prompt does not require tool calling or retrieval-augmented generation. All necessary data must be assembled by the application before invocation. If your module inventory is too large for a single context window, batch the modules into groups of 20-30, score each batch independently, then run a second merge-and-rank pass with the batch summaries. Next step: After the harness produces a validated, human-reviewed ranking, feed the top candidates into the Strangler Fig Migration Step Planning Prompt to generate the actual extraction sequence with proxy points and rollback gates.

IMPLEMENTATION TABLE

Expected Output Contract

The JSON schema, field definitions, data types, and validation rules the model must satisfy for the Service Extraction Candidate Scoring Prompt.

Field or ElementType or FormatRequiredValidation Rule

extraction_candidates

array

Schema check: must be a non-empty array. If empty, retry with lower confidence threshold.

extraction_candidates[].module_name

string

Parse check: must match a module or package name from [SYSTEM_CONTEXT]. Non-match triggers citation check.

extraction_candidates[].business_criticality_score

number (0.0-1.0)

Schema check: must be a float between 0.0 and 1.0 inclusive. Values outside range trigger retry.

extraction_candidates[].change_frequency_score

number (0.0-1.0)

Schema check: must be a float between 0.0 and 1.0 inclusive. Null not allowed.

extraction_candidates[].coupling_isolation_score

number (0.0-1.0)

Schema check: must be a float between 0.0 and 1.0 inclusive. Higher score means lower coupling.

extraction_candidates[].team_readiness_score

number (0.0-1.0)

Schema check: must be a float between 0.0 and 1.0 inclusive. If [TEAM_CONTEXT] is null, set to 0.5 and flag in risk_notes.

extraction_candidates[].risk_level

string

Enum check: must be one of 'low', 'medium', 'high', 'critical'. Invalid value triggers retry.

extraction_candidates[].dependency_ordering_rank

integer

Parse check: must be a positive integer starting from 1. Duplicate ranks trigger validation failure.

extraction_candidates[].rationale_summary

string

Length check: must be 50-300 characters. Shorter triggers retry for insufficient detail; longer triggers truncation.

extraction_candidates[].risk_notes

string

Null allowed. If risk_level is 'high' or 'critical' and risk_notes is null, trigger human review flag.

extraction_candidates[].dependency_ordering_constraints

array of strings

Schema check: each string must reference another module_name in the candidates list. Unresolved references trigger retry.

recommended_extraction_sequence

array of strings

Ordering check: must match dependency_ordering_rank ascending. Mismatch triggers re-sort and retry.

metadata.confidence_threshold_applied

number (0.0-1.0)

Schema check: must match [CONFIDENCE_THRESHOLD] input. Mismatch triggers retry.

metadata.generated_at

string (ISO 8601)

Format check: must be valid ISO 8601 datetime. Invalid format triggers retry.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when scoring service extraction candidates and how to guard against it with validation, retry prompts, or human review.

01

Score Inflation from Vague Criteria

What to watch: The model assigns high scores across all candidates because scoring dimensions like 'business criticality' or 'team readiness' are too abstract. Without concrete anchors, every module looks like a priority. Guardrail: Define each scoring dimension with specific, observable evidence requirements. Include a calibration example showing a low-score and high-score candidate with explicit rationale. Add a validator that flags score distributions where the standard deviation is below a threshold.

02

Dependency Ordering Violations

What to watch: The extraction sequence ignores hard dependencies. A module is recommended for extraction before its dependencies are extracted, creating impossible migration plans or requiring temporary shims that add risk. Guardrail: Require the prompt to output a dependency graph alongside the ranked list. Add a post-processing validator that checks each candidate's dependencies exist earlier in the sequence. Flag violations for human review before accepting the plan.

03

Ignoring Coupling Hotspots

What to watch: The model recommends extracting a module that appears isolated but has hidden runtime coupling—shared database tables, in-memory caches, or implicit API contracts. The extraction creates a distributed monolith worse than the original. Guardrail: Include a mandatory coupling analysis step in the prompt that checks for shared data stores, synchronous call chains, and schema co-dependence. Add a 'coupling isolation' score dimension with a minimum threshold before a candidate qualifies.

04

Team Readiness Overestimation

What to watch: The model assumes teams are ready to own extracted services without evidence. Scores reflect aspirational readiness rather than current capacity, skills, and operational maturity. Guardrail: Require team readiness evidence as a prompt input field—current on-call load, domain expertise, and deployment ownership history. Add a constraint that 'team readiness' cannot exceed a baseline score without explicit evidence. Flag candidates where readiness is scored high but evidence is missing.

05

Output Format Drift Under Long Contexts

What to watch: When scoring many candidates, the model drops fields, reorders the JSON schema, or omits the dependency ordering constraints from later entries. Partial outputs break downstream automation. Guardrail: Use a strict JSON schema with required fields and enum constraints. Add a post-generation validator that checks every candidate has all required fields, scores are within defined ranges, and the dependency ordering list is complete. Retry with a repair prompt if validation fails.

06

Risk Level Homogenization

What to watch: Every candidate gets a 'medium' risk rating because the model avoids making sharp distinctions. The risk dimension becomes useless for prioritization. Guardrail: Force a distribution constraint in the prompt—require at least one high-risk and one low-risk classification across the candidate set. Define risk levels with concrete triggers: 'high risk' requires evidence of shared database dependency, tight coupling, or team capacity gaps. Validate the distribution in post-processing.

IMPLEMENTATION TABLE

Evaluation Rubric

Pass/fail criteria and scoring dimensions for evaluating the quality of a service extraction candidate scoring output before it is used to make architectural decisions.

CriterionPass StandardFailure SignalTest Method

Output Schema Compliance

Valid JSON matching the expected [OUTPUT_SCHEMA] with all required fields present and no extra top-level keys

JSON parse failure, missing candidates array, or missing rank/score/rationale fields within a candidate object

Schema validation with JSON Schema or Pydantic model; automated parse check

Scoring Dimension Completeness

Every candidate includes a score for all dimensions specified in [SCORING_DIMENSIONS] (e.g., business_criticality, change_frequency, coupling_isolation, team_readiness, risk_level)

One or more candidates missing a required dimension score; null or placeholder values used instead of numeric scores

Field presence check per candidate; assert all dimension keys exist and values are non-null numbers

Ranking Consistency

Candidates are ordered by composite score descending; no candidate with a lower composite score appears above a candidate with a higher composite score

Rank order contradicts composite scores; two candidates with identical scores have no tie-breaking explanation

Sort validation: assert rank field matches sorted order of composite scores; check for tie-breaker rationale when scores are equal within 0.01

Dependency Ordering Validity

Recommended extraction sequence respects dependency constraints: no candidate appears before its declared dependencies in [DEPENDENCY_MAP]

A candidate is recommended for extraction before a service it depends on; circular dependency not flagged as a risk

Topological sort check against declared dependency graph; assert extraction order index of each candidate is greater than extraction order index of all its dependencies

Rationale Grounding

Each candidate's rationale references at least one concrete input from [SYSTEM_CONTEXT], [COUPLING_DATA], or [TEAM_TOPOLOGY]; no hallucinated module names

Rationale mentions modules, APIs, or teams not present in input context; generic justifications with no specific evidence

Entity grounding check: extract all module/service names from rationale and verify each appears in input context; flag any unmatched entities

Risk Level Calibration

Risk level assignments are consistent with coupling isolation scores: candidates with coupling_isolation below [LOW_COUPLING_THRESHOLD] are not marked as low_risk

A candidate with high coupling to the monolith is marked low_risk; risk level contradicts coupling or team readiness scores

Cross-field validation: assert risk_level is not 'low' when coupling_isolation < [LOW_COUPLING_THRESHOLD] or team_readiness < [READINESS_THRESHOLD]

Score Range Adherence

All dimension scores fall within the defined range [MIN_SCORE] to [MAX_SCORE] inclusive; composite score is a valid weighted sum

Scores outside defined range; composite score does not match weighted sum of dimension scores using [DIMENSION_WEIGHTS]

Range check per dimension; recompute composite score from dimension scores and weights and assert within 0.01 tolerance

Extraction Sequence Length

Recommended extraction sequence includes between [MIN_CANDIDATES] and [MAX_CANDIDATES] candidates; does not recommend extracting all candidates simultaneously

Sequence is empty, contains only one candidate, or recommends extracting all candidates in a single phase without sequencing

Count validation: assert length of extraction_sequence array is within configured bounds; check for phase grouping where parallel extraction is explicitly justified

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet). Remove the strict output schema requirement and accept a markdown table or bulleted list. Focus on getting a quick ranked list of 5-10 candidate modules without full scoring rigor. Replace [OUTPUT_SCHEMA] with: Return a markdown table with columns: Module, Business Criticality (High/Med/Low), Change Frequency (High/Med/Low), Coupling Isolation (High/Med/Low), Team Readiness (High/Med/Low), Risk Level (High/Med/Low), Extraction Rank.

Watch for

  • Model inventing module names that don't exist in [CODEBASE_CONTEXT]
  • Inconsistent ordinal vs. cardinal ranking
  • Skipping dependency ordering constraints entirely
  • Overly optimistic team readiness scores when [TEAM_CONTEXT] is sparse
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.