一键导入
std-generator
Generate comprehensive v2.1-ENHANCED STD YAML with pattern metadata, variables, test structure from ALL STP scenarios (single file)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate comprehensive v2.1-ENHANCED STD YAML with pattern metadata, variables, test structure from ALL STP scenarios (single file)
用 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
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
Discover code entry points from Jira data when no PR data exists
| name | std-generator |
| description | Generate comprehensive v2.1-ENHANCED STD YAML with pattern metadata, variables, test structure from ALL STP scenarios (single file) |
| model | claude-opus-4-6 |
Transforms all scenarios from a Software Test Plan (STP) into ONE comprehensive v2.1-ENHANCED Software Test Description (STD) YAML file with:
Key Features:
When project_context.repo_rules is available, apply these rules:
From repo_rules.std_format (SOFTWARE_TEST_DESCRIPTION.md):
Preconditions:, Steps:, Expected: (exact section names)[NEGATIVE] indicator for failure scenariosParametrize: section with inline [Markers: ...] syntax__test__ = False placement: class-level for grouped tests, after function for standaloneFrom repo_rules.agents_rules (AGENTS.md):
tier2 is implicit — do NOT emit @pytest.mark.tier2 in STD metadata@pytest.mark.network, etc.pytest.skip/skipif are forbidden@pytest.mark.incremental for dependent tests, not pytest-dependencyFrom repo_rules.testing_tiers (testing-tiers.md):
These rules affect the classification, test_structure, and PSE docstring generation
within each scenario in the STD YAML.
scenarios: Array of ALL scenario rows from STP Section III
scenario_id: Scenario number (e.g., 1, 2, 3)tier: Tier classification (e.g., "Tier 1", "Tier 2")priority: Priority (e.g., "P0", "P1", "P2")description: Scenario description textrequirement_id: Requirement ID (e.g., "PROJ-59657")stp_context: Context from the STP document
jira_issue: Jira ticket ID and metadatafeature_description: Feature overview (from Feature Overview section)related_prs: List of GitHub PRs (from Metadata)api_endpoints: API endpoints (from Section I.3 API Extensions, if applicable)known_limitations: Known limitations (from Section I.2)test_environment: Test environment requirements (from Section II.3)source_constants (optional): Array of literal constants extracted from source code by the STP Builder
Each constant has:
name: Constant identifier (e.g., "SENTINEL", "SCRIPT_PATH")value: Exact value from source code (verbatim, never paraphrased)source_file: File where the constant was foundline: Line number (or — for PR-derived paths)Example:
source_constants:
- name: "SENTINEL"
value: "# --- managed section - do not edit ---"
source_file: "pkg/scripts/sync.sh"
line: 14
stp_file_path: Path to source STP file (e.g., outputs/stp/PROJ-66855/PROJ-66855_test_plan.md)
Single comprehensive STD YAML file:
{JIRA_ID}_test_description.yamlPROJ-66855_test_description.yamloutputs/std/{JIRA_ID}/{JIRA_ID}_test_description.yamlStructure:
---
# Document Metadata (shared)
document_metadata: {...}
common_preconditions: {...}
# Scenarios Array (one entry per STP scenario)
scenarios:
- scenario_001: {...}
- scenario_002: {...}
- scenario_003: {...}
...
---
When generating an STD, read templates from {project_context.config_dir}/templates/std/
if available (provides project-specific values for infrastructure, operators, tools, etc.).
Fall back to the generic skeleton templates in this skill's templates/ directory when
config_dir is null (auto-discovery mode).
Purpose: Shared metadata for the entire test suite
Required fields:
document_metadata:
std_version: "2.1-enhanced"
generated_date: "YYYY-MM-DD"
jira_issue: "{JIRA_ID}"
jira_summary: "{Jira issue summary}"
source_bugs: ["{PROJ-XXXXX}", ...] # If applicable
stp_reference:
file: "outputs/stp/{JIRA_ID}/{JIRA_ID}_test_plan.md"
version: "v1"
sections_covered: "Section III - Requirements-to-Tests Mapping"
# related_prs is internal metadata for code generation context.
# It MUST NOT be propagated to Phase 1 stub module docstrings.
# Stub docstrings contain only STP Reference and Jira ID.
related_prs:
- repo: "{org/repo}"
pr_number: {number}
url: "{PR_URL}"
title: "{PR title}"
merged: true
owning_sig: "{sig-name}"
participating_sigs: ["{sig-1}", "{sig-2}"]
total_scenarios: {count}
tier_1_count: {count} # tier mode only (0 in auto mode)
tier_2_count: {count} # tier mode only (0 in auto mode)
unit_count: {count} # auto mode only (0 in tier mode)
functional_count: {count} # auto mode only (0 in tier mode)
e2e_count: {count} # auto mode only (0 in tier mode)
p0_count: {count}
p1_count: {count}
existing_coverage_count: {count} # scenarios with EXISTING_COVERAGE status
new_count: {count} # scenarios with NEW status
test_strategy_mode: "tier|auto"
Derivation:
Purpose: Code generation configuration for downstream test file generation
Mode-dependent population:
test_strategy: "tier")Read from {project_context.config_dir}/code_generation_config.yaml. This file
contains all project-specific values: framework, imports, context init, timeout
constants, helper library mappings, and inference rules.
test_strategy: "auto" or config_dir: null)Populate from test_strategy output (from test-strategy-resolver skill):
code_generation_config:
std_version: "2.1-enhanced"
framework: "{test_strategy.framework}" # e.g., "testing"
assertion_library: "{test_strategy.assertion_library}" # e.g., "testify"
language: "{test_strategy.language}" # e.g., "go"
package_name: "{test_strategy.package_name}" # e.g., "cli"
# Co-located test placement
target_test_directory: "{resolved_directory}" # e.g., "internal/cli"
filename_prefix: "qf_" # prefix for generated test files
imports:
standard: "{test_strategy.imports.standard}"
framework: "{test_strategy.imports.framework}"
project: "{test_strategy.imports.project}"
# Omit project-specific fields in auto mode:
# context_init, dot_imports, project-specific import groups,
# timeout_constants, helper_library_imports
Resolving target_test_directory (auto mode):
From the PR diff changed_files, identify ALL package directories
where production code was modified (e.g., internal/cli/run.go → internal/cli)
Verify each directory contains existing _test.go files (confirming
tests belong there)
If a single directory dominates the changes, use it as the primary value
If multiple directories changed, set target_test_directory to the
primary directory AND add a target_test_directories list field:
target_test_directory: "internal/cli" # primary (most changes)
target_test_directories: # all candidate packages
- "internal/cli"
- "internal/forge/github"
- "internal/harness"
If no .go files changed (e.g., only shell scripts or docs), derive
from imports.project entries — translate each import path to a
filesystem path relative to the module root (e.g.,
github.com/org/repo/internal/cli → internal/cli)
Never set to null. If nothing resolves from changed files or
imports, scan test scenarios for referenced functions/types and resolve
their packages. As a last resort, use the module root directory.
The test generator uses target_test_directories (plural) when available
to distribute tests per-scenario to the correct package. When only
target_test_directory (singular) is set, it still resolves per-scenario
placement from each scenario's referenced imports.
Skip project-specific fields (context_init, dot_imports, project-specific import groups, timeout constants, helper_library_imports) when in auto mode. These are project-specific and have no meaning for auto-detected projects.
In tier mode, the code_generation_config section is populated from
{project_context.config_dir}/code_generation_config.yaml. The file provides:
code_generation_config:
std_version: "2.1-enhanced"
framework: "{from config}" # e.g., "ginkgo-v2"
assertion_library: "{from config}" # e.g., "gomega"
language: "{from config}" # e.g., "go"
package_name: "{INFER_FROM_SIG}" # resolved via config package_name_rules
target_test_directory: "{INFER_FROM_SIG_AND_COMPONENT}"
filename_prefix: "qf_"
context_init: [...] # from config
imports: # from config (groups vary per project)
dot_imports: [...]
standard: [...]
# Additional project-specific import groups from config
timeout_constants: {...} # from config
helper_library_imports: {...} # from config
Derivation:
owning_sig using package_name_rules in configcomponents.yaml
component_package_map if available, or derive from owning_sig using
target_test_directory_rules in config
config_dir has repositories.yaml with a test_directory field, use thatnull — use owning_sig default as last resort"qf_" (from _defaults.yaml test_file_prefix)code_generation_config.yamlPurpose: Infrastructure and environment requirements shared by ALL scenarios
Required fields:
common_preconditions:
infrastructure:
- name: "{Platform name}"
requirement: "{Platform version from project config}"
validation: "{Platform validation command}"
- name: "{Product name}"
requirement: "{Product version from project config}"
validation: "{Product validation command}"
- name: "{Additional infrastructure}"
requirement: "{From STP Section II.5}"
validation: "{Validation command}"
operators:
- name: "{Operator name}"
namespace: "{namespace}"
validation: "{cli_tool get resource command}"
cluster_configuration:
topology: "{Single-node|Multi-node}"
cpu_virtualization: "{Standard|Nested}"
storage: "{StorageClass requirement}"
network: "{CNI requirement}"
rbac_requirements:
- permission: "{verb} on {resource}"
scope: "{Cluster|Namespace: {namespace}}"
validation: "{cli_tool} auth can-i {verb} {resource}"
Derivation:
Purpose: Array of detailed scenario specifications
Structure: One entry per STP scenario
Required fields for each scenario:
scenarios:
- scenario_id: "{NUM}"
test_id: "TS-{JIRA_ID}-{NUM:03d}"
tier: "{Tier 1|Tier 2}" # tier mode
test_type: "{unit|functional|e2e}" # auto mode (use instead of tier)
priority: "{P0|P1|P2}"
mvp: {true|false}
requirement_id: "{REQUIREMENT_ID}"
# ===== COVERAGE STATUS (from STP deduplication) =====
coverage_status: "{NEW|PARTIAL_COVERAGE|EXISTING_COVERAGE}" # optional, defaults to NEW
covered_by: # present only for EXISTING_COVERAGE or PARTIAL_COVERAGE
- test_function: "{existing test function name}"
test_file: "{path to existing test file}"
behavior_tested: "{brief description}"
# For EXISTING_COVERAGE scenarios: only include scenario_id, test_id,
# requirement_id, coverage_status, and covered_by. Skip all sections
# below (patterns, variables, test_structure, test_steps, assertions).
# ===== PATTERN METADATA (AUTO-GENERATED, tier mode only) =====
patterns:
primary: "{matched_primary_pattern}"
secondary:
- "{matched_setup_pattern_1}"
- "{matched_setup_pattern_2}"
- "{matched_execution_pattern_1}"
helpers_required:
- name: "{helper_library_name}"
functions: ["{function1}", "{function2}"]
purpose: "{what_it_does}"
decorators:
- "{decorator_1}"
- "{decorator_2}"
# ===== VARIABLE DECLARATIONS (AUTO-GENERATED in v2.1) =====
variables:
closure_scope:
- name: "{variable_name}"
type: "{Go_type}"
initialized_in: "{BeforeAll|It}"
used_in: ["{BeforeAll}", "{It}", "{AfterEach}"]
comment: "{Brief description}"
# =========================================================
# ===== TEST STRUCTURE (AUTO-GENERATED in v2.1) =====
test_structure:
type: "{single|table-driven}"
describe:
wrapper: "SIG"
description: "{Feature description}"
decorators:
- "{SIG_decorator}"
- "Serial"
context:
description: "{Scenario description}"
decorators:
- "Ordered"
- "decorators.OncePerOrderedCleanup"
it:
description: "should {test_objective}"
test_id_format: "[test_id:{test_id}]"
# ===================================================
code_structure: |
Context("{scenario_description}", Ordered) {
BeforeAll(func() {
// Setup
})
It("[test_id:{test_id}]should {test_objective}", func() {
// Test
})
}
# =============================================
test_objective:
title: "{scenario.description}"
what: |
{Expand scenario description into 2-3 sentences explaining:
- What functionality is being tested
- What specific aspect/behavior is validated
- What operations are performed}
why: |
{Explain business/technical rationale:
- Why this test is important
- What user need it addresses
- What could break if this fails}
acceptance_criteria:
- "{Criterion 1: clear, measurable condition}"
- "{Criterion 2: ...}"
classification:
test_type: "{Functional|Integration|E2E}"
scope: "{Single-component|Multi-component}"
automation_approach: "{from project config or auto-detected}"
specific_preconditions:
# Scenario-specific requirements (beyond common_preconditions)
- name: "{Specific requirement}"
requirement: "{Details}"
validation: "{Command}"
test_data:
# YAML definitions for this specific scenario
resource_definitions:
- name: "{resource_name}"
type: "{ResourceType — from project's API types}"
yaml: |
{Complete YAML definition}
api_endpoints:
# If applicable
- operation: "{operation_name}"
method: "{GET|POST|PUT|DELETE}"
path: "{API path}"
expected_status: {200|201|etc}
test_steps:
setup:
- step_id: "SETUP-01"
action: "{Setup action}"
command: "{Command or API call}"
validation: "{Expected result}"
pattern_id: "{matched_pattern}" # AUTO-ADDED
code_template: | # AUTO-ADDED
{code from pattern library}
test_execution:
- step_id: "TEST-01"
action: "{Test action}"
command: "{Command or API call}"
validation: "{Expected result}"
pattern_id: "{matched_pattern}" # AUTO-ADDED
code_template: | # AUTO-ADDED
{code from pattern library}
cleanup:
- step_id: "CLEANUP-01"
action: "{Cleanup action}"
command: "{Command}"
assertions:
- assertion_id: "ASSERT-01"
priority: "P0"
description: "{What is being validated}"
condition: "{Expected condition}"
failure_impact: "{What failure means}"
dependencies:
kubernetes_resources:
- "{Resource type}: {name}"
external_tools:
- "{Tool name} {version}+"
scenario_specific_rbac:
- "{permission description}"
Derivation:
test_objective.title: Use scenario.description verbatimtest_objective.what: Expand description with specificstest_objective.why: Infer from STP Section I.1 (Requirement Review)acceptance_criteria: Extract from scenario description and STP acceptance criteriaclassification: Infer from tier and scenario complexityspecific_preconditions: Add scenario-specific requirements (e.g., external router for networking tests)test_data: Generate realistic YAML for VMs, pods, networks based on scenario
source_constants are provided in the input,
use them verbatim for any matching test_data fields. Specifically:
value from source_constants, never infer or paraphrasetest_steps: Expand scenario into 5-10 detailed steps (setup → execute → cleanup)assertions: Extract validation points from scenario description (2-5 per scenario)dependencies: List K8s resources, tools, and RBAC specific to this scenarioMode gate: Pattern enhancement applies in tier mode only (test_strategy: "tier").
In auto mode, skip this entire section — auto-detected projects do not have pattern
libraries, decorators, or project-specific helpers. Auto-mode scenarios use a simpler
structure: test_objective, test_steps, assertions, and reference code_generation_config.
CRITICAL (tier mode): All scenarios MUST include pattern metadata for production-ready STD
For each scenario, analyze the description and automatically add pattern metadata using the rules below.
Apply these rules to match scenarios to patterns from {project_context.config_dir}/patterns/ directory:
Analyze the scenario description for these keywords:
network-connectivity-001migration-001network-hotplug-001vm-lifecycle-001console-001snapshot-001clone-001Identify required resources and add setup patterns:
factory-* pattern from pattern librarywait-* pattern (wait for resource ready)Identify test actions and add execution patterns:
network-ping-001migration-execute-001console-001network-hotplug-execute-001Based on matched patterns, automatically infer required helper libraries:
Pattern → Helper Mapping:
Read from {project_context.config_dir}/code_generation_config.yaml helper_library_imports section.
Each pattern maps to one or more helper libraries defined in the project config.
Helper Library Functions:
Read from {project_context.config_dir}/code_generation_config.yaml helper_functions section.
The project config defines available helper functions, their signatures, and return types.
Add test decorators based on tier and domain:
Tier-based:
decorators.Tier1decorators.Tier2Domain-based (from scenario description):
decorators.SigNetworkdecorators.SigComputedecorators.SigStoragedecorators.SigComputeAlways add:
Ordered (for proper test execution order)decorators.OncePerOrderedCleanup (for cleanup after ordered tests)For each matched pattern:
{project_context.config_dir}/patterns/tier1_patterns.yamltemplate field for that patterncode_template to the corresponding test steppattern_id to link step to patternExample:
test_steps:
setup:
- step_id: "SETUP-01"
action: "Create resource instance"
pattern_id: "factory-001" # Added
code_template: | # Added from pattern library
resource := factory.NewDefault(
builder.WithInterface(iface),
builder.WithNetwork(network),
)
For each scenario, generate a Ginkgo test structure hint:
Context("{scenario_description}", Ordered) {
BeforeAll(func() {
// Setup from test_steps.setup
})
It("[test_id:{test_id}]should {test_objective}", func() {
// Test execution from test_steps.test_execution
})
}
Replace placeholders:
{scenario_description}: Brief description of scenario{test_id}: The test_id field (e.g., TS-PROJ12345-001){test_objective}: The test_objective.title fieldLocation: {project_context.config_dir}/patterns/tier1_patterns.yaml
Available Patterns:
network-connectivity-001 - Network connectivity testsfactory-001 - Resource creation with factorywait-002 - Wait for resource readyconsole-001 - Console loginmigration-001 - Live migrationnetwork-def-001 - Network definition creationfactory-pod-001 - Pod creationtable-001 - Table-driven testsnetwork-hotplug-001 - Network interface hotplugsnapshot-001 - Snapshot operationsclone-001 - Cloning operationsEach pattern provides:
Before generating the STD file, validate pattern metadata:
patterns.primary fieldpatterns.helpers_required arraypatterns.decorators arraycode_structure fieldpattern_id where applicablecode_template where applicable{project_context.config_dir}/patterns/System Prompt:
You are an expert QE engineer generating a comprehensive Software Test Description (STD) from a Software Test Plan (STP).
Your task:
1. Read ALL scenarios from the STP Section III (Requirements-to-Tests Mapping table)
2. Extract shared metadata from STP Sections I and II
3. Generate ONE comprehensive STD YAML file with:
- document_metadata (shared across all scenarios)
- common_preconditions (shared infrastructure/environment)
- scenarios array (detailed spec for each scenario)
Guidelines:
- Generate ONE file for ALL scenarios (not one file per scenario)
- Extract common preconditions to avoid duplication
- Be specific and detailed in scenario specifications
- Use realistic patterns from the project's pattern library
- Include complete YAML definitions for test resources
- Link scenarios to requirements (Jira, GitHub PRs)
- Prioritize assertions (P0 = critical, P1 = nice to have)
CRITICAL - Pattern Enhancement (AUTO-GENERATED):
- For EACH scenario, analyze the description and automatically add pattern metadata
- Apply pattern matching rules (keywords → patterns, resources → setup patterns, etc.)
- Infer helper libraries from matched patterns
- Add decorators based on tier and domain
- Generate code templates from pattern library (`{project_context.config_dir}/patterns/tier1_patterns.yaml`)
- Add code_structure hint for each scenario
- Add pattern_id and code_template to each test step
- This is NOT optional - ALL scenarios MUST have pattern metadata
Output only valid YAML. Do not include explanations outside the YAML structure.
User Prompt Template:
Generate a comprehensive Software Test Description (STD) YAML file for ALL scenarios in the following STP:
STP FILE: {stp_file_path}
DOCUMENT METADATA:
Jira Issue: {jira_id} - {jira_summary}
Source Bugs: {source_bugs}
Related PRs: {related_prs}
Owning SIG: {owning_sig}
Total Scenarios: {total_scenarios}
STP CONTEXT:
Feature Description: {feature_description}
Non-Goals: {non_goals}
Test Environment: {test_environment}
Fix Versions: {fix_versions}
SOURCE CONSTANTS (from STP Section III.2, if present):
{source_constants_array}
NOTE: These values were extracted from actual source code by the STP Builder.
Use them VERBATIM in test_data fields. Do not infer, paraphrase, or modify.
ALL SCENARIOS (from STP Section III.1):
{scenarios_array}
Generate ONE comprehensive STD YAML file with:
1. document_metadata (shared metadata for entire test suite)
2. common_preconditions (shared infrastructure/environment requirements)
3. scenarios (array with detailed spec for each scenario)
Output filename: {JIRA_ID}_test_description.yaml
Output only valid YAML.
Before outputting the STD YAML, validate ALL of the following:
Base STD Structure:
Pattern Enhancement:
patterns section with primary fieldpatterns.helpers_required arraypatterns.decorators arraycode_structure fieldpattern_id where applicablecode_template where applicable{project_context.config_dir}/patterns/tier1_patterns.yamlv2.1 Enhancement:
code_generation_config section exists at document levelcode_generation_config.std_version is "2.1-enhanced"code_generation_config.package_name is inferred from owning_sigvariables sectiontest_structure sectionvariables.closure_scope includes at minimum: ctx, namespace, errtest_structure.context.decorators includes: Ordered, decorators.OncePerOrderedCleanup= (not :=) for closure variablesExpect(err) calls use ExpectWithOffset(1, err)Source Constants Compliance (when source_constants provided):
source_constant_ref fieldIf ANY validation fails:
STD generation is successful when:
If scenario description is vague:
If STP context is incomplete:
If YAML generation fails:
Primary output:
outputs/std/{JIRA_ID}/{JIRA_ID}_test_description.yamlExample:
outputs/std/PROJ-66855/PROJ-66855_test_description.yamlNote: This comprehensive STD YAML is the single source of truth for all test scenarios. It is used by downstream generators (stub-generator, test-generator) to produce test stubs and working test code.
See supplemental.md (in this skill directory) for detailed input/output examples.
v2.1 adds auto-generated code_generation_config, variables, and test_structure sections,
plus code template transformations (variable shadowing fixes, ExpectWithOffset, auto-cleanup).
For detailed algorithms, inference rules, transformation pseudocode, and the v2.1 changelog,
see supplemental.md (in this skill directory).
End of STD Generator Skill