The safe-action-advanced skill enhances the next-safe-action framework with features like binding arguments and handling errors. It is aimed at developers using the next-safe-action in their applications for enhanced functionality.
$ npx skills add https://github.com/next-safe-action/skills --skill safe-action-advancedsafe-action-advanced is a skill for the next-safe-action library that provides advanced functionality for server action development in Next.js applications. It enables developers to bind arguments to actions, work with metadata schemas, handle framework-specific errors, and leverage type inference utilities for enhanced type safety. The skill integrates seamlessly with the next-safe-action ecosystem and is designed for teams building robust, type-safe server-side logic. It complements other next-safe-action skills like forms, hooks, and validation error handling to provide comprehensive server action capabilities.
Install the skill using the provided npx command.
Pass extra arguments to actions via .bind()
Attach typed metadata to actions
Handle various framework errors in actions
Infer types from action functions and middleware
$ npx skills add https://github.com/next-safe-action/skills --skill safe-action-advancedgit clone https://github.com/next-safe-action/skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Act as an expert in next-safe-action framework using the safe-action-advanced skill. Help me [IMPLEMENT/BIND/DEBUG] the next-safe-action in my [COMPANY] [APPLICATION/WEBSITE] using [SPECIFIC_FEATURE] like argument binding or error handling. Provide code snippets and best practices for [INDUSTRY] applications. Here's the current setup: [DATA]
### Safe Action Advanced Implementation Guide
**Context:** You're integrating next-safe-action into a healthcare dashboard for `MediTrack Solutions` to validate patient data submissions while ensuring HIPAA compliance.
#### 1. Argument Binding Example
```typescript
import { createSafeActionClient } from 'next-safe-action';
import { z } from 'zod';
const safeAction = createSafeActionClient({
bindServerSideState: true,
handleServerError: (error) => {
console.error('Action error:', error);
return { code: 'INTERNAL_ERROR', message: 'Failed to process request' };
}
});
const updatePatientRecord = safeAction
.schema(z.object({
patientId: z.string().min(1),
data: z.object({
bloodPressure: z.number().min(70).max(190),
temperature: z.number().min(35).max(42)
})
}))
.action(async ({ parsedInput }) => {
// Business logic here
return { success: true, updatedRecord: parsedInput };
});
```
#### 2. Error Handling Pattern
```typescript
try {
const result = await updatePatientRecord({ patientId: '123', data: { bloodPressure: 120, temperature: 37 } });
if (result.data?.success) {
console.log('Record updated:', result.data.updatedRecord);
} else {
console.warn('Action failed:', result.data?.code);
}
} catch (error) {
console.error('Unexpected error:', error);
}
#### Key Features Demonstrated:
- **Strict Input Validation:** Zod schemas ensure data quality
- **Error Boundaries:** Clean error handling without exposing internals
- **State Binding:** Server-side state preserved between actions
- **Type Safety:** Full TypeScript support throughout
Would you like me to adapt this for your specific use case or focus on a particular aspect of safe-action-advanced?Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan