← 返回 Skills 市场
pgeraghty

Detect File Type - Local

作者 pgeraghty · GitHub ↗ · v0.2.0
cross-platform ✓ 安全检测通过
420
总下载
1
收藏
0
当前安装
5
版本数
在 OpenClaw 中安装
/install detect-file-type-local
功能描述
Local, offline AI-powered file type detection — no network, no API keys
使用说明 (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

安全使用建议
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.
功能分析
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.
能力评估
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.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install detect-file-type-local
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /detect-file-type-local 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
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
元数据
Slug detect-file-type-local
版本 0.2.0
许可证
累计安装 0
当前安装数 0
历史版本数 5
常见问题

Detect File Type - Local 是什么?

Local, offline AI-powered file type detection — no network, no API keys. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 420 次。

如何安装 Detect File Type - Local?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install detect-file-type-local」即可一键安装,无需额外配置。

Detect File Type - Local 是免费的吗?

是的,Detect File Type - Local 完全免费(开源免费),可自由下载、安装和使用。

Detect File Type - Local 支持哪些平台?

Detect File Type - Local 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Detect File Type - Local?

由 pgeraghty(@pgeraghty)开发并维护,当前版本 v0.2.0。

💬 留言讨论