Claude Code & MCP Masterclass
0/15 complete

Module 02 · CLI Workflows

Slash Commands and Custom Workflows

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.

// concept

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:

// prompt — copy me6 lines
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.

// concept

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:

// prompt — copy me6 lines
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

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

Failure Cases to Diagnose

6 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

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

Hands-On Exercise

5 steps

  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

Completion Rubric

6 checks — tick as you verify

0/6

// sources

Sources

// check_yourself

Check yourself

4 questions · answers and options are taken word-for-word from this course

0/4
  1. 1 / 4 · diagnose

    Your work shows this failure mode: “Arguments inserted into shell text.” What does the lesson tell you to do about it?