shell-test-mock-path-pattern

Override PATH to mock external commands and log invocations in shell scripts.

Updated Nov 9, 2025
One-click install
npx skills add https://github.com/manifoldlogic/claude-code-plugins --skill shell-test-mock-path-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shell-test-mock-path-pattern
Source: https://github.com/manifoldlogic/claude-code-plugins/tree/main/plugins/worktree/skills/shell-test-mock-path-pattern
Command: npx skills add https://github.com/manifoldlogic/claude-code-plugins --skill shell-test-mock-path-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill addresses the challenge of testing shell scripts that rely on external commands without the need for those commands to be installed or configured, streamlining the testing process.

Core Features & Use Cases

  • Mocking External Commands: Simulate external command behavior without actual command installation.
  • Path Override and Logging: Override the PATH environment variable to use mock executables and log command invocations for verification.
  • Use Case: Ideal for testing shell scripts that interact with tools like crewchief, gh, or jq, allowing for accurate argument passing and command orchestration verification without real command execution.

Quick Start

Run the following command to test your shell script:

setup() {
    TEST_TMP=$(mktemp -d)
    mkdir -p "$TEST_TMP/mock-bin"
    touch "$TEST_TMP/mock.log"
}

Frequently Asked Questions about shell-test-mock-path-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I mock external commands in shell script tests?

Mock external commands in shell script tests by overriding the PATH environment variable to point to mock executables. This simulates command behavior and logs invocations for verification without requiring actual command installation.

What is the best way to test shell scripts that rely on external commands like gh or jq without installing them?

Testing shell scripts that rely on external commands like gh or jq without installation is best done by simulating their behavior through PATH overrides. This approach intercepts command calls, allowing accurate argument passing and orchestration verification.

Can I verify command arguments passed during shell script testing?

Yes, you can verify command arguments passed during shell script testing by logging command invocations. The mocking mechanism records interactions with simulated external commands, providing a log file for accurate verification of argument passing and orchestration.

Do I need to install external commands to test my shell scripts?

No, you do not need to install external commands to test your shell scripts. The mocking mechanism simulates external command behavior by overriding the PATH, streamlining the testing process without requiring actual command installation or configuration.

How does PATH overriding work for mocking external commands?

PATH overriding for mocking external commands works by redirecting the shell to custom mock executables instead of the real binaries. This environment variable override captures command invocations and logs them for verification during shell script tests.

Are there limitations to simulating external command behavior in shell scripts?

A limitation of simulating external command behavior in shell scripts is that it only mimics command invocation and argument passing via PATH overrides. It does not execute actual command logic, meaning complex command outputs or internal state changes are not simulated.