home / skills / chachamaru127 / claude-code-harness / crud

crud skill

/skills/crud

This skill auto-generates production-ready CRUD for specified entities with validation, authorization, tests, and minimal diff.

npx playbooks add skill chachamaru127/claude-code-harness --skill crud

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.3 KB
---
name: crud
description: "CRUDをサクッと自動生成。ボイラープレートはAIにお任せ。Use when user mentions CRUD, entity generation, or wants to create API endpoints. Do NOT load for: UI component creation, form design, database schema discussions."
description-en: "Auto-generate CRUD quickly. Boilerplate left to AI. Use when user mentions CRUD, entity generation, or wants to create API endpoints. Do NOT load for: UI component creation, form design, database schema discussions."
description-ja: "CRUDをサクッと自動生成。ボイラープレートはAIにお任せ。Use when user mentions CRUD, entity generation, or wants to create API endpoints. Do NOT load for: UI component creation, form design, database schema discussions."
allowed-tools: ["Read", "Write", "Edit", "Bash", "Grep", "Glob"]
argument-hint: "<entity-name>"
user-invocable: false
---

# CRUD Skill

Auto-generates CRUD functionality for specified entities (tables) at **production-ready level**.

## Quick Reference

- "**Create CRUD for task management**" → `/crud tasks`
- "**Want search and pagination too**" → Includes all together
- "**Include permissions (who can view/edit)**" → Sets up authorization/rules together

## Deliverables

- CRUD + validation + authorization + tests, **complete production-safe set**
- Minimize diff to match existing DB/code

**Features**:
- Validation (Zod) auto-add
- Auth/authorization (Row Level Security) auto-config
- Relations (one-to-many, many-to-many) support
- Pagination, search, filters
- Auto-generated test cases

---

## Auto-invoke Skills

**This skill must explicitly invoke the following skills with the Skill tool**:

| Skill | Purpose | When to Call |
|-------|---------|--------------|
| `impl` | Implementation (parent skill) | CRUD feature implementation |
| `verify` | Verification (parent skill) | Post-implementation verification |

---

## Execution Flow

Detailed steps are described in the phases below.

### Phase 1: Entity Analysis

1. Parse entity name from $ARGUMENTS
2. Detect existing schema (Prisma, Drizzle, raw SQL)
3. Infer field types and relations

### Phase 2: CRUD Generation

1. Generate model/schema if needed
2. Create API endpoints (REST or tRPC)
3. Add validation schemas (Zod)
4. Configure authorization rules

### Phase 3: Test Generation

1. Create unit tests for each endpoint
2. Add integration tests
3. Generate test fixtures

### Phase 4: Verification

1. Run type check
2. Run tests
3. Verify build

---

## Supported Frameworks

| Framework | Detection | Generated Files |
|-----------|-----------|-----------------|
| **Next.js + Prisma** | `prisma/schema.prisma` | API routes, Prisma client |
| **Next.js + Drizzle** | `drizzle.config.ts` | API routes, Drizzle queries |
| **Express** | `express` in package.json | Controllers, routes |
| **Hono** | `hono` in package.json | Route handlers |

---

## Output Structure

```
src/
├── lib/
│   └── validations/
│       └── {entity}.ts        # Zod schemas
├── app/api/{entity}/
│   ├── route.ts              # GET (list), POST (create)
│   └── [id]/
│       └── route.ts          # GET, PUT, DELETE
└── tests/
    └── {entity}.test.ts      # Test cases
```

---

## Related Skills

- `impl` - Feature implementation
- `verify` - Build verification
- `auth` - Authentication/authorization

Overview

This skill auto-generates production-ready CRUD for specified entities, producing API endpoints, validation, authorization, and tests. It minimizes diffs against existing schemas and supports common JS frameworks like Next.js with Prisma or Drizzle, Express, and Hono. Use it when you need a complete backend feature scaffold for an entity without manual boilerplate.

How this skill works

The skill analyzes the target entity and the repository schema (Prisma, Drizzle, or raw SQL) to infer fields and relations. It generates or updates model/schema files, creates API routes (REST or tRPC), adds Zod validation, configures authorization rules (including row-level security), and scaffolds unit and integration tests. After implementation it calls the implementation and verification skills to run type checks, tests, and build verification.

When to use it

  • You mention CRUD generation for an entity or table
  • You want API endpoints plus validation and auth created together
  • You need pagination, search, filters, and relations handled
  • You want production-ready tests and fixtures auto-generated
  • You need minimal-diff integration with an existing schema

Best practices

  • Specify the entity name and any special fields or relations up front
  • Indicate preferred DB layer (Prisma, Drizzle, or raw SQL) if repository detection is ambiguous
  • Request authorization rules (who can view/edit) early so ACLs are scaffolded properly
  • Keep UI/form design or component requests separate — this skill focuses on backend CRUD only
  • Run the verification step after generation to ensure types and tests pass locally

Example use cases

  • Create CRUD for a tasks entity with search, pagination, and tests
  • Add a Projects API with many-to-many relations to users and appropriate row-level authorization
  • Generate a Contacts resource with Zod validation and integration tests to verify endpoints
  • Scaffold endpoints for a legacy table while minimizing changes to the existing schema

FAQ

Will this change my database schema automatically?

It may generate or suggest schema files when needed, but it aims to minimize diffs; confirm schema migrations before applying to production.

Can it create frontend forms or UI components?

No. This skill intentionally excludes UI component or form design and focuses solely on backend CRUD, validation, auth, and tests.