Skip to main content
skill CX Codex

use-facet-crates — Claude Code skill: what it does, how to install

The use-facet-crates skill steers Rust code toward facet crates instead of serde-based alternatives, with exceptions for interop, benchmarks, and compatibility tests.

Apache-2.0 1 installs ★ 2,590 updated 2026-10-26

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add facet-rs/facet --skill use-facet-crates -a claude-code
Open on GitHub

What use-facet-crates does

The skill sets a crate-selection policy for the facet workspace. It maps serde to facet, serde_json to facet-json, toml to facet-toml, serde_yaml to facet-yaml, and clap to figue. Data types should use #[derive(Facet)] where the facet approach applies.

It covers new code and internal tools that do not need serde compatibility. The instructions also tell the agent to inspect Cargo.toml when adding dependencies or reviewing code. One concrete follow-up targets tools/benchmark-analyzer/src/report.rs, where chart data currently uses serde_json::to_string().

serde_json remains acceptable when an external crate requires serde, when a benchmark compares facet with serde, or when code tests serde compatibility. That constraint matters: replacing the dependency can break an integration contract.

What it helps with

  • choose facet replacements for new Rust code
  • migrate JSON serialization from serde_json to facet-json
  • parse TOML with facet-toml
  • replace clap argument parsing with figue
  • inspect Cargo.toml for serde-family dependencies

Example prompts for the agent

  • Review this Rust module and replace serde-based crates with the matching facet alternatives.
  • Migrate chart data in tools/benchmark-analyzer/src/report.rs from serde_json to facet-json.
  • Inspect Cargo.toml and explain which serde dependencies must stay for compatibility.

How to install use-facet-crates

1Skills CLI (Vercel)

npx skills add facet-rs/facet --skill use-facet-crates -a claude-code

2Manually: put the files in place

~/.claude/skills/use-facet-crates/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/use-facet-crates/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about use-facet-crates

How do I install use-facet-crates in Claude Code?

Run npx skills add facet-rs/facet --skill use-facet-crates -a claude-code, then check ~/.claude/skills/use-facet-crates/SKILL.md.

What does use-facet-crates do?

It guides Rust changes toward facet crates instead of serde-based alternatives. It also records the cases where serde_json is acceptable and asks for dependency checks in Cargo.toml.

When can a project keep using serde_json?

Keeping it is acceptable for external-crate interoperability, facet-versus-serde benchmarks, or tests that target serde compatibility. New code without that constraint should use facet-json.

Source text

SKILL.md · Apache-2.0
---
name: use-facet-crates
description: Guidelines for using facet crates (facet-json, facet-toml, figue) instead of serde-based alternatives for consistent dogfooding
---

# 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 of         | Use                | Notes                                    |
|--------------------|--------------------|-----------------------------------------|
| `serde`            | `facet`            | Core derive and traits                  |
| `serde_json`       | `facet-json`       | JSON serialization/deserialization      |
| `toml`             | `facet-toml`       | TOML parsing                            |
| `serde_yaml`       | `facet-yaml`       | YAML support                            |
| `clap`             | `figue`            | CLI argument parsing (separate repo)    |
| `serde_derive`     | `facet` (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

```rust
// 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.

© facet-rs · Apache-2.0 · facet-rs/facet

Similar skills

All skills for Programming languages →

Project sponsors

Companies that keep this analytics open