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.
- Starts whenA teammate delegates a refactor issue that names the module and what to clean up
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
- 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.
Claude Code or Codex adds tests where the module's behavior isn't covered, in their own commit, then cleans it up on a teammate's machine with every test passing. Progress shows in the issue's agent session.
The pull request is linked on the issue. Public interfaces stay as they were unless the issue asks otherwise.
Delegate an issue that names the module and what to clean up. Merlin keeps to that module.
Claude Code or Codex adds tests where the module's behavior isn't covered, in their own commit, then cleans it up on a teammate's machine with every test passing. Progress shows in the issue's agent session.
The pull request is linked on the issue. Public interfaces stay as they were unless the issue asks otherwise.
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
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.
- 01Pick the refactor issue
- 02Read all of invoice.ts
- 03Check the test coverage
- 04Write tests for discounts
- 05Write tests for proration
- 06Move tax into its own file
- 07Move PDF rendering out
- 08Fix the imports
- 09Run the tests after each move
- 10Open a pull request
- 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.
- Refactor delegated to
MerlinThe issue names the module and the goal Adds tests, then splits it on Sofia's MacBookClaude Code keeps the tests green
- 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.
- 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.
- 02Connect LinearIntegrationsConnect your Linear workspace so issues can be delegated to Merlin.
- 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.
- 04Keep your code on the machineRuntimeMerlin reads the code in a local project on the runtime, so keep the repository checked out there.
- 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.
- 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.
Once, when you paste it
- PromptYou paste the prompt to @Merlin
- GuidanceMerlin saves your rules as workspace guidance
Every time an issue is delegated to Merlin
- IntegrationLinear hands Merlin the issue
- RuntimeMerlin picks an available machine
- ContextThe run gathers context
- WorkClaude Code or Codex adds tests and refactors
- SteeringYour team steers it from the issue
- ResultMerlin links the pull request on the issue
Related use cases
More engineering tasks you can hand to Merlin.
- Integrations
Engineering
Upgrade a dependency and fix what breaks
Delegate a dependency upgrade to Merlin in Linear. It bumps the version, fixes the breaking changes and opens one pull request linked on the issue.
Upgrade issue delegated to MerlinOne pull request, linked on the issue - IntegrationsYour agent's MCP
Engineering
Remove a feature flag that's fully rolled out
Mention Merlin on a flag cleanup issue in Linear. It checks the gate is fully rolled out in Statsig, removes the flag and its dead code and opens a pull request.
@Merlinin a Linear commentPull request linked on the issue - Integrations
Engineering
Write a design doc for a change
Mention Merlin on a Linear issue for a change you're planning. It reads the code involved and writes the approach, options and risks as a Linear document.
@Merlinin a Linear commentA design doc linked 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.