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"
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
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/command-to-subagent/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How command-to-subagent Compares
| Feature / Agent | command-to-subagent | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/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
Expert guidance for creating slash commands. Use when working with slash commands, creating custom commands, understanding command structure, or learning YAML configuration.
Command Development
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
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
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
Generates individual .claude/commands files from templates
kitt-create-subagents
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
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
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
專責處理 CBF (Commanded Behavior Frame) 類型的需求。讀取規格目錄結構,生成/審查 Command Side 設計與實作。支援 Java、TypeScript、Go 多語言。
claude-command-authoring
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
Use these when you want low-noise lint/test output (good for LLM/CI logs) while staying aligned with repo policy.
bgo
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.