agent-command-authoring
Create Claude Code slash commands, OpenCode command files, and Pi prompt templates that delegate to the right subagent or skill. Use when creating new commands or refactoring existing ones to follow platform conventions.
Best use case
agent-command-authoring is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Create Claude Code slash commands, OpenCode command files, and Pi prompt templates that delegate to the right subagent or skill. Use when creating new commands or refactoring existing ones to follow platform conventions.
Teams using agent-command-authoring 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/agent-command-authoring/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How agent-command-authoring Compares
| Feature / Agent | agent-command-authoring | 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?
Create Claude Code slash commands, OpenCode command files, and Pi prompt templates that delegate to the right subagent or skill. Use when creating new commands or refactoring existing ones to follow platform conventions.
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.
Related Guides
SKILL.md Source
# Agent Command Authoring
Create commands for Claude Code, OpenCode, and Pi that are thin wrappers around
reusable agent capabilities.
## When to Use This Skill
Use this skill when:
- Creating a new custom command
- Refactoring an existing command to delegate correctly
- Porting commands between Claude Code, OpenCode, and Pi
- Ensuring consistency between command implementations across agent harnesses
## Platform Model
Different harnesses support different delegation mechanisms:
| Platform | Command location | Preferred delegation |
|----------|------------------|----------------------|
| Claude Code | `.claude/commands/<name>.md` | `Task(subagent-name)` for context-independent tasks; `Skill(skill-name)` for session-context-dependent tasks |
| OpenCode | `.config/opencode/command/<name>.md` | `agent: subagent-name` for context-independent tasks; omit `agent:` and call the skill directly for session-context-dependent tasks |
| Pi | `.pi/prompts/<name>.md` project-local, or `~/.pi/agent/prompts/<name>.md` global | Prompt template that invokes the skill directly |
Pi does **not** have subagents by default, so Pi command templates should not
reference `Task(...)`, `agent:`, or "use the `<name>` subagent". Convert those
to direct skill invocation.
## The Delegation Pattern
For Claude Code and OpenCode, commands should usually be **thin wrappers** that
delegate to subagents, which in turn delegate to skills:
```
command → subagent → skill
```
For Pi, commands are prompt templates and should invoke skills directly:
```
prompt template → skill
```
## Claude Code Command Structure
**Claude Code command** (`.claude/commands/<name>.md`):
```yaml
---
description: Brief description of what the command does
allowed-tools: Task(subagent-name)
---
Use the `<subagent-name>` subagent to accomplish this task.
```
### Frontmatter Fields
| Field | Required | Description |
|-------|----------|-------------|
| `description` | Yes | 1-2 sentence description of what the command does |
| `allowed-tools` | Yes for subagent commands | `Task(subagent-name)` to invoke the subagent |
| `argument-hint` | No | Hint for command arguments (e.g., `[feature_name [subtask_number]]`) |
### `allowed-tools` Format
For commands that delegate to subagents:
- `Task(subagent-name)` - Invoke a subagent
For commands that must run in the current session context:
- `Skill(skill-name)` - Invoke the skill directly
**Example:**
```yaml
allowed-tools: Task(git-committer)
```
## OpenCode Command Structure
**OpenCode command** (`.config/opencode/command/<name>.md`):
```yaml
---
description: Brief description of what the command does
agent: <subagent-name>
---
Use the `<subagent-name>` subagent to accomplish this task.
```
### Frontmatter Fields
| Field | Required | Description |
|-------|----------|-------------|
| `description` | Yes | 1-2 sentence description of what the command does |
| `agent` | Yes for subagent commands | Name of the subagent to invoke |
| `argument-hint` | No | Hint for command arguments |
For session-context-dependent commands, omit `agent:` so the command runs in
the primary agent's context, and invoke the skill directly in the body.
## Pi Prompt Template Structure
**Pi prompt template** (`.pi/prompts/<name>.md` or `~/.pi/agent/prompts/<name>.md`):
```yaml
---
description: Brief description of what the command does
argument-hint: "[optional-args]"
---
Use the `<skill-name>` skill to accomplish this task.
Arguments: $ARGUMENTS
```
### Frontmatter Fields
| Field | Required | Description |
|-------|----------|-------------|
| `description` | No, but recommended | Description shown in `/` autocomplete |
| `argument-hint` | No | Hint shown before the description in autocomplete |
### Pi Rules
- Filename becomes the slash command: `.pi/prompts/review.md` creates `/review`.
- Use `$1`, `$2`, `$@`, or `$ARGUMENTS` for arguments.
- Do not include Claude/OpenCode-only fields: `allowed-tools`, `agent`, `model`,
`mode`, `permission`, or `tools`.
- Do not reference subagents unless a Pi extension/package explicitly provides
them. Prefer direct skill invocation.
- After adding or changing templates in a running Pi session, run `/reload`.
### Common Subagent → Skill Mapping for Pi
When porting existing Claude/OpenCode commands to Pi, map common subagents to
skills:
| Subagent | Pi skill |
|----------|----------|
| `git-committer` | `git-commit` |
| `git-stager` | `git-staging` |
| `code-linter` | `code-linting` |
| `test-runner` | `test-running` |
| `pr-describer` | `describing-prs` |
| `prp-generator` | `prp-generation` |
| `task-generator` | `task-generation` |
## Naming Conventions
Command names should use the **imperative form** of verbs (telling the agent what to do):
- ✅ `commit`, `stage`, `lint`, `test`, `review`, `reflect`
- ❌ `committing`, `git-committer`, `do-linting`
The imperative form gives commands their characteristic feel:
- "commit" = "perform a commit"
- "stage" = "stage changes"
- "test" = "run tests"
## Command Body
The command body should be **5-20 lines maximum** and contain only delegation
and argument-passing instructions.
**Claude/OpenCode subagent command:**
```markdown
Use the `<subagent-name>` subagent to accomplish this task.
```
**Pi prompt template or direct-skill command:**
```markdown
Use the `<skill-name>` skill to accomplish this task.
Arguments: $ARGUMENTS
```
**Do NOT include:**
- Full implementation steps
- Duplicated content between command wrappers
- More than ~20 lines of content
- Platform-specific frontmatter in the wrong platform's command file
## Examples
### Minimal Command (Claude Code)
```yaml
---
description: Create well-formatted commits using conventional commits style
allowed-tools: Task(git-committer)
---
Use the `git-committer` subagent to create a well-formatted commit.
```
### Minimal Command (OpenCode)
```yaml
---
description: Create well-formatted commits using conventional commits style
agent: git-committer
---
Use the `git-committer` subagent to create a well-formatted commit.
```
### Minimal Command (Pi)
```yaml
---
description: Create well-formatted commits using conventional commits style
---
Use the `git-commit` skill to create a well-formatted commit.
```
### Command with Arguments (Claude Code)
```yaml
---
description: Generate a PRP
argument-hint: [feature_name]
allowed-tools: Task(prp-generator)
---
Use the `prp-generator` subagent to create a Product Requirements Prompt.
```
### Command with Arguments (Pi)
```yaml
---
description: Generate a PRP
argument-hint: "[feature_name]"
---
Use the `prp-generation` skill to create a Product Requirements Prompt.
Feature: $ARGUMENTS
```
## Why This Pattern?
1. **Single source of truth**: Skills contain all implementation content
2. **Easier maintenance**: Changes to skills automatically propagate
3. **Platform consistency**: Commands are thin wrappers with platform-specific frontmatter
4. **Token efficiency**: Skills load progressively via progressive disclosure
5. **No duplication**: Implementation lives in one place (the skill)
6. **Isolation where available**: Claude/OpenCode subagents run context-independent tasks in their own context
7. **Pi compatibility**: Pi prompt templates preserve slash-command ergonomics without assuming subagents
## Anti-Pattern to Avoid
**BAD** - Command with full implementation:
```yaml
---
description: Stage changes
allowed-tools: Bash(git add:*)
---
# Staging Changes
Stage relevant changes via `git add`...
1. Run `git status` to check for already staged changes
2. Verify no staged changes exist...
3. Run `git status` again...
4. Carefully review which files are relevant...
5. Stage only the relevant files...
6. Run `git status` again...
```
**BAD for Pi** - Pi template that references a subagent:
```yaml
---
description: Stage changes via git add
---
Use the `git-stager` subagent to stage relevant changes.
```
**GOOD for Pi** - Pi template that invokes the skill directly:
```yaml
---
description: Stage changes via git add
---
Use the `git-staging` skill to stage relevant changes.
```
**BAD for Claude/OpenCode** - Command that delegates directly to skill for a
context-independent task when a subagent exists:
```yaml
---
description: Stage changes via git add
allowed-tools: Skill(git-staging)
---
Use the `git-staging` skill to stage relevant changes.
```
**GOOD for Claude/OpenCode** - Command that delegates to subagent for a
context-independent task:
```yaml
---
description: Stage changes via git add
allowed-tools: Task(git-stager)
---
Use the `git-stager` subagent to stage relevant changes.
```
**EXCEPTION** - Commands that are inherently session-context-dependent (e.g.
"review what I just wrote", "remove duplication I just introduced") should
skip the subagent and invoke the skill directly. Subagents start with a fresh
context and will not know what was recently worked on unless the parent agent
tells them — which defeats the purpose of the command.
```yaml
---
description: Remove code duplication you just introduced
allowed-tools: Skill(code-refactoring-dry)
---
Use the `code-refactoring-dry` skill to remove duplication in the files you
have worked on in this session.
```
In OpenCode, omit the `agent:` field entirely for the same effect. In Pi, all
prompt templates should use this direct skill-invocation style.
## Workflow
1. **Check for existing skill**: Identify the skill the command should use.
2. **For Claude/OpenCode context-independent commands**: Check for an existing
subagent that delegates to that skill:
- Claude Code: `.claude/agents/<name>.md`
- OpenCode: `.config/opencode/agents/<name>.md`
3. **If no subagent exists for Claude/OpenCode**: Ask the user if they want one created.
- If yes, use the `subagent-authoring` skill to create it first.
- If no, create only the Pi template or stop and explain the limitation.
4. Create/refactor Claude Code command with `allowed-tools: Task(subagent-name)`.
5. Create/refactor OpenCode command with `agent: subagent-name`.
6. Create/refactor Pi prompt template with direct skill invocation in `.pi/prompts/<name>.md`.
7. Verify the chains:
- Claude/OpenCode: command → subagent → skill
- Pi: prompt template → skill
## Missing Subagent Handling
Before creating a Claude/OpenCode subagent command, always verify the target
subagent exists:
```bash
# Check Claude Code subagent
ls ~/.claude/agents/<subagent-name>.md
# Check OpenCode subagent
ls ~/.config/opencode/agents/<subagent-name>.md
```
If either file is missing, **ask the user**:
> "The subagent `<subagent-name>` doesn't exist yet. Would you like me to
> create it using the `subagent-authoring` skill before proceeding with
> the Claude/OpenCode command?"
Do NOT create Claude/OpenCode commands that reference non-existent subagents.
This requirement does not apply to Pi prompt templates, which should reference
skills directly.
## Verification
After creating or refactoring commands:
```bash
# YAML/frontmatter sanity check for generated markdown files
python3 - <<'PY'
from pathlib import Path
import yaml
for root in ['.claude/commands', '.config/opencode/command', '.pi/prompts']:
for path in Path(root).glob('*.md'):
text = path.read_text()
if text.startswith('---\n'):
yaml.safe_load(text.split('---', 2)[1])
print('command frontmatter ok')
PY
```
For Pi, also check that templates do not contain Claude/OpenCode-only fields:
```bash
grep -RIn 'allowed-tools\|^agent:\|Task(\|subagent' .pi/prompts || true
```
Run `/reload` in active Pi sessions after changing Pi prompt templates.
## Related Skills
- `subagent-authoring` - For creating Claude/OpenCode subagent definitions that delegate to skills
- `skill-authoring` - For creating skills themselvesRelated Skills
subagent-authoring
Create subagent definitions for Claude Code and OpenCode that delegate to skills. Use when creating new subagents or refactoring existing ones to follow the delegation pattern.
slow-command-running
Pipe long running commands through tee(1) to allow watching output and repeated analyses without rerunning
skill-authoring
Create and maintain Claude Code skills following Anthropic best practices. Use when building new skills, refactoring existing ones, or ensuring skills follow official guidelines for structure, naming, progressive disclosure, and testing.
allow-agent-commands
Add or change allowed commands in AI agent permission configs (OpenCode, Claude Code)
xlsx-to-csv
Convert XLSX spreadsheets (single or multi-sheet) to CSV files you can read and grep. Use whenever you need to process an .xlsx report from Xero, Cryptio, bank exports, or any tool that delivers spreadsheet output.
xero-mcp
Use the Xero MCP server — obtain/refresh OAuth2 bearer tokens, troubleshoot authentication, and pick up other operational notes for working with Xero MCP tools. Use when Xero MCP tools fail with authentication errors, when the bearer token has expired (tokens last ~30 min), before starting any Xero workflow, or for general guidance on Xero MCP usage.
xero-browser
General Xero browser automation notes. Use when automating any Xero page with agent-browser — covers non-standard UI patterns, waiting, and dropdown menus.
test-running
Run tests according to repository guidelines. Use after linting passes, before staging changes.
task-orchestration
Orchestrate the complete development workflow for implementing sub-tasks from a task list. Use for end-to-end feature implementation with quality controls.
task-implementation
Implement a single sub-task from a task list. Use when working on feature development with existing task lists.
task-generation
Generate a detailed task list from a PRP. Use after a PRP is created and ready for implementation planning.
safe-rm
Safely delete files / directories without asking for permission