Skill filetypes

From benbrastmckie/nvim · View interactive version

Skill filetypes is an AI agent skill from the GitHub repository benbrastmckie/nvim. File format conversion routing with specialized sub-agent dispatch

How to use this skill

Skill file

Filetypes Skill

Thin wrapper that routes file format operations to the filetypes-router-agent, which then delegates to specialized sub-agents based on file type.

Context Pointers

Reference (do not load eagerly):

Note: This skill is a thin wrapper. Context is loaded by the delegated agents, not this skill.

Trigger Conditions

This skill activates when:

Direct Invocation

Implicit Invocation (during task implementation)

When an implementing agent encounters any of these patterns:

Plan step language patterns:

File extension detection:

Task description keywords:

When NOT to trigger

Do not invoke for:


Execution

1. Input Validation

Validate required inputs:

# Validate source exists
if [ ! -f "$source_path" ]; then
  return error "Source file not found: $source_path"
fi

# Determine output path if not provided
if [ -z "$output_path" ]; then
  source_dir=$(dirname "$source_path")
  source_base=$(basename "$source_path" | sed 's/\.[^.]*$//')
  source_ext="${source_path##*.}"

  # Infer target extension
  case "$source_ext" in
    pdf|docx|xlsx|pptx|html) output_path="${source_dir}/${source_base}.md" ;;
    md) output_path="${source_dir}/${source_base}.pdf" ;;
    *) return error "Cannot infer output format for .$source_ext" ;;
  esac
fi

2. Context Preparation

Prepare delegation context:

{
  "source_path": "/absolute/path/to/source.pdf",
  "output_path": "/absolute/path/to/output.md",
  "metadata": {
    "session_id": "sess_{timestamp}_{random}",
    "delegation_depth": 1,
    "delegation_path": ["orchestrator", "convert", "skill-filetypes"]
  }
}

3. Invoke Router Agent

CRITICAL: You MUST use the Task tool to spawn the router agent.

Required Tool Invocation:

Tool: Task (NOT Skill)
Parameters:
  - subagent_type: "filetypes-router-agent"
  - prompt: [Include source_path, output_path, metadata]
  - description: "Convert {source_path} to {output_path}"

DO NOT use Skill(filetypes-router-agent) - this will FAIL.

Agents live in .opencode/agents/ or extension agent directories, not .opencode/skills/.

The Skill tool can only invoke skills from .opencode/skills/.

The router will:

4. Return Validation

Validate return matches subagent-return.md schema:

5. Return Propagation

Return validated result to caller without modification.


Return Format

See .opencode/context/core/formats/subagent-return.md for full specification.

Expected successful return:

{
  "status": "converted",
  "summary": "Successfully converted document.pdf to document.md using markitdown",
  "artifacts": [
    {
      "type": "implementation",
      "path": "/absolute/path/to/document.md",
      "summary": "Converted markdown document"
    }
  ],
  "metadata": {
    "session_id": "sess_...",
    "agent_type": "document-agent",
    "delegation_depth": 2,
    "delegation_path": ["orchestrator", "convert", "skill-filetypes", "filetypes-router-agent", "document-agent"],
    "tool_used": "markitdown"
  },
  "next_steps": "Review converted document"
}

Error Handling

Input Validation Errors

Return immediately with failed status if source file not found.

Unsupported Format

Return failed status with clear message about supported formats.

Router/Subagent Errors

Pass through the router/subagent's error return verbatim.

Tool Not Available

Return failed status with installation instructions.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.