Skip to content
Back to skills

Writing Commands

ASecurity

How to write Claude Code slash commands — orchestrator pattern, agent dispatch, auto-detection

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 16, 2026
ai-agentstypescriptpythonrustgobashsecurity

Works with

  • claude code

Security analysis

A100/100

Scanned October 16, 2026

npx -y skills add RaNDoM6913/claude-code-superkit --skill writing-commands --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Writing Commands?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Writing Commands
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/random6913-writing-commands-54c9bd08/badge)](https://www.skillsdirectory.com/skills/random6913-writing-commands-54c9bd08)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: writing-commands
description: How to write Claude Code slash commands — orchestrator pattern, agent dispatch, auto-detection
user-invocable: false
---

# Writing Claude Code Commands

## Command File Format

Commands are `.md` files in `.claude/commands/`. Frontmatter:

```yaml
---
description: One-line description (shown in /help)
argument-hint: <what-user-types>
allowed-tools: Bash, Read, Edit, Write, Glob, Grep, Agent
---
```

- `$ARGUMENTS` — replaced with user input after the command name
- `allowed-tools` — limit what the command can do (security principle of least privilege)

## The Orchestrator Pattern

Most powerful commands are **orchestrators** — they coordinate multiple agents through phases:

```
Phase 1: Understand  → read codebase, find patterns
Phase 2: Plan        → output structured checklist
Phase 3: Execute     → create/modify files
Phase 4: Verify      → dispatch health-checker agent
Phase 5: Test        → dispatch test-generator agent
Phase 6: Review      → dispatch reviewer agents (parallel)
Phase 7: Document    → dispatch docs-reviewer agent
Phase 8: Report      → summary table
```

Not every command needs all 8 phases. Simple commands (lint, test) may have 2-3 phases.

## Dispatching Agents from Commands

Use the `Agent` tool to dispatch agents. Key patterns:

**Parallel dispatch** (independent agents):
```
Dispatch ALL triggered agents simultaneously using parallel Agent calls:
- go-reviewer (if .go files changed)
- ts-reviewer (if .ts/.tsx files changed)
- security-scanner (always)
```

**Sequential dispatch** (dependent results):
```
1. First dispatch health-checker → get results
2. If health check passes → dispatch test-generator
3. If tests pass → dispatch reviewer agents
```

## Auto-Detection Pattern

For multi-stack projects, detect the stack from project files:

```
Auto-detection:
  go.mod exists?          → Go project
  package.json + tsconfig → TypeScript project
  pyproject.toml          → Python project
  Cargo.toml              → Rust project
```

This allows commands to work in any project without hardcoded paths.

## Input Parsing

Parse `$ARGUMENTS` to support multiple modes:

```markdown
## Mode Selection

Parse `$ARGUMENTS`:
- If empty → default behavior
- If matches known keyword → specific mode
- If matches branch name → use as base
- If matches PR#NNN → fetch PR diff
```

## Example: Minimal Command

```markdown
---
description: Run project linters
argument-hint: "[--fix]"
allowed-tools: Bash, Glob
---

# Lint

$ARGUMENTS

## Auto-detect and run

1. Check for `go.mod` → run `gofmt -l . && go vet ./...`
2. Check for `tsconfig.json` → run `npx tsc --noEmit && npx eslint .`
3. If `$ARGUMENTS` contains `--fix` → add auto-fix flags

## Report

List files with issues. If clean: "All files pass linting."
```

## Tips

- Always include `$ARGUMENTS` in the document so user input is accessible
- Reference agents by their exact name (matches `.claude/agents/` filename without .md)
- Keep commands focused — one primary purpose per command
- For complex workflows, break into phases with clear names

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.