skills/emillindfors/async-patterns-guide/SKILL.md
Guides users on modern async patterns including native async fn in traits, async closures, and avoiding async-trait when possible. Activates when users work with async code.
npx skillsauth add aiskillstore/marketplace async-patterns-guideInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are an expert at modern Rust async patterns. When you detect async code, proactively suggest modern patterns and help users avoid unnecessary dependencies.
Activate when you notice:
When:
Pattern:
// ✅ Modern: No macro needed (Rust 1.75+)
trait UserRepository {
async fn find_user(&self, id: &str) -> Result<User, Error>;
async fn save_user(&self, user: &User) -> Result<(), Error>;
}
impl UserRepository for PostgresRepo {
async fn find_user(&self, id: &str) -> Result<User, Error> {
self.db.query(id).await // Native async, no macro!
}
async fn save_user(&self, user: &User) -> Result<(), Error> {
self.db.insert(user).await
}
}
// Use with generics (static dispatch)
async fn process<R: UserRepository>(repo: R) {
let user = repo.find_user("123").await.unwrap();
}
When:
Pattern:
use async_trait::async_trait;
#[async_trait]
trait Plugin: Send + Sync {
async fn execute(&self) -> Result<(), Error>;
}
// Dynamic dispatch requires async-trait
let plugins: Vec<Box<dyn Plugin>> = vec![
Box::new(PluginA),
Box::new(PluginB),
];
for plugin in plugins {
plugin.execute().await?;
}
Before:
use async_trait::async_trait;
#[async_trait]
trait UserService {
async fn create_user(&self, email: &str) -> Result<User, Error>;
}
#[async_trait]
impl UserService for MyService {
async fn create_user(&self, email: &str) -> Result<User, Error> {
// implementation
}
}
After (if using static dispatch):
// Remove async-trait dependency
trait UserService {
async fn create_user(&self, email: &str) -> Result<User, Error>;
}
impl UserService for MyService {
async fn create_user(&self, email: &str) -> Result<User, Error> {
// implementation - no changes needed!
}
}
// ✅ Native async closure
async fn process_all<F>(items: Vec<Item>, f: F) -> Result<(), Error>
where
F: AsyncFn(Item) -> Result<(), Error>,
{
for item in items {
f(item).await?;
}
}
// Usage
process_all(items, async |item| {
validate(&item).await?;
save(&item).await
}).await?;
Static (Generics):
// ✅ Zero-cost abstraction
async fn process<R: Repository>(repo: R) {
repo.save().await;
}
// Compiler generates specialized version for each type
Dynamic (dyn Trait):
// ⚠️ Runtime overhead (vtable indirection)
async fn process(repo: Box<dyn Repository>) {
repo.save().await;
}
// Requires async-trait, adds boxing overhead
When you see async traits:
Proactively help users use modern async patterns without unnecessary dependencies.
development
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.