mime-detection-routing

mime-detection-routing is a skill for Claude Code, Codex from xberg-io/xberg. It costs 93 tokens per session (914 once invoked), scanned A, original, MIT.

A guide to how the xberg codebase identifies file types and selects the extractor that handles each type. MIME types are standard labels such as image/png or application/pdf.

In plain words
What is it for?
Use it when adding a file format, changing extension or byte detection, updating supported MIME types, or debugging extractor selection.
Why use it?
It prevents new format support from being added in only one place or from routing files incorrectly based on extensions, file contents, or MIME labels.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when adding a file format, changing extension or byte detection, updating supported MIME types, or debugging extractor selection.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/xberg-io/xberg/mime-detection-routing
About the project

Xberg is a document-intelligence engine that reads files, URLs, archives, and source trees and extracts text, metadata, images, tables, and structured data, with additional code-language understanding. Developers use it through language bindings, a command-line tool, REST API, or MCP server, and the catalogue entries support those integrations.

xberg-io/xberg · 9,285 stars · on GitHub · docs.xberg.io

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add xberg-io/xberg --skill mime-detection-routing
Clone the repo
git clone --depth 1 https://github.com/xberg-io/xberg

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mime-detection-routing

README.md
[![agentmods](https://agentmods.dev/badge/skills/xberg-io/xberg/mime-detection-routing/github.svg)](https://agentmods.dev/skills/xberg-io/xberg/mime-detection-routing)
Your own site
<a href="https://agentmods.dev/skills/xberg-io/xberg/mime-detection-routing"><img src="https://agentmods.dev/badge/skills/xberg-io/xberg/mime-detection-routing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mime-detection-routing

Your own site · 80×15
<a href="https://agentmods.dev/skills/xberg-io/xberg/mime-detection-routing"><img src="https://agentmods.dev/badge/skills/xberg-io/xberg/mime-detection-routing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 93 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 914 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00093 $0.00914
Opus 5 $0.00046 $0.00457
Sonnet 5 $0.00019 $0.00183
Haiku 4.5 $0.00009 $0.00091

Measured 11d ago against content hash bd944f15c60a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

mime-detection-routing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.ai-rulez/skills/mime-detection-routing/SKILL.md · 70 lines

How it starts

The opening of the file, as written. The whole thing — 70 lines — stays where its author put it; the contents beside it link to each section on GitHub.

MIME Detection & Routing

Detection Flow

Policy -> content and/or extension evidence -> validate_mime_type -> registry.get(mime) -> extractor

Key Functions

Function Location Behaviour
detect_mime_type(path, check_exists: bool) core/mime.rs Path-based only — never reads bytes. Lowercased extension → EXT_TO_MIME, then tree-sitter extension detection (feature tree-sitter), then mime_guess::from_path. check_exists gates a file-existence check, not content inspection.
detect_mime_type_from_bytes(bytes) core/mime.rs Magic-number detection via the infer crate. The only content-sniffing entry point.
validate_mime_type(mime) core/mime.rs Parses the media type, matches its case-insensitive essence against SUPPORTED_MIME_TYPES, and returns the registered MIME spelling. Parameters such as charset do not affect extractor routing. It does not consult the extractor registry.

The FORMATS registry is the single source of truth

FORMATS: &[FormatEntry { extensions, mime_type, aliases }] in core/mime.rs. EXT_TO_MIME and SUPPORTED_MIME_TYPES are LazyLocks derived from it by iteration — there is no m.insert call site to add to, and hand-editing either is impossible.

The full registry publishes 106 formats, 140 unique extensions, and 53 aliases, verified by scripts/sync_supported_counts.py verify. The published count constants describe that static registry; runtime availability is its intersection with registered extractors. Extension lookup is case-insensitive (the extension is lowercased before the map hit).

Registry Selection

let registry = get_document_extractor_registry();          // plugins/registry/mod.rs
let guard = registry.read()?;
let extractor: Arc<dyn DocumentExtractor> = guard.get(mime_type)?;  // Result, not Option

DocumentExtractorRegistry::get (plugins/registry/extractor.rs) returns the highest-priority() extractor for the MIME type, and returns Err — not None — when none matches.

Read the full file on GitHub · 70 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 70 lines · 93 tokens per session scan A bd944f15c60a

Subscribe to this mod's changes

mime-detection-routing is a skill published in the GitHub repository xberg-io/xberg (9,285 stars, last pushed yesterday), licensed MIT. It adds 93 tokens to every session and 914 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

doc-reader

PDF/DOCX/XLSX/image document intelligence — text extraction, table parsing, OCR, financial statement analysis, contract clause detection, document classification, and format conversion. Use when reading, analyzing, extracting data from, or converting documents.

JansenAnalytics/claudex · 51 tokens

mem0-vercel-ai-sdk

Mem0 provider for Vercel AI SDK (@mem0/vercel-ai-provider). TRIGGER when: user mentions "vercel ai sdk", "@mem0/vercel-ai-provider", "createMem0", "retrieveMemories", "addMemories", "getMemories", "searchMemories", "mem0 vercel", "AI SDK provider", "AI SDK memory", or is using generateText/streamText with mem0. Also…

mem0ai/mem0 · 146 tokens

schema-exploration

Lists tables, describes columns and data types, identifies foreign key relationships, and maps entity relationships in a database. Use when the user asks about database schema, table structure, column types, what tables exist, ERD, foreign keys, or how entities relate.

langchain-ai/deepagents · 57 tokens

matlab

Build, review, migrate, and safely plan MATLAB or GNU Octave numerical workflows, including arrays, tabular/time data, tests, projects, graphics, MAT files, and explicit Python interoperability.

K-Dense-AI/scientific-agent-skills · 42 tokens

pennylane

Hardware-agnostic quantum ML framework with automatic differentiation. Use when training quantum circuits via gradients, building hybrid quantum-classical models, or needing device portability across IBM/Google/Rigetti/IonQ. Best for variational algorithms (VQE, QAOA), quantum neural networks, and integration with…

K-Dense-AI/scientific-agent-skills · 98 tokens

mine

Mine a project or conversation into your MemPalace — extract and store memories for later retrieval.

MemPalace/mempalace · 21 tokens