Skip to main content
rule CX Codex

server-actions — Claude Code rule: what it does, how to install

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.

AGPL-3.0 ★ 1,120 updated 2026-11-16

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/server-actions.mdc
Open on GitHub

What server-actions 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.

What it helps with

  • 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 for the agent

  • 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.

How to install server-actions

Manually: put the files in place

.cursor/rules/server-actions.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about server-actions

How do I install server-actions in Claude Code?

Create .claude/rules/server-actions.md and put the rule in that file.

What does server-actions do?

It guides the agent to use Server Actions for data reads and mutations, while keeping API routes for specific cases.

When does the rule allow API routes?

For external webhooks, REST endpoints required by third-party services, or when HTTP headers and status codes need direct control.

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set25

The whole set →
create-agent-template The create-agent-template Claude Code skill turns an agent idea into a Rerun template draft. It interviews about the task, builds the agent, then tests it against challenging cases. CX Codex +1 ★ 1,120repo stars supabase This Claude Code rule sets how the agent accesses a Supabase database. It requires using @src/app/supabase/supabase-helpers.ts instead of querying tables directly. CX Codex +1 ★ 1,120repo stars no-icons-in-buttons no-icons-in-buttons — a Claude Code rule that keeps button content text-only by default. The agent adds an icon only when the user explicitly asks for one. CX Codex +1 ★ 1,120repo stars english-only The english-only Claude Code rule sets English as the language for interface copy and labels. It applies across project files. CX Codex +1 ★ 1,120repo stars input-label The input-label Claude Code rule sets how fields get their captions through the Input component. It applies to *.tsx files and disallows a separate caption above the field. CX Codex +1 ★ 1,120repo stars supabase-typed-mutations The supabase-typed-mutations Claude Code rule adds Database types to Supabase insert, update, and upsert calls. It applies while an agent works with these mutations. CX Codex +1 ★ 1,120repo stars use-shadcn This rule for Claude Code, Codex, and Cursor guides agents to reuse shadcn/ui components. When building UI, it directs them to look for existing project components first. CX Codex +1 ★ 1,120repo stars one-component-per-file The one-component-per-file Claude Code rule keeps each React component in its own file. It applies to *.tsx files. CX Codex +1 ★ 1,120repo stars

Project sponsors

Companies that keep this analytics open