transmute
关于
The `transmute` skill transforms a single function, module, or data structure from one form to another while preserving its core behavior. It's a lightweight, targeted tool for conversions like migrating between languages, paradigms, or API versions. Use it for focused refactoring tasks rather than full-system transformations.
快速安装
Claude Code
推荐npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/transmute在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Transmute
Transform specific piece of code or data from one form to another — language translation, paradigm shift, format conversion, or API migration — while preserving essential behavior and semantics.
When Use
- Convert function from one language to another (Python to R, JavaScript to TypeScript)
- Shift module from one paradigm (class-based to functional, callbacks to async/await)
- Migrate API consumer from v1 to v2 of external service
- Convert data between formats (CSV to Parquet, REST to GraphQL schema)
- Replace dependency with equivalent (moment.js to date-fns, jQuery to vanilla JS)
- Transformation scope is single function, class, or module (not full system)
Inputs
- Required: Source material (file path, function name, or data sample)
- Required: Target form (language, paradigm, format, or API version)
- Optional: Behavioral contract (tests, type signatures, or expected I/O pairs)
- Optional: Constraints (must maintain backward compatibility, performance budget)
Steps
Step 1: Analyze Source Material
Understand exact what source does before attempting transformation.
- Read the source completely — every branch, edge case, and error path
- Identify the behavioral contract:
- What inputs does it accept? (types, ranges, edge cases)
- What outputs does it produce? (return values, side effects, error signals)
- What invariants does it maintain? (ordering, uniqueness, referential integrity)
- Catalog dependencies: what does the source import, call, or rely on?
- If tests exist, read them to understand expected behavior
- If no tests exist, write behavioral characterization tests before transmuting
Got: Complete understanding of what source does (not how it does it). Behavioral contract explicit and testable.
If fail: Source too complex for single transmute? Consider breaking into smaller pieces or escalating to full athanor procedure. Behavior ambiguous? Ask for clarification rather than guessing.
Step 2: Map Source to Target Form
Design transformation mapping.
- For each element in the source, identify the target equivalent:
- Language constructs: loops → map/filter, classes → closures, etc.
- API calls: old endpoint → new endpoint, request/response shape changes
- Data types: data frame columns → schema fields, nested JSON → flat tables
- Identify elements with no direct equivalent:
- Source features missing in target (e.g., pattern matching in a language without it)
- Target idioms that don't exist in source (e.g., R's vectorization vs. Python loops)
- For each gap, choose an adaptation strategy:
- Emulate: reproduce the behavior with target-native constructs
- Simplify: if the source construct was a workaround, use the target's native solution
- Document: if behavior changes slightly, note the difference explicitly
- Write the transformation map: source element → target element, for every piece
Got: Complete mapping where every source element has target destination. Gaps identified and adaptation strategies chosen.
If fail: Too many elements lack direct equivalents? Transformation may be inappropriate (e.g., transmuting highly object-oriented design into language without classes). Reconsider target form or escalate to athanor.
Step 3: Execute Transformation
Write target form following map.
- Create the target file(s) with appropriate structure and boilerplate
- Transmute each element following the map from Step 2:
- Preserve the behavioral contract — same inputs produce same outputs
- Use target-native idioms rather than literal translations
- Maintain or improve error handling
- Handle dependencies:
- Replace source dependencies with target equivalents
- If a dependency has no equivalent, implement a minimal adapter
- Add inline comments only where the transformation was non-obvious
Got: Complete target implementation follows transformation map. Code reads like written native in target form, not mechanical translated.
If fail: Specific element resists transformation? Isolate it. Transform everything else first, then tackle resistant element with focused attention. Truly cannot be transmuted? Document why, provide workaround.
Step 4: Verify Behavioral Equivalence
Confirm transmuted form preserves original's behavior.
- Run the behavioral contract tests against the target implementation
- For each test case, verify:
- Same inputs → same outputs (within acceptable tolerance for numeric conversions)
- Same error conditions → equivalent error signals
- Side effects (if any) are preserved or documented as changed
- Check edge cases explicitly:
- Null/NA/undefined handling
- Empty collections
- Boundary values (max int, empty string, zero-length arrays)
- If the target form adds capabilities (e.g., type safety), verify those too
Got: All behavioral contract tests pass. Edge cases handled equivalent. Any behavioral differences documented and intentional.
If fail: Tests fail? Diff source and target behavior to find divergence. Fix target to match source contract. Divergence intentional (e.g., fixing bug in original)? Document explicit.
Checks Checklist
- Source material full analyzed with explicit behavioral contract
- Transformation map covers every source element
- Gaps identified with adaptation strategies documented
- Target implementation uses native idioms (not literal translation)
- All behavioral contract tests pass against target
- Edge cases verified (null, empty, boundary values)
- Dependencies resolved with target equivalents
- Any behavioral differences documented and intentional
Pitfalls
- Literal translation: Writing Python-in-R or Java-in-JavaScript instead of using target idioms. Result should look native
- Skip behavioral tests: Transmuting without tests means you cannot verify equivalence. Write characterization tests first
- Ignore edge cases: Happy path transmutes easy; edge cases are where bugs hide
- Over-engineer adapter: Dependency needs 200-line adapter? Transmutation scope too large
- Transmute comments verbatim: Comments should explain target code, not echo source. Rewrite them
See Also
athanor— Full four-stage transformation for systems too large for single transmutechrysopoeia— Optimizing transmuted code for maximum value extractionreview-software-architecture— Post-transmutation architecture review for larger conversionsserialize-data-formats— Specialized data format conversion procedures
GitHub 仓库
相关推荐技能
executing-plans
设计该Skill用于当开发者提供完整实施计划时,以受控批次方式执行代码实现。它会先审阅计划并提出疑问,然后分批次执行任务(默认每批3个任务),并在批次间暂停等待审查。关键特性包括分批次执行、内置检查点和架构师审查机制,确保复杂系统实现的可控性。
requesting-code-review
设计该Skill可在完成任务、实现主要功能或合并代码前自动调度代码审查子代理,确保实现符合需求和计划。它支持通过指定git SHA范围进行精准的代码变更审查,帮助开发者在关键节点及时发现潜在问题。核心原则是"早审查、勤审查",适用于开发流程的各个关键阶段。
connect-mcp-server
设计这个Skill指导开发者如何将MCP服务器连接到Claude Code,支持HTTP、stdio和SSE三种传输协议。它涵盖了从安装配置到认证安全的完整流程,适用于集成GitHub、Notion、数据库等外部服务。当开发者需要添加集成、配置外部工具或提及MCP相关功能时,这个Skill能提供实用的操作指南。
web-cli-teleport
设计该Skill帮助开发者根据任务特性选择Claude Code的Web或CLI界面,并指导如何在两种环境间无缝迁移会话。它能分析任务复杂度、迭代需求等要素,推荐最优工作界面和工作流。关键特性包括会话状态管理、环境切换指导和上下文优化建议。
