This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new c09738c6158 Add $gen-ut skills (#37979)
c09738c6158 is described below

commit c09738c615843cd1a2584a2b146833fb32553bd3
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Feb 7 23:15:19 2026 +0800

    Add $gen-ut skills (#37979)
    
    * Add $gen-ut skills
    
    * Add $gen-ut skills
    
    * Add $gen-ut skills
---
 .codex/skills/gen-ut/SKILL.md                      | 128 +++++++++++++++++++++
 .codex/skills/gen-ut/agents/openai.yaml            |  24 ++++
 CODE_OF_CONDUCT.md                                 |   2 +-
 docs/community/content/involved/conduct/code.cn.md |   2 +-
 docs/community/content/involved/conduct/code.en.md |   2 +-
 5 files changed, 155 insertions(+), 3 deletions(-)

diff --git a/.codex/skills/gen-ut/SKILL.md b/.codex/skills/gen-ut/SKILL.md
new file mode 100644
index 00000000000..8b847f90071
--- /dev/null
+++ b/.codex/skills/gen-ut/SKILL.md
@@ -0,0 +1,128 @@
+---
+name: gen-ut
+description: >-
+  Generate standard unit tests for one or more target classes in Apache 
ShardingSphere;
+  use unified rules to complete test coverage and pass quality gates.
+---
+
+# Generate Unit Tests
+
+## Input Contract
+
+Required input:
+- Target class list: one or more classes, preferably fully qualified names.
+
+Optional input:
+- Module name (to scope Maven commands).
+- Test class list (for targeted test execution).
+- Extra constraints (for example forbidden APIs, command allowlist, coverage 
threshold).
+
+Handling missing input:
+- If target classes are missing, request the class list before any coding work.
+- If test classes are missing, discover existing related test classes by the 
`TargetClassName + Test` convention first; if resolution fails, mark as blocked 
and ask the user to provide test classes.
+
+Test class placeholder convention:
+- `<ResolvedTestClass>` can be one fully qualified test class or a 
comma-separated list.
+
+## Mandatory Constraints (Single Source of Rules)
+
+- `R1`: Follow `CODE_OF_CONDUCT.md`.
+- `R2`: Use standard unit tests with `@Test` only; forbid `@RepeatedTest` and 
`@ParameterizedTest`.
+- `R3`: Do not modify production code; only modify `src/test/java` and 
`src/test/resources`.
+- `R4`: Enumerate all branch paths of target public methods before coding.
+- `R5`: Apply minimal branch coverage: one branch maps to one test method;
+  do not cover the same branch in multiple test methods.
+- `R6`: Each test method covers one scenario and invokes the target public 
method at most once (extra assertions are allowed for the same scenario).
+- `R7`: Prefer `TypedSPILoader` and `OrderedSPILoader` to build subjects under 
test; subjects under test must be class-level fields.
+- `R8`: If dead code exists, report class name, file path, exact line number, 
and unreachable reason.
+- `R9`: Completion criteria must satisfy one of the following:
+  - `R9-A`: Target class coverage reaches 100% for class/line/branch, target 
test classes are executed successfully by Surefire, Checkstyle passes,
+    and all commands with exit codes are recorded.
+  - `R9-B`: If dead code blocks 100% branch coverage under the "no production 
code changes" rule,
+    report fully as required by `R8` and wait for user decision.
+- `R10`: If a related test class already exists for a target class, extend 
that class to add only missing-coverage tests; create a new test class only 
when no related test class exists.
+- `R11`: Do not claim completion if target tests were not actually executed 
due compile/runtime blockers. First remove blockers with minimal test-scope 
fixes and rerun verification;
+  only when blockers are outside scope and cannot be resolved safely in-turn, 
report exact blocker files/lines/commands and request user decision.
+
+## Execution Boundary
+
+- Only handle unit-test-scope tasks; do not perform production feature 
refactoring.
+- Do not edit generated directories (such as `target/`).
+- Do not use destructive git operations (such as `git reset --hard`, `git 
checkout --`).
+- If module name is missing, module-less command templates are allowed; if 
module is specified, module-scoped commands are mandatory.
+
+## Workflow
+
+1. Re-check `AGENTS.md` and `CODE_OF_CONDUCT.md`.
+2. Locate target classes and existing test classes.
+3. Output branch-path inventory according to `R4`.
+4. Output branch-to-test mapping according to `R5`.
+5. Perform dead-code analysis according to `R8` and record findings.
+6. Implement or extend tests according to `R2/R3/R6/R7/R10`.
+7. Run verification commands and iterate.
+8. Deliver results using the output structure.
+
+## Verification and Commands
+
+With module input:
+
+1. Targeted unit tests:
+```bash
+./mvnw -pl <module> -DskipITs -Dspotless.skip=true -Dtest=<ResolvedTestClass> 
-Dsurefire.failIfNoSpecifiedTests=false test
+```
+
+2. Coverage:
+```bash
+./mvnw -pl <module> -am -DskipITs -Djacoco.skip=false test jacoco:report
+```
+
+3. Checkstyle:
+```bash
+./mvnw -pl <module> -am -Pcheck checkstyle:check -DskipTests
+```
+
+Without module input:
+
+1. Targeted unit tests:
+```bash
+./mvnw -DskipITs -Dspotless.skip=true -Dtest=<ResolvedTestClass> 
-Dsurefire.failIfNoSpecifiedTests=false test
+```
+
+2. Coverage:
+```bash
+./mvnw -DskipITs -Djacoco.skip=false test jacoco:report
+```
+
+3. Checkstyle:
+```bash
+./mvnw -Pcheck checkstyle:check -DskipTests
+```
+
+Command execution rules:
+- Record every command and exit code.
+- If a command fails, record the failure reason and execute at least one 
remediation attempt; if still blocked, continue clearing blockers within test 
scope before escalating.
+- Escalate to user only when blockers are outside safe scope or require 
non-test changes; include exact failing commands, error lines, and attempted 
remediations.
+
+## Output Structure
+
+Respond in the same language as the user and follow this order:
+
+1. Goal and constraints (mapped to `R1-R11`)
+2. Plan and implementation (including branch mapping result)
+3. Dead-code and coverage results (according to `R8/R9`)
+4. Verification commands and exit codes
+5. Risks and next actions
+
+## Quality Self-Check
+
+- Rule definitions must exist only in "Mandatory Constraints"; other sections 
should reference rule IDs only.
+- Final state must satisfy `R9`, and all applicable rules (including `R10` and 
`R11`) must be met, with complete command and exit-code records.
+
+## Maintenance Rules
+
+- After changing any `R` numbering, run `rg -n "R[0-9]+" 
.codex/skills/gen-ut/SKILL.md` to ensure there are no dangling references.
+- After changing skill rules, verify trigger semantics are consistent between 
`SKILL.md` and `agents/openai.yaml`.
+- Fixed final-review order:
+  1. Numbering consistency check
+  2. Duplicate phrase scan
+  3. Semantic alignment check between `SKILL.md` and `agents/openai.yaml`
diff --git a/.codex/skills/gen-ut/agents/openai.yaml 
b/.codex/skills/gen-ut/agents/openai.yaml
new file mode 100644
index 00000000000..8e23918d678
--- /dev/null
+++ b/.codex/skills/gen-ut/agents/openai.yaml
@@ -0,0 +1,24 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+interface:
+  display_name: "Generate Unit Tests"
+  short_description: "Generate standard ShardingSphere unit tests with strict 
quality gates and mandatory executable verification"
+  default_prompt: >-
+    Use $gen-ut to generate standard unit tests for one or more ShardingSphere 
classes.
+    Provide the class set (optional module name and test class) and execute 
according to SKILL.md rules.
+    Do not claim completion unless target tests are actually executed 
successfully; clear test-scope blockers first.
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index 90a978ad0fa..c55b41f5c36 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -92,7 +92,7 @@ The following code of conduct is based on full compliance 
with the [Apache Softw
    - Reasonable design: Combined with production code design, design 
high-quality unit tests.
    - Error tolerance testing: Get expected results through incorrect inputs 
such as illegal data, exception flows, etc.
 - Use `assert` prefix for all test method names.
-- Unit tests must exercise behavior through public APIs only; do not use 
reflection or other means to access private members.
+- Unit tests must exercise behavior through public APIs only. Reflection-based 
invocation of private members is forbidden. If tests must access fields via 
reflection, use `Plugins.getMemberAccessor()` and limit reflection to `Field` 
access only.
 - When a production method is covered by only one test case, name that test 
method `assert<MethodName>` without extra suffixes, and prefer isolating one 
public production method per dedicated test method; when practical, keep test 
method ordering aligned with the corresponding production methods.
 - For parameterized tests, provide display names via parameters and prefix 
each with `{index}:` to include the sequence number.
 - Each test case needs precise assertions, try not to use `not`, 
`containsString` assertions.
diff --git a/docs/community/content/involved/conduct/code.cn.md 
b/docs/community/content/involved/conduct/code.cn.md
index 032f2e08ff0..9eb4a125cbd 100644
--- a/docs/community/content/involved/conduct/code.cn.md
+++ b/docs/community/content/involved/conduct/code.cn.md
@@ -96,7 +96,7 @@ chapter = true
    - 合理性设计(Design):与生产代码设计相结合,设计高质量的单元测试。
    - 容错性测试(Error):通过非法数据、异常流程等错误的输入,得到预期结果。
  - 使用 `assert` 前缀命名所有的测试用例。
- - 单元测试必须通过公共 API 验证行为,禁止通过反射等手段访问私有成员。
+ - 单元测试必须通过公共 API 验证行为,禁止通过反射调用私有成员。 若测试必须通过反射访问字段,应使用 
`Plugins.getMemberAccessor()`,且反射仅限于 `Field` 访问。
  - 当某个生产方法只由一个测试用例覆盖时,测试方法命名为 `assert<MethodName>`,无额外后缀。
  - 每个公有方法使用一个独立的测试方法,测试方法顺序在可行时与生产方法保持一致。
  - 参数化测试需通过参数提供显示名,并以 `{index}:` 前缀标注序号。
diff --git a/docs/community/content/involved/conduct/code.en.md 
b/docs/community/content/involved/conduct/code.en.md
index 08752da0a08..d5f6a6a3e43 100644
--- a/docs/community/content/involved/conduct/code.en.md
+++ b/docs/community/content/involved/conduct/code.en.md
@@ -96,7 +96,7 @@ The following code of conduct is based on full compliance 
with the [Apache Softw
     - Reasonable design: Combined with production code design, design 
high-quality unit tests.
     - Error tolerance testing: Get expected results through incorrect inputs 
such as illegal data, exception flows, etc.
 - Use `assert` prefix for all test method names.
-- Unit tests must exercise behavior through public APIs only; do not use 
reflection or other means to access private members.
+- Unit tests must exercise behavior through public APIs only. Reflection-based 
invocation of private members is forbidden. If tests must access fields via 
reflection, use `Plugins.getMemberAccessor()` and limit reflection to `Field` 
access only.
 - Except for simple `getter /setter` methods, unit tests need full coverage.
 - When a production method is covered by only one test case, name that test 
method `assert<MethodName>` without extra suffixes, and prefer isolating one 
public production method per dedicated test method; when practical, keep test 
method ordering aligned with the corresponding production methods.
 - For parameterized tests, provide display names via parameters and prefix 
each with `{index}:` to include the sequence number.

Reply via email to