はじめてのClaude Codeプロジェクト
入門 6 min
Claude Codeを使い始めると、多くの機能に圧倒されることがあります。この入門ガイドでは、必須のセットアップ手順を順を追って説明します:CLIのインストール、最初のCLAUDE.mdの作成、権限の設定、そして初めてのAI支援コーディングセッションの実行まで。ガイドを終える頃には、Claude Codeの効果を最大限に発揮できる適切に構成されたプロジェクトが整います。
セットアップ入門CLAUDE.md権限オンボーディング
インストールと認証
Claude Code is installed as a global npm package. After installation, you authenticate with your Anthropic account. The CLI stores your credentials securely and manages sessions automatically.
Once authenticated, navigate to your project directory and run 'claude' to start an interactive session. Claude Code automatically detects your project structure, reads package.json, and understands your tech stack without any configuration.
For team environments, consider using environment variables for authentication so that CI/CD pipelines and shared development machines can use Claude Code without manual login steps.
# Install Claude Code globally
npm install -g @anthropic-ai/claude-code
# Authenticate (opens browser)
claude auth login
# Start your first session
cd ~/my-project
claude
# Verify installation
claude --version
CLAUDE.mdの作成
CLAUDE.md is the single most important file for Claude Code productivity. It acts as persistent instructions that Claude reads at the start of every session. Think of it as onboarding documentation for your AI pair programmer.
Start minimal. A good CLAUDE.md answers three questions: What is this project? What tech stack does it use? What conventions should Claude follow? Resist the urge to write a comprehensive document on day one. Instead, add rules organically as you discover patterns.
Place CLAUDE.md at the project root. Claude Code searches for it automatically. You can also create a ~/.claude/CLAUDE.md for global instructions that apply to all projects.
# CLAUDE.md
## Project
E-commerce API built with Node.js + Express + PostgreSQL.
## Stack
- Runtime: Node.js 20
- Framework: Express 4
- Database: PostgreSQL 16 + Prisma ORM
- Testing: Vitest
- Linting: ESLint + Prettier
## Conventions
- Use async/await, never raw promises
- All API responses follow { data, error, meta } shape
- Database queries go through Prisma, no raw SQL
- Tests are co-located: foo.ts → foo.test.ts
権限の設定
Claude Code uses a permission model to control which actions it can take autonomously. By default, it asks for confirmation before running shell commands, editing files, or making network requests. This is safe but can slow you down.
For trusted projects, you can pre-approve specific actions. The three permission modes are: ask (default), auto-approve for read-only operations, and full auto-approve. Most developers start with the default and gradually allow more as they build trust.
You can also configure per-tool permissions. For example, you might allow file edits automatically but require confirmation for git operations. This granular control lets you balance speed with safety.
# Check current permission settings
claude config list
# Allow file reads without confirmation
claude config set autoApprove.read true
# Allow file edits in specific directories
claude config set autoApprove.editPaths "src/**,tests/**"
# In CLAUDE.md, set project-level permissions
# These apply only to this project:
# Allow: Read, Edit, Glob, Grep
# Ask: Bash, Write (new files)
はじめてのコーディングセッション
With setup complete, it is time to do real work. Start with a small, well-defined task to build confidence. Good first tasks include: adding a utility function, writing tests for existing code, or fixing a known bug.
Be specific in your prompts. Instead of 'make the code better,' say 'add input validation to the createUser endpoint in src/routes/users.ts.' Specific prompts produce better results and consume fewer tokens.
After each session, review what Claude did. Check the git diff, run your tests, and note any patterns you want to encode into CLAUDE.md for future sessions. This feedback loop is how you progressively make Claude Code more effective for your specific project.
# Good first tasks - specific and scoped
claude "add a validateEmail utility in src/utils/validators.ts with tests"
claude "fix the null pointer in src/services/user.ts line 47"
claude "add JSDoc comments to all exported functions in src/utils/"
# Review what changed
git diff
npm test
# If something went wrong, undo easily
git checkout -- .
実行プレビュー
はじめてのClaude Codeプロジェクト
はじめてのClaude Codeプロジェクトについて
Claude Codeガイドは、Claude Codeの特定の側面をマスターするための詳細なステップバイステップガイドです。はじめてのClaude Codeプロジェクトは入門レベルのガイドで、日常のワークフローでClaude Codeを最大限に活用するためのベストプラクティス、実践的なテクニック、実用的なヒントを紹介します。