搜索

PythonReactSEOPDF
GitHub Skill

commands-authoring

Guide to writing slash commands for Claude Code. Use when creating commands that set mode, constraints, or workflows invoked via /command-name.

CaptainCrouton89☆ 24 仓库 Stars3 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Writing Slash Commands

Commands specify constraints and mode, not instructions. Claude already knows how to do most things — commands tell it what to do differently.

Structure

---
description: One-line description (shows in /help)
allowed-tools: Tool(pattern:*), Tool(pattern:*)
argument-hint: [arg1] [arg2]
---

Prompt content. Set role, constraints, then get out of the way.

Features

  • $ARGUMENTS — all args as string, or $1, $2 for positional
  • !`git status` — inline bash execution (output included in context)
  • @path/to/file.ts — file reference (contents included inline)

Bash execution requires matching allowed-tools declarations.

Key Rules

  1. Minimal tokens — every line costs context
  2. Constraints > procedures — say what to do differently, not how
  3. Don't restate knowledge — skip things Claude already knows
  4. Limit allowed-tools — only enable what's needed
  5. One concern — focused commands, not kitchen sinks

Invocation Control

Most commands should be user-only or agent-only — rarely both.

Field Who can invoke Description in context Use when
(default) User + Agent Yes Rare — general-purpose commands
disable-model-invocation: true User only No Actions with side effects (commit, deploy, send)
user-invocable: false Agent only Yes Background knowledge, auto-applied patterns

Default to disable-model-invocation: true for most commands. Agent auto-invocation is a footgun — commands that modify state, run tools, or trigger workflows should require explicit user intent. Reserve agent-invocable commands for read-only reference or context-injection where autonomous discovery is the point.

Other Frontmatter

Field Purpose
model Override model (haiku for cheap, opus for capability)
argument-hint Document expected args for autocomplete

When to Use Commands vs Skills

Commands Skills
Quick, frequently used prompts Complex multi-step workflows
Single .md file Directory with SKILL.md + reference files
User explicitly invokes with / Automatic discovery by context
<200 lines Extensive reference documentation

Anti-Patterns

  • Missing description (won't appear in /help or Skill tool)
  • allowed-tools: Bash(*) (overly permissive)
  • Absolute file paths (use @ references instead)
  • No argument-hint when args are expected
  • Long procedural instructions (use constraints instead)

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-03-11
索引更新时间
2026-03-11
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!