# Cairo Deref Coercion

> Explain Cairo deref coercion with Deref/DerefMut traits and Target associated type; use when a request involves wrapper types, field access through wrappers, or deref behavior in Cairo.

- Skill: `teddyjfpender/cairo-deref-coercion` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add teddyjfpender/cairo-deref-coercion`
- Raw SKILL.md: https://api.skillmd.com/api/skills/teddyjfpender/cairo-deref-coercion/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-deref-coercion

---


# Cairo Deref Coercion

## Overview
Guide how deref coercion works via `Deref` and `DerefMut`, and when it applies.

## Quick Use
- Read `references/deref-coercion.md` before answering.
- Show the `Deref` trait and a wrapper example.
- Note that `DerefMut` only applies to mutable variables.

## Response Checklist
- Implement `Deref<T>` with `type Target` and `fn deref(self: T) -> Target`.
- Use deref coercion to access fields on the wrapped type.
- Use `DerefMut` when you need mutable-only coercion; it does not make the target mutable by itself.

## Example Requests
- "Why can I access fields on a wrapper type?"
- "How do I implement Deref for a custom type?"
- "Why does DerefMut require a mut variable?"

