-
Notifications
You must be signed in to change notification settings - Fork 97
Official Rust guidance for AI agents #505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ac54d27
928c20e
40412b3
27d39bf
5770080
52e83f4
7df8cef
0c0cac0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| # Official Rust guidance for AI agents | ||
|
|
||
| | Metadata | | | ||
| | :--------------- | -------------------------------------------------------------------------------- | | ||
| | Point of contact | @nikomatsakis | | ||
| | Status | Proposed | | ||
| | Tracking issue | | | ||
| | Zulip channel | N/A (an existing stream can be re-used or new streams can be created on request) | | ||
|
|
||
| ## Summary | ||
|
|
||
| The lang team will delegate an interested team of experts to publish and maintain guidance for AI coding assistants, teaching current idioms, correcting common mistakes, and updating agents on new features as they stabilize. This guidance will be made available in multiple formats for broad consumability. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that Rust guidance for AI/LLM agents will be created by the "AI community", whether we do anything or not. And in fact I'm sure that it already exists, and that 10 new versions of it will be published by the time this Project Goal even starts to go into effect. I don't think that the Project should be responsible for creating something like this, and that this is so fast moving that it would be better to leave it to the third-party community to work on these guides. If we want to create a best practices guide for Rust, then that sounds reasonable to me, but I think it should be made general, and be primarily for humans, rather than primarily for LLMs, or at least for "whoever uses Rust". LLMs demonstrated that they can learn from materials designed for humans anyway. |
||
|
|
||
| ## Motivation | ||
|
|
||
| ### The status quo | ||
|
|
||
| Opinions on AI coding assistants vary widely and for good reasons. Whatever one's opinion, however, a sizable and growing segment of developers rely on them to author Rust code on a regular basis. The [Vision Doc interviews](https://blog.rust-lang.org/2025/12/03/lessons-learned-from-the-rust-vision-doc-process/) encountered many examples of people using AI agents with Rust. | ||
|
|
||
| For new Rust users, AI offers the option of a personalized tutor that can help them get going quickly and meet them where they are: | ||
|
|
||
| > "I'd say [learning Rust is] a 5. The combo of solid docs + compiler errors + modern help from Copilot makes it really convenient and enjoyable." -- *Software engineer working on data science platforms* | ||
|
|
||
| > "I need to use AI to explain the answer to me. Even though like it has an answer in the book, I didn't feel like that actually explained that to me that well." -- *Software engineer working on security tooling* | ||
|
|
||
| > "Since I didn't really see people or developer community I can engage with, I had to rely on the AI assistant." -- *Robotics software engineer in Nigeria* | ||
|
|
||
| Experienced Rust developers find that Rust's focus on "if it compiles, it works"-level reliability helps AI agents be successful: | ||
|
|
||
| > "One of the things that I really appreciate about Rust is that it gives you that baseline safety from the language itself... I found that the gen models tend to do the best where there are some formal system and verification and safety guardrails around them that prevent them from going completely off the rails." -- *Distinguished engineer working on cloud infrastructure services* | ||
|
|
||
| ### Rust helps AI succeed, but only reactively | ||
|
|
||
| Rust's design works well with AI assistants. Strong types and the borrow checker catch mistakes before they cause runtime problems. Rust's excellent error messages explain what's wrong and guide toward fixes. AI agents can read these and self-correct in ways that aren't possible in more permissive languages. | ||
|
|
||
| But this influence is reactive. Rust can tell an AI "that's wrong" after it suggests something; it can't teach agents what to suggest in the first place. There's no channel to say "async closures are stable now" or "use `cargo add` instead of guessing version numbers" or "here's how to use tokio idiomatically." | ||
|
|
||
| ### Training data lags reality | ||
|
|
||
| AI agents learn from training data, which means they learn from the past. Common issues we see: | ||
|
|
||
| * **Outdated idioms**: Agents default to Rust 2021 patterns even when 2024 features would be cleaner | ||
| * **Over-reliance on `Arc<Mutex<T>>`**: Agents reach for shared mutable state when factoring code to separate mutable from immutable data would be more idiomatic | ||
| * **Version guessing**: Agents hallucinate dependency versions instead of using `cargo add` | ||
| * **Missing new features**: Agents don't know about recently stabilized features like `let chains` or `async closures` | ||
|
|
||
|
|
||
| ## The goal | ||
|
|
||
| ### Official guidance, published for broad consumability | ||
|
|
||
| The lang team will delegate an interested team of experts to publish and maintain guidance to help AI agents use Rust most effectively. This guidance will be made available in multiple ways to help Rust users take advantage of it, regardless of what agent they are using: | ||
|
|
||
| * **Skills file**: can be consumed as plain markdown by any agent that supports skills or custom instructions | ||
| * **Claude Code plugin**: for Claude Code users specifically | ||
| * **Symposium agent mod**: for users of the [Symposium](https://symposium.dev) AI tooling platform (see [FAQ](#what-is-a-symposium-agent-mod-and-what-is-symposium-anyway)) | ||
| * **Potentially more**: we will publish to various marketplaces and platforms as appropriate | ||
|
|
||
| The guidance will cover: | ||
|
|
||
| * **Idiomatic patterns**: modern Rust style, including when to use newer features over older alternatives | ||
| * **New features**: updates as features stabilize, so agents know what's available | ||
| * **Common pitfalls**: patterns that compile but aren't ideal, and what to suggest instead | ||
|
|
||
| ### Ownership and maintenance | ||
|
|
||
| This will be a lang team artifact, similar to how lang owns the Reference. @nikomatsakis will champion the initial development. The guidance will be published as a crate in the rust-lang organization. | ||
|
|
||
| ## Work items | ||
|
|
||
| | Task | Owner(s) | Notes | | ||
| | ----------------------------------------- | ------------- | ------------------------------------------ | | ||
| | Develop initial guidance content | @nikomatsakis | Focus on edition, idioms, common pitfalls | | ||
| | Publish as skills file | @nikomatsakis | Broad compatibility baseline | | ||
| | Publish as Claude Code plugin | @nikomatsakis | Claude Code marketplace | | ||
| | Publish as Symposium agent mod | @nikomatsakis | Deeper integration for Symposium users | | ||
| | Establish update process for new features | @nikomatsakis | Guidance updates as features stabilize | | ||
|
|
||
| ## Team asks | ||
|
|
||
| | Team | Support level | Notes | | ||
| | ------------- | ------------- | -------------------------------------------------------- | | ||
| | [lang] | Medium | Ownership of guidance content; delegation of team; @nikomatsakis as champion and prospective team member | | ||
|
|
||
| ## Frequently asked questions | ||
|
|
||
| ### Why does the Rust project need to do this? | ||
|
|
||
| AI assistants are becoming some developers' primary interface through which they experience programming languages. If we don't provide authoritative guidance, developers get whatever the AI's training data happens to contain, often outdated or incorrect. Publishing guidance gives Rust a direct channel to improve this experience without waiting for model retraining. | ||
|
|
||
| ### Does this constitute a recommendation that Rust developers should use AI? | ||
|
|
||
| No. This work will provide assistance for users who are already choosing to use AI, and provide a team to help interested project developers support such users. | ||
|
|
||
nikomatsakis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ### How will the guidance be kept current? | ||
|
|
||
| As features stabilize, the guidance will be updated to reflect what's newly available. The goal is for the guidance to track Rust's release cadence, so agents learn about new features shortly after they're available, not months or years later when training data catches up. | ||
nikomatsakis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### What about guidance for the standard library, compiler, Cargo, or other tools? | ||
|
|
||
| This experiment primarily focuses on language-specific guidance, but may touch on recommendations for the standard library, compiler, Cargo, or other tools. To the extent it does so, the team delegated to write AI guidance will coordinate with those Rust teams, seek similar delegation arrangements, and include interested parties from those teams as appropriate. | ||
|
|
||
| ### What about crate-specific guidance? | ||
nikomatsakis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| This goal focuses on Rust language guidance. Crate authors can publish their own guidance for their libraries through the same mechanisms. If this proves valuable, future work might explore conventions for crates to ship guidance alongside their code. | ||
|
|
||
| ### What is an MCP server? | ||
|
|
||
| [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) is a standard for connecting AI assistants to external tools and data sources. An MCP server provides tools (functions the agent can call) and resources (data the agent can read). Many AI coding assistants support MCP servers for extending their capabilities. | ||
|
|
||
| ### What is a skills file? | ||
|
|
||
| A [skills file](https://agentskills.io/) is plain markdown that agents can read as context. It's the simplest and most broadly compatible format for providing guidance to AI assistants. Most agents support loading custom instructions or skills from markdown files, making this the baseline format for broad compatibility. | ||
|
|
||
| ### What is a Symposium agent mod? And what is Symposium anyway? | ||
|
|
||
| [Symposium](https://symposium.dev) is a "meta-agent" that extends another agent (e.g., Claude Code, Codex, etc) with custom "agent mods" based on the current crate dependencies, user preferences, or other factors. Agent mods are a generalization of MCP servers, skills files, and Claude Code plugins; built on the [Agent Client Protocol (ACP)](https://agentclientprotocol.com/), they allow crates to customize many aspects of the agent experience. Agent mods can do everything simpler formats can do, plus intercept requests, inject guidance contextually, and more. Publishing a Symposium mod allows deeper integration for users of that platform, while the skills file ensures broad compatibility regardless of tooling choice. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes this any different from existing material like changelogs, release updates, and other learning material?