
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.
- Installs
- 171
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/mhattingpete/claude-skills-marketplace --skill code-transfer- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads code-transfer automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
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
FAQ
What does the code-transfer skill do?
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.
How do I install code-transfer?
Run npx skills add https://github.com/mhattingpete/claude-skills-marketplace --skill code-transfer in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/code-transfer/ (personal) or .claude/skills/code-transfer/ (project).
Which AI agents can use code-transfer?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is code-transfer safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains code-transfer?
It is published by mhattingpete in mhattingpete/claude-skills-marketplace. It has 171 recorded installs.
More from mhattingpete/claude-skills-marketplace
flowchart-creator
mhattingpete/claude-skills-marketplace
Create HTML flowcharts and process diagrams with decision trees, color-coded stages, arrows, and swimlanes. Use when users request flowcharts, process diagrams, workflow visualizations, or decision trees.
codebase-documenter
mhattingpete/claude-skills-marketplace
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.
architecture-diagram-creator
mhattingpete/claude-skills-marketplace
Open the skill to read its SKILL.md instructions.
file-operations
mhattingpete/claude-skills-marketplace
Open the skill to read its SKILL.md instructions.
git-pushing
mhattingpete/claude-skills-marketplace
Open the skill to read its SKILL.md instructions.
test-fixing
mhattingpete/claude-skills-marketplace
Open the skill to read its SKILL.md instructions.
Popular other skills
hyperframes-cli
heygen-com/hyperframes
The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.
triage
mattpocock/skills
Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.
ask-matt
mattpocock/skills
Ask which skill or flow fits your situation. A router over the skills in this repo.
to-questionnaire
mattpocock/skills
Turn a decision you can't fully answer into a questionnaire for someone else to fill in.
loop-me
mattpocock/skills
Grill me about specs for the workflows I want to build, within this workspace.