---
name: add-json-server
description: Use when the user wants to add json-server for local API mocking. Installs json-server and concurrently (if not present), creates mock/db.json, and adds the dev:vite script to package.json.
allowed-tools: Bash Read
metadata:
  category: Setup & Environment
---

# add-json-server

Adds json-server as a local mock API alongside Vite.

## Step 1 — Check dependencies

Read `package.json` and check `devDependencies` for `json-server` and `concurrently`.

## Step 2 — Install missing packages

For each package not present, run:

```bash
bun add -d <package>
```

Only install what's missing. Do not reinstall if already present.

## Step 3 — Run setup script

```bash
bun ${CLAUDE_SKILL_DIR}/scripts/setup.ts
```

This creates `mock/db.json` (empty `{}`) and adds the `dev:vite` script to `package.json` — safe to run multiple times.

## Step 4 — Report to user

Tell the user:
- Which packages were installed (or skipped).
- That `mock/db.json` was created at the project root.
- That a new script `dev:vite` was added to `package.json`.
- How to use it:

```bash
bun run dev:vite
# Starts Vite on port 3000 and json-server on port 3001
```

- To add mock data, edit `mock/db.json` with the desired collections:

```json
{
  "users": [],
  "products": []
}
```
