- Home
- Skills
- Agents & Orchestration
- drf nextjs feature workflow
Works with the AI Agents you already use
drf nextjs feature workflow
Standardized workflow for building type-safe features across Django REST Framework and Next.js.
$12
drf nextjs feature workflow
Example session with this skill installed
Add a CRUD feature for 'Invoice' with a status field (Draft, Sent, Paid), total amount, and link to a Client model. I need the backend service and the TanStack Query hook.
- Read your context and instructions
- Compiled the drf nextjs feature
I have implemented the Invoice feature following the service-layer and dual-serializer patterns.
Feature Implementation: Invoice CRUD
Backend: Django Service & Serializer
# services/invoice_service.py
from decimal import Decimal
from django.db import transaction
from .models import Invoice
def create_invoice(*, client_id: int, total: Decimal, status: str = "Draft") -> Invoice:
# Business logic for invoice initialization
return Invoice.objects.create(client_id=client_id, total=total, status=status)
# serializers.py
from rest_framework import serializers
from .models import Invoice, Client
class InvoiceSerializer(serializers.ModelSerializer):
client = ClientSerializer(read_only=True)
client_id = serializers.PrimaryKeyRelatedField(
queryset=Client.objects.all(), source="client", write_only=True
)
class Meta:
model = Invoice
fields = ["id", "client", "client_id", "total", "status", "created_at"]
read_only_fields = ["id", "created_at"]
Frontend: Zod Schema & API Hook
// lib/schemas/invoice.ts
import { z } from "zod";
export const InvoiceSchema = z.object({
id: z.number(),
total: z.string(), // API returns Decimal as string
status: z.enum(["Draft", "Sent", "Paid"]),
client: z.object({ id: z.number(), name: z.string() }),
created_at: z.string().datetime(),
});
export const InvoiceInputSchema = z.object({
client_id: z.number(),
total: z.string(),
status: z.enum(["Draft", "Sent", "Paid"]),
});
// lib/api/hooks/use-invoices.ts
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
export const invoiceKeys = {
all: ["invoices"] as const,
list: (filters: any) => [...invoiceKeys.all, "list", filters] as const,
};
export function useCreateInvoice() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async (data: z.infer<typeof InvoiceInputSchema>) => {
const res = await fetch("/api/invoices/", {
method: "POST",
body: JSON.stringify(data),
});
return InvoiceSchema.parse(await res.json());
},
onSuccess: () => queryClient.invalidateQueries({ queryKey: invoiceKeys.all }),
});
}
Next steps
- Run
python manage.py makemigrationsto create the Invoice model table. - Register the
InvoiceViewSetinurls.pyusing the standard router. - Implement the
InvoiceFormcomponent usingInvoiceInputSchemafor validation.
Connects securely to your tools. The creator never sees your data.
About this skill
Building features across a decoupled stack often leads to broken contracts, missing tests, and logic leaking into the wrong layers. This skill enforces a strict, end-to-end workflow for adding features to Django REST Framework (DRF) and Next.js codebases, ensuring data integrity from the database to the React component.
What it does
- Database modeling implements models using standardized mixins for auditing and soft deletes while enforcing proper decimal types for currency.
- Dual-pattern serialization configures read-only nested serializers and write-only ID fields to prevent frontend consumption errors.
- Service layer enforcement moves business logic out of ViewSets and into stateless service functions for better testability.
- Type-safe frontend hooks generates Zod schemas and TanStack Query hooks that parse API responses to catch shape drift early.
- Query optimization applies
select_relatedandprefetch_relatedautomatically to prevent N+1 query issues in new endpoints.
How it works
- Define the contract by specifying the resource name, URL patterns, and field mappings for both read and write operations.
- Execute backend tasks including model creation, migration generation, service logic, and ViewSet registration with explicit permissions.
- Verify backend quality by running the test suite, Ruff linting, and Mypy type checks to ensure zero warnings.
- Implement frontend layers starting with Zod schemas and moving through API hooks to React Hook Form integration and page composition.
- Finalize the feature by verifying cache invalidation signals and ensuring both backend and frontend quality gates are green.
Frameworks & tools
This tool is designed for Django, Django REST Framework, and PostgreSQL on the backend, paired with Next.js (App Router), TypeScript, TanStack Query, Zod, and React Hook Form on the frontend.
Why this beats prompting it yourself
Generic prompts often result in logic-heavy ViewSets and frontend hooks that lack proper error handling or cache invalidation. This skill enforces a specific service-layer architecture and a "mock only external boundaries" testing policy that ensures your features are production-ready, not just functional.
Use cases
- Add a complete CRUD feature for a new domain entity from DB migration to dashboard page.
- Expose existing backend logic through a new API action and consume it in a Next.js client.
- Refactor a messy ViewSet into a clean service-layer architecture with accompanying integration tests.
- Sync frontend TypeScript types with backend serializer changes to prevent runtime crashes.
Known limitations
Does not support FastAPI, Flask, or Django templates without DRF. Frontend implementation is specific to Next.js App Router and will not work for Pages Router or Vite-only setups.
Requires Django REST Framework and Next.js App Router. Does not support FastAPI, Flask, or Node.js backends. Logic is optimized for PostgreSQL and TanStack Query.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 11 days ago
Requires