mime-detection-routing

mime-detection-routing is a skill for Claude Code from xberg-io/xberg. It costs 14 tokens per session (917 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 Code

Written for Claude Code: paths in frontmatter.

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,631 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.

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 14 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 917 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.00014 $0.00917
Opus 5.5 $0.00006 $0.00367
Sonnet 5.5 $0.00003 $0.00183
Haiku 4.5 $0.00001 $0.00092

Measured 1mo ago against content hash 0467edb21a81, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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 · 80 lines

How it starts

The opening of the file, as written. The whole thing — 80 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 · 80 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 1mo ago Changed · -18 tokens per session 0467edb21a81
  2. 1mo ago Changed · -13 tokens per session ee4fb4b59c73
  3. 1mo ago Changed · +4 lines · -43 tokens per session 91bfa70e246e
  4. 1mo ago Changed · +6 lines · -5 tokens per session 40b22b8c97a1
  5. 3mo 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,631 stars, last pushed today), licensed MIT. It adds 14 tokens to every session and 917 once invoked, about $0.0001 per session on Opus 5.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

mime-detection-routing compared with skills from other repositories

mime-detection-routing next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
mime-detection-routingxberg-io/xbergSkill9.6ktodayMITA14Claude Code
first-readerShubhamsaboo/awesome-llm-appsSkill146ktodayApache-2.0A174Claude Code, Codex
mcp-apps-builderShubhamsaboo/awesome-llm-appsSkill146ktodayApache-2.0A139Claude Code, Codex
project-graveyardShubhamsaboo/awesome-llm-appsSkill146ktodayApache-2.0A127Claude Code, Codex
commit-archaeologistShubhamsaboo/awesome-llm-appsSkill146ktodayApache-2.0A82Claude Code, Codex
dependency-doctorShubhamsaboo/awesome-llm-appsSkill146ktodayApache-2.0A115Claude Code, Codex
scope-creep-detectorShubhamsaboo/awesome-llm-appsSkill146ktodayApache-2.0A98Claude Code, Codex