Skill leaves become folders (skill.py, skill.test.py, contract.json, mock_data.json, config.json); clean switch, old single-file layout ignored. SKILL.md owns the runner-data doctrine (no mock data); TESTGEN.md owns mocking/testing. Async authoring pipeline: codegen body -> decoupled contract gen -> shared-context testgen -> subprocess auto-run test with a 4-option SemIf regen ladder (trace-only). Opt-in requirements elicitation (REPL asker) with anti-pattern guardrails. Config search auto-populates skill config via SemIf (global -> category); runner resolves tiers into ctx.config and pauses pre-predict for unresolved contract vars with record/ask-again choices.
4.0 KiB
TESTGEN.md — the contract for skill test artifacts
This file is the authoritative spec for the testing/mocking side of a
skill. It is fed verbatim (alongside the finished skill.py) to the model that
produces the test artifacts. The runnable body contract lives in SKILL.md;
this file is deliberately separate so the body writer never embeds mock data
and the test writer never worries about body semantics.
A finished skill leaf is a folder
data/skills/<category>/<name>/ containing (among others) three artifacts
produced here:
| File | Meaning |
|---|---|
contract.json |
The skill's data contract: what the runner must provide. |
mock_data.json |
Fixture data the auto-run test exercises the skill against. |
skill.test.py |
A stdlib-only test, runnable as python skill.test.py. |
contract.json
A single JSON object. Each key is the name of a variable the skill needs; each value is a plain-language, semantic description of the expected values for that variable (what it is, what good values look like).
This contract exists for exactly two consumers:
- User input — the config step asks the human for these variables when they are not already configured.
- SemIf — the config search and the record-vs-ask decision route on the variable names.
Therefore the contract must be flat and semantic. Do NOT put type declarations,
validation logic, or nested data structures in it — the skill body and the test
implement whatever type safety and validation they need on their own. The test
writer consumes skill.py in context and keeps the artifacts compatible, so
the contract never has to carry that burden. Convoluted structure here is
pointless: it only confuses the human and the decision model.
Rules:
- Top level is exactly one JSON object; no arrays, no nesting.
- Each key is the snake_case name of a variable the body reads from
ctx.config. - Each value is a non-empty string describing the expected values in plain
language (e.g.
"The email address the message is sent from."). - Derive the keys by reading the finished
skill.py: everyctx.config[...]access that carries operational data is a contract key. Do not invent keys the body does not use. - Do not include keys for purely internal/derived values.
mock_data.json
Fixture data that satisfies the contract and lets the test exercise the skill
end to end. Any JSON value (object, array, scalar). It is written next to
skill.test.py and loaded relative to the script's working directory.
skill.test.py
A stdlib-only Python script that:
- Runs as
python skill.test.pyfrom the skill folder (its cwd is the folder, somock_data.jsonis reachable at./mock_data.json). - Exercises the skill's
predictandactagainstmock_data.json— call them directly with a real-ishActionContext(a fakeengineis acceptable in the test only; the test is the exception to the no-mocking rule). - Exits 0 on success and non-zero on failure (use
assert/sys.exit(1)with a message). No third-party imports, no network, no writes outside the folder. - Covers at least the happy path and one edge case (missing input, unclear request, unreachable target).
Acceptance criteria
The test artifacts are accepted only if:
contract.jsonis a single flat object of snake_case keys to semantic descriptions, and everyctx.config[...]operational access inskill.pyhas a matching key.mock_data.jsonis valid JSON satisfying the contract.skill.test.pyparses as Python, imports only the stdlib and the agent package, and runs to exit 0 when executed againstmock_data.json.
Produce the three artifacts in this order: first contract.json (derived from
skill.py), then skill.test.py + mock_data.json together (derived from the
same skill.py plus the contract, so they stay consistent).