PTENES
4.3 ~45 min · Intermediate

⌨️ Slash commands and workflows

Create reusable shortcuts and deterministic pipelines that orchestrate multiple agents with a single command.

PIPELINE (sequential) PARALLEL (fan-out) Step 1 research Step 2 writing Step 3 review ~9 min total (3 × 3 min) Trigger /workflow Worker A research Worker B writing Worker C review Result aggregated ~3 min total (parallel) — 3× faster

⌨️ What slash commands are

Slash commands are text shortcuts that expand into full prompts. When you type /review in Claude Code, the harness expands this into a configured code review prompt.

Native commands include /help, /clear, /config, /compact, /doctor. Skills add their own commands, such as /code-review, /security-review, /schedule.

// Most useful native Claude Code commands
/help          → lista todos os comandos disponíveis
/clear         → limpa o histórico da sessão atual
/compact       → comprime o contexto (reduz tokens usados)
/config        → abre configurações interativas
/doctor        → diagnóstico do ambiente
/status        → estado atual do agente

// Skills instaladas adicionam comandos:
/code-review   → revisão de código do diff atual
/security-review → análise de segurança
/schedule      → agendamento de tarefas recorrentes
/loop          → repete comando em intervalo

🛠️ Create Your Own Slash Commands

Custom commands are files .md inside .claude/commands/. The file name (without the extension) becomes the command. The file’s contents are the expanded prompt.

You can use special variables: $ARGUMENTS (arguments passed after the command), $FILE (current file), $SELECTION (selected text).

// .claude/commands/component.md — /component command
Crie um componente React TypeScript chamado $ARGUMENTS.

Requisitos:
- Arquivo em src/components/$ARGUMENTS/$ARGUMENTS.tsx
- Props interface tipada
- Export default
- Storybook em $ARGUMENTS.stories.tsx
- Teste em $ARGUMENTS.test.tsx

Siga os padrões do projeto (verifique componentes existentes).
Use a paleta de cores do design system em src/tokens.

📁 Local scope (.claude/commands/)

Project-specific. Committed to the repository. The whole team has the same commands. Ideal for project standards.

.claude/commands/component.md → /component
.claude/commands/migrate.md → /migrate
.claude/commands/release.md → /release

🌐 Global scope (~/.claude/commands/)

Applies to all projects. Good for personal preferences. Not shared with the team.

~/.claude/commands/standup.md → /standup
~/.claude/commands/summarize.md → /summarize

💡 Naming tips

  • • Short, imperative names: /fix, /test, /deploy
  • • Use kebab-case for multi-word names: /code-review, /add-feature
  • • Document it with a comment at the top of the .md:

🔄 Deterministic workflows

A deterministic workflow is a predefined sequence of steps where each step has deterministic inputs, outputs, and behavior. Running the same workflow with the same inputs always produces the same result.

This contrasts with using the agent freely, where each run can take a different path. Workflows trade flexibility for predictability—essential in CI/CD and critical processes.

Example: release workflow

1

Verify tests

~2 min

Runs the full test suite. If it fails, the workflow stops and notifies you.

2

Version bump

~30s

Increments the version in package.json according to the type (patch/minor/major)

3

Generate CHANGELOG

~1 min

Analyzes commits since the last tag and generates entries in CHANGELOG.md

4

Create a PR and tag

~1 min

Creates a release/vX.Y.Z branch, opens a PR with a changelog, and creates a git tag

🔀 Pipeline vs. Parallel

🔗 Pipeline (Sequential)

Chained steps: A's output is B's input. Use when there is a data dependency between steps.

  • → Easy to debug (error located in the step)
  • → Predictable and auditable
  • → Slower (N steps × time/step)
  • → Example: build → test → publish

⚡ Parallel (fan-out)

Simultaneous steps with no dependencies. Use when the tasks are independent.

  • → Much faster (N steps × time/slowest_step)
  • → Requires a synchronization barrier
  • → Harder to debug (error could be in any worker)
  • → Example: lint + tests + simultaneous analysis
// .claude/commands/release.md — combines pipeline and parallel execution
## Workflow de release — versão $ARGUMENTS

FASE 1 (paralelo): Execute simultaneamente:
  - Verificar testes: npm test
  - Verificar lint: npm run lint
  - Verificar tipos: npm run typecheck

Aguarde todos completarem. Se qualquer um falhar, PARE e reporte.

FASE 2 (pipeline):
  1. Bump version para $ARGUMENTS em package.json
  2. Gere CHANGELOG com commits desde a última tag
  3. Commit: "chore: release $ARGUMENTS"
  4. Crie tag: git tag v$ARGUMENTS
  5. Abra PR com título "Release $ARGUMENTS"

Reporte ao final: versão, commits incluídos, link do PR.

🎯 When to use workflows

✓ Use workflows WHEN

  • ✓ Task is repeated weekly or more often
  • ✓ Involves multiple agents or tools
  • ✓ Needs to be run by other team members
  • ✓ Result must be auditable and reproducible

✗ Don't create a workflow WHEN

  • ✗ It's a one-off or exploratory task
  • ✗ The process is still changing (stabilize it first)
  • ✗ The task is creative and benefits from variation
  • ✗ The cost of maintaining the workflow outweighs the benefit

📊 Frequency rule

If you’re going to do the same task more than 5 times, it's worth creating a slash command. If you're going to do more than 20 times, it’s worth creating a complete workflow with a pipeline and subagents.

🎭 Orchestrate multiple agents

One meta-agent can invoke entire workflows as subtasks. This creates a hierarchy: meta-agent → workflows → subagents. Each level has clearly defined responsibilities.

🏗️ Three-level hierarchy

Level 1: Meta-agent (strategy)
Level 2: Workflows (tactics)
Level 3: Subagents (execution)

📋 Composition principles

  • → Clear interfaces: defined inputs/outputs
  • → Replaceable: each level can be switched
  • → Testable: each workflow can be tested in isolation
  • → Observable: logs propagate through the hierarchy

🎯 Module 4.3 Summary

✓
Slash commands — text shortcuts that expand into full prompts
✓
Custom commands — .md files in .claude/commands/, $ARGUMENTS variables
✓
Deterministic workflows — predefined, idempotent, auditable sequences
✓
Pipeline vs. Parallel — data dependency vs complete independence
✓
When to use — recurring tasks, team use, auditability

Next Module:

4.4 — ⏰ Cron and recurring tasks: agents that never sleep