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

The JetBrains Blog · 软件开发

“Some people use AI to write more code. I use AI to make my code more correct.” Predrag Gruevski’s pinned post sums up his approach to using AI for Rust development. Predrag works on frontier systems at OpenAI , and he created cargo-semver-checks and Trustfall. In his work, there’s very little room for error. Still, he does most of his engineering with AI in the loop, and his quality bar has gone up. But how? We wanted to know what that looks like in practice, so we invited him to a RustRover livestream. His presentation was part of our AI & Rust livestream series with the Rust Foundation , which looks at real-world use cases, successes, and failures where Rust and AI meet. This post focuses on Predrag’s most practical advice: what to review, how to prompt AI coding agents, how to verify their work, and what to do when they get something wrong You can watch the full livestream recording here 👇 Which Rust code deserves the most attention when you use AI? Before you hand anything to an AI agent, sort the work by how much it would cost to get wrong. Not every line of code is equally important. Some lines deserve 1000 times more attention than others. When you typed every line yourself, 10 lines of unsafe Rust and 10 lines of regular code took about the same amount of time to write. Now AI handles the regular code, so you can move that time to the lines where mistakes are expensive. Think of your code on a risk scale. At one end, a mistake is cheap to spot and fix. At the other, it can stay hidden for months and do real damage. Here are three points on that scale: Low-stakes code. A GitHub Actions workflow is a good example. You know what it should do, and the agent has read the docs, so let it write the workflow and test it. If a CI bash script breaks and nothing security-related is at stake, ask the agent to fix it. Logic that other people rely on. cargo-semver-checks catches breaking changes before they ship, and it now runs in Rust’s own CI. In the five years before

查看原文