SkillAgentSearch skills...

m04-zero-cost

CRITICAL: Use for generics, traits, zero-cost abstraction. Triggers: E0277, E0308, E0599, generic, trait, impl, dyn, where, monomorphization, static dispatch, dynamic dispatch, impl Trait, trait bound not satisfied, 泛型, 特征, 零成本抽象, 单态化

Install / Use

npx skills add actionbook/rust-skills --skill m04-zero-cost

Installs into whichever agent you are using.

About this skill
📄

SKILL.md

Installable skill definition

Quality Score

87/100

Supported Platforms

Universal

Tags

Our assessment of m04-zero-cost

m04-zero-cost scores 87/100 on our quality scale, 2172nd of 4,698 Development & Engineering skills we index (top 47%).

Its SKILL.md is 4.5 KB long, well organised into 13 sections with 3 code examples: a solid amount of guidance for an agent.

With 1,479 GitHub stars, it is one of the more widely adopted skills in the catalogue.

Substance
26/30
Structure
18/20
Description
15/15
Adoption
13/20
Freshness
15/15

Maintenance, license and trust

  • The repository was last updated about 3 months ago, so m04-zero-cost is actively maintained.
  • Our last check on 2026-11-02 found the source still online.
  • No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
  • Its trust signals score 88/100, with 1 caution from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.

Safety scan

No issues found

Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.

AI review by kimi-k2.7-code on 2026-10-03. Automated pattern scan on 2026-10-03. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.

m04-zero-cost compared with similar skills

All 4 of these similar skills score higher than m04-zero-cost; compare them before choosing.

SkillScoreStarsUpdatedFormat
m04-zero-cost (this skill)by actionbook871.5k3mo agoSKILL.md
taste-skillby Leonxlnx100116.8k8d agoCLAUDE.md
ai-job-searchby ai-job-search-dev10072.1ktodayCLAUDE.md
claude-howtoby luongnv8910047.3k2d agoCLAUDE.md
lobehubby lobehub10085.6ktodayMCP Server

Frequently asked questions

How do I install m04-zero-cost?
Run npx skills add actionbook/rust-skills --skill m04-zero-cost. The install tabs above show the steps for each supported agent.
Which AI agents does m04-zero-cost work with?
It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
Is m04-zero-cost safe to use?
Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It declares no license and scores 88/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
Is m04-zero-cost still maintained?
The repository was last updated about 3 months ago, so m04-zero-cost is actively maintained.

name: m04-zero-cost description: "CRITICAL: Use for generics, traits, zero-cost abstraction. Triggers: E0277, E0308, E0599, generic, trait, impl, dyn, where, monomorphization, static dispatch, dynamic dispatch, impl Trait, trait bound not satisfied, 泛型, 特征, 零成本抽象, 单态化" user-invocable: false

Zero-Cost Abstraction

Layer 1: Language Mechanics

Core Question

Do we need compile-time or runtime polymorphism?

Before choosing between generics and trait objects:

  • Is the type known at compile time?
  • Is a heterogeneous collection needed?
  • What's the performance priority?

Error → Design Question

| Error | Don't Just Say | Ask Instead | |-------|----------------|-------------| | E0277 | "Add trait bound" | Is this abstraction at the right level? | | E0308 | "Fix the type" | Should types be unified or distinct? | | E0599 | "Import the trait" | Is the trait the right abstraction? | | E0038 | "Make object-safe" | Do we really need dynamic dispatch? |


Thinking Prompt

Before adding trait bounds:

  1. What abstraction is needed?

    • Same behavior, different types → trait
    • Different behavior, same type → enum
    • No abstraction needed → concrete type
  2. When is type known?

    • Compile time → generics (static dispatch)
    • Runtime → trait objects (dynamic dispatch)
  3. What's the trade-off priority?

    • Performance → generics
    • Compile time → trait objects
    • Flexibility → depends

Trace Up ↑

When type system fights back:

E0277 (trait bound not satisfied)
    ↑ Ask: Is the abstraction level correct?
    ↑ Check: m09-domain (what behavior is being abstracted?)
    ↑ Check: m05-type-driven (should use newtype?)

| Persistent Error | Trace To | Question | |-----------------|----------|----------| | Complex trait bounds | m09-domain | Is the abstraction right? | | Object safety issues | m05-type-driven | Can typestate help? | | Type explosion | m10-performance | Accept dyn overhead? |


Trace Down ↓

From design to implementation:

"Need to abstract over types with same behavior"
    ↓ Types known at compile time → impl Trait or generics
    ↓ Types determined at runtime → dyn Trait

"Need collection of different types"
    ↓ Closed set → enum
    ↓ Open set → Vec<Box<dyn Trait>>

"Need to return different types"
    ↓ Same type → impl Trait
    ↓ Different types → Box<dyn Trait>

Quick Reference

| Pattern | Dispatch | Code Size | Runtime Cost | |---------|----------|-----------|--------------| | fn foo<T: Trait>() | Static | +bloat | Zero | | fn foo(x: &dyn Trait) | Dynamic | Minimal | vtable lookup | | impl Trait return | Static | +bloat | Zero | | Box<dyn Trait> | Dynamic | Minimal | Allocation + vtable |

Syntax Comparison

// Static dispatch - type known at compile time
fn process(x: impl Display) { }      // argument position
fn process<T: Display>(x: T) { }     // explicit generic
fn get() -> impl Display { }         // return position

// Dynamic dispatch - type determined at runtime
fn process(x: &dyn Display) { }      // reference
fn process(x: Box<dyn Display>) { }  // owned

Error Code Reference

| Error | Cause | Quick Fix | |-------|-------|-----------| | E0277 | Type doesn't impl trait | Add impl or change bound | | E0308 | Type mismatch | Check generic params | | E0599 | No method found | Import trait with use | | E0038 | Trait not object-safe | Use generics or redesign |


Decision Guide

| Scenario | Choose | Why | |----------|--------|-----| | Performance critical | Generics | Zero runtime cost | | Heterogeneous collection | dyn Trait | Different types at runtime | | Plugin architecture | dyn Trait | Unknown types at compile | | Reduce compile time | dyn Trait | Less monomorphization | | Small, known type set | enum | No indirection |


Object Safety

A trait is object-safe if it:

  • Doesn't have Self: Sized bound
  • Doesn't return Self
  • Doesn't have generic methods
  • Uses where Self: Sized for non-object-safe methods

Anti-Patterns

| Anti-Pattern | Why Bad | Better | |--------------|---------|--------| | Over-generic everything | Compile time, complexity | Concrete types when possible | | dyn for known types | Unnecessary indirection | Generics | | Complex trait hierarchies | Hard to understand | Simpler design | | Ignore object safety | Limits flexibility | Plan for dyn if needed |


Related Skills

| When | See | |------|-----| | Type-driven design | m05-type-driven | | Domain abstraction | m09-domain | | Performance concerns | m10-performance | | Send/Sync bounds | m07-concurrency |

Related Skills

View on GitHub
GitHub Stars1.5k
CategoryDevelopment
Updated2mo ago
Forks114

Languages

Shell

Trust signals

88/100

From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.

1 medium