Editing & rewrite
AuraScore 81/100

Legacy Microservice Refactoring Script Generator

Transforms unstructured legacy service code into modular, production-ready refactoring scripts and modern architectural patterns.

Use this template when rewriting legacy backend logic to resolve technical debt and architectural drift. It delivers an automated codemod script and domain model mapping.

Template

Role: Principal Systems Architect with twenty years of distributed systems and code modernization experience.

Context

  • Source codebase language: {{source_language}}
  • Target architectural pattern: {{target_architecture}}
  • Legacy implementation snippet: {{code_snippet}}
  • Known performance bottlenecks: {{performance_bottlenecks}}
  • Primary framework dependencies: {{dependency_framework}}
  • Minimum test coverage floor: {{test_coverage_threshold}}

Task

Analyze the provided legacy implementation and construct a fully automated migration and refactoring script that rewrites the module into {{target_architecture}}, eliminates {{performance_bottlenecks}}, and generates unit test harnesses matching {{test_coverage_threshold}}.

Method

  1. Parse {{code_snippet}} to identify state mutations, tight couplings, and outdated invocations tied to {{dependency_framework}}.
  2. Map every legacy data flow into decoupled boundaries compliant with {{target_architecture}}.
  3. Identify hotspot algorithms that trigger {{performance_bottlenecks}} and formulate optimized data structures.
  4. Design an executable transformation script in {{source_language}} that automates the migration of legacy interfaces to modern signatures.
  5. Generate replacement business logic incorporating modern asynchronous or memory-safe patterns.
  6. Inject telemetry hooks, structured logging, and boundary guards within the rewritten components.
  7. Produce comprehensive test harnesses validating backward compatibility and enforcing {{test_coverage_threshold}}.

Constraints

  • MUST output runnable code and automation scripts without omitting implementation details.
  • MUST NOT introduce breaking changes to existing external API contracts unless explicitly encapsulated in an adapter.
  • Code formatting must strictly adhere to industry standards for {{source_language}}.
  • Every refactored segment must explicitly address {{performance_bottlenecks}}.

Output format

  • Section 1: Architectural Rewrite Blueprint (markdown summary under 200 words)
  • Section 2: Automated Refactoring Script (executable script block)
  • Section 3: Refactored Source Code (production implementation block)
  • Section 4: Regression Test Harness (test script verifying {{test_coverage_threshold}})

Self-review

  1. Did the script completely eliminate patterns causing {{performance_bottlenecks}}?
  2. Are all dependencies in {{dependency_framework}} updated or properly abstracted?
  3. Is the output strictly executable without generic placeholder comments?
AuraScore breakdown
81/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

writing-content
writing-editing
software-engineering-debugging
refactoring
software-architecture
codemod