kergoth/dotfiles/cram

Claude Code and agent skill by kergoth/dotfiles

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Guide for writing, reading, and debugging cram functional tests (.t files). Use this when working with cram test files, creating new .t tests, debugging test failures, understanding cram output diffs, or when you encounter exit code 80 or .err files from test runs. Also use when the user mentions cram, .t files, or transcript-style shell tests.

Install

npx vskill@latest install kergoth/dotfiles/cram

SKILL.md

The same SKILL.md was published earlier as kergoth/dotfiles/cram.

Cram

Cram is a functional testing framework for command-line programs. Tests are .t files that read like shell session transcripts — commands, expected output, and documentation all in one file.

Core Syntax

text
This is a comment — any unindented line is documentation.
$ command to execute
expected output line
output matched as glob (glob)
output matched as regex (re)
line without trailing newline (no-eol)
escaped unprintable chars \x1b[0m (esc)
[1]
$ multiline command \
> continued here with the > prefix
output from the multiline command

Indentation rules:

  • 2-space indent + $ = shell command
  • 2-space indent + > = continuation of previous command (shell PS2 prompt)
  • 2-space indent (no prefix) = expected output
  • No indent = comment/documentation

Exit codes: A non-zero exit code appears as [N] on its own line as the last expected output. Exit code 0 is implicit and never shown.

Output Matching

Cram tries literal match first, then falls back to the annotated mode:

SuffixMeaning
(none)Exact literal match
(re)Perl-compatible regex
(glob)Glob pattern (*, ?; escape with \)
(no-eol)Line has no trailing newline
(esc)Line contains escaped unprintable characters

Combine when needed: a line can end with (re) and use regex to match escaped output, etc.

Skipping Tests

Exit code 80 means "skip this test." Cram marks it with s in output and does not count it as a failure. Use this for conditional tests:

text
$ command -v some-tool > /dev/null 2>&1 || exit 80
$ some-tool --version
some-tool 1.2.3

Exit code 80 skips the entire `.t` file, not just the remaining commands. If you only want to skip part of a test file, split it into separate .t files and put the skip guard in the one that needs it.

Empty test files are also treated as skipped.

Test Environment

Each test runs in a fresh temporary directory. Key variables provided:

VariableValue
$TESTDIRDirectory containing the .t file
$TESTFILEBasename of the current .t file
$TESTSHELLShell path (from --shell)
$CRAMTMPTest runner's temporary directory
$TMPDIRSame temp directory (also $TEMP, $TMP)

Cram resets these environment variables before each test to ensure reproducibility:

VariableReset to
LANG, LC_ALL, LANGUAGEC
TZGMT
COLUMNS80
CDPATH, GREP_OPTIONS(empty)

Use --preserve-env / -E to skip these resets when testing environment-sensitive behavior.

Failure Output

  • Failed tests produce a unified diff showing expected vs actual output
  • A .err file is written alongside the .t file with the actual output
  • Use cram -i (interactive) to merge actual output back into the .t file —

useful for bootstrapping new tests or updating after intentional changes

Bootstrapping expected output: Run the command manually until it produces correct output, then run cram -i yourtest.t. Cram will prompt you to accept the actual output as the new expected output — no manual transcription needed. This is the standard way to create tests for existing working commands.

Common Patterns

Source helpers from test directory
text
$ source "$TESTDIR/helpers.sh"
Normalize variable output
text
$ date +%Y
\d{4} (re)
Match paths across platforms
text
$ echo "$HOME/some/path"
*/some/path (glob)
Guard on tool availability
text
$ command -v jq > /dev/null 2>&1 || exit 80
$ echo '{"a":1}' | jq .a
1

Pitfalls

  • Commands that read stdin (like ssh) can consume the test shell's stdin

and break subsequent commands. Use ssh -n or redirect stdin explicitly.

  • Daemon processes that inherit stdout without closing it will cause cram to

hang waiting for EOF. Redirect daemon output: daemon > /dev/null 2>&1 &

  • zsh and COLUMNS: COLUMNS=80 cannot be reset when using --shell=zsh

because zsh treats it specially.

  • Trailing whitespace in expected output matters — a literal match includes

it. If a diff shows no visible difference, check for trailing spaces.

Further Reference

For the full CLI options, .cramrc configuration, and additional edge cases, read references/cram-reference.md in this skill directory.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
32
Repository forks
1
7-day trend score
17

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 5 Sep 2026, 2 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/kergoth/dotfiles/cram/badge)](https://verified-skill.com/skills/kergoth/dotfiles/cram)

Something wrong with this skill or its page? Tell us.