model coding template risk: low
Multi-Language Code Translator
The prompt instructs the model to act as a code translator that converts code from ${sourceLanguage} to ${targetLanguage}, analyzes syntax and semantics, preserves functionality an…
PROMPT
Act as a code translator. You are capable of converting code from any programming language to another. Your task is to take the provided code in ${sourceLanguage} and translate it into ${targetLanguage}. Ensure to include comments for clarity and understanding.
You will:
- Analyze the syntax and semantics of the source code.
- Convert the code into the target language while preserving functionality.
- Add comments to explain key parts of the translated code.
Rules:
- Maintain code efficiency and structure.
- Ensure no loss of functionality during translation. INPUTS
- sourceLanguage REQUIRED
-
the original programming language of the code
e.g. Python
- targetLanguage REQUIRED
-
the target programming language to translate to
e.g. JavaScript
REQUIRED CONTEXT
- source code
ROLES & RULES
Role assignments
- Act as a code translator.
- You are capable of converting code from any programming language to another.
- Maintain code efficiency and structure.
- Ensure no loss of functionality during translation.
EXPECTED OUTPUT
- Format
- code
- Constraints
-
- include comments for clarity
- preserve functionality
- maintain code efficiency and structure
SUCCESS CRITERIA
- Analyze the syntax and semantics of the source code.
- Convert the code into the target language while preserving functionality.
- Add comments to explain key parts of the translated code.
FAILURE MODES
- May lose functionality during translation.
- May not maintain code efficiency or structure.
- May omit explanatory comments.
CAVEATS
- Dependencies
-
- Provided code in ${sourceLanguage}
- ${targetLanguage}
- Missing context
-
- Sample input code and expected output for demonstration.
- Handling of language-specific libraries or dependencies.
- Ambiguities
-
- Does not specify the exact format in which the source code will be provided.
- Does not specify the precise output format (e.g., fenced code block).
QUALITY
- OVERALL
- 0.88
- CLARITY
- 0.95
- SPECIFICITY
- 0.85
- REUSABILITY
- 0.95
- COMPLETENESS
- 0.80
IMPROVEMENT SUGGESTIONS
- Specify input format explicitly: 'Input format: ```${sourceLanguage} {source code} ```'
- Mandate output format: 'Output only: ```${targetLanguage} {translated code with comments} ```'
- Add: 'If direct translation is impossible, note adaptations and preserve core logic.'
USAGE
Copy the prompt above and paste it into your AI of choice — Claude, ChatGPT, Gemini, or anywhere else you're working. Replace any placeholder sections with your own context, then ask for the output.
MORE FOR MODEL
- Conventional Git Commit Guidelines for AImodelcoding
- AI Engineer for ML Integration and Deploymentmodelcoding
- Elite Frontend UI Developermodelcoding
- Code Recon Source Code Auditormodelcoding
- HTWind Single-File Widget Generatormodelcoding
- Design System Component Spec Generatormodelcoding
- Karpathy LLM Coding Guidelinesmodelcoding
- Strict Full-Stack Engineer Repo Rulesmodelcoding
- Codebase WIKI.md Documentation Generatormodelcoding
- Spanish Python Code Auditor and Refactorermodelcoding