# Cairo Structs

> Explain how to define and instantiate Cairo structs, field access, mutability, field init shorthand, and update syntax; use when a request involves struct definitions or field-related compile errors in Cairo.

- Skill: `teddyjfpender/cairo-structs` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add teddyjfpender/cairo-structs`
- Raw SKILL.md: https://api.skillmd.com/api/skills/teddyjfpender/cairo-structs/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: teddyjfpender (https://skillmd.com/u/teddyjfpender)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/teddyjfpender/cairo-structs

---


# Cairo Structs

## Overview
Guide struct definitions, instantiation patterns, and safe field updates.

## Quick Use
- Read `references/structs.md` before answering.
- Use clear examples showing `struct` definition and `Type { field: value }` initialization.
- Highlight ownership effects of struct update syntax.

## Response Checklist
- Note that the whole instance must be `mut` to change any field.
- Use field init shorthand when variable names match field names.
- If using update syntax, mention that it moves fields from the source instance.

## Example Requests
- "How do I define a struct with multiple fields in Cairo?"
- "Why can't I mutate just one struct field without `mut`?"
- "How does struct update syntax affect ownership?"

## Cairo by Example
- [Custom Types](https://cairo-by-example.xyz/custom_types)
- [Structures](https://cairo-by-example.xyz/custom_types/structs)
- [Struct visibility](https://cairo-by-example.xyz/mod/struct_visibility)

