/test-plan:test-plan-case-implement <FEATURE_SOURCE> [--test-cases TC-ID,TC-ID] [--target-repo PATH]from test-plan
Generate executable test automation code from test case specifications (default target: opendatahub-tests; override with --target-repo). Skips TC-UI-*. Use after test cases are reviewed to create production-ready pytest code that follows repository conventions.
Ships in test-plan. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Generate executable test automation code (pytest, etc.) from TC-*.md test case specification files. Default target: opendatahub-tests E2E repo (override with --target-repo). UI test cases (TC-UI-*) are skipped.
/test-plan-case-implement <FEATURE_SOURCE> [--test-cases TC-NEG-001,TC-NEG-002] [--target-repo ~/Code/opendatahub-tests]
Examples:
/test-plan-case-implement features/notebooks/RHAISTRAT-400-notebook-spawning/test-plan-case-implement https://github.com/opendatahub-io/opendatahub-test-plans/pull/7 (GitHub PR)/test-plan-case-implement test-plan/RHAISTRAT-400 (GitHub branch)/test-plan-case-implement https://github.com/opendatahub-io/opendatahub-test-plans/pull/7 --test-cases TC-NEG-001,TC-NEG-002 (selective)/test-plan-case-implement features/notebooks/RHAISTRAT-400 --target-repo ~/Code/opendatahub-testsNote: After publishing a test plan, artifacts only exist on the PR branch. Pass the PR URL:
/test-plan-publish
/test-plan-case-implement https://github.com/opendatahub-io/opendatahub-test-plans/pull/7
Parse $ARGUMENTS to extract:
features/notebooks/RHAISTRAT-400-notebook-spawninghttps://github.com/org/repo/pull/7https://github.com/org/repo/tree/test-plan/RHAISTRAT-400 or test-plan/RHAISTRAT-400--test-cases (optional): Comma-separated list of test case IDs to implement (e.g., TC-NEG-001,TC-NEG-002,TC-E2E-001)--target-repo (optional): Override target repository (accepts local path or GitHub URL; default: opendatahub-io/opendatahub-tests)If the first argument is missing or starts with --, fail with usage error showing required format and PR/local path examples.
Install the test-plan package (makes all scripts importable):
bash "${CLAUDE_SKILL_DIR}/../../scripts/bootstrap.sh" --layout "${CLAUDE_SKILL_DIR}" || exit 1
(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && uv sync --extra dev)
If installation fails, inform the user and do NOT proceed.
Parse the first argument from $ARGUMENTS (strip any leading/trailing whitespace, ignore flags).
If no feature source provided or first arg starts with --, exit with the error message from the "From arguments" section above.
If feature source is a GitHub branch or PR URL:
(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && uv run python scripts/repo.py locate-feature-dir "<feature_source>")
Extract feature_dir from the JSON result.
If feature source is a local path, use it directly as feature_dir.
Run unified preflight validation and detection:
(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && uv run python scripts/preflight.py "$feature_dir")
The script returns JSON with:
valid (bool) - If false, show error and stopfeature_dir, tc_count, testplan_frontmatterfrontmatter_components, content_components, all_componentsrepos (component → repo mapping)unique_repos (list of detected repositories)repos_from_frontmatter (repos from Jira components - highest priority)odh_test_context_path (or null if not found)Extract values from the JSON result for subsequent steps.
Parse --test-cases and filter TCs from live files (no cache) before loading
context, conventions, or pattern guides — so an all-implemented / all-UI run exits
without that work:
skill_root=$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)
# Extract --test-cases value (returns space-separated TC IDs or empty string)
tc_arg=$(cd "$skill_root" && uv run python scripts/parse_skill_args.py --test-cases "$ARGUMENTS")
filter_json=$(cd "$skill_root" && uv run python scripts/get_filtered_tcs.py "$feature_dir" "$tc_arg")
On success this prints
{"be_test_cases": [...], "ui_test_cases": [...], "already_implemented": [...], "next": "proceed"|"prompt_user"}.
Never inspect environment variables or run check-interactive yourself.
next is proceed: skip the question. Leave those TCs in already_implemented.next is prompt_user: present the menu below.Interactive re-implement menu (only when next is prompt_user):
Ask one AskUserQuestion whose options are the already_implemented IDs (multi-select):
{N} test case(s) already implemented. Which should be re-implemented?
If the user selects any IDs, re-run with --reimplement-ids (folds those TCs back into
be_test_cases / ui_test_cases by category). Empty selection = re-implement none:
filter_json=$(cd "$skill_root" && uv run python scripts/get_filtered_tcs.py \
"$feature_dir" --reimplement-ids "$selected_ids" "$tc_arg")
Follow next from the new JSON (it will be proceed).
If that leaves be_test_cases empty, inform the user and exit (same empty check below).
If ui_test_cases is not empty, tell the user they are skipped:
Skipping {N} UI test case(s): {ui_test_cases}
If be_test_cases is empty, inform the user and exit:
No backend test cases to implement. All are either UI tests or already implemented.
Present summary:
Implementing {N} backend test case(s): {be_test_cases}
Store be_test_cases for subsequent steps.
If odh_test_context_path == "null", ask user via AskUserQuestion:
odh-test-context not found. Provides test conventions for ~162 opendatahub-io repos.
- Specify path to existing clone
- Clone from GitHub to ~/Code/
- Proceed without it (slower, less accurate)
Handle user choice.
Get and validate target repo (parses --target-repo from arguments, defaults to opendatahub-io/opendatahub-tests):
target_repo=$(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && \
uv run python scripts/validate_target_repo.py "$ARGUMENTS")
The script extracts --target-repo value from $ARGUMENTS, validates it, and returns the repo name or path.
If validation fails, the script exits with error.
Find target repo locally:
target_repo_path=$(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && uv run python scripts/repo.py find-target "$target_repo")
If not found (exit code 1), ask user to clone or specify path. Local clone paths from Step 0.4 are accepted as-is.
IMPORTANT: When analyzing target_repo_path: Read code files and use grep/bash. Do NOT import target repo dependencies (not in test-plan venv) or use inspect.signature().
context_json=$(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && \
uv run python scripts/load_test_context.py "$target_repo" "$odh_test_context_path" "$feature_dir")
The script derives target_repo_name from $target_repo (last path segment), loads
<odh_test_context_path>/tests/<target_repo_name>.json, and writes
<feature_dir>/.test_implementation_context.json when context is found.
JSON:
target_repo_name - e.g. opendatahub-testsuse_odh_context - true if context was foundtest_context - context dict (framework, directories, conventions, linting,
agent_readiness, container_recipe) or nullSet test_context and use_odh_context from the JSON. Do not call
load_repo_test_context or python -c.
Get framework from target repository context:
framework=$(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && \
uv run python scripts/get_framework.py "$target_repo" "$odh_test_context_path")
Returns framework name (pytest, unittest, playwright, robot, ginkgo, go-testing, jest, cypress) or "pytest" (default).
Extract conventions from $target_repo (where tests will be written).
If test_context is not None (target repo has odh-test-context):
Extract and format conventions as markdown:
# Extract repo name from org/repo or local path (e.g., opendatahub-io/opendatahub-tests -> opendatahub-tests)
target_repo_name=$(basename "${target_repo%/}")
(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && uv run python scripts/extract_and_format_conventions.py "$feature_dir" "$target_repo_name" "$odh_test_context_path") > "$feature_dir/.test_implementation_conventions.md"
The script:
.test_implementation_context.json to feature_dirSet conventions_file = <feature_dir>/.test_implementation_conventions.md
If test_context is None (target repo not in odh-test-context):
tests/<target_repo>.json with discovered framework, test directories, conventions, linting toolstests/ directory as examplesStore: conventions (dict or markdown content, or None if not available)
Load repo instructions and pattern guides from TARGET repository (where tests will be written):
(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && uv run python scripts/load_pattern_guides.py "$target_repo_path" "$framework")
Returns JSON with:
repo_instructions_files - Found CLAUDE.md, AGENTS.md, CONSTITUTION.mdrepo_instructions_content - Combined contentpattern_guide_files - Found {framework}-tests.md, testing-standards.mdpattern_guide_content - Combined contentneeds_generation - true if no pattern guides foundIf needs_generation == true:
(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && uv run python scripts/repo.py find-known tiger-team)
/test-rules-generator <target_repo_path> to generate guides for the target repositoryPattern guides describe HOW to write tests in the target repository (fixtures, naming, mocking, file organization). Passed to code generation sub-agents in Step 4.
If use_odh_context == True AND test_context contains container_recipe:
Show user the container validation option via AskUserQuestion:
Container validation is available using odh-test-context.
- Base image: <container_recipe.base_image>
- Can validate linting and test execution in isolated environment
Validate generated tests in container after creation? [yes/no]
If yes: Set validate_in_container = True and store validation_recipe = test_context['container_recipe']
If no: Set validate_in_container = False
If container recipe NOT available:
validate_in_container = FalseUse be_test_cases from Step 0.2b. Parse those files into structured data:
(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && \
uv run python scripts/parse_test_cases.py "$feature_dir" ${be_test_cases[@]})
Returns JSON array of TC dicts, each containing:
This test_cases array will be passed to the sub-agent in Step 4.
CRITICAL: Call map_test_files.py script - do NOT manually create mappings or read existing test files.
Map all TestPlan.md frontmatter components to a test directory in the target repo:
test_dir=$(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && \
uv run python scripts/get_component_test_dir.py "$feature_dir" "$target_repo_path")
tests/ai_hub)tests/ai_safety) — does not enter child packagestestsThen look for or create a package named after TestPlan.md feature under that directory:
test_dir=$(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && \
uv run python scripts/ensure_feature_test_dir.py "$feature_dir" "$target_repo_path" "$test_dir")
feature_name=$(basename "$test_dir")
{component_dir}/{feature} → use it__init__.py when the parent is a Python package)feature_name is the last path segment (used in Step 3.3 file names)Determine file organization strategy from conventions:
by-category (flat: test_{category}_{feature}.py under test_dir)e2e, neg, nfr, ui) are never directoriesby-category-with-subdirs is an alias of by-categorySet strategy variable based on determination above.
Call the script to generate file mapping:
(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && uv run python scripts/map_test_files.py \
"$feature_dir" "$strategy" "$test_dir" \
--feature-name "$feature_name" \
--tc-ids "$(echo ${be_test_cases[@]} | tr ' ' ',')")
Parse the JSON output to extract:
file_mapping - Array of {file_path, test_cases[], function_names[]}strategy, total_test_cases, total_filesThe script handles:
status: Automated, automation_status: Complete, and a
non-empty automation_file keep that path (rewrite the existing file; keep
automation_function when set)e2e/ / neg/ folders)DO NOT manually create /tmp/*.json files, read existing test files, or generate file paths yourself. Use the script output directly.
Present the mapping table to user.
CRITICAL: Invoke /test-plan-generate-test-file sub-agents in parallel (one per file) - do NOT generate code yourself.
Identify common setup requirements across the TCs being implemented:
(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && \
uv run python scripts/analyze_common_setup.py "$feature_dir" ${be_test_cases[@]})
Returns JSON array of preconditions used by 2+ TCs (for fixture generation).
Ensure these variables are in context (sub-agents inherit them):
file_mapping - Array from Step 3test_cases - Array from Step 2framework - From Step 1.1conventions_file - Path to conventions (from Step 1.2)pattern_guide - Content from Step 1.2b (or null)repo_instructions - Content from Step 1.2b (or null)common_setup_requirements - From analyze_common_setup.py abovetarget_repo_path - Repository path (from Step 0.5)feature_dir - Feature directory pathInvoke sub-agents in parallel using Skill tool (one per file in file_mapping):
For each file index i, build a dict and serialize it with json.dumps (do not interpolate
pattern_guide or repo_instructions into a JSON string by hand — they contain quotes and newlines):
payload = {
"file_index": i,
"file_path": file_mapping[i]["file_path"],
"test_cases": tcs_for_this_file, # list of TC dicts
"function_names": file_mapping[i]["function_names"],
"framework": framework,
"conventions_file": conventions_file,
"pattern_guide": pattern_guide, # raw string or None
"repo_instructions": repo_instructions, # raw string or None
"common_setup_requirements": common_setup_requirements,
"target_repo_path": target_repo_path,
"feature_dir": feature_dir,
}
Skill(skill="test-plan:test-plan-generate-test-file", args=json.dumps(payload))
All invocations in one message for parallel execution. Sub-agents have context: fork (isolated, returns clean).
Sub-agents write results to /tmp/test_plan_results/file_{i}.json.
Read result files after all agents complete:
for i in $(seq 0 $((${#file_mapping[@]} - 1))); do
result=$(cat /tmp/test_plan_results/file_${i}.json)
# Parse: file_path, content, tc_ids, functions[], quality_summary, draft_files[], errors[]
done
rm -rf /tmp/test_plan_results/
Collect into files_to_write array. Proceed immediately to Step 5.
CRITICAL: Write the files from files_to_write array. Do NOT generate or modify test code - just write what the sub-agents returned.
For each entry in files_to_write:
mkdir -p <dirname>python -m py_compile <file_path>For each written file:
cd <target_repo_path>
python -c "import sys; sys.path.insert(0, '.'); exec(open('<file_path>').read())"
If validate_in_container == True:
Start container:
podman run -d --name test-context-<repo_name>-validation \
-v <target_repo_path>:/app:Z \
-w /app \
<validation_recipe.base_image> \
sleep infinity
Install system dependencies:
podman exec test-context-<repo_name>-validation bash -c \
"apt-get update && apt-get install -y <system_deps>"
Run setup commands from validation_recipe.setup_commands
Run lint on generated files: Report lint results (pass/fail)
Run tests on generated files: For each generated test file, run pytest and report results
Cleanup container:
podman rm -f test-context-<repo_name>-validation
Present validation summary to user.
"Collects cleanly + scores well" is NOT proof the feature is exercised. Most severe generation defects (an unverified activation gate leaving the feature inactive, false-green assertions) are invisible at generation/collection time and only surface when run against a live cluster.
Prompt the user via AskUserQuestion (modeled on the container-validation prompt in Step 1.3):
These tests have not been run against a live cluster. Generation cannot prove the feature-under-test is actually active — e.g. an activation gate assumed from a credential name may leave it inactive, so every test passes while exercising nothing.
Run/verify the generated tests against a live (or as-close-as-possible) cluster now? [yes/no]
/test-plan-ui-verify. Otherwise guide
them to run the generated files against a live cluster (the repo's normal pytest invocation with
live credentials/kubeconfig) and confirm the feature-under-test is actually active before trusting
results.Record a live-validation status per affected TC — a yes answer alone is NOT proof it ran,
passed, or covered every case. Derive each TC's status from the live verifier result or test exit
status, defaulting to not_run without concrete evidence, and carry it into Step 6.2:
not_run — declined or never executed for this TCblocked — could not run (missing cluster/credentials, collection error, activation gate unconfirmed)failed — ran and failed, or the feature-under-test was confirmed inactivepassed — ran against the live cluster and passed with the feature confirmed activeBuild updates array from sub-agent results (ONLY for successfully implemented TCs):
For each sub-agent result:
functions array (these scored 4+): Create update entrydraft_files (scored 0-3, need manual review)errors (generation failed)Update frontmatter in bulk:
# updates.json: [{"tc_id": "TC-NEG-001", "status": "Automated", "automation_status": "Complete", "automation_file": "...", "automation_function": "..."}]
echo "$updates_json" | (cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && uv run python scripts/update_tc_frontmatter.py "$feature_dir" -)
Returns JSON with updated_count, updated_tcs, errors. Show any errors to user.
If feature source is a GitHub branch, stage, commit, and push updated TC files:
feature_name=$(basename "$feature_dir")
repo_root=$(git -C "$feature_dir" rev-parse --show-toplevel)
if ! publish_result=$(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && uv run python scripts/repo.py publish-artifacts "$repo_root" "$feature_name" "test-plan(<source_key>): mark TCs as implemented"); then
echo "ERROR: publish-artifacts failed"; exit 1
fi
git push origin <branch_name>
Aggregate quality data from all sub-agent results:
Display implementation summary:
not_run/blocked/failed/passed. Only
passed counts as verified coverage; report not_run for any TC lacking concrete evidence and
never mark a TC validated on a yes answer alone.$ARGUMENTS
What SKILL.md sets; muted values are Claude Code's defaults
claude-opus-4-6Other plugins' skills for the same job
16 skills in this plugin
/test-plan-analyze-endpointsAnalyzes strategy, optional ADR, and optional design spec to extract feature scope, AC-traced test objectives, and interfaces under test. Use for extracting technical scope and e2e/UI test surface from requirements documents./test-plan-analyze-infraAnalyzes strategy, optional ADR, and optional design spec to identify test environment configuration, test data, test users, infrastructure, and tooling requirements. Use for determining test execution prerequisites and infrastructure setup needs./test-plan-analyze-risksAnalyzes strategy, optional ADR, and optional design spec to determine test levels, test types, priority definitions, non-functional requirements, and risks with mitigations. Use for identifying what needs testing, how to prioritize test coverage, and what risks to mitigate./test-plan-createGenerate a test plan from a strategy (RHAISTRAT or RHOAIENG), with optional ADR and/or design-spec companions. Use when starting test planning for a new RHOAI feature with a defined Jira strategy./test-plan-create-casesGenerate individual test case files from an existing test plan. Use after plan approval to produce TC specs with preconditions, steps, and expected results by category and priority./test-plan-generate-test-fileGenerate one complete test file with all functions for assigned test cases, including quality scoring and auto-revisiontest-plan@opendatahub-skills is listed by opendatahub-io/skills-registry — review the source before installing
npx claudepluginhub opendatahub-io/skills-registry --plugin test-plan