rust-serde

Diagnose and fix serde serialization contracts, wire-format changes, and silent data loss in Rust.

2|1|Updated Aug 19, 2026
One-click install
npx skills add https://github.com/po4yka/rust-skills --skill rust-serde-po4yka
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rust-serde
Source: https://github.com/po4yka/rust-skills/tree/main/skills/rust-serde
Command: npx skills add https://github.com/po4yka/rust-skills --skill rust-serde-po4yka

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Serde failures are usually silent: a misspelled config key keeps its default, a large integer loses digits, or an older build can no longer read a payload. This Skill helps you audit Serialize/Deserialize derives as published wire contracts and catch breaking changes before they ship. ## Core Features & Use Cases - Contract auditing: ripgrep and cargo tree commands to find every Deserialize derive, serde attribute, and serde_json feature flag in a crate. - Wire-format decisions: rules for deny_unknown_fields, rename_all with alias, the four enum representations, flatten, and try_from validation, including which ones break postcard and bincode. - Compatibility testing: fixture, golden-file, and round-trip test patterns that prove old payloads still parse and new output stays stable. - Use Case: You add rename_all = "camelCase" to a shipped config type and every existing file stops parsing. The Skill explains that rename_all is a wire change and shows the alias fix that reads both spellings. ## Quick Start Ask the agent to audit this Rust crate for serde types whose encoded form is a contract and flag any breaking wire-format risks.

Frequently Asked Questions about rust-serde

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make serde reject unknown fields in a Rust config file?▼

Add #[serde(deny_unknown_fields)] to the struct so a misspelled key fails at parse time with an error naming the field and byte offset. Without it, serde silently discards unknown keys and the intended field keeps its default value.

How do I rename a serde field without breaking existing payloads?▼

Use #[serde(rename = "new_name", alias = "old_name")]. rename sets the written spelling while alias keeps the old spelling accepted on read, so old payloads keep parsing until every writer is upgraded.

Which serde enum representation should I use for JSON messages?▼

Internal tagging with #[serde(tag = "type")] is the usual choice for JSON because the tag reads naturally and the payload stays flat. Use external tagging when the type must also go through binary formats like postcard or bincode, which reject the other representations at runtime.

Why does serde_json turn large integers into floats?▼

By default serde_json::Number holds only i64, u64, or f64, so an integer outside that range parses into Value as an f64 and loses digits. Parse into the typed field instead, or enable the arbitrary_precision feature to store digits as text.

Can I use serde flatten together with deny_unknown_fields?▼

No, serde documents the combination as unsupported. The deny rule fires first and the flatten map never receives anything, returning an unknown field error. Pick either the catch-all map or the strict schema, not both.

Why does my serde type work with JSON but fail on postcard or bincode?▼

Positional binary formats cannot represent flatten, internally or adjacently tagged enums, untagged enums, or skip_serializing_if; these compile but fail at runtime. Use external tagging, no flatten, and version the whole payload for postcard or bincode.