ワンクリックで
extract-test-cases
Extract Test Cases from Policy Documents
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Extract Test Cases from Policy Documents
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Emit Catala
Create Sample Tests
Draft or Update Test Cases
Expand Test Coverage
Generate a Demo App (Catala-Python Backend)
Refine Ruleset Guidance for a Domain
| name | extract-test-cases |
| description | Extract Test Cases from Policy Documents |
Scan policy input documents for concrete numerical examples and write them to extracted-tests.yaml for use by /create-tests and /expand-tests.
/extract-test-cases [<domain>] # auto-detect program or prompt if ambiguous
/extract-test-cases [<domain> <program>] # target a specific <program>.catala_en
If <domain> is not provided, list all $DOMAINS_DIR/*/specs/*.catala_en files and prompt the user to choose.
Read ../../core/output-fencing.md now.
<domain> not found. Run /extract-ruleset <domain> first.
:::
Stop.$DOMAINS_DIR/<domain>/specs/<program>.catala_en missing → Print:
:::error
No Catala source found. Run /extract-ruleset <domain> first.
:::
Stop.$DOMAINS_DIR/<domain>/specs/naming-manifest.yaml missing → Print:
:::error
specs/naming-manifest.yaml not found. Run /extract-ruleset <domain> first.
:::
Stop.input/ has documents? — If $DOMAINS_DIR/<domain>/input/ is empty or absent → Print:
:::error
No input documents found in $DOMAINS_DIR/<domain>/input/. Add policy documents and re-run.
:::
Stop.ls $DOMAINS_DIR/<domain>/policy_facets/extracted-tests.yaml 2>/dev/null
If extracted-tests.yaml already exists:
:::user_input
Found extracted-tests.yaml with N cases (last extracted from M documents). Re-extract from input docs, or keep existing?
Options: [r]e-extract / [k]eep
:::
If [keep], stop.
Read $DOMAINS_DIR/<domain>/specs/<program>.catala_en and $DOMAINS_DIR/<domain>/specs/naming-manifest.yaml and collect:
inputs.<Entity>.<field>, computed.<name>, and outputs.<name> blocks. For type-shaping decisions during value mapping (e.g., should a 2100 be emitted as 2100, $2,100, or an enum constructor?), consult each entry's type: and enum_variants: fields per the U7 type extension.## <Heading> lines paired with *Source: input/policy_docs/<rel>.md — <citation>* italic-prose lines bracket each fenced rule block. Walk the Catala source and collect every *Source: <file> — <citation>* line plus the immediately-preceding ## <Heading>. Build a source citation list of <citation> — <heading> strings (and the corresponding <rel>.md paths) for the matching steps below.For each compressed mirror under $DOMAINS_DIR/<domain>/policy_facets/compressed/ (scanned recursively for *.md), check relevance using the source citation list first, then fall back to vocabulary. Path-relative mirroring: a mirror at policy_facets/compressed/<rel>.md corresponds to source doc input/policy_docs/<rel>.md — record <rel> so it can be reconstituted into the canonical source.file path in the output.
<rel>.md — no terms matching <program> source citations or vocabulary."If policy_facets/compressed/ is absent or empty, fall back to scanning $DOMAINS_DIR/<domain>/input/policy_docs/ directly and read source docs throughout — log: ⚠ Compressed mirrors missing — run /index-inputs <domain> to enable token-efficient reads.
Read content from the caveman-compressed mirror at $DOMAINS_DIR/<domain>/policy_facets/compressed/<rel>.md by default — these mirrors are token-reduced derivatives of the source docs and are sufficient for most example extraction. Only fall back to the source doc at $DOMAINS_DIR/<domain>/input/policy_docs/<rel>.md when the compressed text is ambiguous, unclear, or questionable for the specific example you are trying to extract (e.g., concrete numerical values appear truncated or elided, a referenced table is mentioned but its rows are not reproduced in the mirror, or the calculation walk-through has been compressed past the point of being usable). The compressed mirror is the default; the source read is the escape hatch.
Within each relevant file:
<program> ruleset (i.e., its inputs or conclusions reference the program vocabulary or a cited section). Discard examples that belong to a different program or benefit type.type: and enum_variants: to shape values correctly (e.g., a boolean field accepts true/false; an enum field's value must be one of the declared variant names). If a needed value is missing or unclear in the compressed mirror, re-read the same section from the source doc per the fallback rule above before giving up on the example.computed: field, not a fact input), record it in the notes: YAML key and omit from inputs — do not guess or coerce.expected.* output decision fields (e.g., expected.eligible, expected.reasons, expected.adjusted_income) from the document's stated conclusion, not from running the rules.["extracted"] plus any applicable rule tags (e.g., "allow", "deny", "earned_income").<rel>.md." and continue to the next file.Regardless of which mirror was read, write source.file in the output as the canonical source path under input/policy_docs/<rel>.md (see Output Format below). The compressed mirror is an implementation detail of the read; the canonical citation is always the source doc.
Write to $DOMAINS_DIR/<domain>/policy_facets/extracted-tests.yaml (create the policy_facets/ directory if absent):
:::important Created $DOMAINS_DIR//policy_facets/extracted-tests.yaml :::
Then record the tests-tier manifest so /check-freshness can later detect drift between specs/*.catala_en and the freshly-written extracted-tests.yaml:
xlator record-tier-manifest <domain> --tier tests
If the command exits non-zero, emit :::error with the captured stderr and stop.
Note on the [keep] path: when the analyst chose [keep] at the pre-flight prompt (line 52 above) the skill exits before reaching this output step, and the manifest is not rewritten. This is intentional: the prior manifest reflects the Catala-source SHA at the time extracted-tests.yaml was actually written. If the source has since changed, the subsequent /check-freshness run will correctly report tests tests_stale against that recorded SHA, which is the desired drift signal.
:::detail
extracted_tests:
Rules:
case_id values are ext_001, ext_002, … — assigned sequentially across all input filesshort_description is a concise, unique gist of description (e.g. Approve — earned income within limit). Populate it here when the example's intent is clear; if omitted, /create-tests synthesizes one at copy-in time. Providing it upstream keeps the label tied to the source example.source.file is always relative to repo rootnotes: is optional — include only when unmappable values need recordingpolicy_facets/compressed/<rel>.md first. Only fall back to input/policy_docs/<rel>.md when the compressed text for a specific example is ambiguous, unclear, or questionable (e.g., truncated numerical values, missing table rows, elided calculation steps). Do not pre-emptively read source docs to save a second pass — the mirror is sufficient for the majority of examples.source.file always cites the source doc, not the mirror — write input/policy_docs/<rel>.md in the output regardless of which file was actually read.notes:, not inputs: