formatting-with-toon
БесплатноБез исполняемых скриптовНе проверенFormats structured data using TOON v2.0 to minimize tokens while preserving readability. Use when outputs include tables, logs, events, or repeated records…
от majiayu000★ 31 звезда на GitHubОб этом скилле
TOON v2.0 Formatter Skill (AGGRESSIVE MODE)
Purpose
AGGRESSIVELY apply TOON v2.0 format to save 30-60% tokens on structured data. Use TOON by default for biggish, regular data. Use native Zig encoder for 20x performance.
When to Use (AGGRESSIVE)
TOON ALL DAY - Use automatically for:
- ✅ Arrays with ≥ 5 similar items
- ✅ Tables, logs, events, transactions, analytics
- ✅ API responses with uniform structure (≥60% field overlap)
- ✅ Database query results
- ✅ Repeatedly-used, structured data in prompts
- ✅ RAG pipelines, tool calls, agents passing data around
- ✅ Benchmarks/evals where prompt size = money
- ✅ Shape is more important than labels
- ✅ You know what each column means
- ✅ Can declare headers once, go row-by-row
MAYBE, BUT NOT AUTOMATICALLY - Be selective when:
- ⚠️ Human collaborators reading/editing data a lot
- ⚠️ APIs/tools expect JSON (use JSON on wire, TOON in prompts)
- ⚠️ Structure is uneven (many optional keys, weird nesting)
NO, JUST DON'T - Stick to JSON/text for:
- ❌ Short arrays (< 5 items)
- ❌ One-off examples in docs
- ❌ Narrative text, instructions, essays
- ❌ Deep, irregular trees where hierarchy matters
What is TOON v2.0?
TOON (Token-Oriented Object Notation) v2.0 reduces token consumption by 30-60% for structured data:
Three Array Types
1. Tabular (uniform objects ≥5 items):
[2]{id,name,balance}:
1,Alice,5420.50
2,Bob,3210.75
2. Inline (primitives ≤10):
tags[5]: javascript,react,node,express,api
3. Expanded (non-uniform):
- name: Alice
role: admin
- name: Bob
level: 5
Three Delimiters
Comma (default, most compact):
[2]{name,city}: Alice,NYC Bob,LA
Tab (for data with commas):
[2\t]{name,address}: Alice 123 Main St, NYC
Pipe (markdown-like):
[2|]{method,path}: GET|/api/users
Key Folding
Flatten nested objects (25-35% extra savings):
server.host: localhost
server.port: 8080
database.host: db.example.com
Progressive Details
Use the process and examples below when you need full TOON application workflows.
Process
1. Detect Suitable Data
When encountering array data, check if it meets TOON criteria:
- ✅ Array with ≥5 items
- ✅ Objects with ≥60% field uniformity (most objects share same fields)
- ✅ Flat or moderately nested structure
How to check uniformity:
- Extract all field names from all objects
- Count how many objects have the most common set of fields
- Calculate:
(objects with common fields / total objects) × 100 - If ≥60%, uniformity is good for TOON
2. Estimate Token Savings
Quick estimation method:
- JSON tokens ≈
(item count × field count × 4) + overhead- Example: 10 items × 5 fields × 4 = ~200 tokens
- TOON tokens ≈
20 (header) + (item count × field count × 2)- Example: 20 + (10 × 5 × 2) = ~120 tokens
- Savings ≈
(JSON - TOON) / JSON × 100%- Example: (200 - 120) / 200 = 40% savings
3. Apply TOON v2.0 Aggressively
AGGRESSIVE MODE: Use Zig encoder for optimal results
If data meets criteria:
Method 1: Use Zig Encoder (Recommended - 20x faster):
.claude/utils/toon/zig-out/bin/toon encode data.json \
--delimiter tab \
--key-folding \
> data.toon
Method 2: Manual TOON (for inline generation):
- Detect array type (inline/tabular/expanded)
- Choose delimiter (comma/tab/pipe)
- Apply key folding if nested objects
- Build TOON header:
[N]{fields}:orkey[N]: values - Output formatted TOON
Show brief summary:
📊 Using TOON v2.0 (estimated 42% savings, 10 items)
Format: Tabular with tab delimiter
Key folding: enabled
[10\t]{id,name,address,status}:
1 Alice 123 Main St, NYC active
2 Bob 456 Oak Ave, LA inactive
...
Otherwise, use JSON and explain why:
Using JSON because:
- Only 3 items (too small)
- Or: Low uniformity (only 45% have same fields)
- Or: Deeply nested structure
4. Show Formatted Output
Immediately show in TOON with brief explanation:
📊 API Endpoints (15 items, TOON format - saved 40.1% tokens):
[15]{method,path,description,auth,rateLimit}:
GET,/api/users,List all users,required,100/min
POST,/api/users,Create new user,required,50/min
...
No long explanations needed - just use it!
Best Practices
Always Show Format Decision
When working with data, always indicate which format you're using and why:
📊 Using TOON (estimated 42% token savings)
[count]{fields}:...
or
ℹ️ Using JSON (deeply nested structure, TOON not suitable)
{...}
When NOT to Use TOON
Explain when JSON is better:
- Deeply nested data: TOON excels with flat/tabular structures
- Low uniformity (<70%): Different fields per object reduces TOON benefits
- Small arrays (<10 items): Overhead not worth it
- Single records: Use JSON for clarity
Performance Tips
- **Batch proc
Установить formatting-with-toon в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл formatting-with-toon?
Formats structured data using TOON v2.0 to minimize tokens while preserving readability. Use when outputs include tables, logs, events, or repeated records and token budgets matter. Triggers include "format table", "structured data", "TOON", "minimize tokens", or "large list".
Как установить скилл formatting-with-toon?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл formatting-with-toon запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic