| name | migrate-c |
| description | Analyze a C runtime file and suggest pure TML replacement. Use when the user says "migrate", "migra", "replace C", or wants to convert C runtime code to TML. |
| user-invocable | true |
| argument-hint | <c-file-path> |
Delegation: Use the Agent tool to dispatch a c-to-tml-migrator agent with model: sonnet for this task.
C-to-TML Migration Analysis Workflow
1. Read the C File
Read the file from $ARGUMENTS (typically in compiler/runtime/).
2. Analyze Each Function
For each function in the file:
- Classify as: pure algorithm, OS API wrapper, LLVM intrinsic wrapper, or FFI bridge
- Check usage: Search the compiler C++ source for callers (
grep for the function name in compiler/src/)
- Check if already migrated: Search
lib/ for TML implementations
3. Migration Assessment
For each function, determine the migration path per CLAUDE.md's three-tier rule:
- Pure TML (strongly preferred): Functions that are pure algorithms (sorting, string manipulation, math formatting, data structures)
- @extern("c") FFI (acceptable): Functions that wrap OS APIs or external libraries (file I/O, crypto, networking)
- Keep in C (last resort): Functions requiring inline asm, OS-level I/O, or panic/abort handlers
4. Report
Present a table:
| Function | Lines | Callers | Migration Path | Effort |
|----------|-------|---------|---------------|--------|
| func_name | N | M calls | Pure TML / FFI / Keep | Low/Med/High |
And for "Pure TML" candidates, sketch the TML implementation approach using memory intrinsics (ptr_read, ptr_write, mem_alloc, etc.).
IMPORTANT
Follow CLAUDE.md: NEVER add new C code. Always prefer pure TML implementations.