Agent skill

Code Translation

by ArabelaTso in ArabelaTso/Skills-4-SE

Convert code between programming languages while preserving functionality and semantics.

Apache-2.0Auto-check passedWriting & Content

Install Code Translation

skills CLI
$ npx skills add ArabelaTso/Skills-4-SE --skill code-translation -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ArabelaTso/Skills-4-SE code-translation --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ArabelaTso/Skills-4-SE.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/code-translation .claude/skills/code-translation && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
code-translation
GitHub stars
253
Token cost
~3.1k tokens
SKILL.md length
467 words
Files
4 (incl. references)
Skills in repo
151
Repo updated
First seen
Licence
Apache-2.0

At a glance

Convert code between programming languages while preserving functionality and semantics.

  • Works in 12 steps: Analyze Source Code → Choose Translation Strategy → Translate Code → …
  • Translating functions
  • SKILL.md covers Translation Workflow, Quick Translation Examples, Common Translation Patterns and Translation Decision Tree, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Code Translation is an agent skill from ArabelaTso/Skills-4-SE. Convert code between programming languages while preserving functionality and semantics. Use when: (1) Translating functions, classes, or modules between languages (Python, JavaScript/TypeScript, Java, Go, Rust, C/C++), (2) Migrating entire projects to a different language, (3) Need idiomatic translation that follows target language conventions, (4) Converting between different paradigms (OOP to functional, etc.), (5) Porting legacy code to modern languages. Provides language-specific patterns, idiomatic…

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/idiomatic_guide.md`, `references/language_patterns.md` and `references/project_migration.md`).

It sits in Writing & Content, covering Translation. It works with Python, JavaScript, Java and TypeScript. The repository describes itself as: A curated list of 180+ useful Claude Skills for Software Engineering and resources for customizing AI for SE workflows. The licence is Apache-2.0.

When your agent uses it

  • Translating functions
  • Modules between languages (Python
  • JavaScript/TypeScript
  • Migrating entire projects to a different language

Example prompts

  • “/code-translation”

Requirements

  • Python 3

Workflow steps

12 steps, taken from the step headings in SKILL.md.

  1. Analyze Source Code
  2. Choose Translation Strategy
  3. Translate Code
  4. Verify Correctness
  5. Preserve Behavior, Not Structure
  6. Use Target Language Features
  7. Maintain Type Safety When Possible
  8. Handle Library Differences
  9. Test Rigorously
  10. Literal Translation
  11. Ignoring Language Safety
  12. Wrong Abstraction Level

What it can do on your machine

Read from SKILL.md and the folder at commit 4f38503. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python, javascript, go, typescript and java).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Code Translation loads about 3.1k tokens when it runs, and up to ~11k if it reads all its reference files. Until then it costs about 145 tokens; SKILL.md has 467 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~145
When it runs · the whole SKILL.md, loaded when a task matches
~3.1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~11k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ArabelaTso/Skills-4-SE at commit 4f38503, republished under its Apache-2.0 licence (© ArabelaTso). 467 words, ~3,066 tokens.

Download SKILL.mdSave it as .claude/skills/code-translation/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
code-translation
description
Convert code between programming languages while preserving functionality and semantics. Use when: (1) Translating functions, classes, or modules between languages (Python, JavaScript/TypeScript, Java, Go, Rust, C/C++), (2) Migrating entire projects to a different language, (3) Need idiomatic translation that follows target language conventions, (4) Converting between different paradigms (OOP to functional, etc.), (5) Porting legacy code to modern languages. Provides language-specific patterns, idiomatic translation guides, and project migration strategies.

Code Translation

Convert code between programming languages while preserving functionality, adapting to target language idioms and best practices.

Translation Workflow

1. Analyze Source Code

Understand what the code does:

  • Core functionality and algorithms
  • Dependencies and external libraries
  • Language-specific features used
  • Performance characteristics
2. Choose Translation Strategy

Direct Translation: Literal conversion maintaining structure

  • Use for: Simple algorithms, data transformations, utility functions
  • Pros: Faster, easier to verify correctness
  • Cons: May not be idiomatic in target language

Idiomatic Translation: Adapt to target language patterns

  • Use for: Production code, public APIs, long-term maintenance
  • Pros: Native-feeling code, better performance, maintainable
  • Cons: Takes longer, requires deep language knowledge

Recommended: Start with direct translation, then refine to idiomatic.

3. Translate Code

Perform the translation following language patterns and conventions.

4. Verify Correctness

Ensure translated code behaves identically to source:

  • Port existing tests
  • Add behavioral tests
  • Compare outputs on same inputs

Quick Translation Examples

Python → JavaScript

Source (Python)

python
def calculate_total(items):
    """Calculate total price with tax."""
    subtotal = sum(item['price'] * item['quantity'] for item in items)
    tax = subtotal * 0.08
    return subtotal + tax

# Usage
items = [
    {'name': 'Widget', 'price': 10.0, 'quantity': 2},
    {'name': 'Gadget', 'price': 15.0, 'quantity': 1}
]
total = calculate_total(items)

Target (JavaScript)

javascript
function calculateTotal(items) {
    // Calculate total price with tax
    const subtotal = items.reduce(
        (sum, item) => sum + item.price * item.quantity,
        0
    );
    const tax = subtotal * 0.08;
    return subtotal + tax;
}

// Usage
const items = [
    { name: 'Widget', price: 10.0, quantity: 2 },
    { name: 'Gadget', price: 15.0, quantity: 1 }
];
const total = calculateTotal(items);
JavaScript → Python

Source (JavaScript)

javascript
async function fetchUserData(userId) {
    try {
        const response = await fetch(`/api/users/${userId}`);
        if (!response.ok) {
            throw new Error(`HTTP ${response.status}`);
        }
        return await response.json();
    } catch (error) {
        console.error(`Failed to fetch user: ${error.message}`);
        return null;
    }
}

Target (Python)

python
import aiohttp
import logging

async def fetch_user_data(user_id: int) -> dict | None:
    """Fetch user data from API."""
    try:
        async with aiohttp.ClientSession() as session:
            async with session.get(f'/api/users/{user_id}') as response:
                if not response.ok:
                    raise ValueError(f'HTTP {response.status}')
                return await response.json()
    except Exception as e:
        logging.error(f'Failed to fetch user: {e}')
        return None
Java → Go

Source (Java)

java
public class UserService {
    private final UserRepository repository;

    public UserService(UserRepository repository) {
        this.repository = repository;
    }

    public Optional<User> findById(Long id) {
        return repository.findById(id);
    }

    public List<User> findAll() {
        return repository.findAll();
    }
}

Target (Go)

go
type UserService struct {
    repository UserRepository
}

func NewUserService(repository UserRepository) *UserService {
    return &UserService{repository: repository}
}

func (s *UserService) FindById(id int64) (*User, error) {
    return s.repository.FindById(id)
}

func (s *UserService) FindAll() ([]User, error) {
    return s.repository.FindAll()
}

Common Translation Patterns

Data Structures

Lists/Arrays

python
# Python
numbers = [1, 2, 3]
numbers.append(4)
javascript
// JavaScript
const numbers = [1, 2, 3];
numbers.push(4);
go
// Go
numbers := []int{1, 2, 3}
numbers = append(numbers, 4)

Dictionaries/Maps

python
# Python
user = {"name": "Alice", "age": 30}
javascript
// JavaScript
const user = { name: "Alice", age: 30 };
go
// Go
user := map[string]interface{}{
    "name": "Alice",
    "age":  30,
}
Error Handling

Exceptions → Error Returns

python
# Python
def divide(a, b):
    if b == 0:
        raise ValueError("Cannot divide by zero")
    return a / b
go
// Go
func divide(a, b float64) (float64, error) {
    if b == 0 {
        return 0, errors.New("cannot divide by zero")
    }
    return a / b, nil
}

Error Returns → Exceptions

go
// Go
result, err := divide(10, 0)
if err != nil {
    return err
}
python
# Python
try:
    result = divide(10, 0)
except ValueError as e:
    print(f"Error: {e}")
Async/Concurrency

Python asyncio → JavaScript async/await

python
# Python
async def fetch_all(urls):
    tasks = [fetch(url) for url in urls]
    return await asyncio.gather(*tasks)
javascript
// JavaScript
async function fetchAll(urls) {
    const promises = urls.map(url => fetch(url));
    return await Promise.all(promises);
}

JavaScript Promises → Go Goroutines

javascript
// JavaScript
const results = await Promise.all([
    fetchUser(1),
    fetchUser(2),
    fetchUser(3)
]);
go
// Go
var wg sync.WaitGroup
results := make([]*User, 3)

for i := 1; i <= 3; i++ {
    wg.Add(1)
    go func(id int) {
        defer wg.Done()
        results[id-1] = fetchUser(id)
    }(i)
}
wg.Wait()

Translation Decision Tree

Is this a complete project migration?
├─ Yes → See [project_migration.md](references/project_migration.md)
│         Follow 8-phase migration process
│
└─ No → Is this a function/class/module?
        │
        ├─ Single function
        │  ├─ Simple logic? → Direct translation
        │  └─ Complex logic? → Idiomatic translation
        │
        ├─ Class with methods
        │  ├─ Does target language have classes?
        │  │  ├─ Yes → Translate class structure
        │  │  └─ No → Convert to module/functions
        │
        └─ Full module
           └─ Translate file by file
              Consider dependencies first

Language-Specific Guidance

For Idiomatic Translation

See idiomatic_guide.md for:

  • Language-specific idioms and patterns
  • Naming conventions (snake_case, camelCase, PascalCase)
  • Standard library usage
  • Anti-patterns to avoid
  • Community style guides
For Specific Language Pairs

See language_patterns.md for detailed patterns:

  • Python ↔ JavaScript/TypeScript
  • Java ↔ Python
  • Python ↔ Go
  • C++ ↔ Rust
  • TypeScript ↔ Go
  • Common patterns across all languages
For Project Migration

See project_migration.md for:

  • 8-phase migration process
  • Dependency mapping
  • Build system translation
  • Testing strategies
  • Deployment configuration
  • Incremental migration approaches

Best Practices

1. Preserve Behavior, Not Structure

Focus on what the code does, not how it's written:

python
# Python (imperative)
total = 0
for item in items:
    total += item.price
javascript
// JavaScript (functional - different structure, same behavior)
const total = items.reduce((sum, item) => sum + item.price, 0);
Show full SKILL.md (188 more words)Show less
2. Use Target Language Features

Don't fight the language - embrace its strengths:

python
# Python - use list comprehensions
squares = [x**2 for x in range(10)]

# Not: Java-style loop
squares = []
for x in range(10):
    squares.append(x**2)
3. Maintain Type Safety When Possible

Add type hints/annotations in statically typed languages:

python
# Python source (dynamic)
def greet(name):
    return f"Hello, {name}"
typescript
// TypeScript (add types)
function greet(name: string): string {
    return `Hello, ${name}`;
}
4. Handle Library Differences

Map to equivalent libraries or implement abstractions:

python
# Python using requests
import requests
response = requests.get(url)
data = response.json()
javascript
// JavaScript using fetch
const response = await fetch(url);
const data = await response.json();
5. Test Rigorously

Verify translated code behaves identically:

python
# Port tests alongside code
def test_calculate_total():
    items = [{"price": 10, "quantity": 2}]
    assert calculate_total(items) == 21.6  # 20 + 8% tax
javascript
// Same test in target language
test('calculateTotal', () => {
    const items = [{ price: 10, quantity: 2 }];
    expect(calculateTotal(items)).toBe(21.6);
});

Translation Checklist

Before Translation
  • Understand source code functionality
  • Identify dependencies and library equivalents
  • Choose translation strategy (direct vs idiomatic)
  • Set up target project structure
During Translation
  • Translate core logic first
  • Adapt to target language idioms
  • Handle error handling differences
  • Map data structures appropriately
  • Convert async/concurrency patterns
  • Translate comments and documentation
After Translation
  • Port or create tests
  • Verify behavioral equivalence
  • Code review for idioms
  • Performance testing
  • Update documentation
  • Add type hints/annotations if applicable

Common Pitfalls

1. Literal Translation

❌ Translating line-by-line without adapting ✅ Adapting to target language patterns

2. Ignoring Language Safety

❌ Using any/interface{}/Object everywhere ✅ Proper typing and error handling

3. Wrong Abstraction Level

❌ Translating implementation details ✅ Translating behavior and intent

4. Missing Edge Cases

❌ Assuming same behavior for edge cases ✅ Testing boundary conditions

5. Performance Blindness

❌ Ignoring performance characteristics ✅ Profiling and optimizing for target language

Example: Complete Translation

Python Source

python
class Calculator:
    """Simple calculator with memory."""

    def __init__(self):
        self.memory = 0

    def add(self, a: float, b: float) -> float:
        """Add two numbers."""
        result = a + b
        self.memory = result
        return result

    def recall(self) -> float:
        """Recall last result."""
        return self.memory

    def clear(self):
        """Clear memory."""
        self.memory = 0

TypeScript Translation

typescript
/**
 * Simple calculator with memory.
 */
class Calculator {
    private memory: number = 0;

    /**
     * Add two numbers.
     */
    add(a: number, b: number): number {
        const result = a + b;
        this.memory = result;
        return result;
    }

    /**
     * Recall last result.
     */
    recall(): number {
        return this.memory;
    }

    /**
     * Clear memory.
     */
    clear(): void {
        this.memory = 0;
    }
}

Go Translation (Idiomatic)

go
// Calculator is a simple calculator with memory.
type Calculator struct {
    memory float64
}

// NewCalculator creates a new calculator.
func NewCalculator() *Calculator {
    return &Calculator{memory: 0}
}

// Add two numbers and store result in memory.
func (c *Calculator) Add(a, b float64) float64 {
    result := a + b
    c.memory = result
    return result
}

// Recall returns the last result.
func (c *Calculator) Recall() float64 {
    return c.memory
}

// Clear resets the memory to zero.
func (c *Calculator) Clear() {
    c.memory = 0
}

© ArabelaTso, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in skills/code-translation of ArabelaTso/Skills-4-SE.

  • SKILL.md
  • references/idiomatic_guide.md
  • references/language_patterns.md
  • references/project_migration.md

Open the folder on GitHubat commit 4f38503

Compare with similar skills

Code Translation next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Code Translation compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Code Translation this skillArabelaTso/Skills-4-SE253—~3.1kAutomated safety check: PassApache-2.0
Fory Releaseapache/fory4.6k—~2.9kAutomated safety check: PassApache-2.0
CodeQL Security Scantrailofbits/skills7.4k—~4.6kAutomated safety check: NotesCC-BY-SA-4.0
Fory Version Bumpapache/fory4.6k—~1.1kAutomated safety check: PassApache-2.0
Fory Performance Optimizationapache/fory4.6k—~2.2kAutomated safety check: PassApache-2.0
Cross-Language Coding Standardszereight/gitlab-mcp2k1 repos~1.4kAutomated safety check: PassMIT

Similar skills

  • Fory Release

    apache/fory

    Prepare an Apache Fory release candidate from a clean release branch, including the version bump, RC tag, JVM staging, ASF source artifacts, SVN upload, and vote email.

    4.6k GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • CodeQL Security Scan

    trailofbits/skills

    Official

    Scans a codebase for vulnerabilities with CodeQL's data flow and taint tracking in run-all or important-only modes, including data extensions for project-specific sources and sinks.

    7.4k GitHub stars~4.6k tokensUpdated 5 days ago
    SecurityAuto-check: notes
  • Bump Apache Fory release or post-release development versions across Java, Kotlin, Scala, Python, Rust, Go, C++, C, Dart, JavaScript, Swift, integration tests, examples, and source docs.

    4.6k GitHub stars~1.1k tokensUpdated today
    MobileAuto-check passed
  • Run profile-driven bottleneck optimization across Apache Fory implementations (Java, C++, Python/Cython, Go, Rust, Swift, C, JavaScript/TypeScript, Dart, Kotlin, Scala).

    4.6k GitHub stars~2.2k tokensUpdated today
    MobileAuto-check passed
  • Shared reference for naming, function size, complexity and error handling rules that reviewer agents apply across TypeScript, Python, Go, Rust, Java, C# and Swift.

    2k GitHub starsUsed in 1 repo~1.4k tokens
    DevelopmentAuto-check passed
  • Dbg

    theodo-group/debug-that

    Debug applications using the dbg CLI debugger. An agent skill from theodo-group/debug-that.

    158 GitHub stars~1.9k tokensUpdated 4 mo ago
    DevelopmentAuto-check passed

More from ArabelaTso/Skills-4-SE

All 151 skills in this repo
  • Framework Migration Assistant

    ArabelaTso/Skills-4-SE

    Automatically migrate Python web applications between frameworks (Flask → FastAPI, Django → FastAPI).

    253 GitHub stars~1.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Metamorphic Test Generator

    ArabelaTso/Skills-4-SE

    Generate test cases using metamorphic testing by applying transformations based on metamorphic properties.

    253 GitHub stars~798 tokensUpdated 1 mo ago
    Auto-check passed
  • Reproduction Trace Instrumenter

    ArabelaTso/Skills-4-SE

    Instruments programs to capture execution traces specifically for reproducing reported bugs, enabling consistent replay and diagnosis of failures.

    253 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Spring Mvc To Boot Migrator

    ArabelaTso/Skills-4-SE

    Automatically migrate Spring MVC applications to Spring Boot.

    253 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check passed
  • State Snapshot Instrumenter

    ArabelaTso/Skills-4-SE

    Instrument programs (Python, C/C++, Java) to capture snapshots of key program states at runtime, including variables, memory, and call stacks.

    253 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check passed

Questions about Code Translation

What does Code Translation do?

Convert code between programming languages while preserving functionality and semantics. Code Translation is an agent skill from ArabelaTso/Skills-4-SE. Convert code between programming languages while preserving functionality and semantics.

When should I use Code Translation?

Code Translation fits situations like: translating functions; modules between languages (Python; javaScript/TypeScript; migrating entire projects to a different language.

How do I install Code Translation in Claude Code?

Run `npx skills add ArabelaTso/Skills-4-SE --skill code-translation -a claude-code`. Or copy the skill folder (skills/code-translation in ArabelaTso/Skills-4-SE) into .claude/skills/code-translation in your project. Claude Code loads it when a task matches its description.

How do I install Code Translation in Codex?

Run `npx skills add ArabelaTso/Skills-4-SE --skill code-translation -a codex`. Or copy the skill folder (skills/code-translation in ArabelaTso/Skills-4-SE) into .agents/skills/code-translation in your project. Codex loads it when a task matches its description.

Can I use Code Translation in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ArabelaTso/Skills-4-SE --skill code-translation -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/code-translation, .gemini/skills/code-translation, .github/skills/code-translation and .opencode/skills/code-translation in your project.

What does Code Translation need to run?

SKILL.md names no scripts, command-line tools or credentials: Code Translation is instructions for the agent only. Our summary lists: Python 3.

Does Code Translation access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Code Translation safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Code Translation use?

Code Translation is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Code Translation use?

About 3.1k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 7.7k tokens, read only when the agent opens those files.

What are the alternatives to Code Translation?

Skills that share tags, products or a category with Code Translation: Fory Release (apache/fory, 4.6k stars), CodeQL Security Scan (trailofbits/skills, 7.4k stars), Fory Version Bump (apache/fory, 4.6k stars) and Fory Performance Optimization (apache/fory, 4.6k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Code Translation?

ArabelaTso (a GitHub user) maintains it in ArabelaTso/Skills-4-SE, which has 253 GitHub stars. The repository holds 151 skills in this directory. The repository was last updated on August 21, 2026.

Source: ArabelaTso/Skills-4-SE on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.