smithery/valec3

backend-api-response-formatting

Consistent response structure, error handling.

Installation

$ npx skills add smithery/valec3 --skill backend-api-response-formatting

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/valec3 · top by installs.

npx skills add smithery/valec3

Browse all from smithery/valec3

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,538 B
  • docs SUMMARY.md 85 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

Backend API Response Formatting

When to use this skill

  • API development
  • Consistent responses
  • Error handling
  • Client expectations

Workflow

  • Define response format
  • Wrap data consistently
  • Include metadata
  • Standard error format
  • Document responses

Instructions

Success Response

<?php

return $this->respond([
    'success' => true,
    'data' => $users,
    'meta' => [
        'page' => 1,
        'per_page' => 10,
        'total' => 100
    ]
]);

Error Response

<?php

return $this->fail([
    'success' => false,
    'error' => [
        'code' => 'VALIDATION_ERROR',
        'message' => 'Invalid input',
        'details' => [
            'email' => ['Email is required']
        ]
    ]
], 400);

Response Trait

<?php

trait ApiResponseTrait
{
    protected function success($data, $message = null, $code = 200)
    {
        return $this->respond([
            'success' => true,
            'message' => $message,
            'data' => $data
        ], $code);
    }

    protected function error($message, $code = 400, $details = null)
    {
        return $this->fail([
            'success' => false,
            'error' => [
                'message' => $message,
                'details' => $details
            ]
        ], $code);
    }
}

Resources

  • Consistent structure
  • Include success flag
  • Standard error format