← Back to Skills Marketplace
pgeraghty

Detect File Type - Local

by pgeraghty · GitHub ↗ · v0.2.0
cross-platform ✓ Security Clean
420
Downloads
1
Stars
0
Active Installs
5
Versions
Install in OpenClaw
/install detect-file-type-local
Description
Local, offline AI-powered file type detection — no network, no API keys
README (SKILL.md)

Detect File Type - Local

Local-only, offline file type detection. Uses an embedded ML model (Google Magika) to identify 214 file types by content — no network calls, no API keys, no data leaves the machine. All inference runs on-device via ONNX Runtime.

When to Use

  • Identify unknown files by their content (not just extension) — locally, without sending data anywhere
  • Verify that a file's extension matches its actual content
  • Check MIME types before processing uploads or downloads
  • Triage files in a directory by type
  • Detect extension mismatches and masquerading (e.g., .pdf.exe, .xlsx.lnk)
  • Flag suspicious polyglot-style payloads (for example PDF/ZIP or PDF/HTA-style chains)
  • When privacy matters — file bytes never leave the local machine

Installation

pip install detect-file-type-local

From source:

pip install -e /path/to/detect-file-type-skill

Usage

Single file

detect_file_type path/to/file

Multiple files

detect_file_type file1.pdf file2.png file3.zip

Recursive directory scan

detect_file_type --recursive ./uploads/

From stdin

cat mystery_file | detect_file_type -

# Optional best-effort fast path (head only)
cat mystery_file | detect_file_type --stdin-mode head --stdin-max-bytes 1048576 -

Output formats

detect_file_type --json file.pdf    # JSON (default)
detect_file_type --human file.pdf   # Human-readable
detect_file_type --mime file.pdf    # Bare MIME type

Programmatic (Python)

python -m detect_file_type path/to/file

Output Schema (JSON)

Single file returns an object; multiple files return an array.

{
  "path": "document.pdf",
  "label": "pdf",
  "mime_type": "application/pdf",
  "score": 0.99,
  "group": "document",
  "description": "PDF document",
  "is_text": false
}

Fields

Field Type Description
path string Input path (or - for stdin)
label string Detected file type label (e.g., pdf, png, python)
mime_type string MIME type (e.g., application/pdf)
score float Confidence score (0.0–1.0)
group string Category (e.g., document, image, code)
description string Human-readable description
is_text bool Whether the file is text-based

Exit Codes

Code Meaning
0 All files detected successfully
1 Fatal error (no results produced)
2 Partial failure (some files failed, some succeeded)

Error Handling

Errors are printed to stderr. Common cases:

  • File not found: error: path/to/file: No such file or directory
  • Permission denied: error: path/to/file: Permission denied
  • Not a regular file: error: path/to/dir: Not a regular file

When processing multiple files, detection continues for remaining files even if some fail.

Limitations

  • Default stdin mode (spool) writes stdin to a temporary file and uses Magika path detection.
  • --stdin-mode head is best effort and may miss trailing-byte signatures.
  • Very small files (\x3C ~16 bytes) may produce low-confidence results
  • Empty files are detected as empty
  • Detection is content-based — file extensions are ignored

Security Context

Usage Guidance
This skill appears to do what it says: local file-type detection using Google Magika. Before installing, consider: 1) Verify the magika dependency's behavior (some ML libraries may download models or telemetry on first run) if you require a provably offline tool. 2) Be cautious when piping untrusted, very large streams into stdin: default mode spools to a temp file (the project documents this) which can consume disk; use --stdin-mode head with a conservative --stdin-max-bytes for untrusted inputs. 3) Install from PyPI or a vetted source and pin versions (pyproject pins magika range). 4) Run the tool in a sandbox or CI environment first if you need higher assurance, and inspect the magika package/source for network calls or hidden behaviors. Overall the package is internally consistent with its stated purpose, but verify the third-party dependency for an absolute offline guarantee.
Capability Analysis
Type: OpenClaw Skill Name: detect-file-type-local Version: 0.2.0 The skill bundle is designed for local, offline file type detection using Google Magika. Code analysis confirms that it performs read-only operations, uses secure temporary file handling for stdin (`tempfile.mkstemp`), and does not contain any network calls or arbitrary code execution. The `SKILL.md` and `README.md` provide clear, non-malicious instructions and explicitly state security features like no network access and no file modification. The `SECURITY.md` file further details the threat model and mitigations, acknowledging potential resource exhaustion for unbounded stdin streams but classifying it as an operational control rather than a vulnerability in the tool's design. There is no evidence of intentional harmful behavior or prompt injection attempts.
Capability Assessment
Purpose & Capability
Name, description, and required artifacts line up: it needs python3 and the magika dependency to perform local file-type detection. The listed install package matches the project and the CLI entrypoint is coherent with the stated purpose.
Instruction Scope
SKILL.md and CLI code stick to reading file bytes, stdin, and formatting output; no instructions reference unrelated files, env vars, or network endpoints. Note: default stdin handling spools input to a temporary file (deleted after use), which can consume disk for large/abused streams; the code and SECURITY.md call this out. This behaviour is within scope but operationally relevant.
Install Mechanism
Install uses a PyPI-style package (uv -> detect-file-type-local) and pyproject.toml declares the dependency on magika. There are no downloads from obscure URLs, no extract-from-URL steps, and the package appears packaged for standard Python installation.
Credentials
The skill requires no environment variables or credentials. One caveat: the skill depends on the third-party magika package; the skill's docs claim inference and model are embedded/offline, but the runtime behavior of the magika package (e.g., whether it attempts network access to fetch models on first run) is not governed by this skill. Verify magika's docs/source if you need a strict offline guarantee.
Persistence & Privilege
The skill does not request always:true, does not persist across other skills, and runs with caller permissions. Temporary files are created for stdin spool mode and removed; no system-wide configuration changes are performed.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install detect-file-type-local
  3. After installation, invoke the skill by name or use /detect-file-type-local
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v0.2.0
Breaking: renamed CLI binary to detect_file_type and updated skill title.
v0.1.3
- Updated description in SKILL.md for greater clarity: now highlights "no network, no API keys" - Bumped version to 0.1.3 - No functional or usage changes; documentation/metadata edit only
v0.1.2
- Adds detection of masquerading and polyglot-style files for improved security use cases. - Introduces new CLI options for stdin processing: `--stdin-mode` (supports `spool` and `head`) and `--stdin-max-bytes`. - Documentation updated with guidance for masquerading/ATT&CK scenarios and polyglot payload detection. - Minor improvements to output and error handling for clarity.
v0.1.1
- Added OpenClaw auto-install metadata with `uv` installer support. - Updated installation instructions to include both PyPI and source methods. - Changed homepage URL to the new repository location.
v0.1.0
Initial public release
Metadata
Slug detect-file-type-local
Version 0.2.0
License
All-time Installs 0
Active Installs 0
Total Versions 5
Frequently Asked Questions

What is Detect File Type - Local?

Local, offline AI-powered file type detection — no network, no API keys. It is an AI Agent Skill for Claude Code / OpenClaw, with 420 downloads so far.

How do I install Detect File Type - Local?

Run "/install detect-file-type-local" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Detect File Type - Local free?

Yes, Detect File Type - Local is completely free (open-source). You can download, install and use it at no cost.

Which platforms does Detect File Type - Local support?

Detect File Type - Local is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Detect File Type - Local?

It is built and maintained by pgeraghty (@pgeraghty); the current version is v0.2.0.

💬 Comments