skills/structuring-nextjs-app-router/SKILL.md
Standardize and preserve Next.js App Router project structure across `src/`, including route files, page composition, API modules, server actions, hooks, providers, helpers, and shared utilities. Use this skill whenever the user asks to add, move, rename, refactor, or review files in a Next.js App Router codebase, especially if the task affects file placement, page architecture, or folder naming.
npx skillsauth add ilya-valasiuk/agent-skills structuring-nextjs-app-routerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill to place new code in the correct part of a Next.js App Router repo and to keep architecture consistent during refactors.
src/app focused on routing concerns and thin route filessrc/components/<page-name>/<PageName>.tsxInspect nearby files before creating or moving anything.
Decide what kind of artifact the user needs:
Then place it using references/REFERENCE.md.
app/ thinWhen editing src/app, prefer route files that do orchestration rather than UI implementation.
page.tsx should load data, read params, call helpers/actions as needed, and render page components from src/components/...layout.tsx, template.tsx, error.tsx, loading.tsx, and not-found.tsx should stay focused on route behaviorcomponents/src/components/common/<component-name>/src/components/<page-name>/components/ subfoldersIf the task is mainly about building or restructuring React components, also follow the building-components skill if it is available.
src/apisrc/actionssrc/helperssrc/utilssrc/constants and src/typesDo not mix these concerns just because a file is convenient to reach from a page.
Follow the full placement matrix in references/REFERENCE.md.
High-value defaults:
src/app/api/**/route.tssrc/components/<page-name>/<PageName>.tsxsrc/api/<domain>/module.ts, queries.ts, and types.tssrc/actions/<domain>/index.tssrc/context/<context-name>/src/providers/<provider-name>/<ContextName>Context.tsx<ProviderName>Provider.tsxuseX.tsMatch exported names to filenames whenever practical.
When the user asks to reorganize or standardize a Next.js repo:
src/ categories unless the repo already has them or the user asked for themBefore finishing, verify:
src/apppage.tsx without a good reasonsrc/ folderExample 1
Input: "Add a new Services page in a Next.js App Router app."
Expected structure:
src/app/[[locale]]/services/page.tsxsrc/components/services/Services.tsxsrc/components/services/components/...Example 2
Input: "Create blog query hooks and fetchers."
Expected structure:
src/api/blog/module.tssrc/api/blog/queries.tssrc/api/blog/types.tssrc/api/blog/constants.tssrc/api/blog/helpers.tsAdd optional domain files when the logic clearly belongs to that domain rather than to shared API utilities.
Example 3
Input: "Add a contact form server action."
Expected structure:
src/actions/contact/index.tssrc/actions/contact/types.tssrc/actions/contact/constants.tssrc/actions/contact/helpers.tstesting
Prepare and open pull requests using the team's PR template, including a short PR title, diff-based classification into Features and Fixes, and an approval checkpoint before any push or PR creation. Use when the user asks to create, draft, preview, or open a pull request.
development
Enforces classNames package usage patterns and Tailwind CSS class ordering conventions in React components. Use this skill whenever writing or reviewing component className props, applying Tailwind classes, using the classnames package, organizing breakpoint-specific styles, writing conditional class expressions, or when the user asks about CSS class ordering, mobile-first responsive patterns, or how to handle className props in components.
testing
Explains how to create and review TypeORM migrations. Use this skill whenever the user wants to change an entity, add or update schema-related database objects, generate a migration, or decide whether a database change should be handled through TypeORM metadata or a custom migration.
development
Builds, restructures, and standardizes React components according to project conventions (placement, folder/file naming, exports, props patterns). Use when adding components or when reorganizing existing components during refactors, migrations, or component moves.