---
name: "serde-json-zero-copy-deserialization"
description: "Serialize and deserialize Rust data structures at maximum speed with zero-copy borrows."
metadata:
  author: "David Tolnay"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "derive serialize deserialize serde"
  - "serde zero copy &str"
  - "skip_serializing_if serde"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Serde & Serde JSON Zero-Copy Serialization in Rust

Implements Serde: #[derive(Serialize, Deserialize)], field attributes (rename, skip_serializing_if, default), zero-copy deserialization using &'a str from raw JSON bytes, and custom Visitor implementations.

## When to Invoke
Invoke this skill whenever you need to:
- derive serialize deserialize serde
- serde zero copy &str
- skip_serializing_if serde

## Execution SOP & Rules
1. Add derives: #[derive(Serialize, Deserialize)] on struct definitions.
2. Configure attributes: #[serde(rename_all = 'snake_case', default)].
3. Zero-copy borrow: struct FastPayload<'a> { name: &'a str } deserializing from &[u8].
4. Parse JSON: let data: User = serde_json::from_str(&json_str)?; or serde_json::to_string(&data)?;.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
