Rust Engineer

Writes, reviews, and debugs idiomatic Rust code with memory safety and zero-cost abstractions.

Development / Languagesdevelopmentlanguages
by AgentVoltv1.0.0Published 1y ago1 install
Free to sign up · every skill included with AgentVolt Pro

Before & after

Same prompt, same agent — the only difference is the skill.

PromptRefactor Rust code to handle 10x concurrent database requests
Beforegeneric AI agent
Rust's async/await and tokio runtime are great for handling concurrent requests. You'll want to think about ownership and lifetimes — making sure your references live long enough for the async operations. Connection pooling is critical for database performance, so you might want to use a library like sqlx with a connection pool. You could spawn tasks with tokio::spawn to handle multiple requests concurrently. Error handling gets trickier with async — you'll want to make sure errors propagate correctly. Do you have the current code I can look at? Understanding the data structures and error types will help me suggest the right async patterns.
Afterwith Rust Engineer
REFACTORING PLAN

CURRENT BOTTLENECK
• Sequential database queries in loop
• New connection per request = 100ms overhead × 10 requests = 1000ms total
• Single-threaded execution blocks on I/O

ASYNC PATTERN: tokio with connection pool
1. Initialize connection pool at startup:
   let pool = sqlx::PgPool::connect(db_url).await?;
   pool.set_max_connections(20); // Match DB max_connections / threads

2. Spawn concurrent tasks:
   let handles: Vec<_> = requests.iter()
     .map(|req| {
       let pool = pool.clone(); // Arc handle, no move
       tokio::spawn(async move { query_db(&pool, req).await })
     }).collect();

3. Await all in parallel:
   let results = futures::future::try_join_all(handles).await?;

OWNERSHIP STRATEGY
→ Pool is Arc, cloning is cheap (reference count increment)
→ Request data is moved into spawned tasks (no shared mutable state)
→ Lifetime: async fn does not need explicit lifetimes if no borrowed references cross await
→ Error handling: .map_err() converts per-task errors, then collect() in parent

RESULT
Old: 1000ms for 10 queries
New: 100ms for 10 queries (limited by single slowest query + pool overhead)
Scaling: Pool size 20, 10 concurrent tasks = 2 batches through queue

TEST STRATEGY
• Unit: Mock database returns in 50ms
• Integration: Real DB, measure latency distribution
• Load: Drive 50 concurrent requests, track p95 latency and error rate

About this skill


name: rust-engineer description: Use when Writes, reviews, and debugs idiomatic Rust code with memory safety and zero-cost abstractions.

Rust Engineer

Writes, reviews, and debugs idiomatic Rust code with memory safety and zero-cost abstractions. Implements ownership patterns, manages lifetimes, designs trait hierarchies, builds async applications with tokio, and structures error handling with Result/Option. Use when building Rust applications, solving ownership or borrowing issues, designing trait-based APIs, implementing async/await concurrency, creating FFI bindings, or optimizing for performance and memory safety. Invoke for Rust, Cargo, ownership, borrowing, lifetimes, async Rust, tokio, zero-cost abstractions, memory safety, systems programming.

What you get

  • Public GitHub repo
  • the skills/rust-engineer folder with SKILL.md and references.

Customize your output

  • Fork the repo and extend the skill's reference files for your own stack conventions.

Example output

Activates on a matching request (e.g. building or reviewing Rust Engineer code) and can chain with other skills in the pack.

Best for

Full-stack developers and engineering teams using Claude Code.

SKILL.md preview

SKILL.md
---
name: rust-engineer
description: Use this skill when writing, reviewing, or debugging idiomatic Rust code, especially around ownership, lifetimes, trait design, or async concurrency.
version: 1.0.0
category: Development / Languages
author: AgentVolt
license: proprietary
tags:
  - development
  - languages
---

# Rust Engineer

Writes and reviews idiomatic Rust: correct ownership and lifetime handling, trait-based API design, async concurrency with tokio, and Result/Option error handling done the Rust way instead of ported from another language's habits.

## When to use

… (sign up to view the full skill)
Sign up to view, copy, and install the full skill

More development skills

View all Development skills →