- Home
- Skills
- Frontend & Web Apps
- nextjs feature architecture
Works with the AI Agents you already use
nextjs feature architecture
Scalable feature-based architecture for Next.js App Router projects to eliminate folder clutter and circular imports.
$4.99
nextjs feature architecture
Example session with this skill installed
I need to add a checkout flow to my Next.js app. Where should I put the payment processing logic and the success page?
- Read your context and instructions
- Compiled the nextjs feature architecture
- Generated the UI component
I will help you architect the checkout feature using a domain-driven structure. This keeps your payment logic isolated from your UI and ensures your routes remain thin.
Checkout Feature Architecture
| File / Folder | Path | Responsibility |
|---|---|---|
| Route | src/app/checkout/success/page.tsx | Entry point for the success view. |
| Action | src/features/checkout/actions/process-payment.ts | Server action for Stripe/LemonSqueezy processing. |
| Query | src/features/checkout/queries/get-order-summary.ts | Server-side read for the final order state. |
| Schema | src/features/checkout/schema.ts | Zod validation for payment methods and addresses. |
| Lib | src/lib/stripe.ts | Initialized Stripe client used by the action. |
Implementation Detail
// src/features/checkout/actions/process-payment.ts
"use server"
import { stripe } from "@/lib/stripe";
import { checkoutSchema } from "../schema";
export async function processPayment(formData: FormData) {
// 1. Validate input with schema
// 2. Check auth
// 3. Call Stripe SDK from lib
// 4. Invalidate relevant tags
}
Next steps
- Create the
src/features/checkout/directory and subfolders foractionsandqueries. - Initialize your payment provider client in
src/lib/. - Map the
checkout/successroute to a clean component in the feature folder.
page.tsx
TSX · React component
Example file from a real run - the skill writes it into your workspace.
Connects securely to your tools. The creator never sees your data.
About this skill
Stop dumping every component, hook, and utility into a global folder that becomes impossible to navigate as your project grows. This skill implements a scalable, domain-driven architecture for Next.js App Router projects, ensuring your codebase remains maintainable by grouping code by business capability.
What it does
- Domain-based grouping organizes code into features like
auth,cart, orproductsinstead of technical file types. - Dependency enforcement ensures a clean flow from
apptofeaturestosharedtoliblayers. - Server/Client boundary management keeps routes thin and prevents data clients from leaking into UI components.
- Backend-agnostic integration provides clear placement for Supabase, Prisma, Drizzle, or external SDKs within the
liblayer. - Feature anatomy scaling guides the growth of features from flat files to structured subdirectories only when complexity demands it.
How it works
- Project Inspection analyzes your current
srcstructure to identify existing features and architectural patterns. - Placement Mapping determines exactly where new logic belongs, whether it is a server action, a query, or a shared UI component.
- Scaffold & Refactor generates the necessary file structure for new features or suggests targeted moves to fix circular dependencies.
- Boundary Verification checks that feature-specific state and hooks are not being illegally accessed by unrelated domains.
Frameworks & tools
Specifically designed for Next.js App Router projects using TypeScript. It works with any data layer including Prisma, Drizzle, Supabase, and standard REST/GraphQL clients.
Why this beats prompting it yourself
Generic prompts often result in "folder soup" where everything is flat in src/components. This skill applies a specific, tested hierarchy that prevents circular imports and keeps your server-side logic strictly separated from client interactivity.
Use cases
- Migrating a messy
src/componentsfolder into a clean feature-based structure. - Scaffolding a new business module with its associated queries, actions, and schemas.
- Determining if a new hook should be feature-scoped or moved to a shared utility layer.
- Refactoring fat
page.tsxfiles into thin route handlers and domain components.
Known limitations
Does not automatically restructure existing projects unless requested. It defers to official Next.js documentation for specific API syntax which varies between versions.
Does not automatically restructure legacy code without a specific request. Defer to official docs for version-specific Next.js API syntax.
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 5 days ago