api-contract-define

A command template for defining how a backend and frontend exchange data through a REST API, including URLs, requests, responses, and errors.

In plain words
What is it for?
Planning create, read, update, and delete operations, request and response data structures, pagination, validation, and error handling for a feature.
Why use it?
It gives both sides a shared agreement before implementation, reducing mismatched field names, formats, and endpoint behavior.

Command for Claude Code

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 commands/mort-lab/excel-mcp/api-contract-define
Clone the repo
git clone --depth 1 https://github.com/mort-lab/excel-mcp

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 809 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod 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.00000 $0.00809
Opus 5 $0.00000 $0.00404
Sonnet 5 $0.00000 $0.00162
Haiku 4.5 $0.00000 $0.00081

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

Security

Grade A, and why

api-contract-define 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.

Origin

This is a copy

100% identical to api-contract-define — 258 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.claude/commands/prp-commands/api-contract-define.md · 130 lines

How it starts

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

Define API Contract Between Backend and Frontend

Feature: $ARGUMENTS

Task: Create detailed API contract specification for backend/frontend coordination

  1. Define RESTful endpoints:

    Base URL: /api/v1/{feature}
    
    Endpoints:
    - GET /api/v1/{features}
      Query params: page, size, sort, filter
      Response: Page<{Feature}Response>
    
    - GET /api/v1/{features}/{id}
      Path param: id (Long)
      Response: {Feature}Response
    
    - POST /api/v1/{features}
      Body: {Feature}Request
      Response: {Feature}Response (201 Created)
    
    - PUT /api/v1/{features}/{id}
      Path param: id (Long)
      Body: {Feature}Request
      Response: {Feature}Response
    
    - DELETE /api/v1/{features}/{id}
      Path param: id (Long)
      Response: 204 No Content
    
  2. Define request/response DTOs:

    // Request DTO (for POST/PUT)
    interface {Feature}Request {
      name: string;        // min: 2, max: 100
      description?: string; // max: 1000
      // Add domain-specific fields
    }
    
    // Response DTO (for GET)
    interface {Feature}Response {
      id: number;
      name: string;
      description?: string;
      createdAt: string;   // ISO 8601
      updatedAt: string;   // ISO 8601
      // Add computed fields
    }
    
    // Page response wrapper
    interface Page<T> {
      content: T[];
      totalElements: number;
      totalPages: number;
      size: number;
      number: number;
    }
    
  3. Define error responses:

    {
      "timestamp": "2024-01-20T10:30:00Z",
      "status": 400,
      "error": "Bad Request",
      "message": "Validation failed",
      "path": "/api/v1/{features}",
      "errors": [
        {
          "field": "name",
          "message": "Name is required"
        }
      ]
    }
    
  4. Define validation rules:

    • Backend: Bean Validation annotations
    • Frontend: Matching Zod schemas
    name: required, 2-100 chars
    description: optional, max 1000 chars
    email: valid email format
    date: ISO 8601 format
    

Read the full file on GitHub · 130 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. 2d ago First seen · 130 lines · 0 tokens per session scan A 35760ecd2e5f

Subscribe to this mod's changes

api-contract-define is a command published in the GitHub repository mort-lab/excel-mcp (5 stars, last pushed 25d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 809 tokens. A static security scan graded it A with 0 findings. It is 100% identical to api-contract-define, differing in 258 lines, and is treated as a copy.