Skip to content
Back to skills

Setup App Infrastructure

ASecurity

Sets up shared infrastructure in a Next.js App Router project: T3 Env validation, LogLayer logging, ServiceError plus retry helper, server action result types, cookie toasts. Use when adding or checking this infrastructure in a Next.js project; NOT for the rules (nextjs-rules) or feature scaffolding (generate-feature-package).

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 17, 2026
developmentbashnextjsnodegit

Works with

  • cli

Security analysis

A100/100

Pro scans all 13 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add JanSzewczyk/claude-plugins --skill setup-app-infrastructure --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Setup App Infrastructure?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Setup App Infrastructure
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/janszewczyk-setup-app-infrastructure/badge)](https://www.skillsdirectory.com/skills/janszewczyk-setup-app-infrastructure)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: setup-app-infrastructure
description: "Sets up shared infrastructure in a Next.js App Router project: T3 Env validation, LogLayer logging, ServiceError plus retry helper, server action result types, cookie toasts. Use when adding or checking this infrastructure in a Next.js project; NOT for the rules (nextjs-rules) or feature scaffolding (generate-feature-package)."
allowed-tools: Read, Glob, Grep, Write, Edit, Bash
argument-hint: "[env | logging | errors | actions | toast | all]"
---

# Set up app infrastructure

Installs the shared modules a Next.js app needs before features are written. This skill holds
the steps and the copy-in files; how to use what it installs is in `env-rules`, `loglayer-rules`, `nextjs-server-action-rules` and
`nextjs-rules`.

| Argument | Module | Already present when | Reference |
| --- | --- | --- | --- |
| `env` | T3 Env: `data/env/server.ts`, `data/env/client.ts` | `createEnv` found | [env.md](./references/env.md) |
| `logging` | LogLayer: `lib/logger.ts`, `proxy.ts` request id | `createLogger` found | [logging.md](./references/logging.md) |
| `errors` | `ServiceError`, `withRetry`, `app/error.tsx` | `ServiceError` found | [errors.md](./references/errors.md) |
| `actions` | `ActionResponse`, `RedirectAction`, form packages | `ActionResponse` found | [actions.md](./references/actions.md) |
| `toast` | `lib/toast/`, sonner, `<ToastHandler />` | `setToastCookie` found | [toast.md](./references/toast.md) |

No argument or `all`: every module that is missing. Ask nothing unless the argument names none of these.

Copy-in files are in `assets/`: `action-types.ts`, `service-error.ts`, `with-retry.ts`, `lib/toast/`.

## Steps

1. **Read the project.** Find the source root (`src/` or the repository root), the package manager
   (lockfile), the type-check script (`type-check`, `typecheck`, or `tsc --noEmit`), and the existing
   modules with `grep -rlE "createEnv|createLogger|ServiceError|ActionResponse|setToastCookie" --include="*.ts" --include="*.tsx" .`
   outside `node_modules`.
2. **Set the alias.** The templates import with `~/`. Check `tsconfig.json`; when `paths` has no
   `~/*`, add `"paths": { "~/*": ["./src/*"] }` (`["./*"]` without a `src/` folder). If the project
   already uses another alias for the same folder, replace `~/` in the copied files instead.
3. **Order the modules.** `env` first, then `logging`, then `errors`, `actions`, `toast`. `logging`,
   `errors` and `toast` need `env`; `errors` needs `logging`. A requested module whose dependency
   is missing installs the dependency first.
4. **Install only what is missing.** For each module, read its reference and:
   - install the packages with the project's package manager;
   - create each file from the reference or `assets/`, in the project's folders;
   - never overwrite an existing file: when a file exists with another shape, add only the missing parts
     (a `redact` config, `x-request-id`, a variable) and list what you left alone.
5. **Wire it.** Do the wiring the reference ends with: `.env.example` and `.gitignore` entries, the
   Vitest setup, `proxy.ts` or `middleware.ts`, `<ToastHandler />` in the root layout, `app/error.tsx`.
6. **Check.** Run the type-check script, fix what the new files break (path aliases, `ServiceError`
   import paths, strict-mode errors), and run it again until it passes. Run the project's tests
   when the env or logging module was added.
7. **Report.** Per module: installed, already present, or partly present, with the files created or
   changed, the packages added, and anything found that breaks a rule (`console.*`, `process.env`
   outside the env files, services that throw) as a list for the user; do not refactor it.

## Do not

- Restate or reinterpret the rules in project files; link to the rules skill when a comment needs one.
- Add variables, loggers or error codes the project does not need yet.
- Edit generated files of `nextjs-rules`, `nextjs-server-action-rules`, `loglayer-rules` or `env-rules`.

Files in this skill

  • SKILL.md3.8 KB
  • assets/action-types.ts1.4 KB
  • assets/lib/toast/components/toast-handler.tsx1.6 KB
  • assets/lib/toast/constants.ts276 B
  • assets/lib/toast/server/toast.cookie.ts1.1 KB
  • assets/lib/toast/types.ts158 B
  • assets/service-error.ts4.4 KB
  • assets/with-retry.ts1.5 KB
  • references/actions.md1.6 KB
  • references/env.md4.1 KB
  • references/errors.md3.7 KB
  • references/logging.md4.8 KB
  • references/toast.md2.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.