- name
- easycode-skill
- description
- Use when users ask to generate Java code from database tables with EasyCode-style templates, including parsing db config, remembering last-used generation settings, resolving output paths from base package, and producing a file generation plan/execution.
EasyCode Skill
Purpose
This skill turns natural-language requests into deterministic EasyCode-style generation inputs and execution steps.
Use this skill when users ask for:
- Generating Java code from one or more DB tables
- MyBatisPlus or custom template-group generation
- Reusing previous DB/package/author/template settings
- Auto-mapping
base_packageto project output paths
Inputs and Contract
- Normalize the request to
generate_java_codeschema in references/function-schema.json. - Require explicit table names.
- Fill missing fields from local state when available.
- If critical DB fields are still missing, ask only for missing items.
- When available, pass
generation_config.table_columnsfor full field-level rendering parity. - If
table_columnsis absent, script attempts JDBC metadata fetch fromdb_connection.
Workflow
- Parse user intent.
- Load recent state from
.easycode-skill/state.jsonby running:
- python3 scripts/easycode_skill.py state --show
- Merge request + state + defaults:
- default template_group is Custom-V3. - default output root is src/main/java.
- Validate template group against references/template-groups.md.
- Preview output plan:
- python3 scripts/easycode_skill.py plan --spec '<json>'
- Execute generation:
- python3 scripts/easycode_skill.py execute --spec '<json>' - add --overwrite only when user confirms replacement - add --run-project-format to run formatter after generation
- Persist successful config:
- python3 scripts/easycode_skill.py state --save --spec '<json>'
- Helper commands:
- python3 scripts/easycode_skill.py check-driver --db-type mysql - python3 scripts/easycode_skill.py spec-template --db-type mysql --tables user,order - python3 scripts/easycode_skill.py interactive (首次 1~9 步引导,后续仅输入表名)
Generation Rules
- Path mapping:
- Convert base_package (for example com.app.admin) to src/main/java/com/app/admin. - Append template-level relative package (for example entity, mapper, service, controller).
- Template groups:
- MyBatisPlus -> configs/EasyCodeConfig-mybatispuls.json (fallback project root file) - Custom-V2 -> configs/EasyCodeConfig-V2.json (fallback project root file) - Custom-V3 -> configs/EasyCodeConfig-V3.json (fallback project root file)
- JDBC drivers:
- Preferred lookup is drivers/drivers-paths.json. - Skill-local jars under drivers/<db>/ are supported. - If still missing, pass db_connection.driver_jar.
- Safety:
- Always show a pre-write file list. - If file exists, mark as overwrite_candidate and ask for confirmation before replacing.
Current Renderer Status
- The script uses a Java Velocity bridge to render template
codewith EasyCode global macros (init/define/autoImport/mybatisSupport). executewrites rendered output (not scaffold), andplancan include rendered content with--include-content.- If
table_columnsis missing, script auto-fetches metadata through JDBC. - When no JDBC driver is found locally, pass
db_connection.driver_jar(and optionaldb_connection.driver_class) or providetable_columns. - Default JDBC type preferences:
- Number -> Long - Time/Date/Timestamp -> Date - Override via generation_config.type_mapping when needed. - Optional interactive prompt: add --interactive-type-mapping to plan/execute when type_mapping is not specified.
- Optional project formatter:
- set generation_config.project_format_command to custom command(s), or - use --run-project-format and let script auto-detect gradlew/mvnw format tasks.
Memory Policy
Persist these keys after successful run:
db_type,url,userauthor,base_package,template_group- optional
project_root,output_root - interactive mode also persists
pass,driver_jar,driver_class,type_mapping,project_format_commandfor next-run defaults.
Do not store plaintext password in state. If password must be cached, store encrypted value from host secret manager.
Execution Guidance
- Prefer deterministic script calls for plan/state actions.
- For actual rendering, use the project’s EasyCode engine implementation when available.
- If engine invocation is unavailable, still provide a complete plan and clearly report blocked execution step.
Response Style
When reporting execution:
- Show resolved template group
- Show resolved base output directory
- Show generated/updated file count
- Show blocked items (if any) and exact next action