Skip to content
Back to skills

Cairo Generics Traits

ASecurity

Explain Cairo generics and traits at a high level, including monomorphization and code size impact; use when a request asks why generics/traits reduce duplication, how trait bounds relate to generics, or why contract size increases with generics.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
documentation

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 27, 2026

npx -y skills add David-Li0406/meta-skill-evloving --skill cairo-generics-traits --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cairo Generics Traits?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cairo Generics Traits
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-cairo-generics-traits/badge)](https://www.skillsdirectory.com/skills/david-li0406-cairo-generics-traits)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cairo-generics-traits
description: Explain Cairo generics and traits at a high level, including monomorphization and code size impact; use when a request asks why generics/traits reduce duplication, how trait bounds relate to generics, or why contract size increases with generics.
---

# Cairo Generics and Traits Overview

## Overview
Provide conceptual guidance on generics and traits, including when to use them and tradeoffs like monomorphization.

## Quick Use
- Read `references/generics-traits.md` before answering.
- Use simple examples (like `Option<T>`) to explain placeholders for types.
- Call out monomorphization when users ask about binary or contract size.

## Response Checklist
- Identify duplicated logic that generics can remove.
- Explain that each concrete type produces a specialized implementation.
- Mention traits as behavior constraints for generic types.
- For generic impls, remind users to add required trait bounds (`+Drop<T>`, `+Copy<T>`).
- For generic structs, remind users to add `#[derive(Drop, Copy)]`.

## Common Pitfalls
- **Missing trait bounds**: Generic impls need `+Drop<T>` and often `+Copy<T>` in the impl signature.
- **Missing derives**: Generic structs need `#[derive(Drop, Copy)]` to work with the trait bounds.
- **Syntax**: Use `impl Foo<T, +Drop<T>, +Copy<T>> of MyTrait<T>` (note the `+` prefix).

## Example Requests
- "Why did my contract get bigger after adding generics?"
- "What do generics and traits buy me in Cairo?"
- "How do trait bounds relate to generics?"
- "My generic implementation won't compile"

## Cairo by Example
- [Generics](https://cairo-by-example.xyz/generics)
- [Traits](https://cairo-by-example.xyz/generics/gen_trait)
- [Bounds](https://cairo-by-example.xyz/generics/bounds)
- [Multiple bounds](https://cairo-by-example.xyz/generics/multi_bounds)

Files in this skill

  • SKILL.md1.8 KB
  • references/generics-traits.md2.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…