java-response-wrapper

A Java and Spring Boot pattern for wrapping API responses in consistent objects. The responses can represent success, failure, or paginated data, with fields such as status, message, data, and timing information.

In plain words
What is it for?
Use it to create response and page-result classes, return them from controllers, and connect them to global exception handling in Spring Boot APIs.
Why use it?
It gives clients one predictable response shape across API endpoints. It also separates HTTP status codes from application-level result codes and standardizes pagination and error handling.

Skill for Claude CodeCodex

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/lambert0529/skills/java-response-wrapper
Any agent
npx skills add lambert0529/skills --skill java-response-wrapper
Clone the repo
git clone --depth 1 https://github.com/lambert0529/skills

Made for: Claude Code, Codex.

Per session 83 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 664 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 $0.00083 $0.00664
Opus 5 $0.00042 $0.00332
Sonnet 5 $0.00017 $0.00133
Haiku 4.5 $0.00008 $0.00066

Measured 2d ago against content hash acfbeb2a9bbc, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

java-response-wrapper 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 2d 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.

java/java-response-wrapper/SKILL.md · 81 lines

What it actually says

Java 统一响应格式规范

快速开始

实现统一响应格式的基本步骤:

  1. 创建统一响应包装类(使用 assets/ResultTemplate.java
  2. 创建分页响应类(使用 assets/PageResultTemplate.java
  3. 在 Controller 中使用统一响应格式
  4. 配置全局异常处理器返回统一格式

统一响应包装类

规范要求

  • 所有 API 响应使用统一的格式
  • 包含:状态码、消息、数据、时间戳
  • 提供静态工厂方法
  • 支持泛型

代码模板见 assets/ResultTemplate.java

分页响应格式

规范要求

  • 包含数据列表、总数、页码、每页数量、总页数
  • 提供便捷的构建方法
  • 支持从 Spring Data 的 Page 对象转换

代码模板见 assets/PageResultTemplate.java

Controller 层使用

规范要求

  • 所有 Controller 方法返回 ResponseEntity<Result<T>>
  • 使用 Result.success()Result.failure() 构建响应
  • HTTP 状态码与业务状态码分离

示例

@GetMapping("/{id}")
public ResponseEntity<Result<UserDTO>> getUser(@PathVariable Long id) {
    UserDTO user = userService.getById(id);
    return ResponseEntity.ok(Result.success(user));
}

@PostMapping
public ResponseEntity<Result<UserDTO>> createUser(
        @Valid @RequestBody CreateUserRequest request) {
    UserDTO user = userService.create(request);
    return ResponseEntity.status(HttpStatus.CREATED)
            .body(Result.success("用户创建成功", user));
}

响应格式示例

详细示例见 references/response-formats.md

详细参考

注意事项

  1. HTTP 状态码:HTTP 状态码表示请求处理状态,业务状态码表示业务结果
  2. 时间戳格式:使用毫秒时间戳,前端可根据需要转换
  3. 空值处理:成功时 data 可以为 null,失败时建议为 null
  4. 分页参数:页码从 1 开始,而非 0
  5. 向后兼容:响应格式变更时考虑向后兼容性
Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 2d ago First seen · 81 lines · 83 tokens per session scan A acfbeb2a9bbc

Subscribe to this mod's changes

java-response-wrapper is a skill published in the GitHub repository lambert0529/skills (11 stars, last pushed 7mo ago), licensed Apache-2.0. It adds 83 tokens to every session and 664 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.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens