AGENT SKILL

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

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

  1. Identify parent classes and trace the full chain
  2. If parent is BaseReq or BaseResponse → EXCLUDE all their properties (handled by HTTP middleware)
  3. Choose approach:
    • Interface Extension (recommended): use extends when parent is reused across multiple children
    • Flattened Interface: copy all properties into one interface when standalone

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

  1. Analyze Java class — properties, annotations, types, inheritance
  2. If inheritance exists → read parent class files
  3. Handle BaseReq/BaseResponse exclusion if applicable
  4. Create interface with PascalCase name
  5. Apply type mapping (including @BigDecimalToNumber, @TimestampFormat)
  6. Apply nullability (@NonNull → required, else optional)
  7. Preserve property names exactly as in API
  8. Migrate comments preserving original language

Validation Checklist

  • [ ] @NonNull/@NotNull properties 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/BaseResponse properties 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

HeathWang
HeathWang/hw-cc-plugin

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.

设计师
★ 1
HeathWang
HeathWang/hw-cc-plugin

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.

★ 1
HeathWang
HeathWang/hw-cc-plugin

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.

★ 1
HeathWang
HeathWang/hw-cc-plugin

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.

Skill与智能体开发
★ 1
HeathWang
HeathWang/hw-cc-plugin

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.

前端开发
★ 1
HeathWang
HeathWang/hw-cc-plugin

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.

★ 1