# Decompose a function that outgrew a single responsibility

A function that grew several jobs, split so each piece can be understood and tested alone.

Category: Refactors and cleanup
Source: https://letsship.ai/use-cases/decompose-an-overgrown-function
Published: 2026-08-25

## Goal

Split a function that does several things into pieces that each do one.

## Acceptance criteria

- Each extracted piece has one responsibility and its own test
- The public behaviour is unchanged
- Parameter counts stay within the project's limit
- The original function reads as a sequence of named steps

## What lands as proof

Tests on each extracted piece, which is what the original size made impossible.

## Prompt

Copy this to an agent to open the ticket:

```text
Create a Linear issue in my team and assign it to the SHIP agent.

Title: Decompose {function}

Description: Split a function that does several things into pieces that each do one.

Acceptance criteria:
- Each extracted piece has one responsibility and its own test
- The public behaviour is unchanged
- Parameter counts stay within the project's limit
- The original function reads as a sequence of named steps

Before you create the issue, find the longest function in this repository and replace {function} with it.
```

## Questions

### What does the agent actually change?

The ticket is scoped to one outcome: split a function that does several things into pieces that each do one. Work that serves that outcome is in scope, and anything outside it is left for a separate ticket, so the pull request stays reviewable.

### How do I know the work is done?

The pull request carries the evidence, not only the diff. Here that means same behaviour, each piece tested on its own, so a reviewer can confirm the result without reproducing the work locally.

### How much oversight does this need?

None is required before the run starts. Every claim this ticket makes can be checked by machine, so the agent works straight through and a person reviews the finished pull request like any other.
