# Design

> Why bytepeel exists and the principles behind it.

## Why this exists

LLM agents cannot reliably decode hex, base64 or binary formats by reading them:
they produce plausible but wrong bytes. The usual workaround, a throwaway
Python script, routinely gets the edge cases wrong: missing base64 padding,
URL-safe alphabets, 10-byte negative varints, zigzag applied to the wrong
type, or a LEN field that is a submessage being printed as garbage text.

bytepeel moves the byte-exact work into a tested tool and leaves the judgment
to the agent. When the bytes are genuinely ambiguous, it reports ranked
alternatives instead of guessing silently.

## Principles

1. **Never resolve ambiguity silently.** LEN fields carry ranked `alts`;
   varints carry every integer view (`uint`, `int`, `sint`).
2. **Every node and field has a byte range,** so results can be cited and sliced.
3. **Deterministic.** The same input and options always give byte-identical JSON.
4. **Errors are data.** Stable `code`s and byte `offset`s let an agent fix its
   call in one turn.
5. **Zero dependencies in `bytepeel-core`.** Small, auditable, builds anywhere
   including WASM.
6. **Token-frugal output.** Compact JSON, long text and hex capped (with
   `"truncated":true`), and `--get` to extract exactly one field.
