config-loading-precedence
How Xberg resolves configuration — CLI-mode and server/MCP-mode precedence orders, project config walk-up, user config fallback, field-level inline JSON merge…
Skill by xberg-io
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/xberg-io-config-loading-precedence
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/config-loading-precedence
What's inside
- Skill name
config-loading-precedence- Description
- How Xberg resolves configuration — CLI-mode and server/MCP-mode precedence orders, project config walk-up, user config fallback, field-level inline JSON merge (merge_json_into_config), the ExtractionOverrides CLI layer, and the two mechanisms that make a config change silently do nothing. Load when adding a config flag or env var, changing config precedence, or debugging why a setting is or isn't taking effect.
- License
- MIT
- Instructions
- 92 lines in SKILL.md · view on GitHub
Agent Skills spec issues
- name: missing
Files (2)
- SKILL.md
- index.md
SKILL.md (first lines)
# Configuration Loading & Precedence
## CLI Mode Precedence (highest to lowest)
1. Individual CLI flags (`--ocr`, `--output-format`, `--chunk`)
2. Inline JSON config (`--config-json` or `--config-json-base64`)
3. Config file (`--config path.toml`)
4. Auto-discovered config (`xberg.{toml,yaml,yml,json}` in cwd/parents, then the user config dir)
5. Default values
## Server/MCP Mode Precedence
1. CLI arguments (`--host`, `--port`)
2. Environment variables (`XBERG_HOST`, `XBERG_PORT`)
3. Config file `[server]` section
4. Defaults (`127.0.0.1:8000`)
## Config File Discovery
`ExtractionConfig::discover()` (`core/config/extraction/loaders.rs`) uses the same deterministic
format precedence at every level:
1. Walks the current directory and its parents, probing `xberg.toml`, `xberg.yaml`,
`xberg.yml`, then `xberg.json` in each directory. The first hit wins.
2. If that finds nothing, falls back to the per-user global config directory
(`dirs::config_dir()/xberg`) and probes four basenames in a fixed order:
`xberg.toml`, `xberg.yaml`, `xberg.yml`, `xberg.json`.
## Inline JSON Config
Field-level merge (not whole-object replacement):
```rust
fn merge_json_into_config(base: &ExtractionConfig, json: Value) -> Result<ExtractionConfig> {
let mut config_json = serde_json::to_value(base)?;
// Merge fields from json into config_json
serde_json::from_value(merged)?
}
```
Use `--config-json-base64` for shell escaping.
## Config File Formats
**TOML** (`xberg.toml`):
```toml
use_cache = true
[ocr]
backend = "tesseract"
languages = ["eng", "deu"]
[security_limits]
max_archive_size = 524288000
```
**YAML** and **JSON** follow equivalent structure.
## CLI Flag Overrides
`crates/xberg-cli/src/commands/overrides/mod.rs`: the `ExtractionOverrides` struct's `validate()`
runs first, then `apply(self, config: &mut ExtractionConfig)` lays individual CLI flags over
the merged config. There is no `apply_extraction_overrides()` and no `commands.rs` —
`commands/` is a directory.
Inline JSON enters through `apply_json_overrides(config, config_json, config_json_base64)`
(`crates/xberg-cli/src/input.rs`), which delegates to `merge_json_into_config`.
## Two silent no-op mechanisms
**Duplicate `Default` impls.** `TesseractConfig` is defined twice — public
(`types/formats.rs`, binding-friendly types) and internal (`ocr/types.rs`, engine-side types)
— bridged by a `From` impl, each with its own `Default`. Changing one default fixes only the
routes that materialise that struct. Before changing any config default, grep the **bare**
type name (a `pub use module::*;` makes a qualified path unsearchable) and check for a second
definition.
**Unknown keys are rejected.** Nearly every config struct under `core/config/` (including
`ExtractionConfig`, `OcrConfig`, `PdfConfig`, `ChunkingConfig` and `LlmConfig`) carries
`#[serde(deny_unknown_fields)]`, so a typo'd key fails to parse instead of being ignored. Check the
struct's definition before relying on that for a new one. Write config fixtures against the serde
**wire** names (`ChunkingConfig`'s `max_characters` is `max_chars` on the wire; the field name
is only an alias).
## Critical Rules
1. CLI flags always win over config file
2. JSON merge is field-level, not whole-object
3. Auto-discovery probes TOML, YAML, YML, then JSON in each directory before walking to its parent
4. `--config-json-base64` for shell-safe JSON passing
5. Server config uses `[server]` section + extraction configFrom xberg-io/xberg, MIT.
More from xberg-io/xberg
- 0.769score
xberg-extracting-keywords
xberg-io
Use when extracting keywords (YAKE/RAKE) from documents — and, secondarily, when detecting document language or generating embeddings for RAG and search.
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
xberg-extracting-with-ocr
xberg-io
Use when extracting text from scanned PDFs, photographed pages, or images that have no embedded text layer.
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
xberg
xberg-io
Extract text, tables, metadata, and images from 107 document formats (PDF, Office, images, HTML, email, archives, academic) using Xberg.
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
xberg-chunking
xberg-io
Use when splitting extracted text into chunks for LLM context windows or RAG ingestion.
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
xberg-extracting-tables
xberg-io
Use when extracting tabular data from PDFs, spreadsheets, or images.
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
crate-structure
xberg-io
The Xberg workspace layout — the version source of truth (root Cargo.toml [workspace.package] version), the 19 workspace members and 3 excluded crates, the…
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
wasm-constraints
xberg-io
WASM build constraints for the crates/xberg-wasm crate — the wasm-target feature set, no-tokio sync-only internal APIs, the crate-private SyncExtractor trait…
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
feature-flag-policy
xberg-io
Cargo feature flags for crates/xberg — ORT-incompatible targets (WASM, Android x86_64 emulator), type-only and tract inference companion features…
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
mime-detection-routing
xberg-io
MIME type detection and extractor routing in core/mime.rs — the FORMATS registry that EXT_TO_MIME and SUPPORTED_MIME_TYPES are derived from, the path-based…
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
xberg-batch-extraction
xberg-io
Use when extracting from many files at once with shared config, bounded parallelism, per-file overrides, and error recovery.
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
alef-generated-bindings
xberg-io
Alef-managed generated bindings in packages/* and binding crates — the regeneration workflow (task alef:generate / alef:verify), the alef.toml section layout…
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
xberg-picking-a-format
xberg-io
Use when choosing an output format for extracted documents — plain text, markdown, djot, HTML, JSON, or DocTags.
SkillAFreshness: A★ 9.4KClaude Code +9
Signals
- Stars
- 9,441
- Forks
- 600
- Open issues
- 7
- Last commit (this folder)
- Oct 14, 2026 (14 days ago)
- Last release
- Oct 13, 2026 (14 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/xberg-io/xberg
- Website
- docs.xberg.io
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from xberg-io
- 0.769score
feature-flag-policy
xberg-io
Cargo feature flags for crates/xberg — ORT-incompatible targets (WASM, Android x86_64 emulator), type-only and tract inference companion features…
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
mime-detection-routing
xberg-io
MIME type detection and extractor routing in core/mime.rs — the FORMATS registry that EXT_TO_MIME and SUPPORTED_MIME_TYPES are derived from, the path-based…
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
crate-structure
xberg-io
The Xberg workspace layout — the version source of truth (root Cargo.toml [workspace.package] version), the 19 workspace members and 3 excluded crates, the…
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
alef-generated-bindings
xberg-io
Alef-managed generated bindings in packages/* and binding crates — the regeneration workflow (task alef:generate / alef:verify), the alef.toml section layout…
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
wasm-constraints
xberg-io
WASM build constraints for the crates/xberg-wasm crate — the wasm-target feature set, no-tokio sync-only internal APIs, the crate-private SyncExtractor trait…
SkillAFreshness: A★ 9.4KClaude Code +9 - 0.769score
xberg
xberg-io
Extract text, tables, metadata, and images from 107 document formats (PDF, Office, images, HTML, email, archives, academic) using Xberg.
SkillAFreshness: A★ 9.4KClaude Code +9
Cite this page
config-loading-precedence skill. Agent Mart. https://agentmart.dev/skills/xberg-io-config-loading-precedence (last updated 2026-10-24)