code-transfer
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.
Install
mkdir -p .claude/skills/code-transfer && curl -L -o skill.zip "https://mcp.directory/api/skills/download/4383" && unzip -o skill.zip -d .claude/skills/code-transfer && rm skill.zipInstalls to .claude/skills/code-transfer
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
- Find:
Grep(pattern="def validate_user", -n=true, -A=20) - Extract:
Read(file_path="auth.py", offset=45, limit=15) - Check target:
Read(file_path="validators.py") - Insert: Use
line_insert.pyor Edit based on context
Extract Class to New File
- Locate:
Grep(pattern="class DatabaseConnection", -n=true, -A=50) - Extract:
Read(file_path="original.py", offset=100, limit=50) - Create:
Write(file_path="database.py", content="<extracted>") - Update imports:
Editin original file - Remove old class:
Editwith replacement
Insert at Specific Line
- Validate:
Read(file_path="main.py", offset=20, limit=10) - Insert:
python3 skills/code-transfer/scripts/line_insert.py main.py 25 "logger.info('...')" --backup - Verify:
Read(file_path="main.py", offset=23, limit=5)
Reorganize Into Modules
- Analyze:
Read(file_path="utils.py") - Identify groups:
Grep(pattern="^def |^class ", -n=true) - Extract each category:
Writenew files - 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
--backupfor significant changes - Critical file operations
- Large deletions
Integration
- code-refactor: Refactor after transferring
- test-fixing: Run tests after reorganizing
- feature-planning: Plan large reorganizations
More by mhattingpete
View all skills by mhattingpete →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
pdf-to-markdown
aliceisjustplaying
Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.
Related MCP Servers
Browse all serversUnlock seamless Figma to code: streamline Figma to HTML with Framelink MCP Server for fast, accurate design-to-code work
Easily automate Microsoft 365 tasks with simplified Graph API authentication. Access email, calendar, OneDrive, and more
Convert files easily with File Format Converter (Pandoc): transform PDF, HTML, Markdown, HEIC to JPG, JPG to PDF, and mo
Manage Android devices with ADB: execute shell commands, install apps, capture screenshots, and transfer files for effic
Access and manage your WSL Filesystem seamlessly from Windows. Effortlessly read, write, and edit files across Linux and
Easily convert Figma designs to code. Extract components from Figma files, generate hierarchies & metadata for smooth Fi
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.