# safe-action-validation-errors

Guides coding assistants on handling input and manual validation errors in next-safe-action. Useful when writing server actions and UI error displays.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 1200 installs · ★ 1
- Author: next-safe-action
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/next-safe-action/skills/tree/HEAD/skills/safe-action-validation-errors/SKILL.md
- Updated: 2026-09-03
- HTML: https://affpapa.org/en/nevibecode/skills/safe-action-validation-errors

## What it does

The skill provides coding agents with conventions for server mutations created with the `next-safe-action` package. It explains how to report issues originated by schema checks alongside custom business logic triggered directly in backend functions.

The material details how `returnValidationErrors` interrupts execution. Because this helper throws an internal `ActionServerValidationError`, any code placed beneath it will not run.

The guide also outlines data structures returned to client components. It contrasts standard nested trees containing `_errors` properties with flat maps using `fieldErrors` and `formErrors`, ensuring the agent renders error text accurately.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add next-safe-action/skills --skill safe-action-validation-errors -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/safe-action-validation-errors/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/safe-action-validation-errors/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add next-safe-action/skills --skill safe-action-validation-errors -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/safe-action-validation-errors/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add next-safe-action/skills --skill safe-action-validation-errors -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/safe-action-validation-errors/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install next-safe-action/skills safe-action-validation-errors
```

2. **Manually: put the files in place**
- File: `.github/skills/safe-action-validation-errors/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add next-safe-action/skills --skill safe-action-validation-errors -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/next-safe-action/skills --path skills/safe-action-validation-errors
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/safe-action-validation-errors/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add next-safe-action/skills --skill safe-action-validation-errors -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/next-safe-action/skills/tree/HEAD/skills/safe-action-validation-errors/SKILL.md

## When to use it
- send custom validation messages from server actions
- render nested field errors in form markup
- attach root-level errors to an entire form
- handle flattened error payloads on the client

## Example prompts
- Write a Next.js registration action with next-safe-action and reject duplicate emails via returnValidationErrors
- Show how to display nested error messages from result.validationErrors in a form
- Add a top-level form error to my server action without targeting a specific input

## Similar
- [frontend-design](https://affpapa.org/en/nevibecode/skills/frontend-design.md) — skill · 1025790 installs
- [design-taste-frontend](https://affpapa.org/en/nevibecode/skills/design-taste-frontend.md) — skill · 678700 installs
- [prototype](https://affpapa.org/en/nevibecode/skills/prototype.md) — skill · 986201 installs
- [hyperframes](https://affpapa.org/en/nevibecode/skills/heygen-com-hyperframes.md) — skill · 1200000 installs
- [hyperframes-cli](https://affpapa.org/en/nevibecode/skills/heygen-com-hyperframes-cli.md) — skill · 1300000 installs
- [webapp-testing](https://affpapa.org/en/nevibecode/skills/webapp-testing.md) — skill · 186758 installs

From the same set: [next-safe-action/skills](https://affpapa.org/en/nevibecode/by/next-safe-action/skills.md) — 9 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
