Prompt Engineering Refactoring Architecture

Architecture Cleanup Prompt — Boundaries Without a Redesign

Dependency cycles, leaky modules, misplaced responsibilities — cleaned up within the existing design. Explicitly not an invitation to invent a new architecture.

Overview

Architecture refactors attract scope explosions: asked to break one dependency cycle, the model proposes a hexagonal rewrite. This prompt uses the architecture cleanup goal with its built-in fence — straighten boundaries and dependencies within the existing design; do not invent a new architecture, introduce new layers, or redesign the system. The priorities are practical: modules expose purpose not internals, high-level policy stops depending on low-level detail, cycles get broken, misplaced responsibilities move to the module that owns the concept. An aggressive risk profile allows real restructuring — staged, verifiable, and traceable to the goal.

Workflow

  1. Fence the scope

    Cleanup within the existing design — the contract names the redesign temptation and forbids it.

  2. Fix direction and ownership

    Dependencies point from policy to detail, cycles break, responsibilities move to their owning module.

  3. Verify at the seams

    Module moves change visibility and initialization order — every consumer must still get the same contract.

Why This Works

  • The explicit no-redesign fence prevents the scope explosion these refactors are famous for
  • Dependency direction is checkable — vibes-based "cleaner architecture" is not
  • Integration-level validation catches what unit-level checks miss in module moves

Best for

  • Codebases where module boundaries eroded gradually
  • Restructuring that must stay shippable at every stage
  • Teams that want cleanup, not an architecture pitch

Not for

  • Designing a new system architecture from requirements — out of scope by the contract's own rules
  • Documenting the existing architecture — that's the Markdown Output Builder's space

Use cases

  • Breaking a dependency cycle between two packages
  • Moving misplaced responsibilities to the module that owns them
  • Narrowing a module interface that leaks internals

Tip: Save time by exploring related resources and tools that integrate with this workflow.

Explore all resources