Engineering

Refactor a module without changing what it does

Delegate a refactor to Merlin in Linear. It adds tests where coverage is thin, cleans up the module with the tests green and opens a pull request.

@Merlin from now on, when a refactor is delegated to you, first add tests where the module's behavior isn't covered, in their own commit. Then clean up the module as the issue describes without changing what it does, keep the tests green and open a pull request in acme/web linked to the issue. Don't change public interfaces unless the issue asks, and leave unrelated code alone.

ENG · tech debt
Get started for free
  1. Starts whenA teammate delegates a refactor issue that names the module and what to clean up
  2. Merlin worksClaude Code or Codex adds tests where coverage is thin, then cleans up the module and keeps every test passing on a teammate's machine
  3. You getA pull request linked on the issue, with the new tests in their own commit

Tools

  • Linear
  • GitHub

Capabilities

  • Integrations

How it works

From a refactor issue to a cleaner module with the tests still green.

Delegate an issue that names the module and what to clean up. Merlin keeps to that module.

ENENG › Issues › ENG-481

Split billing/invoice.ts by responsibility

invoice.ts is 900 lines of tax, discounts and PDF rendering. Split it into smaller modules and keep createInvoice's signature.

Activity

Sofiadelegated the issue to Merlin·now

Leave a comment…

Properties

Todo

Sofia

Merlin

Labels

Tech debt

Before and after

Refactors happen with a safety net, not on a quiet Friday.

Without Merlin

An engineer reads a long module end to end, writes the missing tests and moves code one piece at a time.

  1. 01Pick the refactor issue
  2. 02Read all of invoice.ts
  3. 03Check the test coverage
  4. 04Write tests for discounts
  5. 05Write tests for proration
  6. 06Move tax into its own file
  7. 07Move PDF rendering out
  8. 08Fix the imports
  9. 09Run the tests after each move
  10. 10Open a pull request
  11. 11Link it on the issue

With Merlin

Delegate the issue and review a split that kept every test green, with the new tests in their own commit.

  1. Refactor delegated to MerlinThe issue names the module and the goal
  2. Adds tests, then splits it on Sofia's MacBookClaude Code keeps the tests green
  3. Pull request linked on the issueNew tests in their own commit

Setup

Connect Linear and GitHub, then delegate refactors with a clear goal.

Set these up once and anyone on the team can hand a refactor to Merlin from its issue.

  1. 01Connect a machineRuntimeInstall the Merlin desktop app or CLI on a computer running Claude Code or Codex. You can also use a machine a teammate shares with your workspace.
  2. 02Connect LinearIntegrationsConnect your Linear workspace so issues can be delegated to Merlin.
  3. 03Install the GitHub appIntegrationsPick the repositories Merlin can access, so it can read and link the pull requests there. Pushes use the machine owner's own Git access.
  4. 04Keep your code on the machineRuntimeMerlin reads the code in a local project on the runtime, so keep the repository checked out there.
  5. 05Describe the target shape in the issueIntegrations

    Name the module, how to split it and which public functions must keep their signatures. Merlin leaves code outside that scope alone.

  6. 06Paste the setup promptGuidanceAn owner or admin sends the prompt below to @Merlin once, and it becomes workspace guidance for every future run.

Prompt

Tell Merlin how to take on a delegated refactor.

@Merlin from now on, when a refactor is delegated to you, first add tests where the module's behavior isn't covered, in their own commit. Then clean up the module as the issue describes without changing what it does, keep the tests green and open a pull request in acme/web linked to the issue. Don't change public interfaces unless the issue asks, and leave unrelated code alone.

ENG · tech debt

Once, when you paste it

  1. PromptYou paste the prompt to @Merlin
  2. GuidanceMerlin saves your rules as workspace guidance

Every time an issue is delegated to Merlin

  1. IntegrationLinear hands Merlin the issue
  2. RuntimeMerlin picks an available machine
  3. ContextThe run gathers context
  4. WorkClaude Code or Codex adds tests and refactors
  5. SteeringYour team steers it from the issue
  6. ResultMerlin links the pull request on the issue

Bring your coding agents into the tools your team already uses.

Let your whole team hand work to Claude Code and Codex today. Connect one machine and add Merlin to Slack, Linear or GitHub. 14-day free trial, no API keys, no card.