A Rust implementation of the autonomous coding agent for C/C++ to Rust migration, using the Claude Code SDK.
- Multi-phase migration workflow: Overview, Execute, Generate Tests, Security, Migration Planning, Transfer
- Phase management: Automatic phase detection and advancement based on project artifacts
- Progress tracking: Real-time progress display with migration task tracking
- Security hooks: Allowlist-based bash command validation (Note: Currently not enabled)
- Embedded prompts: Prompts are embedded in the binary for easy deployment
- MCP support: Optional Serena MCP server integration for semantic code analysis
cd auto-rs
cargo build --releaseThe binary will be at target/release/auto-rs.
Run the migration workflow to convert C/C++ code to Rust.
# Basic usage
auto-rs --project-dir /path/to/project migrate
# With source directory to migrate
auto-rs --project-dir /path/to/project --src-dir /path/to/c-code migrate
# With max iterations
auto-rs --project-dir /path/to/project --max-iterations 10 migrate
# OpenHarmony mode (docker build/test)
auto-rs --project-dir /path/to/project migrate --openharmonyRun the validation workflow after migration is complete. This verifies API compatibility, runs FFI bridge tests, analyzes coverage, performs fuzz testing, and benchmarks performance.
# Basic validation
auto-rs --project-dir /path/to/project validate
# With original C/C++ project for FFI testing
auto-rs --project-dir /path/to/project validate --original-project /path/to/original# Basic usage (defaults to migrate command)
auto-rs --project-dir /path/to/project --model claude-sonnet-4-20250514
# With source directory to migrate
auto-rs --project-dir /path/to/project --src-dir /path/to/c-code --model claude-sonnet-4-20250514
# With max iterations
auto-rs --project-dir /path/to/project --max-iterations 10
# With MCP servers enabled
auto-rs --project-dir /path/to/project --enable-mcp
# With custom prompts directory
auto-rs --project-dir /path/to/project --prompts-dir /path/to/prompts
# Verbose logging
auto-rs --project-dir /path/to/project --verbose| Option | Short | Description |
|---|---|---|
--project-dir |
-p |
Project directory path (required) |
--model |
-m |
Claude model to use (default: claude-sonnet-4-20250514) |
--max-iterations |
-n |
Maximum number of iterations |
--src-dir |
-s |
Source directory to copy into the project |
--enable-mcp |
Enable MCP servers (Serena) | |
--verbose |
-v |
Enable verbose logging |
--prompts-dir |
Custom prompts directory path |
| Option | Description |
|---|---|
--openharmony |
Use OpenHarmony-specific prompts (docker build/test, OH developer test framework) |
| Option | Description |
|---|---|
--original-project |
Path to original C/C++ project for FFI testing |
ANTHROPIC_AUTH_TOKEN: Required. Your Anthropic API authentication token.ANTHROPIC_BASE_URL: Optional. Custom API base URL.CLAUDE_ENABLE_MCP: Optional. Set to1,true,yes, oronto enable MCP servers.
- Overview & Orientation: Analyze the codebase structure and architecture
- Execute (Build, Test, Analysis): Build the project, run tests, perform static analysis
- Generate Tests: Identify test gaps and generate additional tests
- Security Assessment: Analyze security vulnerabilities
- Migration Planning (OpenSpec): Create migration plan with OpenSpec specifications
- Transfer (Implementation): Implement the actual migration
- Info Gathering: Collect information about the migrated codebase
- API Compatibility: Verify public API compatibility with original C/C++ library
- FFI Bridge Testing: Test FFI bridges between Rust and C/C++
- Coverage Analysis: Analyze test coverage
- Benchmark: Performance benchmarking against original implementation
- Fuzz Testing: Run fuzz tests on the migrated code
When running with --openharmony, the agent uses specialized prompts for OpenHarmony OS development:
- Docker-based builds: All build/test commands run inside the
oh-devdocker container - OH Developer Test Framework: Uses
start.shandrun -T UT -tp <part>commands - BUILD.gn templates: Uses
ohos_rust_unittest,ohos_rust_library, etc.
# Start the docker container
./docker_run_co.sh
# Inside the container:
cd /home/openharmony/openharmony
# Build component
./build.sh --product-name opi5plus --ccache commonlibrary/c_utils/base:utils
# Run tests
bash ./test/testfwk/developer_test/start.sh
# >>> run -T UT -tp utils
# >>> quit| Variable | Description |
|---|---|
OH_IMAGE_NAME |
Docker image name (default: oh_builder:new) |
OH_CONTAINER_NAME |
Container name (default: oh-dev) |
OH_COMPONENT_HOST_PATH |
Host path to component source |
OH_COMPONENT_PATH |
Path inside container |
auto-rs/
├── Cargo.toml
├── src/
│ ├── lib.rs # Library exports
│ ├── main.rs # CLI entry point and agent loop
│ ├── client.rs # Claude SDK client configuration
│ ├── phases.rs # Phase management
│ ├── progress.rs # Progress tracking
│ ├── prompts.rs # Prompt loading utilities
│ ├── security.rs # Security hooks
│ └── validate.rs # Validation phase management
├── prompts/
│ ├── initializer_prompt.md
│ ├── coding_prompt.md
│ ├── spec.txt
│ ├── phases/
│ │ ├── phase1_overview.md
│ │ ├── phase2_execute.md
│ │ ├── phase3_generate_tests.md
│ │ ├── phase4_security.md
│ │ └── phase5_migration_planning.md
│ ├── validate/
│ │ ├── validate1_info_gathering.md
│ │ ├── validate2_api_compatibility.md
│ │ ├── validate3_ffi_bridge.md
│ │ ├── validate4_coverage.md
│ │ ├── validate5_fuzz.md
│ │ └── validate6_benchmark.md
│ └── openharmony/
│ ├── initializer_prompt.md
│ └── coding_prompt.md
└── assets/
└── openharmony_developer_test_guide.md
The agent uses multiple layers of security:
- Sandbox: OS-level bash command isolation
- Permissions: File operations restricted to project directory
- Security hooks: Bash commands validated against an allowlist (Note: Currently not enabled)
The security module allows a minimal set of commands needed for development:
- File inspection:
ls,cat,head,tail,wc,grep - File operations:
cp,mkdir,chmod,mv,rm,touch - Build tools:
make,cmake,gcc,g++,clang,cargo,rustc - Version control:
git - And more (see
src/security.rsfor the full list)
MIT