Agent skill

let-chains-advisor

Identifies deeply nested if-let expressions and suggests let chains for cleaner control flow. Activates when users write nested conditionals with pattern matching.

Stars 232
Forks 15

Install this agent skill to your Project

npx add-skill https://github.com/aiskillstore/marketplace/tree/main/skills/emillindfors/let-chains-advisor

SKILL.md

Let Chains Advisor Skill

You are an expert at using let chains (Rust 2024) to simplify control flow. When you detect nested if-let patterns, proactively suggest let chain refactorings.

When to Activate

Activate when you notice:

  • Nested if-let expressions (3+ levels)
  • Multiple pattern matches with conditions
  • Complex guard clauses
  • Difficult-to-read control flow

Let Chain Patterns

Pattern 1: Multiple Option Unwrapping

Before:

rust
fn get_user_email(id: &str) -> Option<String> {
    if let Some(user) = database.find_user(id) {
        if let Some(profile) = user.profile {
            if let Some(email) = profile.email {
                return Some(email);
            }
        }
    }
    None
}

After:

rust
fn get_user_email(id: &str) -> Option<String> {
    if let Some(user) = database.find_user(id)
        && let Some(profile) = user.profile
        && let Some(email) = profile.email
    {
        Some(email)
    } else {
        None
    }
}

Pattern 2: Pattern Matching with Conditions

Before:

rust
fn process(data: &Option<Data>) -> bool {
    if let Some(data) = data {
        if data.is_valid() {
            if data.size() > 100 {
                process_data(data);
                return true;
            }
        }
    }
    false
}

After:

rust
fn process(data: &Option<Data>) -> bool {
    if let Some(data) = data
        && data.is_valid()
        && data.size() > 100
    {
        process_data(data);
        true
    } else {
        false
    }
}

Pattern 3: Multiple Result Checks

Before:

rust
fn load_config() -> Result<Config, Error> {
    if let Ok(path) = get_config_path() {
        if let Ok(content) = std::fs::read_to_string(path) {
            if let Ok(config) = toml::from_str(&content) {
                return Ok(config);
            }
        }
    }
    Err(Error::ConfigNotFound)
}

After:

rust
fn load_config() -> Result<Config, Error> {
    if let Ok(path) = get_config_path()
        && let Ok(content) = std::fs::read_to_string(path)
        && let Ok(config) = toml::from_str(&content)
    {
        Ok(config)
    } else {
        Err(Error::ConfigNotFound)
    }
}

Pattern 4: While Loops

Before:

rust
while let Some(item) = iterator.next() {
    if item.is_valid() {
        if let Ok(processed) = process_item(item) {
            results.push(processed);
        }
    }
}

After:

rust
while let Some(item) = iterator.next()
    && item.is_valid()
    && let Ok(processed) = process_item(item)
{
    results.push(processed);
}

Requirements

  • Rust Version: 1.88+
  • Edition: 2024
  • Cargo.toml:
toml
[package]
edition = "2024"
rust-version = "1.88"

Your Approach

When you see nested patterns:

  1. Count nesting levels (3+ suggests let chains)
  2. Check if all branches return/continue
  3. Suggest let chain refactoring
  4. Verify Rust version compatibility

Proactively suggest let chains for cleaner, more readable code.

Expand your agent's capabilities with these related and highly-rated skills.

aiskillstore/marketplace

perigon-backend

Perigon ASP.NET Core + EF Core + Aspire conventions

232 15
Explore
aiskillstore/marketplace

perigon-agent

Pointers for Copilot/agents to apply Perigon conventions

232 15
Explore
aiskillstore/marketplace

perigon-angular

Angular 21+ standalone/Material/signal conventions for Perigon WebApp

232 15
Explore
aiskillstore/marketplace

fastapi-mastery

Comprehensive FastAPI development skill covering REST API creation, routing, request/response handling, validation, authentication, database integration, middleware, and deployment. Use when working with FastAPI projects, building APIs, implementing CRUD operations, setting up authentication/authorization, integrating databases (SQL/NoSQL), adding middleware, handling WebSockets, or deploying FastAPI applications. Triggered by requests involving .py files with FastAPI code, API endpoint creation, Pydantic models, or FastAPI-specific features.

232 15
Explore
aiskillstore/marketplace

context7-efficient

Token-efficient library documentation fetcher using Context7 MCP with 86.8% token savings through intelligent shell pipeline filtering. Fetches code examples, API references, and best practices for JavaScript, Python, Go, Rust, and other libraries. Use when users ask about library documentation, need code examples, want API usage patterns, are learning a new framework, need syntax reference, or troubleshooting with library-specific information. Triggers include questions like "Show me React hooks", "How do I use Prisma", "What's the Next.js routing syntax", or any request for library/framework documentation.

232 15
Explore
aiskillstore/marketplace

browser-use

Browser automation using Playwright MCP. Navigate websites, fill forms, click elements, take screenshots, and extract data. Use when tasks require web browsing, form submission, web scraping, UI testing, or any browser interaction.

232 15
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results