Skip to content
Back to skills

Api

ASecurity

Centralized API client for the web frontend with React Query integration. Trigger: when fetching or mutating data from the backend API.

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 26, 2026
ai-agentstypescriptpythongobashreactdockerapifrontendbackend

Works with

  • cli
  • api

Security analysis

A100/100

Scanned October 4, 2026

npx -y skills add JNZader/repoforge --skill api --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Api?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Api
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jnzader-api/badge)](https://www.skillsdirectory.com/skills/jnzader-api)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: add-api-endpoint
description: >
  Centralized API client for the web frontend with React Query integration.
  Trigger: when fetching or mutating data from the backend API.
license: Apache-2.0
metadata:
  author: repoforge
  version: "1.0"
complexity: medium
token_estimate: 450
dependencies: []
related_skills: []
load_priority: high
---

<!-- L1:START -->
# add-api-endpoint

One sentence: Centralized API client for the web frontend with React Query integration.

Trigger: when fetching or mutating data from the backend API.
<!-- L1:END -->

<!-- L2:START -->
## Quick Reference

| Task | Pattern |
|------|---------|
| Fetch generations | `useGenerations()` |
| Start generation | `useStartGeneration()` |
<!-- L2:END -->

<!-- L3:START -->
## Critical Patterns (Summary)

### Error Handling with ApiError

Handle structured API errors using the `ApiError` class which provides `status` and `code` fields for precise error categorization.

```typescript
import { ApiError } from '@/lib/api';

try {
  const data = await fetchApi<User>('/api/user');
} catch (error) {
  if (error instanceof ApiError) {
    // Handle specific status codes
    if (error.status === 401) {
      // Redirect to login
    }
  }
}
```

### useStartGeneration Mutation

Use the `useStartGeneration` mutation to trigger generation workflows with automatic query invalidation.

```typescript
import { useStartGeneration } from '@/lib/api';

const { mutate, isLoading } = useStartGeneration();
mutate({ mode: 'docs' });
```
## When to Use

- Fetching generation data or provider lists from the backend
- Starting new generation workflows with proper mutation handling
- Canceling in-progress generation tasks
- Querying analytics and provider information

## Commands

```bash
docker compose -f docker-compose.dev.yml up -d
python repoforge/cli.py dev
```

## Anti-Patterns

### Don't: Ignore ApiError status codes

Accessing `error.message` without checking `error.status` or `error.code` leads to brittle error handling that breaks on different error types.

```typescript
// BAD - assumes all errors are generic
catch (error) {
  console.error(error.message); // Misses status/code context
}
```
<!-- L3:END -->

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.