CO

Manages code insertion and extraction tasks, supporting both individual edits and large-scale refactoring.

Install

mkdir -p .claude/skills/code-transfer && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/4383" && unzip -o skill.zip -d .claude/skills/code-transfer && rm skill.zip

Installs to .claude/skills/code-transfer

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Transfer code between files with line-based precision. Use when users request copying code from one location to another, moving functions or classes between files, extracting code blocks, or inserting code at specific line numbers.
231 chars✓ has a “when” trigger
Beginner

Key capabilities

  • Batch-copies code across files
  • Inserts code at exact line numbers
  • Extracts function or class blocks into new files
  • Creates file backups before insertion
  • Handles multi-file refactoring at scale

How it works

It utilizes a python-based line_insert script for precision insertion or batch processing scripts for large-scale movement.

Inputs & outputs

You give it
Target file path, line numbers, and operation
You get back
Modified files or extracted code blocks

When to use code-transfer

  • Extracting a class to a new file
  • Moving functions between modules
  • Inserting code blocks at specific lines

About this skill

Code Transfer

Transfer code between files with precise line-based control. Dual-mode operation: native tools (1-10 files) or execution mode (10+ files, 90% token savings).

Operation Modes

Basic Mode (Default)

Use Read, Edit, Bash scripts for 1-10 file operations. Works immediately, no setup required.

Execution Mode (10+ files)

from api.filesystem import batch_copy
from api.code_analysis import find_functions

functions = find_functions('app.py', pattern='handle_.*')
operations = [{
    'source_file': 'app.py',
    'start_line': f['start_line'],
    'end_line': f['end_line'],
    'target_file': 'handlers.py',
    'target_line': -1
} for f in functions]
batch_copy(operations)

When to Use

  • "copy this code to [file]"
  • "move [function/class] to [file]"
  • "extract this to a new file"
  • "insert at line [number]"
  • "reorganize into separate files"

Core Operations

1. Extract Source Code

Read(file_path="src/auth.py")                              # Full file
Read(file_path="src/auth.py", offset=10, limit=20)         # Line range
Grep(pattern="def authenticate", -n=true, -A=10)           # Find function

2. Insert at Specific Line

Use line_insert.py script for line-based insertion:

python3 skills/code-transfer/scripts/line_insert.py <file> <line_number> <code> [--backup]

Examples:

# Insert function at line 50
python3 skills/code-transfer/scripts/line_insert.py src/utils.py 50 "def helper():\n    pass"

# Insert with backup
python3 skills/code-transfer/scripts/line_insert.py src/utils.py 50 "code" --backup

# Insert at beginning
python3 skills/code-transfer/scripts/line_insert.py src/new.py 1 "import os"

When to use:

  • User specifies exact line number
  • Inserting into new/empty files
  • Inserting at beginning/end without context

3. Insert Relative to Content

Use Edit when insertion point is relative to existing code:

Edit(
  file_path="src/utils.py",
  old_string="def existing():\n    pass",
  new_string="def existing():\n    pass\n\ndef new():\n    return True"
)

Workflow Examples

Copy Function Between Files

  1. Find: Grep(pattern="def validate_user", -n=true, -A=20)
  2. Extract: Read(file_path="auth.py", offset=45, limit=15)
  3. Check target: Read(file_path="validators.py")
  4. Insert: Use line_insert.py or Edit based on context

Extract Class to New File

  1. Locate: Grep(pattern="class DatabaseConnection", -n=true, -A=50)
  2. Extract: Read(file_path="original.py", offset=100, limit=50)
  3. Create: Write(file_path="database.py", content="<extracted>")
  4. Update imports: Edit in original file
  5. Remove old class: Edit with replacement

Insert at Specific Line

  1. Validate: Read(file_path="main.py", offset=20, limit=10)
  2. Insert: python3 skills/code-transfer/scripts/line_insert.py main.py 25 "logger.info('...')" --backup
  3. Verify: Read(file_path="main.py", offset=23, limit=5)

Reorganize Into Modules

  1. Analyze: Read(file_path="utils.py")
  2. Identify groups: Grep(pattern="^def |^class ", -n=true)
  3. Extract each category: Write new files
  4. Update original: Re-export or redirect

Best Practices

Planning:

  • Understand dependencies (imports, references)
  • Identify exact start/end of code block
  • Check target file structure
  • Ensure necessary imports included

Preservation:

  • Include docstrings and comments
  • Transfer related functions together
  • Update imports in both files
  • Maintain formatting/indentation

Validation:

  • Verify insertion placement
  • Check syntax
  • Test imports
  • Suggest running tests

Backups:

  • Use --backup for significant changes
  • Critical file operations
  • Large deletions

Integration

  • code-refactor: Refactor after transferring
  • test-fixing: Run tests after reorganizing
  • feature-planning: Plan large reorganizations

When not to use it

  • Manual quick-fix edits
  • Refactoring code that relies on complex IDE-specific symbol resolution

Limitations

  • May struggle with complex conditional logic in large files
  • Requires exact line reference knowledge

How it compares

It operates with precise line-level control instead of relying on generic LLM file-rewrite capabilities that might hallucinate or break context.

Compared to similar skills

code-transfer side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
code-transfer (this skill)19moReviewBeginner
ast-grep-find37moReviewIntermediate
clean43moReviewIntermediate
framework-migration-code-migrate14moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

More by mhattingpete

View all by mhattingpete

dashboard-creator

mhattingpete

Create HTML dashboards with KPI metric cards, bar/pie/line charts, progress indicators, and data visualizations. Use when users request dashboards, metrics displays, KPI visualizations, data charts, or monitoring interfaces.

31157

architecture-diagram-creator

mhattingpete

Create comprehensive HTML architecture diagrams showing data flows, business objectives, features, technical architecture, and deployment. Use when users request system architecture, project documentation, high-level overviews, or technical specifications.

824

conversation-analyzer

mhattingpete

Analyzes your Claude Code conversation history to identify patterns, common mistakes, and opportunities for workflow improvement. Use when user wants to understand usage patterns, optimize workflow, identify automation opportunities, or check if they're following best practices.

899

codebase-documenter

mhattingpete

Generates comprehensive documentation explaining how a codebase works, including architecture, key components, data flow, and development guidelines. Use when user wants to understand unfamiliar code, create onboarding docs, document architecture, or explain how the system works.

613

code-execution

mhattingpete

Execute Python code locally with marketplace API access for 90%+ token savings on bulk operations. Activates when user requests bulk operations (10+ files), complex multi-step workflows, iterative processing, or mentions efficiency/performance.

10

ensemble-solving

mhattingpete

Generate multiple diverse solutions in parallel and select the best. Use for architecture decisions, code generation with multiple valid approaches, or creative tasks where exploring alternatives improves quality.

17

Search skills

Search the agent skills registry