Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    drf nextjs feature workflow

    1

    Standardized workflow for building type-safe features across Django REST Framework and Next.js.

    $12

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    drf nextjs feature workflow

    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

    1. Run python manage.py makemigrations to create the Invoice model table.
    2. Register the InvoiceViewSet in urls.py using the standard router.
    3. Implement the InvoiceForm component using InvoiceInputSchema for 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_related and prefetch_related automatically to prevent N+1 query issues in new endpoints.

    How it works

    1. Define the contract by specifying the resource name, URL patterns, and field mappings for both read and write operations.
    2. Execute backend tasks including model creation, migration generation, service logic, and ViewSet registration with explicit permissions.
    3. Verify backend quality by running the test suite, Ruff linting, and Mypy type checks to ensure zero warnings.
    4. Implement frontend layers starting with Zod schemas and moving through API hooks to React Hook Form integration and page composition.
    5. 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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

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

    Git

    Permissions

    Terminal / Shell
    Network Access
    Read Files
    Environment Variables
    Listed11 days ago

    What's inside

    Frequently Asked Questions

    It solves the 'broken contract' problem by enforcing a unified workflow that links Django models, service-layer logic, and Zod-validated TanStack Query hooks in one automated process.

    This skill is designed for advanced LLMs like GPT-4o and Claude 3.5 Sonnet that support file-system manipulation and multi-step reasoning across Python and TypeScript environments.

    No, this skill is specifically optimized for the Next.js App Router; it does not support legacy Pages Router setups or non-Django backends like FastAPI.

    You receive the core agentic workflow instructions, a set of standardized Django mixins, and the configuration templates for generating type-safe TanStack Query hooks.

    The skill is built to work with existing Django/Next.js projects that follow standard conventions, though it performs best when you allow it to initialize its preferred service-layer structure.

    Unlike generic prompts, this skill enforces 'Service Layer' architecture, moving logic out of ViewSets to ensure your code remains testable and scalable as your application grows.

    New in Agents & Orchestration