refactor-java-09-code-optimize

Installation
SKILL.md

Engineering Code Optimization — refactor-chain · Java lane · step 09/09

Bundle: refactor-chain (orchestrated, self-healing refactor chain-of-skills). Lane: Java layered-architecture (Maven) · Position: step 09 of 09 · Prerequisite: refactor-java-08-common-extract · Next: refactor-code-solid (default final pass). Adaptivity: Selects the product-line ruleset from pom.xml <groupId> (grp.pt, grp.budget, gfmis.bgtex / com.ctjsoft.gfmis).

Purpose

This step performs systematic code-quality optimization on @Service and @Repository classes. It repairs SQL injection vulnerabilities (parameterizing value concatenation, whitelisting dynamic table names, regex-validating dynamic column names), enhances logging (unified Lombok @Slf4j, method-entry and exception logging), and cleans up redundant code (StringBufferStringBuilder, redundant variable elimination, nested-condition simplification, unified empty-collection checks). Because optimization rules differ between product lines, the skill detects the product line from pom.xml and loads the matching ruleset first.

When to use

  • The user wants to optimize service/DAO code quality, harden against SQL injection, add logging, or remove redundant code.
  • Trigger phrases: "optimize module code", "fix SQL injection", "security fix", "enhance logging", "@Slf4j", "clean up code", "code optimization", "engineering code optimization", "code review optimization".

Rules enforced

Detect the product line first (Step 0, non-skippable): read the module's pom.xml, extract <groupId> (falling back to <parent>'s <groupId>), and map it to a product-line directory. Exact match takes priority over prefix match: grp.ptproducts/技术中台/; grp.budgetproducts/预算/; gfmis.bgtex, com.ctjsoft.gfmis, grp.gfmisproducts/执行/; grp.gfmis.* prefix → products/执行/; com.ctjsoft.gfmis.v3products/指标/; any other groupId falls back to the default products/技术中台/.

Installs
1
GitHub Stars
3
First Seen
Jul 2, 2026
refactor-java-09-code-optimize — ahmedbenaw/refactor-chain