agentleFS
JuanMarchettoJuanMarchetto/agent-skills/skills/migration-validator/SKILL.md

migration-validator

Skill5 starsChanged 8 months agoMITView on GitHub

Safety verification checklist for C-to-Rust migrations. Validates compilation, unsafe block minimization, memory safety, API compatibility, and idiomatic Rust patterns. Use when: validate migration, check Rust safety, verify converted code, migration QA.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If repair adds unsafe → reject that iteration, try again

    line 51
  2. Distinctive:

    Keep the version with highest score throughout repair loop

    line 55
  3. Distinctive:

    If nothing passes validation, use best version as fallback (not raw c2rust)

    line 56
  4. Distinctive:

    Prefer: compiling version > high-score non-compiling > c2rust fallback

    line 57

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Migration Validation Checklist

Compilation Check

  • Rust code compiles with rustc --edition 2024
  • No errors, only warnings acceptable if minor
  • Clippy passes with 0 warnings (cargo clippy)

Safety Check

  • Count unsafe blocks (target: 0 for easy/medium, minimize for hard)
  • Every unsafe block has a // SAFETY: comment
  • No raw pointer dereferences without bounds checking
  • No transmute unless absolutely necessary
  • No unwrap() on user-controlled data

Semantic Equivalence

  • Same function signature (equivalent types)
  • Same behavior for all valid inputs
  • Same error conditions / edge cases
  • Overflow behavior matches (wrapping vs. checked)
  • Printf format matches exactly (especially %g → custom format_g())
  • Bool/int distinction preserved (C int 0/1 ≠ Rust bool)

Differential Testing

  • Compile C with cc -std=gnu11 -lm
  • Compile Rust with rustc --edition 2024
  • Run both with identical test inputs
  • Compare outputs byte-by-byte (not just "looks similar")
  • Test edge cases: empty input, max values, null/None, negative numbers
  • Float tolerance: exact match preferred, tolerance only for known precision differences

Idiomatic Score

Enhanced formula with positive AND negative signals:

  • Base: 100
  • Negative: - (unsafe_blocks * 10) - (clippy_warnings * 2) - (unwrap_count * 3) - (as_casts * 1)
  • Positive: + min(10, result_count * 2) + min(5, option_count) + min(5, iter_usage)
  • Ranges: 90-100 Excellent, 70-89 Good, 60-69 Acceptable, <60 Needs repair

Quality Floor (P0)

  • Track baseline unsafe count from initial translation
  • NEVER allow repair to increase unsafe above baseline
  • If repair adds unsafe → reject that iteration, try again
  • This prevents the "oscillation" problem where repair trades quality for compilation

Best-Version Tracking (P1)

  • Keep the version with highest score throughout repair loop
  • If nothing passes validation, use best version as fallback (not raw c2rust)
  • Prefer: compiling version > high-score non-compiling > c2rust fallback

Repair Loop Rules

  • Effective iterations scale with file size:
    • <1000 LOC: full configured max (default 5)
    • 1000-2000 LOC: min(configured, 3)
    • 2000 LOC: min(configured, 2)

    • Chunked translations: max(configured, 8) — chunks are small, repair is affordable
  • Stall detection: 2 unchanged error counts → re-translate at temp 0.7
  • Temperature ramp: base 0.2 + 0.1 per iteration (capped at 1.0)
  • Quality gate: if initial translation has >5 unsafe → re-translate at temp 0.5
  • P5: Idiomatic hints — when compiles + diff passes but score < threshold, repair agent gets refactoring hints instead of empty feedback (prevents wasted iterations)

Validated Production Migrations

These fixtures are regression-tested and represent known-good migrations:

FileLOC C→RustScoreUnsafeNotes
add, power, gcd, etc.<501000Simple arithmetic
hash_table.c204→~200810malloc/free → Box/Vec
cjson_combined.c520→3191000JSON parser, recursive data
expr_eval.c1686→1446100074 functions, recursive descent
cjson_full_combined.c1696→1439100*0Full cJSON library (49/78 fns)
picohttpparser.c1102→15511000HTTP parser, state machine
genann_combined.c642→6221000Neural network, fn ptrs→enum, autonomous pipeline
olive_combined.c1443→117610002D graphics, pixel buffers, checksum diff test
http_parser_combined.c3680→1492N/A0HTTP parser, goto state machine→line parsing, manual completion
miniz_core_standalone.c4429N/AN/AFallbackUnsafe (ceiling case)

Powered by Noricum — autonomous C/C++ to Rust migration agent

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.