claude-code-mcp
0/15 complete

Module 2: CLI Workflows · 20 min

Slash Commands and Custom Workflows

// sabak

Turn this lesson into one checked practice output

By the end, you should be able to explain the core idea behind “Slash Commands and Custom Workflows” in your own words, apply it to one small real or sample task, and identify what still needs human review.

  1. 1

    Learn

    Read the 20-minute lesson without copying an output blindly.

  2. 2

    Try

    Use a small, non-sensitive example that you can inspect line by line.

  3. 3

    Review

    Check facts, fit, and risk; save one improvement note for next time.

Reusable Claude Code workflows should encode a bounded procedure, inputs, checks, and stop conditions. Product terminology evolves—current documentation may present built-in commands, skills, or prompt workflows differently—so verify the live extension guide before creating files.

Choose a Repeatable Job

A good workflow is invoked often and has stable evidence, such as reviewing an API change, preparing a release note, or running a lesson-quality check. Define:

purpose and user
required arguments
allowed files/tools
ordered checks
output artifact
failure and escalation behavior

Do not hide deployment, deletion, payment, messaging, or credential rotation behind a casual command. Keep consequential operations in separately authenticated systems.

Design the Prompt as an Interface

Validate missing or ambiguous inputs. Tell the workflow to inspect current facts, not rely on remembered file structure. Require citations to file paths or test output. Bound the deliverable and forbid unrelated edits.

Example review contract:

Input: target branch or diff
Read: changed source, tests, relevant project rules
Check: correctness, security, regressions, missing tests
Output: findings ordered by severity with file references
Do not: edit, commit, push, or publish
Stop: target unavailable or generated diff is too large

Worked Example

A Lahore agency creates a review-api-change workflow. It accepts a diff reference, loads API-specific rules, runs no mutation, and returns only evidence-backed findings. The team tests it against one known vulnerable sample and one clean sample.

A separate apply-review-fix task is not automatically chained. A human decides which finding is valid and opens a bounded implementation session.

Store the tested workflow beside its fixtures so later revisions can be compared against the same expected evidence and failure behavior.

Failure Cases to Diagnose

  • Command is a giant universal prompt: split by job.
  • Arguments inserted into shell text: validate and pass safely.
  • Workflow edits while reviewing: separate read and write roles.
  • Current repository ignored: inspect before action.
  • No version or owner: document maintenance.
  • Success means polished prose: define evidence and checks.

🇵🇰 Pakistan Angle

Create workflows for reproducible client deliverables: website QA, quotation validation, localization review, or safe content checks. Do not encode unverifiable claims about Pakistani pricing, laws, or market behavior; require dated authoritative sources.

When selling a workflow, disclose its tool/data access and verification duties. The client is buying a controlled process, not guaranteed AI accuracy.

Hands-On Exercise

  1. Select one stable repeated job.
  2. Define inputs, permissions, steps, output, and stops.
  3. Implement using the current official extension mechanism.
  4. Test known-pass, known-fail, missing-input, and adversarial-input cases.
  5. Document owner and version.

Completion Rubric

  • Workflow has one bounded purpose.
  • Inputs are validated.
  • Review and mutation are separated.
  • Output requires evidence.
  • Failure/stop behavior is explicit.
  • Tests and maintenance owner exist.

Sources

Key takeaway: package repeatable reasoning as a small tested interface with validated inputs and evidence—not as an opaque command that silently gains authority.

Self-check

Before you mark Lesson 2.1 complete

  • Can I explain “Slash Commands and Custom Workflows” without reading the lesson back word for word?
  • Did I complete the lesson’s practice step on a real or clearly labelled sample task?
  • Did I check the result for invented facts, private data, unsafe actions, and mismatch with the brief?