Skip to content
Back to skills

Write Scrut Tests

ASecurity

Apply scrut test conventions when creating, editing, or reviewing scrut tests in tests/scrut/ for CLIs, zsh plugins, and sourced libraries. To set up scrut, use add-scrut-cli-tests.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 2, 2026
ai-agentsshellbashtesting

Works with

  • cli

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned November 10, 2026

npx -y skills add cboone/agent-harness-plugins --skill write-scrut-tests --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Write Scrut Tests?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Write Scrut Tests
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/cboone-write-scrut-tests/badge)](https://www.skillsdirectory.com/skills/cboone-write-scrut-tests)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: write-scrut-tests
description: >-
  Apply scrut test conventions when creating, editing, or reviewing scrut tests
  in tests/scrut/ for CLIs, zsh plugins, and sourced libraries. To set up scrut,
  use add-scrut-cli-tests.
---

# Scrut Test Style Guide

Apply the scrut test conventions from `./references/SCRUT.md` when creating or editing scrut CLI test files.

## Key Conventions

Read `./references/SCRUT.md` for the complete guide. Summary:

### File Organization

- Place tests in `tests/scrut/` at the repository root
- One file per behavior group (`help.md`, `error-handling.md`, `flag-validation.md`)
- Use `kebab-case.md` file names describing the behavior tested

### Test Structure

- One logical assertion per scrut block for precise failure locations
- Use `>` continuation prefix to split long `&&`-chained commands across lines
- Order blocks: happy path first, then common variations, then edge cases, then errors
- Level-1 heading for the test group, level-2 headings for individual test cases

### Binary Invocation

- Always reference the binary via `"${TOOL_BIN}"` environment variable, never by path
- Use `NO_COLOR=1` for commands that may produce colored output
- Use `$(mktemp -d "${TMPDIR:-/tmp}/scrut.XXXXXX")` for commands that create files

### Assertion Selection

- Exact match (default) for stable, deterministic output like help text
- `(glob)` for dynamic values: versions, timestamps, commit hashes, paths
- `(glob+)` for variable-length sections you want to acknowledge but not pin
- `(regex)` only when glob patterns are insufficient
- Prefer `NO_COLOR=1` over `(escaped)` matching for colored output

### Error Testing

- Always include the expected exit code: `[1]`
- Redirect stderr to stdout: `2>&1`
- Pipe through `head -1` for long error output with usage text
- Use `{output_stream: stderr}` attribute as an alternative to redirection

### Maintainability

- Pin help text and error messages exactly (catches regressions in user-facing text)
- Use glob for values that change between builds (versions, hashes, timestamps)
- Review diffs after `make test-scrut-update` to ensure glob/regex patterns were not replaced with literals

## Zsh Plugin and Library Testing

For testing zsh plugins and sourced library code with scrut, read `./references/zsh-plugin-testing.md`. Key points:

- Use `--shell zsh` flag with `scrut test` and `scrut update`
- Use `source "${TESTDIR}/path/to/file.zsh"` instead of `"${TOOL_BIN}"`
- Each scrut block supports only one `$` line; additional `$` lines are treated as expected output
- Do not set `ERR_EXIT` at file level; use `emulate -LR zsh` with strict options inside functions
- Chain `source` and function calls with `&&` on the same command line

## Pull Request Review

When reviewing a pull request, apply `./references/review-checklist.md`: the rules of this guide that a reviewer can check in a diff, ranked as Important, Nits and Do not flag. The same checklist is installed into repositories for automated reviewers, so update it whenever a rule here changes.

## Validation

After writing or editing scrut tests, run them to verify:

```bash
make test-scrut
```

If snapshots need updating after intentional output changes:

```bash
make test-scrut-update
```

Files in this skill

  • SKILL.md3.1 KB
  • references/SCRUT.md12.7 KB
  • references/review-checklist.md2.7 KB
  • references/zsh-plugin-testing.md3.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.