home / skills / codyswanngt / lisa / plan-reduce-max-lines-per-function

plan-reduce-max-lines-per-function skill

/.claude/skills/plan-reduce-max-lines-per-function

This skill reduces function line limits in TypeScript projects by updating eslint thresholds, identifying violators, and delivering a concrete refactor plan.

npx playbooks add skill codyswanngt/lisa --skill plan-reduce-max-lines-per-function

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.6 KB
---
name: plan-reduce-max-lines-per-function
description: This skill should be used when reducing the maximum lines per function threshold and fixing all violations. It updates the eslint threshold configuration, identifies functions exceeding the new limit, generates a brief with refactoring strategies, and creates a plan with tasks to split oversized functions.
allowed-tools: ["Read", "Bash", "Glob", "Grep"]

---

# Reduce Max Lines Per Function

Target threshold: $ARGUMENTS lines per function

If no argument provided, prompt the user for a target.

## Step 1: Gather Requirements

1. **Read current config** from eslint thresholds (eslint.thresholds.json or similar)
2. **Run lint** with the new threshold to find violations:
   ```bash
   bun run lint 2>&1 | grep "max-lines-per-function"
   ```
3. **Note for each violation**:
   - File path and line number
   - Function name
   - Current line count

If no violations at $ARGUMENTS, report success and exit.

## Step 2: Compile Brief and Delegate

Compile the gathered information into a structured brief:

```
Reduce max lines per function threshold to $ARGUMENTS.

Functions exceeding threshold (ordered by line count):
1. [file:function] (lines: X, target: $ARGUMENTS) - Line Y
2. ...

Configuration change: eslint.thresholds.json, maxLinesPerFunction to $ARGUMENTS

Refactoring strategies: extract functions, early returns, extract conditions, use lookup tables, consolidate logic

Verification: `bun run lint 2>&1 | grep "max-lines-per-function" | wc -l` → Expected: 0
```

Invoke `/plan-execute` with this brief to create the implementation plan.

Overview

This skill reduces the maximum allowed lines per function across a TypeScript codebase and fixes all violations. It updates the ESLint threshold configuration, discovers functions that exceed the new limit, and produces a refactoring brief plus a task plan to split oversized functions.

How this skill works

The skill reads the existing ESLint thresholds configuration and updates the maxLinesPerFunction value to the requested target. It runs the linter with the new threshold to identify every violation, collects file paths, function names, line counts and locations, then generates a concise brief with refactoring strategies. Finally, it creates a prioritized task list to split or simplify offending functions and verifies success by re-running the lint check.

When to use it

  • Lowering the max lines per function threshold to improve readability and maintainability.
  • Enforcing tighter coding standards as part of a style-guide or CI gating change.
  • Preparing a large codebase for modularization or easier unit testing.
  • Prioritizing technical debt reduction focused on long functions.
  • After merging a policy change that requires smaller, single-responsibility functions.

Best practices

  • Pick a realistic target that balances readability and effort; solicit team agreement before mass changes.
  • Run the updated linter locally to get a full list of violations before assigning work.
  • Order violations by line count and business impact to prioritize high-return refactors.
  • Favor small, verifiable refactors: extract helper functions, early returns, and condition extraction.
  • Include lint verification in CI and require zero remaining violations before merge.

Example use cases

  • Reduce max lines per function from 300 to 150 to make functions more testable.
  • Enforce a stricter threshold for a new microservice to ensure consistent style across teams.
  • Perform a sprint of automated refactors where each oversized function is split into tasks.
  • Create a developer onboarding task list that teaches refactoring patterns while fixing violations.

FAQ

What inputs are required to run this skill?

Provide the target max lines per function. If omitted, the skill will prompt for the desired threshold.

How does the skill verify that all violations are fixed?

It reruns the linter and counts max-lines-per-function violations; success is when the count is zero.