AI студия Владимира Ломтева
УСЛУГИПРОЕКТЫСТАТЬИБАЗА ЗНАНИЙМаркетплейсПолезные сервисы

Оставьте заявку,
чтобы обсудить проект

Напишите ваш вопрос, не забудьте указать телефон. Мы перезвоним и все расскажем.

Контакты

Москва

Работаем по всей России
и миру (онлайн)

+7 (999) 760-24-41

Ежедневно с 9:00 до 21:00

lamooof@gmail.com

По вопросам сотрудничества

TelegramWhatsApp

Есть предложение?

Напишите нам в мессенджеры

© 2025 AI студия Владимира Ломтева

Политика конфиденциальностиСогласие на обработку ПДн|ИНН 623412173261
    M15 Anti Pattern — Скилл для ИИ-агентов | AI Рассвет

    M15 Anti Pattern

    Use when reviewing code for anti patterns. Keywords: anti pattern, common mistake, pitfall, code smell, bad practice, code review, is this an anti pattern, better way to do this, common mistake to avoid, why is this bad, idiomatic way, beginner mistake, fighting borrow checker, clone everywhere, unwrap in production, should I refactor, 反模式, 常见错误, 代码异味, 最佳实践, 地道写法

    Скиллы для разработки#GitHub#actionbook/rust-skills#skills.sh
    Скачивания
    0
    В избранном
    0
    Комментарии
    0
    Просмотры
    2

    Установить скилл

    Добавьте инструмент одной командой или скачайте проверенный архив версии.

    npx skills add actionbook/rust-skills --skill m15-anti-pattern
    Скачать ZIP
    Версия
    1.0.0+5c40d3ad7851
    Автор
    Владимир Ломтев
    Репозиторий
    actionbook/rust-skills
    GitHub: actionbook/rust-skills

    Как установить

    1. 1Скопируйте команду из блока установки.
    2. 2Запустите её в терминале из каталога проекта.

    Документация

    Anti-Patterns

    Layer 2: Design Choices

    Core Question

    Is this pattern hiding a design problem?

    When reviewing code:

    • Is this solving the symptom or the cause?
    • Is there a more idiomatic approach?
    • Does this fight or flow with Rust?

    Anti-Pattern → Better Pattern

    Anti-Pattern Why Bad Better
    .clone() everywhere Hides ownership issues Proper references or ownership
    .unwrap() in production Runtime panics ?, expect, or handling
    Rc when single owner Unnecessary overhead Simple ownership
    unsafe for convenience UB risk Find safe pattern
    OOP via Deref Misleading API Composition, traits
    Giant match arms Unmaintainable Extract to methods
    String everywhere Allocation waste &str, Cow<str>
    Ignoring #[must_use] Lost errors Handle or let _ =

    Thinking Prompt

    When seeing suspicious code:

    1. Is this symptom or cause?

      • Clone to avoid borrow? → Ownership design issue
      • Unwrap "because it won't fail"? → Unhandled case
    2. What would idiomatic code look like?

      • References instead of clones
      • Iterators instead of index loops
      • Pattern matching instead of flags
    3. Does this fight Rust?

      • Fighting borrow checker → restructure
      • Excessive unsafe → find safe pattern

    Trace Up ↑

    To design understanding:

    "Why does my code have so many clones?"
        ↑ Ask: Is the ownership model correct?
        ↑ Check: m09-domain (data flow design)
        ↑ Check: m01-ownership (reference patterns)
    
    Anti-Pattern Trace To Question
    Clone everywhere m01-ownership Who should own this data?
    Unwrap everywhere m06-error-handling What's the error strategy?
    Rc everywhere m09-domain Is ownership clear?
    Fighting lifetimes m09-domain Should data structure change?

    Trace Down ↓

    To implementation (Layer 1):

    "Replace clone with proper ownership"
        ↓ m01-ownership: Reference patterns
        ↓ m02-resource: Smart pointer if needed
    
    "Replace unwrap with proper handling"
        ↓ m06-error-handling: ? operator
        ↓ m06-error-handling: expect with message
    

    Top 5 Beginner Mistakes

    Rank Mistake Fix
    1 Clone to escape borrow checker Use references
    2 Unwrap in production Propagate with ?
    3 String for everything Use &str
    4 Index loops Use iterators
    5 Fighting lifetimes Restructure to own data

    Code Smell → Refactoring

    Smell Indicates Refactoring
    Many .clone() Ownership unclear Clarify data flow
    Many .unwrap() Error handling missing Add proper handling
    Many pub fields Encapsulation broken Private + accessors
    Deep nesting Complex logic Extract methods
    Long functions Multiple responsibilities Split
    Giant enums Missing abstraction Trait + types

    Common Error Patterns

    Error Anti-Pattern Cause Fix
    E0382 use after move Cloning vs ownership Proper references
    Panic in production Unwrap everywhere ?, matching
    Slow performance String for all text &str, Cow
    Borrow checker fights Wrong structure Restructure
    Memory bloat Rc/Arc everywhere Simple ownership

    Deprecated → Better

    Deprecated Better
    Index-based loops .iter(), .enumerate()
    collect::<Vec<_>>() then iterate Chain iterators
    Manual unsafe cell Cell, RefCell
    mem::transmute for casts as or TryFrom
    Custom linked list Vec, VecDeque
    lazy_static! std::sync::OnceLock

    Quick Review Checklist

    • No .clone() without justification
    • No .unwrap() in library code
    • No pub fields with invariants
    • No index loops when iterator works
    • No String where &str suffices
    • No ignored #[must_use] warnings
    • No unsafe without SAFETY comment
    • No giant functions (>50 lines)

    Related Skills

    When See
    Ownership patterns m01-ownership
    Error handling m06-error-handling
    Mental models m14-mental-model
    Performance m10-performance

    Требования и возможности

    Источник пакета
    https://github.com/actionbook/rust-skills/tree/5c40d3ad785193231b7d0dbfb8e1eb447e5edd94/skills/m15-anti-pattern

    Файлы версии

    ПутьРазмерSHA256
    SKILL.md4838bcbb49e47b76620b...
    patterns/common-mistakes.md8259a1f3c68622feb760...

    Частые вопросы

    Как установить M15 Anti Pattern?
    Используйте команду npx skills add actionbook/rust-skills --skill m15-anti-pattern или скачайте ZIP-архив.
    Можно ли скачать M15 Anti Pattern бесплатно?
    Да, опубликованную версию можно скачать из маркетплейса бесплатно.

    Похожие инструменты

    Смотреть все
    React DoctorUse when finishing a feature, fixing a bug, before committing React code, or when the user types `/doctor`, asks to scan, triage, or clean up React diagnostics. Covers lint, accessibility, bundle size, architecture. Includes a regression check and a full local-triage workflow that fetches the canonical playbook.Argent Android Emulator SetupSet up and connect to an Android emulator using argent MCP tools. Use when starting a new session on Android, booting an emulator, getting a device serial, or before any UI interaction task.Fireworks Tech GraphCreate technical diagrams such as software architecture, data flow, flowcharts, sequence diagrams, C4 reviews, cloud deployments, event streams, observability investigations, agent/memory systems, UML, ER, network topology, timelines, and technical concept maps, then export SVG, PNG, focused semantic SVG-to-GIF motion, or offline interactive HTML. Treat direct requests such as "Generate a GIF", "生成 GIF", or "制作 GIF" as motion requests, and use this skill when the user asks to visualize a system or engineering concept. Do not use for photos, raster artwork, or quantitative data charts.
    Комментарии

    Войдите, чтобы оставить комментарий.

    Комментариев пока нет.

    Установить скилл

    Добавьте инструмент одной командой или скачайте проверенный архив версии.

    npx skills add actionbook/rust-skills --skill m15-anti-pattern
    Скачать ZIP
    Версия
    1.0.0+5c40d3ad7851
    Автор
    Владимир Ломтев
    Репозиторий
    actionbook/rust-skills
    GitHub: actionbook/rust-skills
    Modern Web GuidanceSearch tool for modern web development best practices. MANDATORY: Execute FIRST for all HTML/CSS and clientside JS tasks. Do NOT skip — web APIs evolve rapidly and training weights contain obsolete patterns.