java-to-nextjs
Use when converting Java 1.8 classes to Next.js TypeScript interface definitions - handling type mapping, nullability, inheritance, naming conventions, and BaseReq/BaseResponse exclusions.
- License 许可
- MIT
- 最近更新
- 2026-11-03
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- java-to-nextjs
- description
- Use when converting Java 1.8 classes to Next.js TypeScript interface definitions - handling type mapping, nullability, inheritance, naming conventions, and BaseReq/BaseResponse exclusions.
- allowed-tools
- Read, Grep, Glob
02 资源文件 6
- 参考文档examples/http-server.json505 B
- 参考文档examples/sse-server.json413 B
- 参考文档examples/stdio-server.json695 B
- 参考文档references/authentication.md10.0 KB
- 参考文档references/server-types.md10.4 KB
- 参考文档references/tool-usage.md11.4 KB
03 SKILL.md 正文
Java to Next.js TypeScript Conversion
Overview
Converts Java 1.8 classes to TypeScript 5.0+ interface definitions for Next.js 14+. Output as markdown code blocks only — never modify project files.
Core Constraint
CRITICAL: Output TypeScript interface definitions as markdown code blocks only. Do NOT modify, edit, or alter any project files.
Type Mapping
| Java Type | TypeScript Type |
|---|---|
int / Integer / long / Long |
number |
float / Float / double / Double |
number |
boolean / Boolean |
boolean |
String |
string |
BigDecimal / decimal |
string (default) or number (with @BigDecimalToNumber) |
Date |
string (ISO 8601) |
Timestamp |
number (unix) or string (ISO, with @TimestampFormat) |
List<T> |
T[] |
Map<K,V> |
Record<K, V> |
Object / JSONObject |
Record<string, any> |
Nullability Rules
| Java Annotation | TypeScript |
|---|---|
@NonNull / @NotNull |
Required field (name: string) |
No annotation / @Nullable |
Optional field (name?: string) |
Default: All properties are optional unless explicitly marked non-null.
Naming Conventions
Interface names: PascalCase with meaningful suffixes (SaveEmailData, LoginRequest, UserProfileResponse)
Property names: ⚠️ KEEP IDENTICAL TO JAVA/API — do NOT convert between camelCase and snake_case.
// ✅ Correct
interface SaveEmailData {
inviteCode: string; // matches API
invite_url?: string; // preserves snake_case
}
// ❌ Wrong
interface SaveEmailData {
InviteCode: string; // changed to PascalCase
inviteUrl?: string; // changed snake_case to camelCase
}
Inheritance Handling
- Identify parent classes and trace the full chain
- If parent is
BaseReqorBaseResponse→ EXCLUDE all their properties (handled by HTTP middleware) - Choose approach:
- Interface Extension (recommended): use
extendswhen parent is reused across multiple children - Flattened Interface: copy all properties into one interface when standalone
- Interface Extension (recommended): use
Documentation
Migrate Java comments to TypeScript preserving original language:
- Chinese comments → keep Chinese
- English comments → keep English
- Use JSDoc (
/** */) for interfaces, inline//for properties
Step-by-Step Workflow
- Analyze Java class — properties, annotations, types, inheritance
- If inheritance exists → read parent class files
- Handle
BaseReq/BaseResponseexclusion if applicable - Create interface with PascalCase name
- Apply type mapping (including
@BigDecimalToNumber,@TimestampFormat) - Apply nullability (
@NonNull→ required, else optional) - Preserve property names exactly as in API
- Migrate comments preserving original language
Validation Checklist
- [ ]
@NonNull/@NotNullproperties are required (no?) - [ ] All other properties are optional (
?) - [ ] Interface uses PascalCase naming
- [ ] Property names match API contract exactly
- [ ] Inheritance detected and parent classes analyzed
- [ ]
BaseReq/BaseResponseproperties excluded if applicable - [ ] Type mappings correct (especially
BigDecimal,Date, arrays) - [ ] Documentation migrated in original language
- [ ] Output is markdown code block only (no file modifications)
04 同仓库更多 Skills
reconstructing-ui-from-screenshots
Use when implementing or correcting an app or web UI from a design image, screenshot, mockup, or reference PNG where accurate size, spacing, color, typography, assets, and alignment matter.
question-answer
Use when the user wants a read-only explanation of existing code behavior, architecture, control flow, data flow, dependencies, or implementation decisions and has not requested project changes.
java-to-swift
Use when converting Java 1.8 classes to Swift 5.0+ Codable structs - handling type mapping, nullability, inheritance flattening, BaseReq exclusions, and property naming conventions.
ios-i18n-workflow
Use when iOS apps using SwiftGen L10n need localization work - adding keys, checking missing translations, or cleaning unused entries. Triggered by hardcoded strings, missing L10n references, incomplete translations across multiple languages, or unused localization cleanup requests.
improve-codebase-architecture
Use when the user wants architectural deepening opportunities for a codebase or named files, shown as a visual HTML report, and when they then pick candidates from that report to implement in the code already reviewed.
handoff
Use when the user asks to create a handoff, session summary, context compact, continuation note, 交接文档, 压缩上下文, or instructions for the next agent to resume work later.