Introduction
- この記事では、Claude Code を使って生産性を向上させるための、入手可能なすべてではない最も重要なツールを紹介します。著名な作家の有名な引用文 Discourse on the Method からの言葉に従って進めます:
- “States with fewer laws are often better governed, provided those laws are strictly followed.” - René Descartes
- 私たちの例えでは、つまり:「すべてを正しく取り入れようとするよりも、特定のツールと概念に従う方が良い」という意味です。
- 2026年時点で既に知っておくべき、AI を使ったコーディングの明らかな一般的なヒントは省略します。例えば:
- AI が生成したコードを必ずレビューし、テストし、PR を作成する前に何が起きているかを理解しておく必要がある、ということは言うまでもありません。
General concepts to reach better results with Claude Code
-
コンテキストをすべて埋め尽くさない:
- “Most best practices are based on one constraint: Claude’s context window fills up fast, and performance degrades as it fills.” - Claude Code Docs
- それを回避するには、タスクを終えたら
/clear を使ってコンテキストをリセットします。複数回の不正確なコード生成の後にもクリアを使ってコンテキストを整理してください。
- または
/compact を使って、コンテキストをクリアしつつ、会話の要約をコンパクトに保持することができます。カスタムコンパクトを作成できます: /compact focus on x,y,z
- 迅速な質問には
/btw を使います。これらはコンテキストに含めたくない場合に便利です。
-
Claude Code に仕事の検証を行う方法を提供する
- “Claude performs dramatically better when it can verify its own work, like run tests, compare screenshots, and validate outputs.” - Claude Code Docs
-
Plan mode vs Act Mode を使うタイミング
- 大きな変更または複雑な変更には Plan mode をみ使用して、探索・分析・実行前に見直して変更できる計画を作成します。レビュー後、Act mode に切り替えます。
- 開発者と同様に、ビジネス上の問題を理解(探索)、それを技術的制約(計画)へ翻訳、そしてコードを開発(実行)します。
-
Time travel: 過去のチェックポイントに戻るには
/rewind を使用します。コード変更のみ、会話のみ、または両方を復元できます。
CLAUDE.md
- CLAUDE.md は、会話の開始時に Claude によって読み込まれます。
- この文書には、コードスタイルと規約、プロジェクト概要、アーキテクチャ、ワークフロー、品質保証などを含めます。
- 巨大な CLAUDE.md は避け、代わりにルールやスキルに分割します。
-
よくある失敗パターン: 「CLAUDE.md の過度な指定」。CLAUDE.md が長すぎると、重要な規則がノイズの中に紛れて半分が無視されてしまうことがあります。」 - Claude Code Docs
- 共通の Claude の間違いを防ぐルールがあり、それが繰り返し発生する場合、過大な CLAUDE.md がそれを無視させている原因となっている可能性があります。
-
What is a big CLAUDE.md? More than 200 lines.
- “Files over 200 lines consume more context and may reduce adherence.” - Claude Code Docs
- Use
/init to initialize a CLAUDE.md using Claude itself, then refine it.
- You can have more than one CLAUDE.md in monorepos.
Rules
- Contextual instructions tied to specific path, applied automatically by Claude when working into files within that path.
- Used to enforce specific patterns, architecture, and conventions related to that path only.
---
paths:
- "src/api/**/*.ts"
---
# API Development Rules
- All API endpoints must include input validation
- Use the standard error response format
- Include OpenAPI documentation comments
Skills
- Used to extend Claude's knowledge with specific information about your project.
- Claude applies them automatically, or you can invoke them manually with
/skill-name.
-
How to add one skill? Add a SKILL.md file in the following path:
.claude/skills/skill-name/SKILL.md
- Great examples of Claude skills:
Subagents
- We use skills when we want a topic “specialist” within the main context. We use custom subagents when we want a specialist outside the main context; in the end, they provide a short summary to keep in the main context.
- There are default code agents within Claude Code for exploring the codebase, planning, general-purpose tasks, Bash, and more.
Custom Subagents
- We can also create subagents for our specific tasks.
-
/agents → create a new agent → generate with Claude Code → edit what is required
- such as tools, AI model, background color, and memory
- we can allow only read access, use MCPs, load skills into it, and more
- Example of a custom subagent: Supported fields - Claude Code Docs
---
name: code-reviewer
description: Reviews code for quality and best practices
tools: Read, Glob, Grep
model: sonnet
---
You are a code reviewer. When invoked, analyze the code and provide
specific, actionable feedback on quality, security, and best practices.
Using custom subagents
-
Natural language:
“Use the test-runner subagent to fix failing tests”
-
Mention subagent:
@"code-reviewer (agent)" look at the auth changes
-
Run an entire session as a subagent:
claude --agent code-reviewer
- Or it can be automatically decided by Claude Code when to use each agent.
-
Running in background for multitasking:
“run this in the background”
Parallel Claude Code for parallel tasks with Git worktrees
- As developers, we sometimes need to handle multiple tasks at the same time across different projects. For example, as a full-stack developer, you may need to create an API route and consume it on the frontend. Or, while you wait for the AI to generate code for later review, you can work on another feature or fix.
- Normally, with Git worktrees, we do the following to create separate branches and working directories without switching branches:
git worktree add ../feature-a -b feature-a
-
git worktree add ../feature-b -b feature-b
-
cd ./ → main branch
-
cd ../feature-a → feature-a
-
cd ../feature-b → feature-b
- With Claude Code, it is similar, but we get the Git advantages along with independent context and history for each worktree:
claude --worktree feature-auth
cd ../feature-auth
Reduce Token Usage While Coding
- There are also configurations to be set up as an account manager, applying rate limits and more. But as direct Claude Code users, there are major actions to be taken:
-
Action 1: Use
/clear and /compact to reduce context size
- “Token costs scale with context size: the more context Claude processes, the more tokens you use” - Claude Code Docs
アクション 2: タスクに適したモデルを使用します。/model を使ってモデルを切り替えます
- これは、特定のタスクのために構成されたエージェントとカスタムサブエージェントを使用することで作られています。
- 「Sonnet はほとんどのコーディングタスクをうまく処理し、Opus よりコストが低い。複雑なアーキテクチャ上の意思決定や多段の推論には Opus を用意しておく。」 - Claude Code Docs
-
アクション 3: 不要なファイル読み取りは常に避ける
- 型付き言語では、コードのナビゲーションを容易にするためにコードインテリジェンスプラグインを活用し、不要なファイルを読むことを避けることでトークンの使用量を削減します。 - ドキュメント
- Skill ファイルは、アーキテクチャやフォルダ構成の詳細を含む、Claude にドメイン知識を提供し、不要なファイル読み取りを回避します。
- 必要なログのみを提供するためにフックを使用します。例えば、すべてのテストを送信する代わりに、失敗したものだけを送信するようフックを使用します。 フックの使用に関するドキュメント
-
アクション 4: 短い CLAUDE.md を提供し、指示をスキルへ移し、必要な場合にのみそれらを使用します。CLAUDE.md には、一般的なプロジェクト概要とコード慣例のみを含め、従うべき具体的な指示は含めません。
このアクションの大半は、二つの部分に要約できます:
- 1 - コンテキストサイズを縮小する。
- 2 - ツールを正しく使用する: 短い CLAUDE.md、特定タスクの指示のためのスキル、複雑なタスクの計画モード、冗長な出力のためのサブエージェントなど。
具体的な使用方法の詳細、設定などはこちら: /status
参考資料