Agent skill

Server Actions

by davepoon in davepoon/buildwithclaude

This skill should be used when the user asks about "Server Actions", "form handling in Next.js", "mutations", "useFormState", "useFormStatus", "revalidatePath", "revalidateTag", or needs guidance on…

MITAuto-check passedFrontend & Design

Install Server Actions

skills CLI
$ npx skills add davepoon/buildwithclaude --skill server-actions -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install davepoon/buildwithclaude server-actions --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/davepoon/buildwithclaude.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/nextjs-expert/skills/server-actions .claude/skills/server-actions && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
server-actions
GitHub stars
3.6k
Used in
1 other repo
Token cost
~1.9k tokens
SKILL.md length
156 words
Files
4 (incl. references)
Skills in repo
245
Repo updated
First seen
Licence
MIT

At a glance

This skill should be used when the user asks about "Server Actions", "form handling in Next.js", "mutations", "useFormState", "useFormStatus", "revalidatePath", "revalidateTag", or needs guidance on…

  • Works in 4 steps: Always validate input - Never trust… → Check authentication - Verify user is… → Use CSRF protection - Built-in with… → …
  • Asks about Server Actions
  • SKILL.md covers Overview, Defining Server Actions, Form Handling and useFormState Hook, plus 8 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Server Actions is an agent skill from davepoon/buildwithclaude. This skill should be used when the user asks about "Server Actions", "form handling in Next.js", "mutations", "useFormState", "useFormStatus", "revalidatePath", "revalidateTag", or needs guidance on data mutations and form submissions in Next.js App Router.

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files, including reference files (for example `examples/mutation-patterns.md`, `references/form-handling.md` and `references/revalidation.md`).

It sits in Frontend & Design, covering Forms and validation. It works with Next.js. The repository describes itself as: A single hub to find Claude Skills, Agents, Commands, Hooks, Plugins, and Marketplace collections to extend Claude Code, Claude Desktop, Agent SDK and OpenClaw. The licence is MIT.

When your agent uses it

  • Asks about Server Actions
  • Form handling in Next.js
  • Needs guidance on data mutations and form submissions in Next.js App Router

Example prompts

  • “Server Actions”
  • “form handling in Next.js”
  • “mutations”
  • “/server-actions”

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Always validate input - Never trust client data
  2. Check authentication - Verify user is authorized
  3. Use CSRF protection - Built-in with Server Actions
  4. Sanitize output - Prevent XSS attacks

What it can do on your machine

Read from SKILL.md and the folder at commit 10bfc43. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Server Actions loads about 1.9k tokens when it runs, and up to ~7.2k if it reads all its reference files. Until then it costs about 68 tokens; SKILL.md has 156 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~68
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from davepoon/buildwithclaude at commit 10bfc43, republished under its MIT licence (© davepoon). 156 words, ~1,912 tokens.

Download SKILL.mdSave it as .claude/skills/server-actions/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
server-actions
description
This skill should be used when the user asks about "Server Actions", "form handling in Next.js", "mutations", "useFormState", "useFormStatus", "revalidatePath", "revalidateTag", or needs guidance on data mutations and form submissions in Next.js App Router.
version
1.0.0

Next.js Server Actions

Overview

Server Actions are asynchronous functions that execute on the server. They can be called from Client and Server Components for data mutations, form submissions, and other server-side operations.

Defining Server Actions

In Server Components

Use the 'use server' directive inside an async function:

tsx
// app/page.tsx (Server Component)
export default function Page() {
  async function createPost(formData: FormData) {
    'use server'
    const title = formData.get('title') as string
    await db.post.create({ data: { title } })
  }

  return (
    <form action={createPost}>
      <input name="title" />
      <button type="submit">Create</button>
    </form>
  )
}
In Separate Files

Mark the entire file with 'use server':

tsx
// app/actions.ts
'use server'

export async function createPost(formData: FormData) {
  const title = formData.get('title') as string
  await db.post.create({ data: { title } })
}

export async function deletePost(id: string) {
  await db.post.delete({ where: { id } })
}

Form Handling

Basic Form
tsx
// app/actions.ts
'use server'

export async function submitContact(formData: FormData) {
  const name = formData.get('name') as string
  const email = formData.get('email') as string
  const message = formData.get('message') as string

  await db.contact.create({
    data: { name, email, message }
  })
}

// app/contact/page.tsx
import { submitContact } from '@/app/actions'

export default function ContactPage() {
  return (
    <form action={submitContact}>
      <input name="name" required />
      <input name="email" type="email" required />
      <textarea name="message" required />
      <button type="submit">Send</button>
    </form>
  )
}
With Validation (Zod)
tsx
// app/actions.ts
'use server'

import { z } from 'zod'

const schema = z.object({
  email: z.string().email(),
  password: z.string().min(8),
})

export async function signup(formData: FormData) {
  const parsed = schema.safeParse({
    email: formData.get('email'),
    password: formData.get('password'),
  })

  if (!parsed.success) {
    return { error: parsed.error.flatten() }
  }

  await createUser(parsed.data)
  return { success: true }
}

useFormState Hook

Handle form state and errors:

tsx
// app/signup/page.tsx
'use client'

import { useFormState } from 'react-dom'
import { signup } from '@/app/actions'

const initialState = {
  error: null,
  success: false,
}

export default function SignupPage() {
  const [state, formAction] = useFormState(signup, initialState)

  return (
    <form action={formAction}>
      <input name="email" type="email" />
      <input name="password" type="password" />
      {state.error && (
        <p className="text-red-500">{state.error}</p>
      )}
      <button type="submit">Sign Up</button>
    </form>
  )
}

// app/actions.ts
'use server'

export async function signup(prevState: any, formData: FormData) {
  const email = formData.get('email') as string

  if (!email.includes('@')) {
    return { error: 'Invalid email', success: false }
  }

  await createUser({ email })
  return { error: null, success: true }
}

useFormStatus Hook

Show loading states during submission:

tsx
// components/submit-button.tsx
'use client'

import { useFormStatus } from 'react-dom'

export function SubmitButton() {
  const { pending } = useFormStatus()

  return (
    <button type="submit" disabled={pending}>
      {pending ? 'Submitting...' : 'Submit'}
    </button>
  )
}

// Usage in form
import { SubmitButton } from '@/components/submit-button'

export default function Form() {
  return (
    <form action={submitAction}>
      <input name="title" />
      <SubmitButton />
    </form>
  )
}

Revalidation

revalidatePath

Revalidate a specific path:

tsx
'use server'

import { revalidatePath } from 'next/cache'

export async function createPost(formData: FormData) {
  await db.post.create({ data: { ... } })

  // Revalidate the posts list page
  revalidatePath('/posts')

  // Revalidate a dynamic route
  revalidatePath('/posts/[slug]', 'page')

  // Revalidate all paths under /posts
  revalidatePath('/posts', 'layout')
}
revalidateTag

Revalidate by cache tag:

tsx
// Fetching with tags
const posts = await fetch('https://api.example.com/posts', {
  next: { tags: ['posts'] }
})

// Server Action
'use server'

import { revalidateTag } from 'next/cache'

export async function createPost(formData: FormData) {
  await db.post.create({ data: { ... } })
  revalidateTag('posts')
}

Redirects After Actions

tsx
'use server'

import { redirect } from 'next/navigation'

export async function createPost(formData: FormData) {
  const post = await db.post.create({ data: { ... } })

  // Redirect to the new post
  redirect(`/posts/${post.slug}`)
}

Optimistic Updates

Update UI immediately while action completes:

tsx
'use client'

import { useOptimistic } from 'react'
import { addTodo } from '@/app/actions'

export function TodoList({ todos }: { todos: Todo[] }) {
  const [optimisticTodos, addOptimisticTodo] = useOptimistic(
    todos,
    (state, newTodo: string) => [
      ...state,
      { id: 'temp', title: newTodo, completed: false }
    ]
  )

  async function handleSubmit(formData: FormData) {
    const title = formData.get('title') as string
    addOptimisticTodo(title) // Update UI immediately
    await addTodo(formData)  // Server action
  }

  return (
    <>
      <form action={handleSubmit}>
        <input name="title" />
        <button>Add</button>
      </form>
      <ul>
        {optimisticTodos.map(todo => (
          <li key={todo.id}>{todo.title}</li>
        ))}
      </ul>
    </>
  )
}

Non-Form Usage

Call Server Actions programmatically:

tsx
'use client'

import { deletePost } from '@/app/actions'

export function DeleteButton({ id }: { id: string }) {
  return (
    <button onClick={() => deletePost(id)}>
      Delete
    </button>
  )
}

Error Handling

tsx
'use server'

export async function createPost(formData: FormData) {
  try {
    await db.post.create({ data: { ... } })
    return { success: true }
  } catch (error) {
    if (error instanceof PrismaClientKnownRequestError) {
      if (error.code === 'P2002') {
        return { error: 'A post with this title already exists' }
      }
    }
    return { error: 'Failed to create post' }
  }
}

Security Considerations

  1. Always validate input - Never trust client data
  2. Check authentication - Verify user is authorized
  3. Use CSRF protection - Built-in with Server Actions
  4. Sanitize output - Prevent XSS attacks
tsx
'use server'

import { auth } from '@/lib/auth'

export async function deletePost(id: string) {
  const session = await auth()

  if (!session) {
    throw new Error('Unauthorized')
  }

  const post = await db.post.findUnique({ where: { id } })

  if (post.authorId !== session.user.id) {
    throw new Error('Forbidden')
  }

  await db.post.delete({ where: { id } })
}

Resources

For detailed patterns, see:

  • references/form-handling.md - Advanced form patterns
  • references/revalidation.md - Cache revalidation strategies
  • examples/mutation-patterns.md - Complete mutation examples

© davepoon, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in plugins/nextjs-expert/skills/server-actions of davepoon/buildwithclaude.

  • SKILL.md
  • examples/mutation-patterns.md
  • references/form-handling.md
  • references/revalidation.md

Open the folder on GitHubat commit 10bfc43

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in davepoon/buildwithclaude, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Server Actions next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Server Actions compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Server Actions this skilldavepoon/buildwithclaude3.6k1 repos~1.9kAutomated safety check: PassMIT
Buzzformbuildnbuzz/buzzform101—~1.5kAutomated safety check: PassMIT
Frontend Patterns Templatebybren-llc/safe-agentic-workflow421—~2kAutomated safety check: PassMIT
Zod Validation Expertdavila7/claude-code-templates32k3 repos~2.4kAutomated safety check: PassMIT
Shadcn UIjh941213/my-cc-harness1264 repos~9.7kAutomated safety check: NotesMIT
Fp TS Reactaiskillstore/marketplace4305 repos~4.8kAutomated safety check: PassNone

Similar skills

  • Buzzform

    buildnbuzz/buzzform

    A skill your agent uses when working with BuzzForm schema-driven forms, @buildnbuzz/form-core, @buildnbuzz/form-react, or any related APIs like defineSchema, InferType, FormProvider, useDataField…

    101 GitHub stars~1.5k tokensUpdated 4 mo ago
    Frontend & DesignAuto-check passed
  • Frontend Patterns Template

    bybren-llc/safe-agentic-workflow

    Frontend patterns for modern web frameworks, component libraries, auth flows, and analytics. Use when building UI components, creating pages, implementing…

    421 GitHub stars~2k tokensUpdated 2 mo ago
    Frontend & DesignAuto-check passed
  • Zod Validation Expert

    davila7/claude-code-templates

    Expert in Zod — TypeScript-first schema validation. An agent skill from davila7/claude-code-templates.

    32k GitHub starsUsed in 3 repos~2.4k tokens
    Frontend & DesignAuto-check passed
  • Shadcn UI

    jh941213/my-cc-harness

    Complete shadcn/ui component library guide including installation, configuration, and implementation of accessible React components.

    126 GitHub starsUsed in 4 repos~9.7k tokens
    Frontend & DesignAuto-check: notes
  • Fp TS React

    aiskillstore/marketplace

    Practical patterns for using fp-ts with React - hooks, state, forms, data fetching.

    430 GitHub starsUsed in 5 repos~4.8k tokens
    Frontend & DesignAuto-check passed
  • Frontend Development

    avibebuilder/claude-prime

    A skill your agent uses for ANY work involving React, Next.js, TypeScript, or Tailwind in the browser layer.

    120 GitHub stars~1.3k tokensUpdated 4 mo ago
    Frontend & DesignAuto-check passed

More from davepoon/buildwithclaude

All 245 skills in this repo
  • Qwen Vision

    davepoon/buildwithclaude

    A skill your agent uses when the user asks to "analyze video", "watch this video", "what happens in this video", "describe this clip", "review this footage", "classify these videos", "compare…

    3.6k GitHub starsUsed in 1 repo~1.2k tokens
    Auto-check passed
  • Hard Predict Future

    davepoon/buildwithclaude

    Activate this agent for any future-oriented question that requires deep quantitative analysis, historical precedents, and structured scenario planning.

    3.6k GitHub starsUsed in 1 repo~4.2k tokens
    Auto-check passed
  • iOS Hig Design Guide

    davepoon/buildwithclaude

    Build, update, and apply iOS design specifications using Apple Human Interface Guidelines (HIG) source data.

    3.6k GitHub stars~735 tokensUpdated 2 days ago
    Auto-check passed
  • Video Downloader

    davepoon/buildwithclaude

    Download YouTube videos with customizable quality and format options.

    3.6k GitHub starsUsed in 1 repo~871 tokens
    Auto-check passed
  • Atlas Cloud Media

    davepoon/buildwithclaude

    Discover Atlas Cloud image and video models, inspect their live schemas, and submit one confirmed media generation request with bounded GET polling.

    3.6k GitHub stars~852 tokensUpdated 2 days ago
    Auto-check passed
  • Slack Gif Creator

    davepoon/buildwithclaude

    Toolkit for creating animated GIFs optimized for Slack, with validators for size constraints and composable animation primitives.

    3.6k GitHub starsUsed in 12 repos~4.3k tokens
    Auto-check passed

Works with

Questions about Server Actions

What does Server Actions do?

This skill should be used when the user asks about "Server Actions", "form handling in Next.js", "mutations", "useFormState", "useFormStatus", "revalidatePath", "revalidateTag", or needs guidance on…. Server Actions is an agent skill from davepoon/buildwithclaude.js App Router.

When should I use Server Actions?

Server Actions fits situations like: asks about Server Actions; form handling in Next.js; needs guidance on data mutations and form submissions in Next.js App Router.

How do I install Server Actions in Claude Code?

Run `npx skills add davepoon/buildwithclaude --skill server-actions -a claude-code`. Or copy the skill folder (plugins/nextjs-expert/skills/server-actions in davepoon/buildwithclaude) into .claude/skills/server-actions in your project. Claude Code loads it when a task matches its description.

How do I install Server Actions in Codex?

Run `npx skills add davepoon/buildwithclaude --skill server-actions -a codex`. Or copy the skill folder (plugins/nextjs-expert/skills/server-actions in davepoon/buildwithclaude) into .agents/skills/server-actions in your project. Codex loads it when a task matches its description.

Can I use Server Actions in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add davepoon/buildwithclaude --skill server-actions -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/server-actions, .gemini/skills/server-actions, .github/skills/server-actions and .opencode/skills/server-actions in your project.

What does Server Actions need to run?

SKILL.md names no scripts, command-line tools or credentials: Server Actions is instructions for the agent only.

Does Server Actions access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Server Actions safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Server Actions use?

Server Actions is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Server Actions use?

About 1.9k tokens (SKILL.md is roughly 7.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 5.3k tokens, read only when the agent opens those files.

What are the alternatives to Server Actions?

Skills that share tags, products or a category with Server Actions: Buzzform (buildnbuzz/buzzform, 101 stars), Frontend Patterns Template (bybren-llc/safe-agentic-workflow, 421 stars), Zod Validation Expert (davila7/claude-code-templates, 32k stars) and Shadcn UI (jh941213/my-cc-harness, 126 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Server Actions?

davepoon (a GitHub user) maintains it in davepoon/buildwithclaude, which has 3,604 GitHub stars. The repository holds 245 skills in this directory. The repository was last updated on October 6, 2026.

Source: davepoon/buildwithclaude on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.