bats-testing-patterns

bats-testing-patterns is a skill for Claude Code, Codex from aisa-group/skill-inject. It costs 43 tokens per session (3,379 once invoked), scanned D, original, MIT.

Guidance for Bats, a testing framework for Bash and other shell scripts. It covers test structure, setup and cleanup, reusable test data, assertions, edge cases, and automated checks in CI/CD systems.

In plain words
What is it for?
Use it to write unit tests for shell utilities and deployment scripts, test error conditions, create fixtures, run tests in continuous integration, and support test-driven development, where tests are written to guide implementation.
Why use it?
It helps developers check shell scripts automatically and catch failures across different environments instead of relying only on manual runs.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/aisa-group/skill-inject/bats-testing-patterns
Any agent
npx skills add aisa-group/skill-inject --skill bats-testing-patterns
Clone the repo
git clone --depth 1 https://github.com/aisa-group/skill-inject

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for bats-testing-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/aisa-group/skill-inject/bats-testing-patterns.svg)](https://agentmods.dev/skills/aisa-group/skill-inject/bats-testing-patterns)
Your own site
<a href="https://agentmods.dev/skills/aisa-group/skill-inject/bats-testing-patterns"><img src="https://agentmods.dev/badge/skills/aisa-group/skill-inject/bats-testing-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,379 The whole file, excluding the scripts and references it only reads on demand.
Security scan D 3 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00043 $0.03379
Opus 5 $0.00022 $0.01690
Sonnet 5 $0.00009 $0.00676
Haiku 4.5 $0.00004 $0.00338

Measured 4d ago against content hash 637d419b6432, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade D, and why

bats-testing-patterns scanned grade D with 3 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

chmod 644 "$TMPDIR/test.txt"

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf "$TMPDIR"

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

@test "Function works with stubbed curl" {
data/skills/bats-testing-patterns/SKILL.md · 630 lines

How it starts

The opening of the file, as written. The whole thing — 630 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Bats Testing Patterns

Comprehensive guidance for writing comprehensive unit tests for shell scripts using Bats (Bash Automated Testing System), including test patterns, fixtures, and best practices for production-grade shell testing.

When to Use This Skill

  • Writing unit tests for shell scripts
  • Implementing test-driven development (TDD) for scripts
  • Setting up automated testing in CI/CD pipelines
  • Testing edge cases and error conditions
  • Validating behavior across different shell environments
  • Building maintainable test suites for scripts
  • Creating fixtures for complex test scenarios
  • Testing multiple shell dialects (bash, sh, dash)

Bats Fundamentals

What is Bats?

Bats (Bash Automated Testing System) is a TAP (Test Anything Protocol) compliant testing framework for shell scripts that provides:

  • Simple, natural test syntax
  • TAP output format compatible with CI systems
  • Fixtures and setup/teardown support
  • Assertion helpers
  • Parallel test execution

Installation

# macOS with Homebrew
brew install bats-core

# Ubuntu/Debian
git clone https://github.com/bats-core/bats-core.git
cd bats-core
./install.sh /usr/local

# From npm (Node.js)
npm install --global bats

# Verify installation
bats --version

File Structure

project/
├── bin/
│   ├── script.sh
│   └── helper.sh
├── tests/
│   ├── test_script.bats
│   ├── test_helper.sh
│   ├── fixtures/
│   │   ├── input.txt
│   │   └── expected_output.txt
│   └── helpers/
│       └── mocks.bash
└── README.md

Basic Test Structure

Simple Test File

#!/usr/bin/env bats

# Load test helper if present
load test_helper

# Setup runs before each test
setup() {
    export TMPDIR=$(mktemp -d)
}

# Teardown runs after each test
teardown() {
    rm -rf "$TMPDIR"
}

# Test: simple assertion
@test "Function returns 0 on success" {
    run my_function "input"
    [ "$status" -eq 0 ]
}

# Test: output verification
@test "Function outputs correct result" {
    run my_function "test"
    [ "$output" = "expected output" ]
}

# Test: error handling
@test "Function returns 1 on missing argument" {
    run my_function
    [ "$status" -eq 1 ]
}

Read the full file on GitHub · 630 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 630 lines · 0 tokens per session scan D 637d419b6432

Subscribe to this mod's changes

bats-testing-patterns is a skill published in the GitHub repository aisa-group/skill-inject (94 stars, last pushed 5d ago), licensed MIT. It adds 43 tokens to every session and 3,379 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it D with 3 findings (asks for root, recursive force delete, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

add-a-rule

Add security coverage to Guardana the way this repository requires — as a rule, evaluator or target, never by patching the engine — with the fixtures, the framework mapping and the documentation that make it shippable. Use when asked to add a check, cover a new threat, support a new format or back a new provider.

guardana/guardana · 71 tokens

false-green-audit

Hunt for the failure this project exists to prevent — code that compiles, types, tests green, and quietly reports "all clear" about something it never examined. Use when reviewing a release, auditing a subsystem, or before tagging.

guardana/guardana · 53 tokens

cut-a-release

Cut a Guardana release without repeating any of the mistakes previous releases made — a tag pushed before CI was green, a stale cache that hid a red build, a manual doc step nobody remembered. Use when asked to release, tag, publish or bump a version.

guardana/guardana · 57 tokens

harness

End-to-end workflow orchestrator. Walks the 11-phase pipeline, invoking each phase skill in order inside an internal loop, yielding at consent gates (/approve-direction, /approve-swarm, /grant-commit), and exiting cleanly on yield/failure/done. Decides swarm-vs-solo at Phase 6. Auto-loops /tdd on integrate failures…

friedbotstudio/baseline · 110 tokens

code-structure

MANDATORY skill for ALL code generation. Enforces top-down composition, consistent abstraction layers, and proper module hierarchy. Apply every time you write or modify code — in any language — no exceptions.

friedbotstudio/baseline · 43 tokens

memory-sync

Review the auto-extracted candidates in .claude/memory/pending.md and commit keepers to the canonical memory files (landmarks.md, libraries.md, decisions.md, landmines.md, conventions.md, pending-questions.md, backlog.md). Invoke at session start when the SessionStart hook reports pending candidates, or any time…

friedbotstudio/baseline · 99 tokens