OpenParable
Skip to content
← Back to skills

Use Facet Crates

Development
use-facet-crates

Use Facet Crates is an Agent Skill for development published in the facet-rs/facet repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Guidelines for using facet crates (facet-json, facet-toml, figue) instead of serde-based alternatives for consistent dogfooding

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/facet-rs/facet/blob/HEAD/.claude/skills/use-facet-crates/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/use-facet-crates, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Use Facet Crates Instead of Serde Ecosystem

When writing code in this workspace, prefer facet-based crates over serde-based ones. This project is building facet as a replacement for serde, so we should dogfood our own libraries.

Crate Replacements

Instead ofUseNotes
serdefacetCore derive and traits
serde_jsonfacet-jsonJSON serialization/deserialization
tomlfacet-tomlTOML parsing
serde_yamlfacet-yamlYAML support
clapfigueCLI argument parsing (separate repo)
serde_derivefacet (derive)#[derive(Facet)] replaces Serialize/Deserialize

When to Use Which

Use facet-json for:

  • New code in this workspace
  • Internal tools (like benchmark-analyzer)
  • Anything that doesn't need serde compatibility

serde_json is acceptable for:

  • Interop with external crates that require serde
  • Benchmarks comparing facet vs serde performance
  • Code that specifically tests serde compatibility

Quick Example

// OLD (serde)
use serde::{Serialize, Deserialize};
use serde_json;

#[derive(Serialize, Deserialize)]
struct Config {
    name: String,
}

let config: Config = serde_json::from_str(json)?;

// NEW (facet)
use facet::Facet;
use facet_json as json;

#[derive(Facet)]
struct Config {
    name: String,
}

let config: Config = json::from_str(json)?;

Checking Dependencies

When adding new dependencies or reviewing code, check Cargo.toml for serde ecosystem crates and consider if facet alternatives exist.

TODO for This Workspace

The benchmark-analyzer currently uses serde_json for JSON serialization in chart data. This should be migrated to facet-json for consistency (eating our own dogfood).

Location: tools/benchmark-analyzer/src/report.rs - uses serde_json::to_string() for chart labels/data.