Skip to content
Development
Command

/translate

Convert code between programming languages with 8x faster performance using parallel translation agents

From plugin
claude-cmd
313180 skills180 commands

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/translate

Context preview

What this command does when you run it.

Convert code between programming languages with 8x faster performance using parallel translation agents

Command definition

translate.md
allowed-tools: Read, Write, Bash(fd:*), Bash(rg:*), Bash(jq:*), Bash(gdate:*), Bash(cargo:*), Bash(go:*), Bash(deno:*), Bash(mvn:*), Bash(gradle:*), Task
name: "Translate"
description: "Convert code between programming languages with 8x faster performance using parallel translation agents"
author: "wcygan"
tags: ["meta","util"]
version: "1.0.0"
created_at: "2025-07-14T00:00:00Z"
updated_at: "2025-07-14T00:00:00Z"

Context

  • Session ID: !`gdate +%s%N`
  • Target translation: $ARGUMENTS
  • Source language detection: !`fd "(package\.json|Cargo\.toml|go\.mod|pom\.xml|build\.gradle|deno\.json)" . -d 3 | head -3 || echo "No build files detected"`
  • Current directory structure: !`fd . -t f -d 2 | head -10 || echo "Limited file access"`
  • Source code files: !`fd "\.(js|ts|py|rs|go|java|kt|rb|php|cs)" . -d 3 | head -10 || echo "No source files found"`
  • Test files: !`fd "(test|spec)" . -t f -d 3 | head -5 || echo "No test files found"`
  • Configuration files: !`fd "\.(json|toml|yaml|yml|xml|gradle)" . -d 2 | head -5 || echo "No config files found"`

Your Task

STEP 1: Initialize translation session and comprehensive source analysis

  • CREATE session state: `/tmp/translate-session-$SESSION_ID.json`
  • PARSE target language/framework from $ARGUMENTS
  • ANALYZE source project structure and detect primary language/framework
  • IDENTIFY translation scope (single file, module, or full project)
  • DETERMINE complexity level and whether sub-agents are needed

**Translation Session Initialization:**

echo "🔄 Initializing translation session..."
session_file="/tmp/translate-session-$SESSION_ID.json"

# Create session state with project analysis
jq -n --arg session_id "$SESSION_ID" \
      --arg target "$ARGUMENTS" \
      --arg timestamp "$(gdate -Iseconds)" \
      --arg source_dir "$(pwd)" \
      '{
        sessionId: $session_id,
        target: $target,
        timestamp: $timestamp,
        sourceDir: $source_dir,
        phase: "initialization",
        sourceLanguage: "auto-detect",
        targetLanguage: null,
        scope: "auto-detect",
        complexity: "unknown",
        translationMappings: {},
        progress: {
          analyzed: false,
          translated: false,
          validated: false,
          documented: false
        }
      }' > "$session_file"

echo "✅ Session initialized: $session_file"

STEP 2: Intelligent source language and framework detection

TRY:

  • DETECT primary source language from build files and file extensions
  • IDENTIFY framework patterns (Express.js, Spring Boot, Axum, etc.)
  • ANALYZE project architecture and patterns
  • MAP dependencies and external libraries
  • ASSESS code complexity and translation feasibility

**Source Language Detection:**

echo "🔍 Detecting source language and framework..."

# Detect primary language
if [ -f "package.json" ]; then
  source_lang="javascript/typescript"
  framework=$(jq -r '.dependencies | keys[]' package.json 2>/dev/null | rg "express|fastify|next|react|vue" | head -1 || echo "vanilla")
elif [ -f "Cargo.toml" ]; then
  source_lang="rust"
  framework=$(rg "axum|warp|rocket|actix" Cargo.toml | head -1 | cut -d'=' -f1 | tr -d ' "' || echo "vanilla")
elif [ -f "go.mod" ]; then
  source_lang="go"
  framework=$(rg "gin|echo|fiber|gorilla" go.mod | head -1 | cut -d' ' -f1 | sed 's|.*/||' || echo "vanilla")
elif [ -f "pom.xml" ] || [ -f "build.gradle" ]; then
  source_lang="java"
  framework=$(rg "spring-boot|quarkus|micronaut" pom.xml build.gradle 2>/dev/null | head -1 | cut -d':' -f2 | tr -d ' "' || echo "vanilla")
else
  source_lang="unknown"
  framework="unknown"
fi

echo "Source: $source_lang ($framework)"

STEP 3: Parse target specification and create translation strategy

CASE target_language: WHEN contains "rust" OR "axum":

  • SET target framework to "rust/axum"
  • LOAD Rust-specific translation patterns
  • PREPARE Cargo.toml template
  • IDENTIFY error handling conversion (exceptions → Result<T, E>)

WHEN contains "go" OR "golang":

  • SET target framework to "go/standard"
  • LOAD Go-specific patterns
  • PREPARE go.mod template
  • IDENTIFY concurrency patterns (async/await → goroutines)

WHEN contains "java" OR "spring" OR "quarkus":

  • SET target framework to "java/spring-boot" or "java/quarkus"
  • LOAD Java enterprise patterns
  • PREPARE Maven/Gradle configuration
  • IDENTIFY dependency injection conversion

WHEN contains "typescript" OR "deno":

  • SET target framework to "typescript/deno"
  • LOAD Deno-specific patterns
  • PREPARE deno.json configuration
  • IDENTIFY import map conversions

STEP 4: Execute translation with intelligent sub-agent delegation

**CRITICAL: Always maximize parallel execution through sub-agents. Translation tasks are perfectly suited for parallel processing, achieving 5-8x performance gains.**

IF project has > 5 source files OR complexity is non-trivial:

**High-Performance Parallel Translation - Deploy 8 Sub-Agents Immediately:**

echo "🚀 Launching 8 parallel translation agents for 8x faster translation..."
echo "⚡ Expected completion: 8-10x faster than sequential processing"

**IMMEDIATELY DEPLOY ALL 8 AGENTS IN PARALLEL:**

  • **Agent 1: Architecture Mapping & Pattern Recognition**
  • Focus: Analyze source code structure, design patterns, architectural decisions
  • Extract: Component relationships, data flow diagrams, service boundaries
  • Output: `/tmp/translate-architecture-$SESSION_ID.json`
  • Performance: Maps entire codebase structure in parallel with other agents
  • **Agent 2: Dependency & Package Translation Engine**
  • Focus: Convert package management systems (npm→cargo, pip→go.mod, maven→gradle)
  • Extract: Library equivalents, version mappings, feature compatibility
  • Output: `/tmp/translate-dependencies-$SESSION_ID.json`
  • Performance: Resolves all dependencies simultaneously
  • **Agent 3: Core Business Logic Translator**
  • Focus: Convert algorithms, business rules, and domain logic
  • Extract: Function mappings, class hierarchies, s
Read more
Ships withclaude-cmd

A lightweight (~46kB) and comprehensive CLI tool for managing Claude commands, configurations, and workflows.

Get the whole plugin