moai-formats-data

Encode, validate, and optimize JSON, YAML, and TOON data formats for LLM transmission.

Updated Jun 18, 2026
One-click install
npx skills add https://github.com/h102-log/pdfrag --skill moai-formats-data-h102-log
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: moai-formats-data
Source: https://github.com/h102-log/pdfrag/tree/main/.claude/skills/moai-formats-data
Command: npx skills add https://github.com/h102-log/pdfrag --skill moai-formats-data-h102-log

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Sending structured data to LLMs consumes excessive tokens, and processing large JSON/YAML files with standard libraries causes memory exhaustion and slow performance. This Skill provides TOON encoding for 40-60% token reduction, high-performance serialization, and schema-based data validation. ## Core Features & Use Cases - TOON Encoding: Compress structured data with type markers (#, !, @, ~) to reduce LLM token usage by 40-60% with lossless round-trip decoding. - High-Performance JSON/YAML: Use orjson for 2-5x faster serialization and ijson for memory-efficient streaming of large files. - Data Validation & Schema Evolution: Validate data against schemas with type checking, custom rules, cross-field validation, and versioned migrations. - Intelligent Caching: Apply LRU eviction, memory-aware cache management, and tag-based invalidation for expensive operations. - Use Case: When building an API that feeds user records to an LLM, validate the records against a schema, encode them with TOON to fit the token budget, and decode the LLM's response back to standard dictionaries. ## Quick Start Ask the AI to encode a sample user dictionary with TOONEncoder and compare the token count against standard JSON output.

Frequently Asked Questions about moai-formats-data

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

FAQPage Schema
How do I reduce token usage when sending JSON data to an LLM?▼

Encode the data with TOON (Token-Optimized Object Notation), which uses type markers like # for numbers and ! for booleans to achieve 40-60% token reduction versus JSON. The encoding is lossless, so you can decode the response back to the original structure.

What is the fastest way to serialize JSON in Python?▼

Use orjson instead of the standard json module for 2-5x faster serialization and deserialization. It supports options like OPT_SERIALIZE_NUMPY and OPT_SORT_KEYS, and outputs bytes directly for efficient network transmission.

How do I process large JSON files without running out of memory?▼

Use ijson to stream-parse large JSON files item by item instead of loading the entire file into memory. Combine it with batch processing to handle gigabyte-scale datasets with constant memory usage.

How do I validate data against a schema in Python?▼

Create a schema defining field types, required flags, length limits, and regex patterns, then call validate with the data and schema. The result includes a valid flag, an errors dictionary, and sanitized data with type coercion applied.

When should I not use TOON encoding?▼

Avoid TOON for human-readable configuration files and long-term data storage, since its compact type-marker syntax sacrifices readability. Use it only for LLM communication contexts where token budget matters, and keep JSON for everything else.