No slash command · from test-plan
Generate one complete test file with all functions for assigned test cases, including quality scoring and auto-revision
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.
None: SKILL.md is the whole skill.
Generate a complete test file for test cases assigned to one file from the file_mapping.
Called in parallel by test-plan-case-implement (one sub-agent per file in file_mapping).
IMPORTANT: This sub-agent does NOT write files to their final destination. It:
echo > /tmp/...)Write tool is intentionally excluded from allowedTools. Uses context: fork for clean return.
$ARGUMENTS)Parent passes all data via Skill args as a JSON block:
{
"file_index": 0,
"file_path": "tests/upgrade/test_odh_cli.py",
"test_cases": [
{"test_case_id": "TC-CLI-001", "title": "...", "objective": "...", ...},
{"test_case_id": "TC-CLI-003", ...}
],
"function_names": ["test_tc_cli_001", "test_tc_cli_003_pre_upgrade_readiness"],
"framework": "pytest",
"conventions_file": "/path/to/conventions.md",
"pattern_guide": "...content or null...",
"repo_instructions": "...content or null...",
"common_setup_requirements": [...],
"target_repo_path": "/path/to/repo",
"feature_dir": "/path/to/feature"
}
Parse this JSON from $ARGUMENTS to extract all needed variables.
Before running any test-plan helper, prepare the caller workspace:
bash "${CLAUDE_SKILL_DIR}/../../scripts/bootstrap.sh" --layout "${CLAUDE_SKILL_DIR}" || exit 1
Extract JSON data block from $ARGUMENTS. Parse to get:
file_index - Index for temp file namingfile_path - Target file path in the target repotest_cases - Array of TC objects for this file (already filtered)function_names - Array of function names for TCsframework - Test framework (pytest, go, jest)conventions_file - Path to conventions filepattern_guide - Pattern guide content (or null)repo_instructions - Repo instructions content (or null)common_setup_requirements - Array of shared preconditionstarget_repo_path - Repository pathfeature_dir - Feature directory pathStore test_cases as tcs_for_this_file for use in later steps.
IMPORTANT: When analyzing target repository: Read code files and use grep/bash. Do NOT import target repo dependencies (not in test-plan venv) or use inspect.signature().
Get full file path: <target_repo_path>/<file_path>
If file exists, list existing functions:
(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && uv run python scripts/list_test_functions.py "$full_file_path")
Returns JSON: {"functions": [{"name": "...", "line": 42, "docstring": "..."}]}
Semantic matching: For each TC and expected function name, check if semantic match exists:
If already-implemented tests found, ask user via AskUserQuestion:
✓ Found {N} already-implemented test(s) in {file_path}:
- TC-E2E-001: test_notebook_creation (line 42)
Options:
1. Skip them - Only implement missing tests
2. Re-generate - Overwrite existing functions
3. Review - Show me existing code first
Set mode: "create" (new file), "append" (add to existing), or filter out implemented TCs.
If mode == "create" (new file), generate header with:
common_setup_requirements has items used in this file:
For each TC in tcs_for_this_file (sequential):
Generate function code using TC spec + conventions + patterns with this priority:
Function structure:
Decorators/Markers:
--strict-markers.tier3), not tier1.skip_on_disconnected (or the repo's equivalent).Function Signature:
Docstring:
{tc_id}: {objective}TC-E2E-001: Verify metadata fields match expected schemaImplementation (AAA pattern):
Correctness guardrails (avoid false-green tests):
A test that passes while the feature is absent or broken is worse than no test. Apply these:
run.yaml env var like
ENABLE_GEMINI), not from the credential name (GEMINI_API_KEY). Injecting only the
credential can leave the feature inactive so every test passes while exercising nothing. If the
gate cannot be verified, emit a prominent TODO and a fixture assertion that fails loudly when
the feature is not actually active.pytest.skip.
Something the active feature must provide (a model the active provider should register, the
provider itself) → pytest.fail. Do NOT default every missing precondition to skip — that hides
the exact defects the test exists to catch.float, not numbers.Real, which also accepts int/bool); add finiteness checks
(reject NaN/inf); assert a collection is non-empty before indexing (response.choices[0]);
iterate all candidates (every container/file/match), not just the first.next()/socket read; on timeout, close the
stream and fail the test.shell=False and allowlist the executable and argument choices; never use shell=True,
os.system, or sh -c (CWE-78). Use exact comparison over substring ("SET" in output also
matches "UNSET"); reject unknown enum values explicitly instead of silently falling through to a
default.Collect each generated function in functions array.
complete_file = header + "\n\n".join(functions)complete_file = existing_content + "\n\n".join(functions)cat > /tmp/test_file_${file_index}.py << 'PYEOF'
$complete_file
PYEOF
python -m py_compile /tmp/test_file_${file_index}.py 2>&1
If syntax error: Fix once, retry. If still invalid: save as .draft, skip scoring.
This skill has Bash; test-plan-score-test-function does not. Load calibration here and pass
it via a temp file. Fail closed on nonzero exit. Adding a pair is dropping a file under
skills/test-plan-score-test-function/calibration/core/, calibration/ui/, or a team dir.
repo_root=$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)
team_list=$(cd "$repo_root" && uv run python scripts/get_component_test_dir.py \
--teams-only "$feature_dir") || {
echo "ERROR: scripts/get_component_test_dir.py --teams-only failed — stopping." >&2
echo "$team_list" >&2
exit 1
}
calibration_raw=$(cd "$repo_root" && uv run python scripts/load_calibration.py \
"${CLAUDE_SKILL_DIR}/../test-plan-score-test-function/calibration" \
--framework "$framework" --include-teams="$team_list") || {
echo "ERROR: scripts/load_calibration.py failed — stopping." >&2
echo "$calibration_raw" >&2
exit 1
}
printf '%s\n' "$calibration_raw" | jq -r '.calibration_text' > /tmp/calibration_${file_index}.md
printf '%s\n' "$calibration_raw" | jq -r '.warnings[]?' >&2
For each function, invoke in parallel:
/test-plan-score-test-function \
--test-code-file /tmp/func_${tc_id}.py \
--tc-file <tc_file_path> \
--conventions-file <conventions_file> \
--framework <framework> \
--output-file /tmp/test_scores/${tc_id}_score.md \
--calibration-file /tmp/calibration_${file_index}.md
Parse score, handle verdicts:
MAX REVISIONS: 1 per function
Build metadata JSON and write to persistent location:
# Create results directory
mkdir -p /tmp/test_plan_results
# Build metadata JSON
cat > /tmp/file_metadata_${file_index}.json << EOF
{
"file_index": ${file_index},
"file_path": "${file_path}",
"tc_ids": ${tc_ids_for_file_json},
"functions": ${functions_json},
"quality_summary": ${quality_summary_json},
"draft_files": ${draft_files_json},
"errors": ${errors_json}
}
EOF
# Format and write complete result (reads /tmp/test_file_${file_index}.py, embeds content)
(cd "$(cd -P "${CLAUDE_SKILL_DIR}/../.." && pwd -P)" && uv run python scripts/format_file_result.py /tmp/file_metadata_${file_index}.json) > /tmp/test_plan_results/file_${file_index}.json
# Output tiny confirmation (NOT full JSON - keeps context clean)
echo '{"status": "complete", "file_index": '${file_index}', "result_file": "/tmp/test_plan_results/file_'${file_index}'.json"}'
CRITICAL: Output ONLY the tiny confirmation JSON. Do NOT add:
The parent reads the full result from the file. This keeps the return value small (~100 bytes) and avoids polluting parent context.
Clean up temporary work files (keep result file for parent):
# Remove temp work files (parallel-safe - indexed by file_index and unique tc_ids)
rm -f /tmp/test_file_${file_index}.py
rm -f /tmp/file_metadata_${file_index}.json
# Remove per-TC temp files
for tc_id in ${tc_ids_for_file[@]}; do
rm -f /tmp/func_${tc_id}.py
rm -f /tmp/test_scores/${tc_id}_score.md
rm -f /tmp/test_scores/${tc_id}_score_revised.md
done
# DO NOT remove /tmp/test_plan_results/file_${file_index}.json - parent will read it
Why keep result file: Parent needs to read the full result after all sub-agents complete. Parent will cleanup /tmp/test_plan_results/ after reading all files.
CRITICAL: After Step 7b cleanup completes, this sub-agent is DONE. Do NOT output any additional text, summaries, or explanations. The tiny confirmation JSON from Step 7a is the complete return value. The parent skill will read the full result from the file and proceed automatically.
When making code generation decisions, follow this priority:
odh-test-context and Tiger Team guides are both from the Tiger Team - one analyzes repos, one provides framework patterns.
Philosophy: Partial success > total failure.
$ARGUMENTS
What SKILL.md sets; muted values are Claude Code's defaults
claude-opus-4-6test-plan@opendatahub-skills is listed by opendatahub-io/skills-registry — review the source before installing
npx claudepluginhub opendatahub-io/skills-registry --plugin test-plan16 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-case-implementGenerate 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./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.