Agents meta-convert-guide

Guide for translating code between programming languages. Use when converting code from one language to another, planning language migrations, understanding conversion challenges, asking about type mappings, idiom translations, or referencing pattern mappings. Covers APTV workflow, type systems, error handling, concurrency, and language-specific gotchas.

install
source · Clone the upstream repo
git clone https://github.com/aRustyDev/agents
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/aRustyDev/agents "$T" && mkdir -p ~/.claude/skills && cp -r "$T/content/skills/meta-convert-guide" ~/.claude/skills/arustydev-agents-meta-convert-guide && rm -rf "$T"
manifest: content/skills/meta-convert-guide/SKILL.md
source content

Language Conversion Guide

Comprehensive patterns and strategies for converting code between programming languages.

Quick Navigation

ResourcePurpose
FORMS.mdTemplates, checklists, decision trees
tables/quick-reference.mdCondensed lookup tables

Examples

FileContent
examples/idiom-translation.mdNull handling, collections, pattern matching
examples/error-handling.mdException→Result, error hierarchies
examples/concurrency.mdPromise/Future, parallel execution
examples/metaprogramming.mdDecorators, macros, DI patterns
examples/serialization.mdJSON, validation, polymorphic types

Reference Guides

FileContent
reference/difficulty-matrix.mdConversion difficulty ratings
reference/type-system-mapping.mdPrimitives, composites, generics
reference/error-handling.mdError models, let-it-crash
reference/concurrency.mdAsync models, channels, goroutines
reference/dev-workflow-repl.md9th pillar, REPL patterns
reference/memory-ownership.mdGC→ownership, borrowing
reference/evaluation-strategy.mdLazy vs eager patterns
reference/metaprogramming.mdMacros, reflection, code gen
reference/type-system-translation.mdStatic↔dynamic, inference
reference/paradigm-translation.mdOOP→FP, FP→FP
reference/serialization.mdLibrary mapping, attributes
reference/typescript-patterns.mdType guards, mapped types
reference/hkt-type-classes.mdHKTs, Functor, Monad
reference/async-patterns.mdCancellation, streams
reference/dependency-management.mdPackage ecosystems
reference/performance.mdPitfalls, benchmarking

Gotchas

FileContent
reference/gotchas/by-family.mdOOP→FP, Dynamic→Static, GC→Ownership
reference/gotchas/by-language.mdPython→Rust, TypeScript→Rust, etc.

When to Use This Skill

  • Converting code from one language to another
  • Planning a language migration
  • Understanding conversion challenges between languages
  • Looking up type mappings or idiom translations
  • Referencing error handling, concurrency, or async patterns across languages
  • Learning about gotchas when converting between specific language families

This Skill Does NOT Cover

  • Creating new conversion skills (see
    meta-convert-dev
    )
  • Language tutorials (see
    lang-*-dev
    skills)
  • Runtime interop/FFI (see language-specific interop skills)

Related Skills

  • meta-convert-dev
    - For creating new
    convert-X-Y
    skills
  • convert-*
    skills - Language-pair specific conversion skills

Core Conversion Methodology

The APTV Workflow

Every conversion follows: Analyze → Plan → Transform → Validate

┌─────────────────────────────────────────────────────────────┐
│                    CONVERSION WORKFLOW                       │
├─────────────────────────────────────────────────────────────┤
│  1. ANALYZE    │  Understand source code structure          │
│                │  • Parse and identify components            │
│                │  • Map dependencies                         │
│                │  • Identify language-specific patterns      │
├─────────────────────────────────────────────────────────────┤
│  2. PLAN       │  Design the target architecture            │
│                │  • Create type mapping table                │
│                │  • Identify idiom translations              │
│                │  • Plan module/package structure            │
├─────────────────────────────────────────────────────────────┤
│  3. TRANSFORM  │  Convert code systematically               │
│                │  • Types and interfaces first               │
│                │  • Core logic second                        │
│                │  • Adopt target idioms (don't transliterate)│
├─────────────────────────────────────────────────────────────┤
│  4. VALIDATE   │  Verify functional equivalence             │
│                │  • Run original tests against new code      │
│                │  • Property-based testing for edge cases    │
│                │  • Performance comparison if relevant       │
└─────────────────────────────────────────────────────────────┘

See also: FORMS.md for APTV phase checklists

Analyze Phase

Before writing any target code:

  1. Parse the source - Understand structure, not just syntax
  2. Identify components:
    • Types/interfaces/classes
    • Functions/methods
    • Module boundaries
    • External dependencies
  3. Note language-specific features:
    • Generics usage
    • Error handling patterns
    • Async patterns
    • Memory management approach

Plan Phase

Create explicit mappings before transforming. Use the templates in FORMS.md:

## Type Mapping Table

| Source (TypeScript) | Target (Rust)      | Notes             |
| ------------------- | ------------------ | ----------------- |
| `string`            | `String` / `&str`  | Owned vs borrowed |
| `number`            | `i32` / `f64`      | Specify precision |
| `T[]`               | `Vec<T>`           | Owned collection  |
| `T \| null`         | `Option<T>`        | Nullable handling |
| `Promise<T>`        | `Future<Output=T>` | Async handling    |

See also: reference/type-system-mapping.md for complete mappings

Transform Phase

Golden Rule: Adopt target idioms, don't write "Source code in Target syntax"

// Source: TypeScript
function findUser(id: string): User | null {
  const user = users.find((u) => u.id === id);
  return user || null;
}
// BAD: Transliterated (TypeScript in Rust clothing)
fn find_user(id: String) -> Option<User> {
    let user = users.iter().find(|u| u.id == id);
    match user {
        Some(u) => Some(u.clone()),
        None => None,
    }
}

// GOOD: Idiomatic Rust
fn find_user(id: &str) -> Option<&User> {
    users.iter().find(|u| u.id == id)
}

See also: examples/idiom-translation.md for more patterns

Validate Phase

  1. Functional equivalence: Same inputs → same outputs
  2. Edge case coverage: Property-based tests
  3. Error behavior: Same error conditions trigger appropriately
  4. Performance baseline: Comparable or better performance

See also: FORMS.md for testing strategy checklist


The 8 Pillars of Conversion

Every comprehensive conversion addresses these domains:

PillarWhat to ConvertReference
1. Module SystemImports, exports, packagesreference/type-system-mapping.md
2. Error HandlingExceptions, Results, panicsreference/error-handling.md
3. ConcurrencyAsync, threads, channelsreference/concurrency.md
4. MetaprogrammingDecorators, macros, reflectionreference/metaprogramming.md
5. Zero/Default ValuesNullability, defaultsreference/type-system-mapping.md
6. SerializationJSON, validation, schemasreference/serialization.md
7. Build SystemPackage managers, dependenciesreference/dependency-management.md
8. TestingTest frameworks, assertionsFORMS.md

The 9th Pillar: Dev Workflow

For REPL-centric languages (Clojure, Elixir, Haskell), add:

SourceTargetConsideration
REPL-centricCompiledDocument workflow changes
Hot reloadRecompileFaster incremental builds
Live inspectionDebuggingLogger, debugger setup

See also: reference/dev-workflow-repl.md


Quick Reference Tables

Type System Comparison

LanguageTypingNull SafetyGenerics
TypeScriptStaticOptional (
strict
)
Full
PythonDynamicNone (runtime)Type hints
RustStaticEnforced (
Option
)
Full
GoStaticNil pointers1.18+
ElixirDynamicnil atomsNone
HaskellStatic (HM)Enforced (
Maybe
)
Full + HKT

See also: tables/quick-reference.md for complete tables

Error Model Comparison

LanguageModelPropagation
TypeScriptExceptions
throw
/
try-catch
PythonExceptions
raise
/
try-except
RustResult type
?
operator
GoError returns
if err != nil
ElixirPattern match
{:ok, _}
/
{:error, _}
HaskellEither/MaybeMonadic bind

See also: reference/error-handling.md

Concurrency Model Comparison

LanguageModelPrimitives
TypeScriptEvent loopPromises, async/await
PythonEvent loopasyncio, await
RustFuturestokio, async/await
GoCSPGoroutines, channels
ElixirActorsProcesses, GenServer
ErlangActorsProcesses, mailboxes

See also: reference/concurrency.md


Common Conversion Patterns

Null Handling

SourceTarget RustPattern
x ?? default
x.unwrap_or(default)
Default value
x?.prop
x.map(|v| v.prop)
Optional chaining
if (x != null)
if let Some(v) = x
Null check

See also: examples/idiom-translation.md

Error Propagation

SourceTargetPattern
throw new Error(msg)
return Err(Error::new(msg))
Throw → Result
try { } catch { }
match result { Ok(_) => ..., Err(_) => ... }
Try/catch → match
Rethrow
?
operator
Propagate error

See also: examples/error-handling.md

Collection Operations

Source (JS/TS)Target (Rust)Notes
.map(f)
.iter().map(f)
Lazy in Rust
.filter(f)
.iter().filter(f)
Lazy in Rust
.reduce(f, init)
.iter().fold(init, f)
Different arg order
.find(f)
.iter().find(f)
Returns Option

See also: tables/quick-reference.md


Decision Trees

When to Clone vs Borrow

Is the data needed after the function returns?
├─ NO → Borrow (&T)
└─ YES → Does caller need to keep using it?
         ├─ NO → Move (T)
         └─ YES → Clone (.clone())

See also: FORMS.md for complete decision trees

GC → Ownership Strategy

Is this data shared across components?
├─ YES → Consider Arc<T> or Rc<T>
└─ NO → Single owner, use moves

Is this data mutated by multiple parts?
├─ YES → Arc<Mutex<T>> or channels
└─ NO → Immutable borrows (&T)

See also: reference/memory-ownership.md


Common Pitfalls

PitfallWrongRight
TransliterationWrite TypeScript in Rust syntaxWrite idiomatic Rust
Ignoring idiomsPort class hierarchies to RustUse enums and traits
1:1 mappingEvery function maps exactlyRestructure as needed
Preserve inefficiencyPort inefficient algorithmsOptimize for target
Ignore conventionscamelCase in Pythonsnake_case (Python)

See also: reference/gotchas/by-family.md


Testing Conversions

Testing Pyramid

         ┌───────────────┐
         │  Integration  │  Same API behavior
         └───────────────┘
    ┌─────────────────────────┐
    │    Property-Based       │  Invariants hold
    └─────────────────────────┘
 ┌───────────────────────────────────┐
 │           Unit Tests              │  Logic matches
 └───────────────────────────────────┘
┌─────────────────────────────────────────┐
│        Input/Output Comparison          │  Golden tests
└─────────────────────────────────────────┘

Golden Testing

  1. Generate test cases from original implementation
  2. Save as JSON fixtures
  3. Run converted code against same inputs
  4. Compare outputs

See also: FORMS.md for testing checklist


Language-Specific Quick Links

Converting FROM

SourceKey GotchasReference
PythonDuck typing, None everywherereference/gotchas/by-language.md
TypeScriptOptional properties, anyreference/typescript-patterns.md
GoZero values, nilreference/gotchas/by-language.md
JavaNull, checked exceptionsreference/gotchas/by-language.md
HaskellHKTs, lazinessreference/hkt-type-classes.md
ElixirPattern matching, processesreference/gotchas/by-language.md

Converting TO

TargetKey ConsiderationsReference
RustOwnership, borrowingreference/memory-ownership.md
GoSimplicity, explicit errorsreference/error-handling.md
PythonDynamic typingreference/type-system-translation.md
ElixirFunctional, BEAMreference/paradigm-translation.md

References

Related Skills

  • meta-convert-dev
    - For creating new
    convert-X-Y
    skills
  • convert-typescript-rust
    - TypeScript → Rust conversion
  • convert-python-rust
    - Python → Rust conversion
  • convert-golang-rust
    - Go → Rust conversion

Language Skills

For language-specific fundamentals (not conversion):

  • lang-typescript-dev
    - TypeScript development patterns
  • lang-python-dev
    - Python development patterns
  • lang-rust-dev
    - Rust development patterns
  • lang-elixir-dev
    - Elixir development patterns