Provides a dedicated reference guide per SOLID letter (SRP file-splitting, OCP composition/plugin patterns, LSP contract compliance, ISP role-based interfaces, DIP constructor injection/factories) plus 23 ready-to-copy templates covering components, hooks, services, stores, Server Actions, API routes, validators, Prisma singletons, i18n, and queries. This is a cross-cutting code-quality skill, not a feature skill — for the framework APIs themselves see nextjs-16 and its sibling skills.
SOLID Next.js - Modular Architecture
Current Date (CRITICAL)
Today: January 2026 - ALWAYS use the current year for your searches.
Search with "2025" or "2026", NEVER with past years.
MANDATORY: Research Before Coding
CRITICAL: Check today's date first, then search documentation and web BEFORE writing any code.
- Use Context7 to query Next.js/React official documentation
- Use Exa web search with current year for latest trends
- Check Vercel Blog of current year for new features
- Verify package versions for Next.js 16 compatibility
Search queries (replace YYYY with current year):
Next.js [feature] YYYY best practices
React 19 [component] YYYY
TypeScript [pattern] YYYY
Prisma 7 [feature] YYYY
Codebase Analysis (MANDATORY)
Before ANY implementation:
- Explore project structure to understand architecture
- Read existing related files to follow established patterns
- Identify naming conventions, coding style, and patterns used
- Understand data flow and dependencies
DRY - Reuse or Create Shared (MANDATORY)
Before writing ANY new code:
- Grep the codebase for similar function names, patterns, or logic
- Check shared locations:
modules/cores/lib/, modules/cores/components/, modules/cores/hooks/
- If similar code exists → extend/reuse instead of duplicate
- If code will be used by 2+ features → create it in
modules/cores/ directly
- Extract repeated logic (3+ occurrences) into shared helpers
- Run
npx jscpd ./src --threshold 3 after creating new files
Agent Workflow (MANDATORY)
Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:
- fuse-ai-pilot:explore-codebase - Analyze project structure and existing patterns
- fuse-ai-pilot:research-expert - Verify latest docs for all stack technologies
- mcp__context7__query-docs - Check integration compatibility
After implementation, run fuse-ai-pilot:sniper for validation.
Absolute Rules (MANDATORY)
1. Files < 100 lines
- Split at 90 lines - Never exceed 100
- Page components < 50 lines (use composition)
- Server Components < 80 lines
- Client Components < 60 lines
- Server Actions < 30 lines each
2. Modular Architecture
See references/architecture-patterns.md for complete structure with feature modules and cores directory.
3. JSDoc Mandatory
/**
* Fetch user by ID from database.
*
* @param id - User unique identifier
* @returns User object or null if not found
* @throws DatabaseError on connection failure
*/
export async function getUserById(id: string): Promise<User | null>
4. Interfaces Separated
modules/auth/src/
├── interfaces/ # Types ONLY
│ ├── user.interface.ts
│ └── session.interface.ts
├── services/ # NO types here
└── components/ # NO types here
SOLID Principles (Detailed Guides)
Each SOLID principle has a dedicated reference guide:
references/single-responsibility.md - One class/function = one reason to change
- File splitting at 90 lines (pages < 50, components < 60, services < 80)
- Component composition patterns
- Next.js page & server action examples
references/open-closed.md - Extend via composition, not modification
- Plugin architecture patterns
- Provider patterns for multiple implementations
- Adapter and strategy patterns
- Adding features without changing existing code
references/liskov-substitution.md - Contract compliance & behavioral subtyping
- Subtypes must be substitutable for base types
- Exception and return type contracts
- Testing LSP compliance
references/interface-segregation.md - Many focused interfaces beat one fat interface
- Role-based interfaces
- Avoiding bloated contracts
- Client-specific interfaces
references/dependency-inversion.md - Depend on abstractions, not implementations
- Constructor injection patterns
- Factory patterns for creation
- IoC containers
- Easy mocking for tests
See references/solid-principles.md for overview and quick reference.
Code Templates
Ready-to-copy code in references/templates/:
| Template |
Usage |
server-component.md |
Server Component with data fetching |
client-component.md |
Client Component with hooks |
service.md |
Service with dependency injection |
hook.md |
React hook with state |
interface.md |
TypeScript interfaces |
store.md |
Zustand store with persistence |
action.md |
Server Action with validation |
api-route.md |
API Route Handler |
validator.md |
Zod validation schemas |
factory.md |
Factory pattern |
adapter.md |
Adapter pattern |
error.md |
Custom error classes |
test.md |
Test templates |
middleware.md |
Auth middleware |
prisma.md |
Prisma singleton |
i18n.md |
Feature/global translations |
query.md |
Database queries (Prisma 7) |
Response Guidelines
- Research first - MANDATORY: Search Context7 + Exa before ANY code
- Show complete code - Working examples, not snippets
- Explain decisions - Why this pattern over alternatives
- Include tests - Always suggest test cases
- Handle errors - Never ignore, use error boundaries
- Type everything - Full TypeScript, no
any
- Document code - JSDoc for complex functions
Forbidden
- ❌ Coding without researching docs first (ALWAYS research)
- ❌ Using outdated APIs without checking current year docs
- ❌ Files > 100 lines
- ❌ Interfaces in component files
- ❌ Business logic in
app/ pages
- ❌ Direct DB calls in components
- ❌ Module importing another module (except cores)
- ❌
'use client' by default
- ❌
useEffect for data fetching
- ❌ Missing JSDoc on exports
- ❌
any type
- ❌ Barrel exports
- ❌ Duplicating existing utility/helper without Grep search first
- ❌ Copy-pasting logic blocks instead of extracting shared function
1---2name: solid-nextjs3description: Use when applying SOLID principles to Next.js architecture — modular structure, file size limits, interface separation, JSDoc.4version: 1.0.05user-invocable: true6references: references/solid-principles.md, references/single-responsibility.md, references/open-closed.md, references/liskov-substitution.md, references/interface-segregation.md, references/dependency-inversion.md, references/architecture-patterns.md, references/templates/server-component.md, references/templates/client-component.md, references/templates/service.md, references/templates/hook.md, references/templates/interface.md, references/templates/store.md, references/templates/action.md, references/templates/api-route.md, references/templates/validator.md, references/templates/factory.md, references/templates/adapter.md, references/templates/error.md, references/templates/test.md, references/templates/middleware.md, references/templates/prisma.md, references/templates/i18n.md, references/templates/query.md7metadata:8 source: https://skillmd.com/skills/fusengine/solid-nextjs9---1011<objective>12Enforces SOLID and DRY architecture on Next.js 16 projects: files under 100 lines (pages < 50, Server Components < 80, Client Components < 60, Server Actions < 30), types isolated in `interfaces/` directories (never in components/pages), mandatory JSDoc on exports, and the module/`modules/cores/` directory structure. Requires researching current Next.js/React/Prisma docs (via Context7/Exa with the current year) before writing any code, and grepping for existing utilities before creating new ones.1314Provides a dedicated reference guide per SOLID letter (SRP file-splitting, OCP composition/plugin patterns, LSP contract compliance, ISP role-based interfaces, DIP constructor injection/factories) plus 23 ready-to-copy templates covering components, hooks, services, stores, Server Actions, API routes, validators, Prisma singletons, i18n, and queries. This is a cross-cutting code-quality skill, not a feature skill — for the framework APIs themselves see nextjs-16 and its sibling skills.15</objective>1617# SOLID Next.js - Modular Architecture1819## Current Date (CRITICAL)2021**Today: January 2026** - ALWAYS use the current year for your searches.22Search with "2025" or "2026", NEVER with past years.2324## MANDATORY: Research Before Coding2526**CRITICAL: Check today's date first, then search documentation and web BEFORE writing any code.**27281. **Use Context7** to query Next.js/React official documentation292. **Use Exa web search** with current year for latest trends303. **Check Vercel Blog** of current year for new features314. **Verify package versions** for Next.js 16 compatibility3233**Search queries (replace YYYY with current year):**34- `Next.js [feature] YYYY best practices`35- `React 19 [component] YYYY`36- `TypeScript [pattern] YYYY`37- `Prisma 7 [feature] YYYY`3839---4041## Codebase Analysis (MANDATORY)4243**Before ANY implementation:**441. Explore project structure to understand architecture452. Read existing related files to follow established patterns463. Identify naming conventions, coding style, and patterns used474. Understand data flow and dependencies4849## DRY - Reuse or Create Shared (MANDATORY)5051**Before writing ANY new code:**521. **Grep the codebase** for similar function names, patterns, or logic532. Check shared locations: `modules/cores/lib/`, `modules/cores/components/`, `modules/cores/hooks/`543. If similar code exists → extend/reuse instead of duplicate554. If code will be used by 2+ features → create it in `modules/cores/` directly565. Extract repeated logic (3+ occurrences) into shared helpers576. Run `npx jscpd ./src --threshold 3` after creating new files5859---6061## Agent Workflow (MANDATORY)6263Before ANY implementation, spawn 3 agents in parallel, one `Agent` call each with a `name`:64651. **fuse-ai-pilot:explore-codebase** - Analyze project structure and existing patterns662. **fuse-ai-pilot:research-expert** - Verify latest docs for all stack technologies673. **mcp__context7__query-docs** - Check integration compatibility6869After implementation, run **fuse-ai-pilot:sniper** for validation.7071---7273## Absolute Rules (MANDATORY)7475### 1. Files < 100 lines7677- **Split at 90 lines** - Never exceed 10078- Page components < 50 lines (use composition)79- Server Components < 80 lines80- Client Components < 60 lines81- Server Actions < 30 lines each8283### 2. Modular Architecture8485See `references/architecture-patterns.md` for complete structure with feature modules and cores directory.8687### 3. JSDoc Mandatory8889```typescript90/**91 * Fetch user by ID from database.92 *93 * @param id - User unique identifier94 * @returns User object or null if not found95 * @throws DatabaseError on connection failure96 */97export async function getUserById(id: string): Promise<User | null>98```99100### 4. Interfaces Separated101102```text103modules/auth/src/104├── interfaces/ # Types ONLY105│ ├── user.interface.ts106│ └── session.interface.ts107├── services/ # NO types here108└── components/ # NO types here109```110111---112113## SOLID Principles (Detailed Guides)114115Each SOLID principle has a dedicated reference guide:1161171. **`references/single-responsibility.md`** - One class/function = one reason to change118 - File splitting at 90 lines (pages < 50, components < 60, services < 80)119 - Component composition patterns120 - Next.js page & server action examples1211222. **`references/open-closed.md`** - Extend via composition, not modification123 - Plugin architecture patterns124 - Provider patterns for multiple implementations125 - Adapter and strategy patterns126 - Adding features without changing existing code1271283. **`references/liskov-substitution.md`** - Contract compliance & behavioral subtyping129 - Subtypes must be substitutable for base types130 - Exception and return type contracts131 - Testing LSP compliance1321334. **`references/interface-segregation.md`** - Many focused interfaces beat one fat interface134 - Role-based interfaces135 - Avoiding bloated contracts136 - Client-specific interfaces1371385. **`references/dependency-inversion.md`** - Depend on abstractions, not implementations139 - Constructor injection patterns140 - Factory patterns for creation141 - IoC containers142 - Easy mocking for tests143144See `references/solid-principles.md` for overview and quick reference.145146---147148## Code Templates149150Ready-to-copy code in `references/templates/`:151152| Template | Usage |153|----------|-------|154| `server-component.md` | Server Component with data fetching |155| `client-component.md` | Client Component with hooks |156| `service.md` | Service with dependency injection |157| `hook.md` | React hook with state |158| `interface.md` | TypeScript interfaces |159| `store.md` | Zustand store with persistence |160| `action.md` | Server Action with validation |161| `api-route.md` | API Route Handler |162| `validator.md` | Zod validation schemas |163| `factory.md` | Factory pattern |164| `adapter.md` | Adapter pattern |165| `error.md` | Custom error classes |166| `test.md` | Test templates |167| `middleware.md` | Auth middleware |168| `prisma.md` | Prisma singleton |169| `i18n.md` | Feature/global translations |170| `query.md` | Database queries (Prisma 7) |171172---173174## Response Guidelines1751761. **Research first** - MANDATORY: Search Context7 + Exa before ANY code1772. **Show complete code** - Working examples, not snippets1783. **Explain decisions** - Why this pattern over alternatives1794. **Include tests** - Always suggest test cases1805. **Handle errors** - Never ignore, use error boundaries1816. **Type everything** - Full TypeScript, no `any`1827. **Document code** - JSDoc for complex functions183184---185186## Forbidden187188- ❌ Coding without researching docs first (ALWAYS research)189- ❌ Using outdated APIs without checking current year docs190- ❌ Files > 100 lines191- ❌ Interfaces in component files192- ❌ Business logic in `app/` pages193- ❌ Direct DB calls in components194- ❌ Module importing another module (except cores)195- ❌ `'use client'` by default196- ❌ `useEffect` for data fetching197- ❌ Missing JSDoc on exports198- ❌ `any` type199- ❌ Barrel exports200- ❌ Duplicating existing utility/helper without Grep search first201- ❌ Copy-pasting logic blocks instead of extracting shared function