Agent skill

Setting up Next.js Project

Configure Next.js projects with ESLint, Prettier, and recommended settings. Use when initializing Next.js projects, setting up linting, or when user mentions Next.js setup/Next.jsセットアップ.

Stars 5
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/camoneart/claude-code/tree/main/skills/setting-up-nextjs-project

SKILL.md

Setting up Next.js Project

Next.jsプロジェクトのセットアップ時に必要な設定を自動化するスキル。

いつ使うか

  • Next.jsプロジェクトを新規作成する時
  • 既存Next.jsプロジェクトにESLint/Prettierを追加する時
  • コードフォーマット設定が必要な時
  • ユーザーが「Next.jsセットアップ」について言及した時

セットアップ手順

1. ESLint + Prettier の必須インストール

Next.jsはESLintを自動インストールするが、Prettierも必ず追加

bash
pnpm add -D prettier eslint-config-prettier prettier-plugin-tailwindcss

パッケージの役割:

  • prettier: コードフォーマッター
  • eslint-config-prettier: ESLintとPrettierの競合を防ぐ
  • prettier-plugin-tailwindcss: Tailwind CSSのクラス順序を整理(Tailwind使用時)

2. 設定ファイルの作成

.prettierrc.json

プロジェクトルートに作成:

json
{
  "semi": true,
  "singleQuote": true,
  "trailingComma": "es5",
  "tabWidth": 2,
  "useTabs": false,
  "printWidth": 100,
  "bracketSpacing": true,
  "arrowParens": "always"
}

.eslintrc.json の更新

既存の設定に eslint-config-prettier を追加:

json
{
  "extends": ["next/core-web-vitals", "prettier"]
}

3. package.json スクリプトの追加

json
{
  "scripts": {
    "format": "prettier --write .",
    "format:check": "prettier --check ."
  }
}

使い方:

  • pnpm run format: 全ファイルをフォーマット
  • pnpm run format:check: フォーマットチェック(CI用)

4. VS Code 設定の推奨

.vscode/settings.json を作成(任意):

json
{
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

完全なセットアップフロー

新規プロジェクト

bash
# 1. Next.jsプロジェクト作成
pnpm dlx create-next-app@latest my-app

# 2. ディレクトリ移動
cd my-app

# 3. Prettier追加
pnpm add -D prettier eslint-config-prettier prettier-plugin-tailwindcss

# 4. 設定ファイル作成
# (このスキルが自動で作成)

# 5. フォーマット実行
pnpm run format

既存プロジェクト

bash
# 1. Prettier追加
pnpm add -D prettier eslint-config-prettier prettier-plugin-tailwindcss

# 2. 設定ファイル追加
# (このスキルが自動で作成)

# 3. ESLint設定更新
# (このスキルが自動で更新)

# 4. フォーマット実行
pnpm run format

設定ファイルテンプレート

詳細なテンプレートは templates/ を参照。

チェックリスト

セットアップ完了前に確認:

  • Prettierがインストールされているか
  • .prettierrc.json が作成されているか
  • .eslintrc.jsonprettier が追加されているか
  • package.json に format スクリプトが追加されているか
  • pnpm run format が正常に動作するか
  • .vscode/settings.json の作成を検討したか

トラブルシューティング

フォーマットが効かない

  1. Prettier拡張がインストールされているか確認
  2. .prettierrc.json の構文エラーを確認
  3. ESLintとの競合を確認(eslint-config-prettier が必要)

Tailwind CSSのクラス順序が整わない

  1. prettier-plugin-tailwindcss がインストールされているか確認
  2. .prettierrc.json にプラグイン設定を追加

参考リンク

Expand your agent's capabilities with these related and highly-rated skills.

camoneart/claude-code

translating-technical-articles

Translates English technical articles (engineering blogs, documentation) to Japanese while preserving layout and structure. Use when the user asks to translate an article, convert English content to Japanese, or mentions translating a URL or technical blog post.

5 0
Explore
camoneart/claude-code

guiding-tdd-development

Guide Test-Driven Development with task splitting, Red-Green-Refactor cycle, and framework auto-detection. Use when developing features with TDD approach, fixing bugs test-first, or when user mentions "TDD", "テスト駆動開発", "test-first", "/tdd".

5 0
Explore
camoneart/claude-code

distributed-tracing

Implement distributed tracing with Jaeger and Tempo to track requests across microservices and identify performance bottlenecks. Use when debugging microservices, analyzing request flows, or implementing observability for distributed systems.

5 0
Explore
camoneart/claude-code

dependency-upgrade

Manage major dependency version upgrades with compatibility analysis, staged rollout, and comprehensive testing. Use when upgrading framework versions, updating major dependencies, or managing breaking changes in libraries.

5 0
Explore
camoneart/claude-code

stripe-integration

Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.

5 0
Explore
camoneart/claude-code

typescript-advanced-types

Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.

5 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results