Agent skill

REST API Contract Review

by decebals in decebals/claude-code-java

Reviews REST API design for correct HTTP verbs, versioning, DTO use, consistent responses and backward compatibility before an API change ships.

MITAuto-check passedBackend & APIs

Install REST API Contract Review

skills CLI
$ npx skills add decebals/claude-code-java --skill api-contract-review -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install decebals/claude-code-java api-contract-review --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/decebals/claude-code-java.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/api-contract-review .claude/skills/api-contract-review && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
api-contract-review
GitHub stars
751
Token cost
~2.8k tokens
SKILL.md length
587 words
Files
2
Skills in repo
18
Repo updated
First seen
Licence
MIT

At a glance

Reviews REST API design for correct HTTP verbs, versioning, DTO use, consistent responses and backward compatibility before an API change ships.

  • Works in 6 steps: HTTP Semantics → URL Design → Request Handling → …
  • Reviewing REST controllers before releasing API changes
  • SKILL.md covers When to Use, Quick Reference: Common Issues, HTTP Verb Semantics and API Versioning, plus 5 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

The skill audits REST endpoints, with examples in Java and Spring annotations. It opens with a table of common problems: the wrong HTTP verb such as POST for an idempotent operation, missing versioning like `/users` instead of `/v1/users`, JPA entities leaked in responses, a 200 status that carries an error body, and inconsistent naming such as `/getUsers` next to `/users`.

It then goes through each area. A verb guide lists which methods are idempotent, safe and allowed a request body; versioning strategies (URL path, header and query parameter) are compared, with URL path recommended along with a checklist covering public APIs and deprecation; and request and response design covers DTOs versus entities, consistent response shapes and pagination of collections. Good and bad code samples illustrate each point, and backward compatibility is part of the scope.

When your agent uses it

  • Reviewing REST controllers before releasing API changes
  • Reviewing a pull request that touches controller code
  • Checking an endpoint set for backward compatibility
  • Deciding on a versioning scheme for a REST API

Example prompts

  • “Review the REST endpoints in UserController for HTTP verb mistakes and missing versioning.”
  • “Check this pull request's controller changes for breaking API changes.”
  • “Our API returns JPA entities directly; show what to change to use DTOs.”
  • “Audit the orders API for inconsistent response shapes and missing pagination.”

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. HTTP Semantics
  2. URL Design
  3. Request Handling
  4. Response Design
  5. Error Handling
  6. Compatibility

What it can do on your machine

Read from SKILL.md and the folder at commit 0d98fe9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are java and bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

REST API Contract Review loads about 2.8k tokens when it runs. Until then it costs about 57 tokens; SKILL.md has 587 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~57
When it runs · the whole SKILL.md, loaded when a task matches
~2.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from decebals/claude-code-java at commit 0d98fe9, republished under its MIT licence (© decebals). 587 words, ~2,759 tokens.

Download SKILL.mdSave it as .claude/skills/api-contract-review/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
api-contract-review
description
Review REST API contracts for HTTP semantics, versioning, backward compatibility, and response consistency. Use when user asks "review API", "check endpoints", "REST review", or before releasing API changes.
license
MIT

API Contract Review Skill

Audit REST API design for correctness, consistency, and compatibility.

When to Use

  • User asks "review this API" / "check REST endpoints"
  • Before releasing API changes
  • Reviewing PR with controller changes
  • Checking backward compatibility

Quick Reference: Common Issues

IssueSymptomImpact
Wrong HTTP verbPOST for idempotent operationConfusion, caching issues
Missing versioning/users instead of /v1/usersBreaking changes affect all clients
Entity leakJPA entity in responseExposes internals, N+1 risk
200 with error{"status": 200, "error": "..."}Breaks error handling
Inconsistent naming/getUsers vs /usersHard to learn API

HTTP Verb Semantics

Verb Selection Guide
VerbUse ForIdempotentSafeRequest Body
GETRetrieve resourceYesYesNo
POSTCreate new resourceNoNoYes
PUTReplace entire resourceYesNoYes
PATCHPartial updateNo*NoYes
DELETERemove resourceYesNoOptional

*PATCH can be idempotent depending on implementation

Common Mistakes
java
// ❌ POST for retrieval
@PostMapping("/users/search")
public List<User> searchUsers(@RequestBody SearchCriteria criteria) { }

// ✅ GET with query params (or POST only if criteria is very complex)
@GetMapping("/users")
public List<User> searchUsers(
    @RequestParam String name,
    @RequestParam(required = false) String email) { }

// ❌ GET for state change
@GetMapping("/users/{id}/activate")
public void activateUser(@PathVariable Long id) { }

// ✅ POST or PATCH for state change
@PostMapping("/users/{id}/activate")
public ResponseEntity<Void> activateUser(@PathVariable Long id) { }

// ❌ POST for idempotent update
@PostMapping("/users/{id}")
public User updateUser(@PathVariable Long id, @RequestBody UserDto dto) { }

// ✅ PUT for full replacement, PATCH for partial
@PutMapping("/users/{id}")
public User replaceUser(@PathVariable Long id, @RequestBody UserDto dto) { }

@PatchMapping("/users/{id}")
public User updateUser(@PathVariable Long id, @RequestBody UserPatchDto dto) { }

API Versioning

Strategies
StrategyExampleProsCons
URL path/v1/usersClear, easy routingURL changes
HeaderAccept: application/vnd.api.v1+jsonClean URLsHidden, harder to test
Query param/users?version=1Easy to addEasy to forget
java
// ✅ Versioned endpoints
@RestController
@RequestMapping("/api/v1/users")
public class UserControllerV1 { }

@RestController
@RequestMapping("/api/v2/users")
public class UserControllerV2 { }

// ❌ No versioning
@RestController
@RequestMapping("/api/users")  // Breaking changes affect everyone
public class UserController { }
Version Checklist
  • All public APIs have version in path
  • Internal APIs documented as internal (or versioned too)
  • Deprecation strategy defined for old versions

Request/Response Design

DTO vs Entity
java
// ❌ Entity in response (leaks internals)
@GetMapping("/{id}")
public User getUser(@PathVariable Long id) {
    return userRepository.findById(id).orElseThrow();
    // Exposes: password hash, internal IDs, lazy collections
}

// ✅ DTO response
@GetMapping("/{id}")
public UserResponse getUser(@PathVariable Long id) {
    User user = userService.findById(id);
    return UserResponse.from(user);  // Only public fields
}
Response Consistency
java
// ❌ Inconsistent responses
@GetMapping("/users")
public List<User> getUsers() { }  // Returns array

@GetMapping("/users/{id}")
public User getUser(@PathVariable Long id) { }  // Returns object

@GetMapping("/users/count")
public int countUsers() { }  // Returns primitive

// ✅ Consistent wrapper (optional but recommended for large APIs)
@GetMapping("/users")
public ApiResponse<List<UserResponse>> getUsers() {
    return ApiResponse.success(userService.findAll());
}

// Or at minimum, consistent structure:
// - Collections: always wrapped or always raw (pick one)
// - Single items: always object
// - Counts/stats: always object { "count": 42 }
Pagination
java
// ❌ No pagination on collections
@GetMapping("/users")
public List<User> getAllUsers() {
    return userRepository.findAll();  // Could be millions
}

// ✅ Paginated
@GetMapping("/users")
public Page<UserResponse> getUsers(
    @RequestParam(defaultValue = "0") int page,
    @RequestParam(defaultValue = "20") int size) {
    return userService.findAll(PageRequest.of(page, size));
}

HTTP Status Codes

Success Codes
CodeWhen to UseResponse Body
200 OKSuccessful GET, PUT, PATCHResource or result
201 CreatedSuccessful POST (created)Created resource + Location header
204 No ContentSuccessful DELETE, or PUT with no bodyEmpty
Error Codes
CodeWhen to UseCommon Mistake
400 Bad RequestInvalid input, validation failedUsing for "not found"
401 UnauthorizedNot authenticatedConfusing with 403
403 ForbiddenAuthenticated but not allowedUsing 401 instead
404 Not FoundResource doesn't existUsing 400
409 ConflictDuplicate, concurrent modificationUsing 400
422 UnprocessableSemantic error (valid syntax, invalid meaning)Using 400
500 Internal ErrorUnexpected server errorExposing stack traces
Anti-Pattern: 200 with Error Body
java
// ❌ NEVER DO THIS
@GetMapping("/{id}")
public ResponseEntity<Map<String, Object>> getUser(@PathVariable Long id) {
    try {
        User user = userService.findById(id);
        return ResponseEntity.ok(Map.of("status", "success", "data", user));
    } catch (NotFoundException e) {
        return ResponseEntity.ok(Map.of(  // Still 200!
            "status", "error",
            "message", "User not found"
        ));
    }
}

// ✅ Use proper status codes
@GetMapping("/{id}")
public ResponseEntity<UserResponse> getUser(@PathVariable Long id) {
    return userService.findById(id)
        .map(ResponseEntity::ok)
        .orElse(ResponseEntity.notFound().build());
}

Error Response Format

Consistent Error Structure
java
// ✅ Standard error response
public class ErrorResponse {
    private String code;        // Machine-readable: "USER_NOT_FOUND"
    private String message;     // Human-readable: "User with ID 123 not found"
    private Instant timestamp;
    private String path;
    private List<FieldError> errors;  // For validation errors
}

// In GlobalExceptionHandler
@ExceptionHandler(ResourceNotFoundException.class)
public ResponseEntity<ErrorResponse> handleNotFound(
        ResourceNotFoundException ex, HttpServletRequest request) {
    return ResponseEntity.status(HttpStatus.NOT_FOUND)
        .body(ErrorResponse.builder()
            .code("RESOURCE_NOT_FOUND")
            .message(ex.getMessage())
            .timestamp(Instant.now())
            .path(request.getRequestURI())
            .build());
}
Security: Don't Expose Internals
java
// ❌ Exposes stack trace
@ExceptionHandler(Exception.class)
public ResponseEntity<String> handleAll(Exception ex) {
    return ResponseEntity.status(500)
        .body(ex.getStackTrace().toString());  // Security risk!
}

// ✅ Generic message, log details server-side
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleAll(Exception ex) {
    log.error("Unexpected error", ex);  // Full details in logs
    return ResponseEntity.status(500)
        .body(ErrorResponse.of("INTERNAL_ERROR", "An unexpected error occurred"));
}

Backward Compatibility

Show full SKILL.md (276 more words)Show less
Breaking Changes (Avoid in Same Version)
ChangeBreaking?Migration
Remove endpointYesDeprecate first, remove in next version
Remove field from responseYesKeep field, return null/default
Add required field to requestYesMake optional with default
Change field typeYesAdd new field, deprecate old
Rename fieldYesSupport both temporarily
Change URL pathYesRedirect old to new
Non-Breaking Changes (Safe)
  • Add optional field to request
  • Add field to response
  • Add new endpoint
  • Add new optional query parameter
Deprecation Pattern
java
@RestController
@RequestMapping("/api/v1/users")
public class UserControllerV1 {

    @Deprecated
    @GetMapping("/by-email")  // Old endpoint
    public UserResponse getByEmailOld(@RequestParam String email) {
        return getByEmail(email);  // Delegate to new
    }

    @GetMapping(params = "email")  // New pattern
    public UserResponse getByEmail(@RequestParam String email) {
        return userService.findByEmail(email);
    }
}

API Review Checklist

1. HTTP Semantics
  • GET for retrieval only (no side effects)
  • POST for creation (returns 201 + Location)
  • PUT for full replacement (idempotent)
  • PATCH for partial updates
  • DELETE for removal (idempotent)
2. URL Design
  • Versioned (/v1/, /v2/)
  • Nouns, not verbs (/users, not /getUsers)
  • Plural for collections (/users, not /user)
  • Hierarchical for relationships (/users/{id}/orders)
  • Consistent naming (kebab-case or camelCase, pick one)
3. Request Handling
  • Validation with @Valid
  • Clear error messages for validation failures
  • Request DTOs (not entities)
  • Reasonable size limits
4. Response Design
  • Response DTOs (not entities)
  • Consistent structure across endpoints
  • Pagination for collections
  • Proper status codes (not 200 for errors)
5. Error Handling
  • Consistent error format
  • Machine-readable error codes
  • Human-readable messages
  • No stack traces exposed
  • Proper 4xx vs 5xx distinction
6. Compatibility
  • No breaking changes in current version
  • Deprecated endpoints documented
  • Migration path for breaking changes

Token Optimization

For large APIs:

  1. List all controllers: find . -name "*Controller.java"
  2. Sample 2-3 controllers for pattern analysis
  3. Check @ExceptionHandler configuration once
  4. Grep for specific anti-patterns:
    bash
    # Find potential entity leaks
    grep -r "public.*Entity.*@GetMapping" --include="*.java"
    
    # Find 200 with error patterns
    grep -r "ResponseEntity.ok.*error" --include="*.java"
    
    # Find unversioned APIs
    grep -r "@RequestMapping.*api" --include="*.java" | grep -v "/v[0-9]"

© decebals, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/api-contract-review of decebals/claude-code-java.

  • SKILL.md
  • README.md

Open the folder on GitHubat commit 0d98fe9

Compare with similar skills

REST API Contract Review next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

REST API Contract Review compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
REST API Contract Review this skilldecebals/claude-code-java751—~2.8kAutomated safety check: PassMIT
Quarkus Patternsaffaan-m/ECC276k1 repos~5.4kAutomated safety check: PassMIT
Quarkus Patternsaffaan-m/ECC276k—~6.1kAutomated safety check: PassMIT
API Design Safetydoccker/cc-use-exp1.1k—~962Automated safety check: PassCustom licence
Code Qualitypiomin/claude-ai-spring-boot1.3k—~2.2kAutomated safety check: PassApache-2.0
Azsdk Common Generate SDK LocallyAzure/azure-sdk-for-android121—~1.5kAutomated safety check: PassMIT

Similar skills

  • Quarkus Patterns

    affaan-m/ECC

    Quarkus 3.x LTS architecture patterns with Camel for messaging, RESTful API design, CDI services, data access with Panache, and async processing.

    276k GitHub starsUsed in 1 repo~5.4k tokens
    Backend & APIsAuto-check passed
  • Quarkus Patterns

    affaan-m/ECC

    Quarkus 3.x LTS architecture patterns with Camel for messaging, RESTful API design, CDI services, data access with Panache, and async processing.

    276k GitHub stars~6.1k tokensUpdated 4 days ago
    Backend & APIsAuto-check passed
  • API Design Safety

    doccker/cc-use-exp

    当设计或修改 REST API 响应结构、处理 API 返回值时触发。防止 API 设计缺陷导致的字段错位、类型歧义等问题。

    1.1k GitHub stars~962 tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • Code Quality

    piomin/claude-ai-spring-boot

    Comprehensive code review for Java - clean code principles, API contracts, null safety, exception handling, and performance.

    1.3k GitHub stars~2.2k tokensUpdated 5 mo ago
    DevelopmentAuto-check passed
  • Azsdk Common Generate SDK Locally

    Azure/azure-sdk-for-android

    Official

    Generate, build, and test Azure SDKs locally from TypeSpec with automatic customization.

    121 GitHub stars~1.5k tokensUpdated 4 mo ago
    Backend & APIsAuto-check passed
  • Create, validate and maintain OpenAPI 3.1 specs for REST APIs, whether designed first or generated from existing code, and use them for docs and client SDKs.

    40k GitHub starsUsed in 9 repos~511 tokens
    Backend & APIsAuto-check passed

More from decebals/claude-code-java

All 18 skills in this repo
  • Java Design Patterns Reference

    decebals/claude-code-java

    A practical Java reference for Builder, Factory, Singleton, Strategy, Observer and other patterns, with a table matching problems to patterns.

    751 GitHub starsUsed in 1 repo~4.4k tokens
    Auto-check passed
  • Jpa Patterns

    decebals/claude-code-java

    JPA/Hibernate patterns and common pitfalls (N+1, lazy loading, transactions, queries).

    751 GitHub starsUsed in 1 repo~4k tokens
    Auto-check passed
  • Logging Patterns

    decebals/claude-code-java

    Java logging best practices with SLF4J, structured logging (JSON), and MDC for request tracing.

    751 GitHub starsUsed in 1 repo~3.3k tokens
    Auto-check passed
  • Java Architecture Review

    decebals/claude-code-java

    Reviews a Java project's architecture at the macro level: package structure, module boundaries, dependency direction and layering.

    751 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check passed
  • Changelog Generator for Java

    decebals/claude-code-java

    Builds changelog entries from conventional commits in a Java project, after working out whether it uses SemVer, two-part versions or calendar versions.

    751 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed
  • Clean Code Principles

    decebals/claude-code-java

    Covers Clean Code principles for Java: DRY, KISS and YAGNI with before-and-after examples, plus naming conventions for variables and booleans.

    751 GitHub stars~3.4k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Questions about REST API Contract Review

What does REST API Contract Review do?

Reviews REST API design for correct HTTP verbs, versioning, DTO use, consistent responses and backward compatibility before an API change ships. The skill audits REST endpoints, with examples in Java and Spring annotations. It opens with a table of common problems: the wrong HTTP verb such as POST for an idempotent operation, missing versioning like `/users` instead of `/v1/users`, JPA entities leaked in responses, a 200 status that carries an error body, and inconsistent naming such as `/getUsers` next to `/users`.

When should I use REST API Contract Review?

REST API Contract Review fits situations like: reviewing REST controllers before releasing API changes; reviewing a pull request that touches controller code; checking an endpoint set for backward compatibility; deciding on a versioning scheme for a REST API.

How do I install REST API Contract Review in Claude Code?

Run `npx skills add decebals/claude-code-java --skill api-contract-review -a claude-code`. Or copy the skill folder (skills/api-contract-review in decebals/claude-code-java) into .claude/skills/api-contract-review in your project. Claude Code loads it when a task matches its description.

How do I install REST API Contract Review in Codex?

Run `npx skills add decebals/claude-code-java --skill api-contract-review -a codex`. Or copy the skill folder (skills/api-contract-review in decebals/claude-code-java) into .agents/skills/api-contract-review in your project. Codex loads it when a task matches its description.

Can I use REST API Contract Review in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add decebals/claude-code-java --skill api-contract-review -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/api-contract-review, .gemini/skills/api-contract-review, .github/skills/api-contract-review and .opencode/skills/api-contract-review in your project.

What does REST API Contract Review need to run?

SKILL.md names no scripts, command-line tools or credentials: REST API Contract Review is instructions for the agent only.

Does REST API Contract Review access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is REST API Contract Review safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does REST API Contract Review use?

REST API Contract Review is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does REST API Contract Review use?

About 2.8k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to REST API Contract Review?

Skills that share tags, products or a category with REST API Contract Review: Quarkus Patterns (affaan-m/ECC, 276k stars), Quarkus Patterns (affaan-m/ECC, 276k stars), API Design Safety (doccker/cc-use-exp, 1.1k stars) and Code Quality (piomin/claude-ai-spring-boot, 1.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains REST API Contract Review?

decebals (a GitHub user) maintains it in decebals/claude-code-java, which has 751 GitHub stars. The repository holds 18 skills in this directory. The repository was last updated on September 6, 2026.

Source: decebals/claude-code-java on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.