---
title: "How to Use AI for Rust Development: Lessons From an OpenAI Engineer"
description: "Predrag Gruevski, an OpenAI engineer who created cargo-semver-checks and Trustfall, uses AI to make Rust code more correct rather than produce more code. He sorts code by risk: low-stakes tasks like CI workflows are delegated, but logic others rely on, such as Rust’s CI tooling, gets scrutiny like constructing false alarms to validate accuracy. Unsafe Rust demands line-by-line review because a 20-line mistake can cause memory safety issues at data center scale, and he spends four hours on 100 lines of unsafe code. Effective prompting requires sketching the design, specifying test structure, stating acceptable assumptions, and being precise; a 45-minute prompt found a single line deletion that made the new trait solver up to 7.5% faster. Verification focuses on design and tests using cargo-mutants, coverage tools, Miri, and sanitizers, with a prompt describing a full state machine verification process."
---

# How to Use AI for Rust Development: Lessons From an OpenAI Engineer

[Jetbrains](https://yomu.fyi/company/jetbrains) · Irina Mihajlovic · Nov 4, 2026

**Type:** Tutorial

## Summary

Predrag Gruevski, an OpenAI engineer who created cargo-semver-checks and Trustfall, uses AI to make Rust code more correct rather than produce more code. He sorts code by risk: low-stakes tasks like CI workflows are delegated, but logic others rely on, such as Rust’s CI tooling, gets scrutiny like constructing false alarms to validate accuracy. Unsafe Rust demands line-by-line review because a 20-line mistake can cause memory safety issues at data center scale, and he spends four hours on 100 lines of unsafe code. Effective prompting requires sketching the design, specifying test structure, stating acceptable assumptions, and being precise; a 45-minute prompt found a single line deletion that made the new trait solver up to 7.5% faster. Verification focuses on design and tests using cargo-mutants, coverage tools, Miri, and sanitizers, with a prompt describing a full state machine verification process.

## Context

Based on a livestream with Predrag Gruevski, an OpenAI engineer working on frontier systems, hosted by JetBrains RustRover and the Rust Foundation.

## Approach / What changed

Sort code by risk: low-stakes code like CI workflows can be delegated; logic others rely on needs scrutiny such as false-alarm testing; unsafe Rust requires line-by-line review at roughly four hours per 100 lines. Write prompts that sketch the design, specify test structure, state acceptable assumptions, and are precise about conditions. Verify AI output using mutation testing (cargo-mutants), coverage tools, Miri, and sanitizers like ASan. Focus design review on API quality and test coverage. When agents err, analyze the cause and update instructions.

## Takeaways

- Prioritize code review by risk: low-stakes code can be tested quickly, but unsafe Rust demands line-by-line review at a cost of four hours per 100 lines, as a 20-line mistake can cause persistent memory safety issues at scale.
- Effective prompts should sketch the design, specify test structure, state acceptable assumptions, and be precise; a 45-minute prompt for Codex found a single line deletion that made the Rust new trait solver up to 7.5% faster.
- Use automated verification techniques like cargo-mutants for mutation testing, Miri and ASan for unsafe code, and coverage tools to ensure tests execute all non-trivial logic, reducing reliance on reading every line.

## FAQ

### How should I prioritize which Rust code to review when using AI?

Sort code by the cost of mistakes. Low-stakes code like CI workflows can be delegated after testing, logic others rely on needs scrutiny like false-alarm testing, and unsafe Rust requires line-by-line review and manual scrutiny.

### What verification techniques should I apply to AI-generated unsafe Rust code?

Have the agent think through important cases and test them under Miri and sanitizers like ASan. Review the safety invariants yourself, and consider writing the unsafe code manually for complete control.

### How do I prompt an AI agent to write reliable Rust code?

Sketch the design, describe test structure, state which assumptions are acceptable, and be precise about conditional requirements. A well-crafted prompt can find non-obvious optimizations, as shown by a 45-minute prompt that found a 7.5% speedup by deleting one line.

**Tags:** [AI](https://yomu.fyi/topic/ai), [Coding Agents](https://yomu.fyi/topic/coding-agents), [Prompt Engineering](https://yomu.fyi/topic/prompt-engineering), [Rust](https://yomu.fyi/topic/rust)

- Source: [Jetbrains](https://blog.jetbrains.com/rust/2026/11/04/ai-for-rust-development)
- Source URL: https://blog.jetbrains.com/rust/2026/11/04/ai-for-rust-development
- Ingested by Yomu: 2026-11-04T18:01:09.551Z

[Read original post](https://blog.jetbrains.com/rust/2026/11/04/ai-for-rust-development)
