From test-plan
Generate one complete test file with all functions for assigned test cases, including quality scoring and auto-revision
npx claudepluginhub opendatahub-io/skills-registry --plugin test-planThis skill uses the workspace's default tool permissions.
Generate a complete test file for test cases assigned to one file from the file_mapping.
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
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.
Parent passes all data via Agent prompt as 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": [...],
"code_repo_path": "/path/to/repo",
"feature_dir": "/path/to/feature"
}
Parse this JSON from prompt to extract all needed variables.
Extract JSON data block from the Agent prompt. Parse to get:
file_index - Index for temp file namingfile_path - Target file path in code 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 preconditionscode_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: <code_repo_path>/<file_path>
If file exists, list existing functions:
(cd $(git -C ${CLAUDE_SKILL_DIR} rev-parse --show-toplevel) && 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-API-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:
Function Signature:
Docstring:
{tc_id}: {objective}TC-API-001: Verify metadata returned correctlyImplementation (AAA pattern):
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.
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
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 $(git -C ${CLAUDE_SKILL_DIR} rev-parse --show-toplevel) && 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