# server-actions

This Claude Code rule guides the choice between Server Actions and API routes for reading or changing data. It applies when an agent writes server-side application logic.

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 1120 repo stars
- Author: rerun-build
- License: AGPL-3.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/rerun-build/rerun/tree/HEAD/apps/ui/.cursor/rules/server-actions.mdc
- Updated: 2026-11-16
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/server-actions

## What it does

The rule steers data reads and mutations toward Server Actions rather than API routes. An action is marked with `'use server'` at file or function scope.

Actions belong either in an `actions.ts` file beside their component or in the shared `@/actions/` directory. API routes are reserved for external webhooks, REST endpoints required by third-party services, and cases that need explicit control over HTTP headers or status codes.

## Install

### Cursor (native platform)

**Manually: put the files in place**
- File: `.cursor/rules/server-actions.mdc` — Frontmatter: description, globs, alwaysApply

### Claude Code

**Manually: put the files in place**
- File: `.claude/rules/server-actions.md` — The paths frontmatter field limits the files: move globs from the source into paths

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/server-actions.instructions.md` — The applyTo field sets which files it applies to: move globs from the source into applyTo

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/server-actions.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/server-actions.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/rerun-build/rerun/tree/HEAD/apps/ui/.cursor/rules/server-actions.mdc

## When to use it
- choose a server-side approach for fetching data
- handle a mutation with a Server Action
- place actions alongside a component or in a shared folder
- keep an API route for an external webhook

## Example prompts
- Add a server-side action to save settings and choose between Server Actions and API routes.
- Move this data read from an API route to a Server Action.
- Create a webhook endpoint that needs custom HTTP status codes.

## Similar
- [github-actions-templates](https://affpapa.org/en/nevibecode/skills/github-actions-templates.md) — skill · 17420 installs
- [github-actions](https://affpapa.org/en/nevibecode/skills/github-actions.md) — skill · 12400 installs
- [agentic-actions-auditor](https://affpapa.org/en/nevibecode/skills/agentic-actions-auditor.md) — skill · 7400 installs
- [provider-actions](https://affpapa.org/en/nevibecode/skills/provider-actions.md) — skill · 4100 installs
- [convex-http-actions](https://affpapa.org/en/nevibecode/skills/convex-http-actions.md) — skill · 2700 installs
- [github-actions-hardening](https://affpapa.org/en/nevibecode/skills/github-actions-hardening.md) — skill · 2200 installs

From the same set: [rerun-build/rerun](https://affpapa.org/en/nevibecode/by/rerun-build/rerun.md) — 25 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
