claude-workspace: Skill for Claude Code

.claude/skills/api-layer/SKILL.md

api-layer is a skill for Claude Code from Piyush8296/claude-workspace. It costs 56 tokens per session (1,875 once invoked), scanned A, original, MIT.

A guide to organizing the code that connects a React or Next.js app to backend services. It covers typed request helpers, authentication handling, errors, retries, cancellation, pagination, uploads, and API routes.

In plain words
What is it for?
Use it to build API clients, fetch and cache backend data, cancel or retry requests, upload files, paginate results, and create Next.js API route handlers.
Why use it?
It keeps network requests consistent and prevents raw fetch calls, error handling, and retry logic from being duplicated across components.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

This is Piyush8296/claude-workspace's own configuration. It tells Claude Code how to work on claude-workspace itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-workspace configures →

Reuse

Borrowing it

Nothing to install: this file belongs to Piyush8296/claude-workspace. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/Piyush8296/claude-workspace/main/.claude/skills/api-layer/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/Piyush8296/claude-workspace

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for api-layer

README.md
[![agentmods](https://agentmods.dev/badge/skills/piyush8296/claude-workspace/api-layer/github.svg)](https://agentmods.dev/skills/piyush8296/claude-workspace/api-layer)
Your own site
<a href="https://agentmods.dev/skills/piyush8296/claude-workspace/api-layer"><img src="https://agentmods.dev/badge/skills/piyush8296/claude-workspace/api-layer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for api-layer

Your own site · 80×15
<a href="https://agentmods.dev/skills/piyush8296/claude-workspace/api-layer"><img src="https://agentmods.dev/badge/skills/piyush8296/claude-workspace/api-layer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,875 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00056 $0.01875
Opus 5.5 $0.00022 $0.00750
Sonnet 5.5 $0.00011 $0.00375
Haiku 4.5 $0.00006 $0.00187

Measured 1mo ago against content hash bad6f8074f81, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

api-layer scanned grade A with 1 finding 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 1mo 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

const res = await fetch(url.toString(), {
.claude/skills/api-layer/SKILL.md · 273 lines

How it starts

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

API Layer

Architecture

Never scatter raw fetch() calls across components. Build a typed API client that handles auth, errors, retries, and cancellation in one place.

Component → TanStack Query hook → API client function → fetchClient (interceptors) → fetch()

Typed Fetch Client

// lib/api/client.ts
import { env } from '@/lib/env';

interface FetchOptions extends Omit<RequestInit, 'body'> {
  body?: unknown;
  params?: Record<string, string | number | undefined>;
  timeout?: number;
}

class ApiError extends Error {
  constructor(
    public status: number,
    public statusText: string,
    public data: unknown,
    public url: string,
  ) {
    super(`${status} ${statusText}: ${url}`);
    this.name = 'ApiError';
  }

  get isUnauthorized() { return this.status === 401; }
  get isForbidden() { return this.status === 403; }
  get isNotFound() { return this.status === 404; }
  get isRateLimit() { return this.status === 429; }
  get isServerError() { return this.status >= 500; }
}

async function fetchClient<T>(path: string, options: FetchOptions = {}): Promise<T> {
  const { body, params, timeout = 10_000, headers: customHeaders, ...rest } = options;

  // Build URL with query params
  const url = new URL(path, env.API_BASE_URL);
  if (params) {
    Object.entries(params).forEach(([k, v]) => {
      if (v !== undefined) url.searchParams.set(k, String(v));
    });
  }

  // Timeout via AbortController
  const controller = new AbortController();
  const timer = setTimeout(() => controller.abort(), timeout);

  try {
    const res = await fetch(url.toString(), {
      ...rest,
      signal: controller.signal,
      headers: {
        'Content-Type': 'application/json',
        ...customHeaders,
      },
      body: body ? JSON.stringify(body) : undefined,
    });

    if (!res.ok) {
      const data = await res.json().catch(() => null);
      throw new ApiError(res.status, res.statusText, data, url.toString());
    }

    // Handle 204 No Content
    if (res.status === 204) return undefined as T;

    return res.json() as Promise<T>;
  } finally {
    clearTimeout(timer);
  }
}

export { fetchClient, ApiError };
export type { FetchOptions };

Read the full file on GitHub · 273 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. 1mo ago First seen · 273 lines · 56 tokens per session scan A bad6f8074f81

Subscribe to this mod's changes

api-layer is a skill published in the GitHub repository Piyush8296/claude-workspace (2 stars, last pushed 6mo ago), licensed MIT. It adds 56 tokens to every session and 1,875 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

senior-dev

Activates the SeniorDev agent for full-stack software engineering. Use this skill when you need production-ready code: Next.js 14 frontends, FastAPI backends, TypeScript strict-mode components, PostgreSQL schemas, Redis caching, authentication flows, or complete REST/GraphQL APIs. SeniorDev always outputs complete…

vignesh2027/Claude-Agentic-Skills2.0-version · 86 tokens

fullstack-developer

Modern web development expertise covering React, Node.js, databases, and full-stack architecture. Use when: building web applications, developing APIs, creating frontends, setting up databases, deploying web apps, or when user mentions React, Next.js, Express, REST API, GraphQL, MongoDB, PostgreSQL, or full-stack…

medy-gribkov/arcana · 0 tokens

authentication-patterns

OAuth 2.0, JWT, SSO, MFA, NextAuth/Clerk/Supabase Auth implementation patterns.

travisjneuman/.claude · 28 tokens

email-systems

Transactional email (Resend, SendGrid, SES), templates (React Email, MJML), deliverability (SPF/DKIM/DMARC), and inboxing best practices. Use when building email infrastructure, designing templates, or troubleshooting deliverability.

travisjneuman/.claude · 55 tokens

microservices-architecture

Microservices architecture patterns and best practices. Use when designing distributed systems, breaking down monoliths, or implementing service communication.

travisjneuman/.claude · 30 tokens

event-driven-architecture

Kafka, RabbitMQ, SQS/SNS, event sourcing, CQRS, saga patterns, dead letter queues, and idempotency. Use when designing asynchronous systems, implementing message-driven workflows, or building event streaming pipelines.

travisjneuman/.claude · 50 tokens