Easycode Skill
by @huhua1990
Use when users ask to generate Java code from database tables with EasyCode-style templates, including parsing db config, remembering last-used generation se...
clawhub install easycode-skill📖 About This Skill
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:
base_package to project output pathsInputs and Contract
1. Normalize the request to generate_java_code schema in references/function-schema.json.
2. Require explicit table names.
3. Fill missing fields from local state when available.
4. If critical DB fields are still missing, ask only for missing items.
5. When available, pass generation_config.table_columns for full field-level rendering parity.
6. If table_columns is absent, script attempts JDBC metadata fetch from db_connection.
Workflow
1. Parse user intent.
2. Load recent state from .easycode-skill/state.json by running:
- python3 scripts/easycode_skill.py state --show
3. Merge request + state + defaults:
- default template_group is Custom-V3.
- default output root is src/main/java.
4. Validate template group against references/template-groups.md.
5. Preview output plan:
- python3 scripts/easycode_skill.py plan --spec '
6. Execute generation:
- python3 scripts/easycode_skill.py execute --spec '
- add --overwrite only when user confirms replacement
- add --run-project-format to run formatter after generation
7. Persist successful config:
- python3 scripts/easycode_skill.py state --save --spec '
8. 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
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).
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)
drivers/drivers-paths.json.
- Skill-local jars under drivers// are supported.
- If still missing, pass db_connection.driver_jar.
overwrite_candidate and ask for confirmation before replacing.Current Renderer Status
code with EasyCode global macros (init/define/autoImport/mybatisSupport).execute writes rendered output (not scaffold), and plan can include rendered content with --include-content.table_columns is missing, script auto-fetches metadata through JDBC.db_connection.driver_jar (and optional db_connection.driver_class) or provide table_columns.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.
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_groupproject_root, output_rootpass, driver_jar, driver_class, type_mapping, project_format_command for next-run defaults.Do not store plaintext password in state. If password must be cached, store encrypted value from host secret manager.
Execution Guidance
Response Style
When reporting execution: