agentleFS
joelbarmettlerUZHjoelbarmettlerUZH/ultrainit.sh/.claude/skills/add-edge-test/SKILL.md

add-edge-test

Skill8 starsChanged 7 months agoApache-2.0View on GitHub

File header: Edge tests document actual behavior (including bugs), not ideal behavior. The pattern from tests/edge/corrupt_state.bats: If you are documenting a known bug, add a comment explaining the bug and why it isn't fixed yet. Edge tests often need specific preconditions. Inject state directly: Because synthesize.sh sets shopt -s nullglob globally at source time (via _common_setup), edge tests can test nullglob interactions: Note: You cannot test non-nullglob behavior in isolation — _common_setup always sources synthesize.sh, which always sets nullglob. For…

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If you are documenting a known bug, add a comment explaining the bug and why it isn't fixed yet.

    line 69

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Before You Start

  • tests/edge/corrupt_state.bats — bug-documenting test pattern (documents known silent failure)
  • tests/edge/special_characters.bats — how to test shell expansion edge cases
  • tests/edge/numeric_edge_cases.bats — bc arithmetic boundary tests
  • tests/helpers/test_helper.bash — _common_setup (all 9 libs sourced, including synthesize.sh's nullglob side effect)

When to Use Edge Tests vs Unit Tests

ScenarioLocation
Testing a known bug (regression)tests/edge/
Testing CLI argument parsingtests/edge/cli_args.bats
Testing budget boundary conditionstests/edge/budget_exhaustion.bats
Testing a lib function's normal behaviortests/unit/
Testing a shell expansion quirktests/edge/

Steps

1. Create the test file

touch tests/edge/<domain>.bats

File header:

#!/usr/bin/env bats
# Edge cases for <domain>: <one-line description of what failure domain this covers>

setup() {
    load '../helpers/test_helper'
    _common_setup
    # Only add mock_claude if testing agent execution paths:
    # load '../helpers/mock_claude'
    # setup_mock_claude
}

teardown() {
    _common_teardown
}

2. Write bug-documenting tests

Edge tests document actual behavior (including bugs), not ideal behavior. The pattern from tests/edge/corrupt_state.bats:

@test "cost files without pipe delimiters are silently treated as zero spend" {
    # Inject malformed cost file (no pipe separators)
    echo "50.00" > "$WORK_DIR/costs/agent.cost"

    run check_budget
    # Documents the bug: malformed files contribute $0, not $50
    assert_success  # budget check passes even though it should detect $50
}

If you are documenting a known bug, add a comment explaining the bug and why it isn't fixed yet.

3. Manual state injection

Edge tests often need specific preconditions. Inject state directly:

@test "bc produces .20 not 0.20 for values under 1" {
    # Set budget so AGENT_BUDGET will be fractional
    TOTAL_BUDGET="1.00"
    _common_setup  # re-source with new budget

    # bc with scale=2: result is '.20' not '0.20'
    local result
    result=$(echo 'scale=2; 1/5' | bc)
    [[ "$result" == ".20" || "$result" == "0.20" ]]
}

4. nullglob side effect tests

Because synthesize.sh sets shopt -s nullglob globally at source time (via _common_setup), edge tests can test nullglob interactions:

@test "empty costs directory does not block budget check" {
    # With nullglob: *.cost matches nothing, expands to empty string
    rm -f "$WORK_DIR/costs"/*.cost
    run check_budget
    assert_success
}

Note: You cannot test non-nullglob behavior in isolation — _common_setup always sources synthesize.sh, which always sets nullglob.

5. Special character edge cases

For shell expansion bugs (see tests/edge/special_characters.bats):

@test "prompts with apostrophes use @file form to avoid expansion" {
    local prompt_file="$TEST_TMPDIR/prompt.txt"
    echo "This project's goal is testing" > "$prompt_file"

    make_claude_envelope '{}' '0.10' > "$MOCK_CLAUDE_RESPONSE"

    run run_agent "test-agent" "@${prompt_file}" \
        "${SCRIPT_DIR}/schemas/identity.json" "Read" "haiku"
    assert_success
}

Verify

make test-edge

Or for a single file:

docker run --rm -v "$(pwd)":/workspace -w /workspace \
    ghcr.io/joelbarmettleruzh/ultrainit-test:latest \
    bats tests/edge/<domain>.bats

Common Mistakes

  1. Testing current (buggy) behavior as if it were correct — the project rule says "write tests to test the actually correct behaviour". For bug-documenting tests, clearly label them as documenting a known bug with a comment, not as asserting the correct behavior.
  2. Forgetting nullglob is always active — synthesize.sh sets shopt -s nullglob at source time. All glob patterns in all tests expand differently than they would in isolation. Tests that rely on a glob pattern returning the literal string when no files match will silently pass for the wrong reason.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.