---
name: nextjs
description: This skill should be used every time you work on Next.js projects or Next.js app code changes in this repository.
compatibility: opencode
title: nextjs
canonical_url: https://skilld.dev/gh/alpha-innovation-labs/opennexus-rs/nextjs
last_updated: 2026-10-06T18:42:02.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install alpha-innovation-labs/opennexus-rs/nextjs`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/nextjs`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/alpha-innovation-labs/opennexus-rs/nextjs) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/nextjs`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/nextjs --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/nextjs --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Next.js Project Structure Rules

This file defines the preferred Next.js project organization for this repo, constrained to folder names that appear in the official Bulletproof React project structure.

## Core Principles

1. Organize by feature and domain, not by file type.
2. Keep app-level orchestration in `app/` only.
3. Treat `features/` as the primary unit of change and ownership.
4. Share across features through top-level `components/`, `hooks/`, `lib/`, `types/`, `utils/`, and `config/`, never by reaching into another feature.
5. Keep feature boundaries explicit: local UI, logic, API calls, state, types, and utilities live together.
6. **Always use `next/link` for internal navigation** - never use `<a href="...">` for internal routes.

## Server Logging (MANDATORY)

1. All server logs must be written to a gitignored project-local directory.
2. Use `pino` as the approved server logging library.

## E2E Testing (MANDATORY)

1. Browser/runtime E2E testing must always use the `agent-browser` skill.
2. The `agent-browser` requirement is strict; do not substitute ad-hoc/manual browser testing.
3. If a server is already running, do not kill it just to rerun tests.

## Tailwind CSS v4 (MANDATORY)

**Tailwind CSS v4 is the only permitted CSS framework.**

### Strict Rules

1. **v4 only** - use current Tailwind v4 setup, not older Tailwind patterns.
2. **No CSS-in-JS** - no styled-components, Emotion, or CSS modules.
3. **No inline styles** - use Tailwind utility classes.
4. **Component patterns** - compose complex styles with utility classes instead of custom class systems.
5. **Arbitrary values** - use square bracket notation for one-off values such as `w-[300px]`.
6. **clsx/tailwind-merge** - use `clsx` and `tailwind-merge` for conditional classes.

### Anti-Patterns (NEVER DO THESE)

- Using styled-components, Emotion, or similar
- Using `@apply` to extract classes
- Using inline `style` props
- Mixing Tailwind with other CSS solutions

## Top-Level Layout

```text
src/
├── app/          # application layer
├── assets/       # static assets
├── components/   # shared components
├── config/       # global configuration
├── features/     # feature based modules
├── hooks/        # shared hooks
├── lib/          # reusable libraries
├── stores/       # global state stores
├── testing/      # test utilities and mocks
├── types/        # shared types
└── utils/        # shared utility functions
```

## Folder Semantics

- `app/`: application glue and composition only.
  - `routes/`, `app.tsx`, `provider.tsx`, `router.tsx`
- `features/`: each feature is a self-contained folder.
  - `features/awesome-feature/`
- `components/`: shared components used across the application.
- `hooks/`: shared hooks used across the application.
- `lib/`: reusable libraries preconfigured for the application.
- `types/`: shared types used across the application.
- `utils/`: shared utility functions.
- `config/`: global configuration and exported environment variables.
- `assets/`: static assets such as images and fonts.
- `stores/`: global state stores.
- `testing/`: test utilities and mocks.

## Feature Structure (Bulletproof)

Each feature owns its UI, logic, and API integration. Add only what the feature needs.

```text
src/features/awesome-feature/
├── api/         # exported API request declarations and API hooks
├── assets/      # feature-specific static assets
├── components/  # feature-scoped UI
├── hooks/       # feature-scoped hooks
├── stores/      # feature state stores
├── types/       # feature types
└── utils/       # feature utilities
```

## Feature Size And Atomicity

Features must stay small, focused, and explainable in one sentence. Avoid turning a single feature into a god-folder that owns multiple unrelated responsibilities.

When a feature grows too large, split it into smaller atomic features using flat names under `features/`:

```text
features/<feature-name>-<subfeature>/
```

This keeps boundaries explicit without introducing an extra architectural layer that Bulletproof React does not define.

Good examples:

- `features/chat-panel-transcript/`
- `features/chat-panel-sidebar/`
- `features/chat-panel-summary/`
- `features/conversation-list/`
- `features/conversation-search/`

Avoid splitting by arbitrary file type or low-level implementation detail.

Less useful examples:

- `features/chat-panel-buttons/`
- `features/chat-panel-utils/`
- `features/chat-panel-misc/`

Use a separate feature when the code has its own UI, logic, state, API interaction, or user-facing responsibility. Keep code nested inside an existing feature when it is only a private implementation detail of that feature.

Rules of thumb:

1. If a feature has multiple distinct user-facing responsibilities, split it.
2. If a folder needs many unrelated components, hooks, stores, and types, split it.
3. If a piece can be understood, tested, and replaced on its own, it can likely be its own feature.
4. Keep cross-feature imports forbidden; compose features at the `app/` layer.

## File Naming

1. Use `kebab-case` for folders and files.
2. Filename matches the primary component or concern.
3. One logical concern per file.

## Import Rules

1. `features/` can import from `components/`, `hooks/`, `lib/`, `types/`, `utils/`, `config/`, and `stores/`.
2. `components/`, `hooks/`, `lib/`, `types/`, `utils/`, `config/`, and `stores/` never import from `features/`.
3. Cross-feature imports are forbidden; compose features at the `app/` layer.

## Example Structure

```text
src/
├── app/
│   ├── routes/
│   ├── app.tsx
│   ├── provider.tsx
│   └── router.tsx
├── assets/
├── components/
├── config/
├── features/
│   └── awesome-feature/
│       ├── api/
│       ├── assets/
│       ├── components/
│       ├── hooks/
│       ├── stores/
│       ├── types/
│       └── utils/
├── hooks/
├── lib/
├── stores/
├── testing/
├── types/
└── utils/
```
