command-to-subagent

Use when converting a Ruly command to use subagent execution, when a command has heavy MCP/API logic that should be isolated, or when asked to "make this a subagent"

16 stars

Best use case

command-to-subagent is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when converting a Ruly command to use subagent execution, when a command has heavy MCP/API logic that should be isolated, or when asked to "make this a subagent"

Teams using command-to-subagent should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/command-to-subagent/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/data-ai/command-to-subagent/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/command-to-subagent/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How command-to-subagent Compares

Feature / Agentcommand-to-subagentStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when converting a Ruly command to use subagent execution, when a command has heavy MCP/API logic that should be isolated, or when asked to "make this a subagent"

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Converting Commands to Subagents

## Overview

Extract execution logic from a command into a dedicated subagent, keeping only the user-facing workflow (preview, confirmation) in the command. This reduces recipe context by isolating API/MCP complexity.

## When to Use

- Command has heavy MCP or API call logic
- Want to reduce token usage in a recipe
- Need to isolate execution complexity from user workflow
- Command follows preview → confirm → execute pattern

## Quick Reference

| Component | Location | Contains |
|-----------|----------|----------|
| Command | `commands/{name}.md` | User workflow (preview, confirm, dispatch) |
| Subagent | `agents/{name}.md` | Execution logic (MCP calls, API operations) |
| Recipe | `recipes.yml` | Subagent registration |

## Conversion Steps

### Step 1: Identify the Split Point

Find where user interaction ends and execution begins:

```
User workflow (COMMAND):     Execution (SUBAGENT):
├─ Parse input               ├─ API/MCP calls
├─ Validate/lookup           ├─ Error handling
├─ Show preview              ├─ Response formatting
├─ Handle revisions          └─ Return structured result
└─ Dispatch on confirm
```

**Split at confirmation** - everything after "send it" / "post it" goes to subagent.

### Step 2: Create the Subagent File

Location: `rules/{domain}/agents/{name}.md`

**Structure:**
```markdown
---
description: Instructions for the {name} subagent when dispatched
alwaysApply: true
requires:
  - ../common.md        # Shared patterns
  - ../../accounts.md   # If needs user lookups
---
# {Name} Subagent - EXECUTION REQUIRED

## ⚠️ CRITICAL: You MUST Execute

**Your ONLY job is to {action}.** If you complete with "0 tool uses", you have FAILED.

## Input Format

You will receive a prompt like:
{show expected input structure}

## Execution Steps

### Step 1: {First action}
{MCP/API call with example}

### Step 2: {Next action}
...

### Step N: Return Result

**On success:**
```json
{"status": "success", "field": "value"}
```

**On error:**
```json
{"status": "error", "error": "message", "step": "which failed"}
```

## Failure Conditions

❌ **FAILED** if you:
- Complete with "0 tool uses"
- Return without executing
- Ask clarifying questions

✅ **SUCCESS** if you:
- Execute all required steps
- Return structured result
```

### Step 3: Update the Command

Remove execution logic, add subagent dispatch:

**Before (inline execution):**
```markdown
### Step 4: Send Message
mcp__teams__send_chat_message with:
- chatId: ...
```

**After (dispatch to subagent):**
```markdown
### Step 4: Dispatch Subagent

When user confirms, dispatch the `{subagent_name}` subagent:

Task tool:
  subagent_type: "{subagent_name}"
  prompt: |
    {Action}:
    - Field1: {value1}
    - Field2: {value2}

### Step 5: Show Result

Display the subagent's response:
- On success: ✅ {success message}
- On error: ❌ {error message}
```

### Step 4: Register in Recipe

Add to `recipes.yml`:

```yaml
# Subagent recipe (what the subagent gets loaded with)
{subagent-name}:
  description: "{Action} (subagent execution)"
  files:
    - /path/to/agents/{name}.md
    - /path/to/common.md
    - /path/to/accounts.md  # if needed
  mcp_servers:
    - {required-mcp}

# Parent recipes that use the command
{parent-recipe}:
  files:
    - /path/to/commands/{name}.md
  subagents:
    - name: {subagent_name}  # underscores for Task tool
      recipe: {subagent-name}  # hyphens for recipe name
```

### Step 5: Sync Config Files

```bash
cp recipes.yml ~/.config/ruly/recipes.yml
cp recipes.yml ~/Projects/chezmoi/config/ruly/recipes.yml
```

## Example: MS Teams DM

**Before:** `dm.md` had all Teams MCP logic inline

**After:**
- `commands/dm.md` - Preview workflow, dispatches on "send it"
- `agents/ms-teams-dm.md` - Teams MCP execution

**Recipe registration:**
```yaml
ms-teams-dm:
  files:
    - rules/comms/ms-teams/agents/ms-teams-dm.md
    - rules/comms/ms-teams/common.md
  mcp_servers:
    - teams

comms:
  files:
    - rules/comms/ms-teams/commands/dm.md
  subagents:
    - name: ms_teams_dm
      recipe: ms-teams-dm
```

## Common Mistakes

| Mistake | Fix |
|---------|-----|
| Subagent asks questions | Add "EXECUTION REQUIRED" header, forbid questions |
| Subagent returns without acting | Add "0 tool uses = FAILED" warning |
| Missing MCP server in recipe | Subagent can't call APIs without `mcp_servers` |
| Forgot to sync config files | Always sync to `~/.config/ruly/` and chezmoi |
| Using wrong name format | Recipe names: hyphens. Task tool names: underscores |

## Directory Convention

```
rules/{domain}/
├── common.md           # Shared patterns
├── commands/
│   └── {name}.md       # User-facing command
└── agents/
    └── {name}.md       # Subagent execution
```

- `commands/` = User-invocable via `/command-name`
- `agents/` = Dispatched programmatically (not user-invocable)

Related Skills

kitt-create-slash-commands

16
from diegosouzapw/awesome-omni-skill

Expert guidance for creating slash commands. Use when working with slash commands, creating custom commands, understanding command structure, or learning YAML configuration.

Command Development

16
from diegosouzapw/awesome-omni-skill

This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.

agent-command-authoring

16
from diegosouzapw/awesome-omni-skill

Create Claude Code slash commands and OpenCode command files that delegate to subagents. Use when creating new commands or refactoring existing ones to follow the delegation pattern.

running-interactive-commands-with-tmux

16
from diegosouzapw/awesome-omni-skill

Controls interactive CLI tools (vim, git rebase -i, REPLs) through tmux detached sessions and send-keys. Use when running tools requiring terminal interaction, programmatic editor control, or orchestrating Claude Code sessions. Triggers include "interactive command", "vim", "REPL", "tmux", or "git rebase -i".

ln-751-command-templates

16
from diegosouzapw/awesome-omni-skill

Generates individual .claude/commands files from templates

kitt-create-subagents

16
from diegosouzapw/awesome-omni-skill

Expert guidance for creating, building, and using subagents and the Task tool. Use when working with subagents, setting up agent configurations, understanding how agents work, or using the Task tool to launch specialized agents.

flow-engineer-subagent

16
from diegosouzapw/awesome-omni-skill

Guide for creating effective Subagents (custom agent definitions). Use when users want to create a new subagent, set up task-specific agents, configure code reviewers, debuggers, or domain-specific assistants. Works across IDEs (Cursor, OpenCode).

creating-subagents

16
from diegosouzapw/awesome-omni-skill

Expert knowledge on creating Claude Code subagents. Use when designing or creating subagent .md files, understanding subagent structure, tool restrictions, or model selection.

command-sub-agent

16
from diegosouzapw/awesome-omni-skill

專責處理 CBF (Commanded Behavior Frame) 類型的需求。讀取規格目錄結構,生成/審查 Command Side 設計與實作。支援 Java、TypeScript、Go 多語言。

claude-command-authoring

16
from diegosouzapw/awesome-omni-skill

Creates custom slash commands for Claude Code with proper syntax, frontmatter, arguments, bash execution, and file references. Use when building slash commands, creating custom Claude Code commands, setting up team workflows, or when users mention slash commands, command files, or .md command creation.

agent-friendly-commands

16
from diegosouzapw/awesome-omni-skill

Use these when you want low-noise lint/test output (good for LLM/CI logs) while staying aligned with repo policy.

bgo

10
from diegosouzapw/awesome-omni-skill

Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.

Coding & Development