next-application-structure

A guide for organising Next.js 14+ applications that use the App Router, a system where folders define web routes. It covers folders, server and browser code, data loading, updates, and tests.

In plain words
What is it for?
Use it when starting or reviewing a Next.js application, defining App Router conventions, separating features, or checking whether the architecture supports the intended React behaviour.
Why use it?
It helps prevent unclear project structure, unsafe mixing of server and browser code, and inconsistent ways of loading or changing data.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/soulcodex/agentic/next-application-structure
Any agent
npx skills add soulcodex/agentic --skill next-application-structure
Clone the repo
git clone --depth 1 https://github.com/soulcodex/agentic

Made for: Claude Code, Codex.

Per session 64 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 624 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00064 $0.00624
Opus 5 $0.00032 $0.00312
Sonnet 5 $0.00013 $0.00125
Haiku 4.5 $0.00006 $0.00062

Measured 2d ago against content hash cc50c7a525fb, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

next-application-structure scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/ui/next-application-structure/SKILL.md · 92 lines

How it starts

The opening of the file, as written. The whole thing — 92 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Next Application Structure Skill

Step 1 — App Router Directory Layout

Organise by route segment and feature ownership:

src/
  app/
    (marketing)/
      page.tsx
    (app)/
      dashboard/
        page.tsx
        loading.tsx
        error.tsx
    api/
      auth/
        route.ts
    layout.tsx
  features/
    auth/
      components/
      server/
      client/
      auth.types.ts
  components/
    ui/
  lib/
    db/
    auth/
    validation/

Step 2 — Server and Client Boundaries

  • Default to Server Components; add 'use client' only when interactivity or browser APIs are needed.
  • Keep data fetching and secrets in server modules/route handlers.
  • Pass serialized data to client components via props.
  • Avoid importing server-only modules into client components.
  • Use alias imports for cross-directory modules and ESM import/export syntax only.

Step 3 — Data Fetching and Mutations

  • Read data in Server Components when possible.
  • Use Route Handlers or Server Actions for mutations.
  • Revalidate with revalidatePath/revalidateTag after mutations.
  • Centralize schema validation (for example Zod) at request boundaries.

Step 4 — State and Caching Strategy

  • URL and route params: App Router primitives.
  • Shared client interaction state: React context or local store in client layer.
  • Remote data cache: Next fetch cache + query library only when client-side refetching is needed.

Step 5 — Testing Parity with React Stack

  • Unit and component tests: Vitest + React Testing Library.
  • E2E flows: Playwright.
  • For Server Components and route handlers, test logic in extracted server utilities where possible.

Step 6 — Verify

  • App Router segments contain page.tsx/layout.tsx and special files only where needed
  • Server-first component model is respected, with minimal 'use client'
  • Secrets and privileged logic stay server-side
  • Mutation flows trigger explicit revalidation
  • pnpm tsc --noEmit and pnpm test pass

Read the full file on GitHub · 92 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 92 lines · 64 tokens per session scan A cc50c7a525fb

Subscribe to this mod's changes

next-application-structure is a skill published in the GitHub repository soulcodex/agentic (10 stars, last pushed 2d ago), licensed MIT. It adds 64 tokens to every session and 624 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

trigger-agents

AI agent patterns with Trigger.dev - chat.agent, Sessions, AI Prompts, Trigger Agent Skills, orchestration, parallelization, routing, evaluator-optimizer, and human-in-the-loop. Use when building LLM-powered tasks that need durable AI chat, parallel workers, approval gates, tool calling, or multi-step agent workflows.

hackerai-tech/hackerai · 70 tokens

trigger-tasks

Build AI agents, workflows and durable background tasks with Trigger.dev. Use when creating tasks, triggering jobs, handling retries, scheduling cron jobs, or implementing queues and concurrency control.

hackerai-tech/hackerai · 39 tokens

hackerai-user-research

Run privacy-safe HackerAI customer research from an authorized PM question and a PostHog cohort. Use for requests to understand user types, recurring jobs, workflows, friction, value drivers, reasons to pay, or customer avatars from actual HackerAI messages, including top-spender research. Also use when a PM asks how…

hackerai-tech/hackerai · 108 tokens

trigger-realtime

Subscribe to Trigger.dev task runs in real-time from frontend and backend. Use when building progress indicators, live dashboards, streaming AI/LLM responses, or React components that display task status.

hackerai-tech/hackerai · 42 tokens

vercel-react-best-practices

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance…

hackerai-tech/hackerai · 67 tokens

logging-best-practices

Use before implementing logs in a medium to large scale production system.

hackerai-tech/hackerai · 19 tokens