extract-function

Extract code blocks into named, typed TypeScript functions with call sites and tests.

11|Updated Apr 16, 2026
One-click install
npx skills add https://github.com/berkcangumusisik/claude-code-practices --skill extract-function
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: extract-function
Source: https://github.com/berkcangumusisik/claude-code-practices/tree/main/skills/extract-function
Command: npx skills add https://github.com/berkcangumusisik/claude-code-practices --skill extract-function

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers refactor repetitive or unclear code blocks by extracting them into named, typed functions, increasing readability and reusability.

Core Features & Use Cases

  • Analyzes a selected code block to identify inputs and outputs.
  • Generates a typed function with proper TypeScript definitions and JSDoc where applicable.
  • Replaces the original block with a call to the new function and returns updated code ready for testing.

Quick Start

Provide the target file path and the line range, and I will extract the block into a named, typed function with a test scaffold.

Frequently Asked Questions about extract-function

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract a code block into a typed function in TypeScript?

To extract a TypeScript code block into a typed function, provide the target file path and line range. The tool analyzes inputs and outputs, generates a function with type annotations, and replaces the original block with a call site.

Can I generate test scaffolds when refactoring JavaScript code blocks?

Yes, you can generate test scaffolds when refactoring JavaScript code blocks. The extraction process creates named, typed functions and optionally returns updated code ready for testing with repeated use cases.

What is the best way to refactor repetitive code blocks into reusable functions?

Refactoring repetitive code blocks into reusable functions is best handled by extracting the targeted lines into a named function. This process enforces type annotations and documentation, increasing readability and reusability across JavaScript files.

Does the function extraction process add JSDoc and type definitions automatically?

Yes, the function extraction process adds JSDoc and type definitions automatically. When analyzing the selected block, it generates proper TypeScript definitions and JSDoc where applicable alongside the new function call site.

What do I need to provide to extract a function from a TypeScript file?

To extract a function from a TypeScript file, you need to provide the target file path and the specific line range of the code block. The tool then handles the type inference, documentation, and call site generation.