ワンクリックで
test-generator
Generate working test code from STD YAML — language and framework driven by project config
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Generate working test code from STD YAML — language and framework driven by project config
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Classify PR review comments on STP/STD documents into auto-fixable vs needs-human categories. Maps free-text feedback to QualityFlow domain rules for automated fix routing.
Resolve Jira ID to project configuration and load project context
Generate comprehensive v2.1-ENHANCED STD YAML with pattern metadata, variables, test structure from ALL STP scenarios (single file)
Orchestrate STP → STD pipeline (generates comprehensive STD YAML only)
Generate test stubs with PSE docstrings from STD YAML — language and framework driven by project config
Detect test conventions from a codebase to drive test generation without tier config
| name | test-generator |
| description | Generate working test code from STD YAML — language and framework driven by project config |
| model | claude-opus-4-6 |
Generates working test code from STD YAML specifications. Reads project config to determine which languages and frameworks to target. Not limited to Go and Python — any language declared in config.
Output: Working test files that compile/pass collection for each configured language/framework.
Note: For test stubs (design review), use stub-generator skills instead.
jira_id: Jira ticket ID (e.g., "MYPROJ-12345")Prerequisites:
outputs/std/{JIRA_ID}/{JIRA_ID}_test_description.yaml{project_context.config_dir}/ (tier mode)code_generation_config in STD YAML (auto mode — config_dir may be null)Test files are always written directly into source package directories
with qf_ filename prefix, co-located with production code:
{resolved_package}/qf_{feature}_test.go (Go)
{resolved_package}/qf_test_{feature}.py (Python)
outputs/go-tests/{JIRA_ID}/summary.yaml (metadata only)
outputs/python-tests/{JIRA_ID}/summary.yaml (metadata only)
Per-scenario package resolution: Each test file is placed in the
source package that contains the code it tests. When the STD YAML
provides target_test_directories (plural), use it as the candidate
list. When only target_test_directory (singular) is provided, use it
as the default but still resolve per-scenario if scenarios reference
functions in other packages.
Resolution order for each scenario's target package:
code_under_test or referenced function → find its
package in SOURCE_REPO_PATHimports.project entries) → derive the
filesystem path from the import pathtarget_test_directory from code_generation_config (default)SOURCE_REPO_PATH is unavailable → error: report
"reason": "no-source-repo" and do not generate tests. Never write
tests to outputs/ or qf-tests/ — they won't compile.The qf_ filename prefix makes QF-generated tests discoverable via
find . -name 'qf_*'.
Generate ONE test case per STD scenario with coverage_status: NEW or
PARTIAL_COVERAGE. Skip EXISTING_COVERAGE — emit a reference comment instead.
19 STD scenarios (12 NEW + 1 PARTIAL + 6 EXISTING) → 13 test functions + 6 reference comments
Pattern-based file grouping is allowed, but EVERY non-EXISTING scenario gets a test
For EXISTING_COVERAGE scenarios, emit a comment referencing the existing test:
// Covered by existing test: TestComparePathPresence_AllPresent
// in internal/scaffold/pathpresence_test.go
When coverage_status is absent on a scenario, treat it as NEW (backward compatible).
Tier mode (config_dir is not null):
Scan {project_context.config_dir}/ for YAML files with
enabled: true and a language: field:
for f in {project_context.config_dir}/*.yaml; do
# Skip non-language files (project.yaml, repositories.yaml, etc.)
# A language config has: enabled, language, framework fields
done
Known file names: go.yaml, python.yaml, tier1.yaml, tier2.yaml
Each language config provides:
language — "go", "python", etc.framework — "testing", "ginkgo-v2", "pytest", etc.imports — organized by category (standard, framework, project)build_command — validation commandtest_patterns — naming conventionsAuto mode (config_dir is null):
Read code_generation_config directly from the STD YAML. The STD YAML IS the config
in auto mode — it contains the detected language, framework, imports, and package name
from the test-strategy-resolver.
# From STD YAML code_generation_config:
language: "go"
framework: "testing"
assertion_library: "testify"
package_name: "cli"
imports:
standard: ["context", "testing"]
framework: ["github.com/stretchr/testify/assert"]
project: ["github.com/org/repo/internal/cli"]
No config directory scanning needed — generate for the single detected language.
Load outputs/std/{JIRA_ID}/{JIRA_ID}_test_description.yaml
Extract:
Tier mode: For each enabled language, read patterns from:
{project_context.config_dir}/patterns/{language}_patterns.yamlAuto mode: Skip pattern loading (no pattern library exists for auto-detected
projects). Instead, read existing test files in SOURCE_REPO_PATH to learn
conventions (indentation, assertion style, helper patterns) directly from the repo.
For each resolved target package directory (from target_test_directories
or target_test_directory), scan existing tests when SOURCE_REPO_PATH
is available:
ls $SOURCE_REPO_PATH/{target_test_directory}/*_test.go 2>/dev/null
Read these files to extract:
package declaration (use exactly this — do not guess)Pass this context to the framework-specific generation below.
For each enabled language config, generate test files using the appropriate framework section below.
File naming (all frameworks): Use the qf_ prefix from
code_generation_config.filename_prefix:
qf_{feature}_test.goqf_test_{feature}.pyFile placement (all frameworks):
$SOURCE_REPO_PATH/{resolved_package}/SOURCE_REPO_PATH is unavailable → error, do not generateWhen writing tests co-located with production code, these rules are critical for compilation:
Import production types — NEVER redeclare them. The test is in the same package (or module), so all types are directly importable. Do NOT copy struct definitions, interfaces, or constants into the test file.
Match the existing package declaration exactly. Read the package
line from existing files in target_test_directory — use that, not
what the STD YAML says, if they differ.
Reuse existing test helpers. If the target directory already has
_test.go files with setup functions, fixtures, or utilities, import
and use them instead of reimplementing.
Import from real packages. Use the import paths from
code_generation_config.imports.project to import production types.
These are real Go import paths that resolve within the module.
No type stubs or shims. If you need a type from internal/foo,
import internal/foo — you can, because the test file lives inside
the module tree.
testing (standard library + testify)When framework: "testing" in the language config:
File structure:
//go:build {build_tags}
package {package_name}
import (
"testing"
// standard imports from config
// framework imports from config
// project imports from code_generation_config.imports.project
)
func TestQF_FeatureName(t *testing.T) {
// shared setup — use production constructors/helpers
t.Run("scenario description", func(t *testing.T) {
// test implementation using REAL production types
// use assert.Equal(t, expected, actual)
// use require.NoError(t, err) for fatal checks
})
}
Rules:
test_patterns.function_prefix (default: "Test")test_patterns.subtest_style (default: "t.Run")test_patterns.assertion_style (default: "testify")build_tags array → //go:build tag1 && tag2imports.standard, imports.test_framework, imports.projecttarget_test_directory (preferred)
or default_packageValidation:
t.Run( calls = count of STD scenariosbuild_tags configuredginkgo-v2 (Ginkgo v2 + Gomega)When framework: "ginkgo-v2" in the language config:
File structure:
package {package_name}
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
// other imports from config
)
var _ = Describe("[JIRA-ID] Feature", func() {
Context("scenario group", func() {
It("[test_id:TS-XXX] should do X", func() {
// test implementation using REAL production types
})
})
})
Rules:
Describe/Context/It hierarchy[test_id:TS-XXX] labels in It() descriptionsBeforeEach for shared setupExpect().To() / Expect().NotTo() for assertionsValidation:
It( blocks = count of STD Functional scenarios[test_id:TS-XXX] presentpytestWhen framework: "pytest" in the language config:
File structure:
"""Tests for {feature} — {JIRA_ID}."""
import pytest
# imports from config
class TestFeature:
"""Tests for feature X.
Markers:
- {markers}
Preconditions:
- {preconditions}
"""
def test_scenario_name(self, fixture1, fixture2):
"""Scenario: {description} [TS-XXX]."""
# test implementation
assert result == expected
Rules:
def test_*() naming conventionconftest.py for shared fixtures (if multiple test files)time.sleep() — use polling utilitiesValidation:
def test_* functions = count of STD End-to-End scenariospytest --collect-only passes (if pytest available)If project_context.feature_toggles.test_case_markers is false, omit
external test case management markers from generated test code.
When project_context.repo_rules is available (e.g., AGENTS.md rules),
apply those coding standards to all generated test code. Common rules:
CRITICAL VALIDATION — MANDATORY
After all files generated:
EXISTING_COVERAGENEW/PARTIAL_COVERAGE scenario has a testEXISTING_COVERAGE scenario has a reference commentPurpose: Verify generated tests compile before committing. This catches import errors, undefined types, and package mismatches immediately.
If Go test files were generated and SOURCE_REPO_PATH is available:
cd $SOURCE_REPO_PATH
go test -run='^$' -count=1 ./{target_test_directory}/...
The -run='^$' flag matches no test names, so tests compile but don't
execute. -count=1 prevents caching.
If compilation fails:
code_generation_config.importspackage line doesn't match the directory —
fix to match existing files.invalid extension, report in summaryFor Python test files:
python3 -m py_compile {target_test_directory}/qf_test_{feature}.py
If pytest is available, also run:
pytest --collect-only {target_test_directory}/qf_test_{feature}.py
Skip the compile gate when:
build_command
in config is set to something other than go test)Generate summary per language:
STD not found: Error + suggest running /std-builder first.
No language configs (tier mode): Error + suggest creating language YAML in config.
No code_generation_config (auto mode): Error + STD YAML may not have been generated
with auto mode. Suggest re-running /std-builder.
Pattern not recognized: Warning + fall back to direct STD-to-test generation.
Validation fails: Save to .invalid extension, show errors, continue.
Compile gate fails after retries: Save files with .invalid extension,
report the compilation errors in summary.yaml, continue with any files
that did compile.
End of Test Generator Skill