Source URL: https://simonwillison.net/2025/Apr/11/llm-fragments-rust/#atom-everything
Source: Simon Willison’s Weblog
Title: llm-fragments-rust
Feedly Summary: llm-fragments-rust
Inspired by Filippo Valsorda’s llm-fragments-go, Francois Garillot created llm-fragments-rust, an LLM fragments plugin that lets you pull documentation for any Rust crate directly into a prompt to LLM.
I really like this example, which uses two fragments to load documentation for two crates at once:
llm -f rust:rand@0.8.5 -f rust:tokio “How do I generate random numbers asynchronously?"
The code uses some neat tricks: it creates a new Rust project in a temporary directory (similar to how llm-fragments-go works), adds the crates and uses cargo doc –no-deps –document-private-items to generate documentation. Then it runs cargo tree –edges features to add dependency information, and cargo metadata –format-version=1 to include additional metadata about the crate.
Via @huitseeker
Tags: llm, rust, ai-assisted-programming, plugins, generative-ai, ai, llms
AI Summary and Description: Yes
Summary: The text discusses the creation of an LLM fragments plugin for Rust that enhances AI-assisted programming by allowing users to pull documentation for Rust crates into prompts for large language models (LLMs). This integration demonstrates the intersection of programming language tooling and generative AI capabilities, which is relevant for professionals engaged in AI and infrastructure development.
Detailed Description: The text describes the development of a new plugin called llm-fragments-rust, inspired by an existing plugin named llm-fragments-go. This plugin facilitates the integration of Rust crate documentation with LLM prompts, allowing programmers to retrieve specific information and enhance their coding experience through AI assistance.
– **Integration of Rust and LLMs**: The plugin connects Rust crate documentation directly to language model prompts, illustrating the synergy between programming frameworks and artificial intelligence.
– **Code Example Provided**: A practical code example shows how multiple fragments can be loaded to generate random numbers asynchronously, highlighting the plugin’s functionality.
– **Technical Implementation**:
– **Temporary Directory Creation**: Similar to llm-fragments-go, the plugin creates a new Rust project in a temporary directory.
– **Documentation Generation**: It utilizes the `cargo doc` command to generate Rust documentation without dependencies, capturing both public and private items.
– **Dependency Management**: The plugin runs commands to gather dependency information and crate metadata, which further aids in the clarity and depth of documentation retrieved.
– **Relevance to Security and Compliance**: While the text primarily focuses on programming enhancements using AI, it also underscores the importance of properly sourcing and documenting code within a secure development environment, a consideration crucial in compliance and security practices in software development.
This innovation signals a noteworthy aspect of generative AI’s role in improving developer productivity and knowledge access, appealing to security, compliance, and infrastructure professionals focused on integrating AI tools into their workflows.