From codeguard-security
Guides migration of C/C++/Assembly code to memory-safe languages (Rust, Go, Java, C#, Swift) with assessment, testing, and incremental rewrite workflows.
How this skill is triggered — by the user, by Claude, or both
Slash command
/codeguard-security:memory-safe-migrationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- User asks to migrate, port, or rewrite C/C++ code to Rust, Go, Java, C#, or Swift
Before writing any new code, ask:
If the project is predominantly C/C++, write the new module in an MSL and integrate via FFI. See references/ffi-security.md for boundary rules.
Follow these steps for every migration task:
Run the assessment script to evaluate migration priority and feasibility:
python scripts/assess-migration.py --file <source_file>
Or manually evaluate using the checklist in references/assessment-checklist.md.
Priority order for migration:
Never migrate a component without test coverage. If no tests exist, write them against the C/C++ implementation before touching anything. These tests become the correctness oracle for the new implementation.
One function or module at a time. Never rewrite an entire codebase in one pass. Follow the Android model: new code in MSL, existing stable code stays in place, proportion of unsafe code decreases over time.
For common migration patterns (buffers, strings, concurrency, error handling), see references/migration-patterns.md.
Every interface between safe and unsafe code is a security boundary. Follow all rules in references/ffi-security.md. Key rules:
unsafe blocks — wrap only the minimum necessary operationunsafe block with a // SAFETY: commentstd::panic::catch_unwind at FFI entry pointsAfter every migration unit, verify:
unsafe surface without documented safety invariantsclippy for Rust, go vet for Go)rustfmt, gofmt)unsafe without annotation, dependency audit)Never do these during migration:
unsafe to replicate C-style patterns in Rust — if extensive unsafe
is needed, the approach should be redesigned or the code should remain in CResult,
Go uses multiple returns. Every error path must be explicitly mappeddefer, try-with-resources,
using, or with patternsFor detailed guidance on specific topics:
npx claudepluginhub cosai-oasis/project-codeguard --plugin codeguard-securityGuides choosing memory-safe languages and reviewing C/C++ code for memory corruption vulnerabilities. Provides threat context and mitigation strategies.
Guides memory-safe coding across languages using RAII, ownership, smart pointers, and resource management. Helps prevent use-after-free and memory leaks.
Provides cross-language patterns for memory-safe programming including RAII, ownership, smart pointers, and resource management. Useful for systems code, resource handling, preventing leaks and use-after-free.