shellspec

Write and run unit tests for Bash and POSIX shells with ShellSpec.

16|1|Updated Oct 3, 2023
One-click install
npx skills add https://github.com/OleksandrKucherenko/e-bash --skill shellspec
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shellspec
Source: https://github.com/OleksandrKucherenko/e-bash/tree/main/.claude/skills/shellspec
Command: npx skills add https://github.com/OleksandrKucherenko/e-bash --skill shellspec

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve?

ShellSpec provides a complete unit testing framework for Bash and POSIX shells, enabling repeatable, readable tests. It helps teams write, run, and maintain tests, mock dependencies, and integrate testing into CI workflows for shell-based projects.

Core Features & Use Cases

  • Comprehensive unit testing framework for Bash and POSIX shells using ShellSpec with a DSL (Describe/Context/It, When/The).
  • Supports mocking, output capture, test isolation, and cross-shell compatibility.
  • Use cases include validating script logic, debugging failures, refactoring for testability, and setting up test infrastructure.

Quick Start

Install ShellSpec, initialize your project, and write your first spec using Describe and It blocks. Create spec files under spec/ and run tests with shellspec. For debugging, use --xtrace; for coverage, enable kcov with --kcov.

Frequently Asked Questions about shellspec

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

FAQPage Schema
How do I write unit tests for Bash scripts?

Unit testing for Bash scripts involves using a framework like ShellSpec to write repeatable, readable tests. You create spec files under a spec/ directory and use Describe and It blocks to define and validate script logic.

Can I use ShellSpec for cross-shell compatibility testing?

ShellSpec supports cross-shell compatibility testing, allowing you to run unit tests across POSIX shells. It requires no external runtimes beyond Bash and ShellSpec, validating script logic consistently across different environments.

What is the best way to integrate shell testing into CI workflows?

Integrating shell testing into CI workflows is achieved by running ShellSpec tests within your pipeline. ShellSpec provides a complete framework to validate script logic, debug failures, and ensure test infrastructure stability across shell projects.

How do I debug failing unit tests in a POSIX shell?

Debugging failing unit tests in a POSIX shell is done by running ShellSpec with the --xtrace flag. This enables detailed execution tracing to help identify and resolve failures while refactoring scripts for testability.

Does ShellSpec require external dependencies to run?

ShellSpec requires no external runtimes beyond Bash and ShellSpec itself. It provides a complete unit testing framework with mocking and output capture features without needing additional dependencies for shell projects.