java-codegen-from-db

java-codegen-from-db is a skill for Claude Code from ZhaoXingPeng/DBJavaGenix. It costs 82 tokens per session (2,728 once invoked), scanned A, original, MIT.

A workflow that generates Spring Boot Java code from MySQL, PostgreSQL, or SQLite database tables. It can create entities, database-access code, services, controllers, and mappers.

In plain words
What is it for?
Use it to reverse-engineer database tables into a Spring Boot project, review the schema, optionally add semantic details, and render code after confirmation.
Why use it?
It reduces the manual work of turning an existing database structure into application code, while checking the project and its dependencies first.

Skill for Claude Code

Written for Claude Code: when-to-use in frontmatter.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/zhaoxingpeng/dbjavagenix/java-codegen-from-db
Any agent
npx skills add ZhaoXingPeng/DBJavaGenix --skill java-codegen-from-db
Clone the repo
git clone --depth 1 https://github.com/ZhaoXingPeng/DBJavaGenix

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for java-codegen-from-db

README.md
[![agentmods](https://agentmods.dev/badge/skills/zhaoxingpeng/dbjavagenix/java-codegen-from-db.svg)](https://agentmods.dev/skills/zhaoxingpeng/dbjavagenix/java-codegen-from-db)
Your own site
<a href="https://agentmods.dev/skills/zhaoxingpeng/dbjavagenix/java-codegen-from-db"><img src="https://agentmods.dev/badge/skills/zhaoxingpeng/dbjavagenix/java-codegen-from-db.svg" alt="Measured on agentmods" height="20"></a>
Per session 82 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,728 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00082 $0.02728
Opus 5 $0.00041 $0.01364
Sonnet 5 $0.00016 $0.00546
Haiku 4.5 $0.00008 $0.00273

Measured 6d ago against content hash c113fccf1001, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

java-codegen-from-db scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/java-codegen-from-db/SKILL.md · 257 lines

How it starts

The opening of the file, as written. The whole thing — 257 lines — stays where its author put it; the contents beside it link to each section on GitHub.

java-codegen-from-db

工作流总览

本 skill 把"从数据库表生成 Java 代码"拆为 5 个显式阶段,每个阶段调用具体的 MCP 工具,关键决策点会暂停让用户确认。不允许跳步——前一步的输出是后一步的输入。

[1] 预检查项目  →  [2] schema 分析  →  [3] 语义增强(可选)
                                              ↓
                  [5] 写盘   ←   [4] 分层渲染(等待用户确认)

阶段 1: 预检查项目(必做)

目的: 在生成代码前确认目标 Spring Boot 项目结构合法、依赖大致齐全。否则生成出来也编译不过。

1.1 验证项目结构

调用 springboot_validate_project:

  • 参数: { "check_dependencies": true, "create_missing_dirs": true, "template_category": "<用户选定的分类>" }
  • 期待返回中包含 Project Structure: ✅ OK✅ Project Root
  • 如果失败 → 告诉用户具体缺什么,不要继续

1.2 分析依赖健康度

调用 springboot_analyze_dependencies:

  • 参数:
    {
      "template_category": "<同上>",
      "database_type": "mysql|postgresql|sqlite",
      "include_swagger": true,
      "include_lombok": true,
      "include_mapstruct": true
    }
    
  • 返回中提取 Missing Dependencies: N:
    • N == 0 → health = 100,继续
    • N ≤ 2 → health = 80,继续但提醒用户
    • N ≤ 5 → health = 60,暂停让用户决定是否继续
    • N > 5 → health = 40,强烈建议先修依赖,问用户是否要看具体清单

1.3 渲染依赖健康仪表盘(MCP App)

如果客户端支持 MCP Apps(_meta 渲染),返回值中应附加:

{
  "_meta": {
    "mcp-apps/component": "dashboard",
    "mcp-apps/data": { "score": <health>, ... }
  }
}

现阶段如未支持,用文本表格代替。


阶段 2: schema 分析(必做)

目的: 拿到目标表的列、主键、外键、索引,这是模板渲染的输入。

2.1 建立或复用连接

如果用户尚未连接:

  • 调用 db_connect_test with {host, port, username, password, database, database_type}
  • 拿到 connection_id,记住它,后续所有调用都要带

2.2 列出表名(可选)

当用户没指明表,先列出来让用户选:

  • 调用 db_query_tables with {connection_id, database}
  • 把表名列给用户,等用户选

2.3 描述目标表

对每张目标表:

  • 调用 db_table_describe with {connection_id, database, table, include_java_types: true}
  • 这一步会返回列定义 + 推断的 Java 类型

2.4 获取外键关系

  • 调用 db_table_foreign_keys with {connection_id, database, table}
  • 多张表时一起调,然后给用户渲染 ER 图(MCP App mermaid 组件)

2.5 渲染 ER 图(MCP App)

当用户选了 ≥ 2 张表,构造 Mermaid erDiagram 字符串,放进 _meta["mcp-apps/source"]


阶段 3: 语义增强(推荐,Phase 4 工具可用后启用)

Read the full file on GitHub · 257 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 257 lines · 82 tokens per session scan A c113fccf1001

Subscribe to this mod's changes

java-codegen-from-db is a skill published in the GitHub repository ZhaoXingPeng/DBJavaGenix (35 stars, last pushed 16d ago), licensed MIT. It adds 82 tokens to every session and 2,728 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.