xberg-picking-a-format
Use when choosing an output format for extracted documents β plain text, markdown, djot, HTML, JSON, or DocTags. Maps consumer (LLM, parser, archive) to the right `--format` / `--content-format` pair.
Install
Copy this folder into your Claude Code project (needs Node.js):
npx degit xberg-io/xberg/plugin/.ai-rulez/skills/xberg-picking-a-format .claude/skills/xberg-picking-a-formatOr install it for every project:
npx degit xberg-io/xberg/plugin/.ai-rulez/skills/xberg-picking-a-format ~/.claude/skills/xberg-picking-a-formatFile content
Made by its original authors and shared under MIT. We show it unchanged, with credit and a link to the source. Source β
---
type: Playbook
title: Picking A Format
description: Use when choosing an output format for extracted documents β plain text, markdown, djot, HTML, JSON, or DocTags. Maps consumer (LLM, parser, archive) to the right `--format` / `--content-format` pair.
x-ai-rulez:
kind: skill
id: xberg-picking-a-format
metadata:
name: xberg-picking-a-format
---
# Picking a format
Xberg has two orthogonal format knobs. Get them right up front and the
downstream code stays simple.
| Knob | What it controls | Values | Default |
| ------------------- | ------------------------------------------------- | -------------------------------------- | ---------------- |
| `--format` | How the CLI prints the result | `text`, `json`, `toon` | `text` (`extract`), `json` (`batch`) |
| `--content-format` | How extracted content is rendered inside `result` | `plain`, `markdown`, `djot`, `html`, `json`, `doctags` | `plain` |
| `--token-reduction` | Strip whitespace / boilerplate for LLM contexts | `off`, `light`, `moderate`, `aggressive`, `maximum` | `off` |
`--format json` returns an envelope wrapping the `ExtractedDocument` β the
document lives under `.result` for `extract` and under `.results[]` for
`batch`, with `content`, `metadata`, `tables`, and `images` as fields of
that nested document. `--format text` prints just `content`.
`--content-format` is what shows up inside that `content` field.
## Decision tree
```text
Who consumes the output?
βββ LLM (Claude, GPT, Gemini, local) β embed/prompt context
β --format text --content-format markdown
βββ Vector store / RAG indexer
β --format json --content-format markdown
β (markdown preserves structure for chunking)
βββ Downstream parser that expects machine-readable JSON
β --format json --content-format plain
β (cleanest text + structured metadata)
βββ Human review / archival
β --format text --content-format markdown
βββ HTML re-rendering / web display
β --format json --content-format html
βββ Lossless intermediate for pandoc / academic tooling
β --format json --content-format djot
βββ Token-budget-constrained pipeline
--format text --content-format plain
(drops markup; add --token-reduction moderate for further savings)
```
## Examples
Feed a PDF directly into an LLM:
```bash
xberg extract paper.pdf --content-format markdown
```
Index a corpus into a RAG store with tables and headings preserved:
```bash
xberg batch docs/*.pdf --format json --content-format markdown \
| jq -c '.result | {content: .content, tables: .tables}'
```
Strip a file to bare text for a token-tight summarizer:
```bash
xberg extract long.pdf \
--content-format plain \
--token-reduction moderate
```
Pull metadata only, ignore content:
```bash
xberg extract file.pdf --format json | jq '.result.metadata'
```
## When in doubt
- **Default to `markdown`** as the content format. It is the best
compromise across LLMs, RAG, and human review, and Xberg has the
most faithful renderer for it.
- Reach for `plain` only when downstream cannot tolerate any markup.
- Reach for `djot` only if you're already in a djot/pandoc pipeline.
- Reach for `html` only when re-rendering for the web.
- Reach for `json` for a heading-driven content tree, or `doctags` for Docling-compatible output.
## Token-reduction (orthogonal)
`--token-reduction` collapses whitespace, strips repeated headers/footers,
and trims boilerplate. It composes with any `--content-format`:
- `off` (default), `light`, `moderate`, `aggressive`, `maximum`.
Use `moderate` as a safe starting point for LLM context windows. `maximum`
is lossy β verify before relying on it.
See `../../references/cli-reference.md` for the full flag set and
`../../references/configuration.md` for the equivalent `output_format` and
`token_reduction` keys in `xberg.toml`.