Création de commandes d'agent

VérifiéSûr

Créez des commandes slash pour Claude Code et OpenCode qui délèguent à des sous-agents. Utilisez cette compétence pour créer ou refactoriser des commandes suivant le modèle de délégation.

Spar Skills Guide Bot
DeveloppementDébutant
08/03/2026
Claude Code
#slash-commands#subagents#command-authoring#claude-code#delegation

Recommandé pour

Synthèse automatique

Cette compétence explique comment rédiger des commandes slash qui se contentent de déléguer à un sous-agent, pour Claude Code et OpenCode.

Points forts

  • Fournit un modèle de délégation explicite commande → sous-agent → skill, facile à répliquer
  • Donne les champs de frontmatter requis pour Claude Code (allowed-tools, argument-hint) et OpenCode (agent)
  • Impose des conventions de nommage à l'impératif et un corps de commande court (5-20 lignes)
  • Justifie le pattern par la maintenance, la cohérence multi-plateforme et l'économie de tokens

Limites

  • Ne couvre pas OpenCode dans la liste des plateformes cibles de ce catalogue, alors que la compétence le documente
  • Suppose que les sous-agents et skills existent déjà : la compétence ne montre pas comment les créer
  • Le texte est tronqué sur la section anti-pattern, qui reste donc incomplète
Quand l'utiliser

À utiliser lorsqu'on crée une nouvelle commande slash ou qu'on refactorise une commande existante pour qu'elle délègue à un sous-agent.

Quand l'éviter

À éviter si l'on cherche à écrire directement la logique d'implémentation dans la commande ou si aucun sous-agent correspondant n'existe encore.

Analyse de sécurité

Sûr
Score qualité88/100

The skill is instructional documentation for creating AI command files. It contains no executable payloads, destructive commands, network calls, or data exfiltration. Bash examples are limited to read-only 'ls' checks for file existence and are presented as guidance, not as commands for the agent to run.

Aucun point d'attention détecté

Comment cette analyse est faite

Exemples

New delegating command
Create a new slash command called `review` that delegates to the code-reviewer subagent, following the delegation pattern.
Refactor an existing command
Refactor my .claude/commands/commit.md so it becomes a thin wrapper around the git-committer subagent instead of containing the full commit instructions.
Add OpenCode equivalent
Create the OpenCode version of my `prp` command that uses the prp-generator agent, matching the Claude Code command.

name: agent-command-authoring description: 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.

Agent Command Authoring

Create commands that delegate to subagents for Claude Code and OpenCode.

When to Use This Skill

Use this skill when:

  • Creating a new custom command
  • Refactoring an existing command to delegate to a subagent
  • Ensuring consistency between Claude Code and OpenCode command implementations

The Delegation Pattern

Commands should be thin wrappers that delegate to subagents (which in turn delegate to skills):

command → subagent → skill

Claude Code command (.claude/commands/<name>.md):

---
description: Brief description of what the command does
allowed-tools: Task(subagent-name)
---

Use the `<subagent-name>` subagent to accomplish this task.

OpenCode command (.config/opencode/command/<name>.md):

---
description: Brief description of what the command does
agent: <subagent-name>
---

Use the `<subagent-name>` subagent to accomplish this task.

Claude Code Command Structure

Frontmatter Fields

| Field | Required | Description | |-------|----------|-------------| | description | Yes | 1-2 sentence description of what the command does | | allowed-tools | Yes | 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

Example:

allowed-tools: Task(git-committer)

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"

OpenCode Command Structure

Frontmatter Fields

| Field | Required | Description | |-------|----------|-------------| | description | Yes | 1-2 sentence description of what the command does | | agent | Yes | Name of the subagent to invoke |

Example:

---
description: Create well-formatted commits using conventional commits style
agent: git-committer
---

Command Body

The command body should be 5-20 lines maximum and contain only:

Use the `<subagent-name>` subagent to accomplish this task.

Do NOT include:

  • Full implementation steps
  • Duplicated content between Claude and OpenCode
  • More than ~20 lines of content

Examples

Minimal Command (Claude Code)

---
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)

---
description: Create well-formatted commits using conventional commits style
agent: git-committer
---

Use the `git-committer` subagent to create a well-formatted commit.

Command with Arguments (Claude Code)

---
description: Generate a PRP
argument-hint: [feature_name]
allowed-tools: Task(prp-generator)
---

Use the `prp-generator` subagent to create a Product Requirements Prompt.

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: Subagents load skills progressively via progressive disclosure
  5. No duplication: Implementation lives in one place (the skill)
  6. Isolation: Subagents run in their own context with appropriate permissions

Anti-Pattern to Avoid

BAD - Command with full implementation:

---
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 - Command that delegates directly to skill (skipping subagent):

---
description: Stage changes via git add
allowed-tools: Skill(git-staging)
---

Use the `git-staging` skill to stage relevant changes.

GOOD - Command that delegates to subagent:

---
description: Stage changes via git add
allowed-tools: Task(git-stager)
---

Use the `git-stager` subagent to stage relevant changes.

Workflow

  1. Check for existing skill: Identify the skill the command should use
  2. Check for existing subagent: Look for a subagent that delegates to that skill
    • Claude Code: .claude/agents/<name>.md
    • OpenCode: .config/opencode/agent/<name>.md
  3. If no subagent exists: Ask the user if they want one created
    • If yes, use the subagent-authoring skill to create it first
    • If no, stop and explain the command cannot be created without a subagent
  4. Create/refactor Claude Code command with allowed-tools: Task(subagent-name)
  5. Create/refactor OpenCode command with agent: subagent-name
  6. Verify the full chain works: command → subagent → skill

Missing Subagent Handling

Before creating a command, always verify the target subagent exists:

# Check Claude Code subagent
ls ~/.claude/agents/<subagent-name>.md

# Check OpenCode subagent
ls ~/.config/opencode/agent/<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 command?"

Do NOT create commands that reference non-existent subagents.

Related Skills

  • subagent-authoring - For creating subagent definitions that delegate to skills
  • skill-authoring - For creating skills themselves

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/agent-command-authoring-mmh8qqsn/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/agent-command-authoring-mmh8qqsn' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/agent-command-authoring-mmh8qqsn/download' --output '.skill-downloads/agent-command-authoring-mmh8qqsn/SKILL.md.part' && mv '.skill-downloads/agent-command-authoring-mmh8qqsn/SKILL.md.part' '.skill-downloads/agent-command-authoring-mmh8qqsn/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/agent-command-authoring-mmh8qqsn/SKILL.md' && test -s '.skill-downloads/agent-command-authoring-mmh8qqsn/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/agent-command-authoring' && cp -R '.skill-downloads/agent-command-authoring-mmh8qqsn' '.claude/skills/agent-command-authoring'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/agent-command-authoring-mmh8qqsn'

openskills read 'agent-command-authoring-mmh8qqsn'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/agent-command-authoring-mmh8qqsn/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires