AgentSkillsCN

cairo-data-types

当请求涉及在 Cairo 中实现可变集合(如向量)或通过 Felt252Dict 处理 Destruct/Drop 时,讲解如何使用结构体、特质与字典来构建自定义数据结构。

SKILL.md
--- frontmatter
name: cairo-data-types
description: Explain Cairo scalar and compound data types, literals, conversions, and string forms; use when a request asks about Cairo types (felt252, integers, bool, strings, tuples, arrays, unit), type annotations, or conversion errors.

Cairo Data Types

Overview

Explain Cairo's core data types, literals, and conversions so answers stay type-correct and safe.

Quick Use

  • Read references/data-types.md before answering.
  • State the target type explicitly and show the correct literal or conversion.
  • Prefer integer types over felt252 when safety (overflow/underflow checks) matters.

Response Checklist

  • Identify whether the value should be felt252, a specific integer type, bool, a string type, or a compound type.
  • When literals are ambiguous, use a type suffix or explicit annotation.
  • For conversions, show try_into/into patterns and mention potential failure where relevant.

Example Requests

  • "What is the difference between felt252 and u64 in Cairo?"
  • "How do I write a short string vs a long string?"
  • "Why does this integer literal need a type annotation?"

Cairo by Example