本文へ移動
Claude Tips

よくある作業の進め方

コードの把握・バグ修正・リファクタリング・テスト・PR 作成など日々の作業で使える進め方と、そのまま使えるプロンプト集をまとめています。

日々の開発で繰り返す作業の進め方を、短い手順とプロンプトの形でまとめたページです。コードの把握、バグ修正、リファクタリング、テスト、プルリクエスト、ドキュメントなどを扱い、後半に場面別のプロンプト集があります。プロンプトの組み立て方や文脈の扱いは 上手に使うコツ を見てください。

  • 手順の例はどの画面(ターミナル・IDE・デスクトップ・Web)でも使えます。言い回しは自分のプロジェクトに合わせて変えます
  • 広い質問から始めて、狭い領域へ絞ると進めやすくなります
  • 数回にわたる作業は、会話の再開・worktree・プランモード・サブエージェントを使い分けます
  • プロンプト集の {} は、自分の内容に置き換える部分です

コードベースを理解する#

全体像をつかむ#

新しいプロジェクトに入ったときの流れです。

  1. プロジェクトのルートへ移動し、claude を起動します
  2. 全体像を尋ねます
  3. 気になる部分を掘り下げます
text
give me an overview of this codebase
explain the main architecture patterns used here
what are the key data models?
how is authentication handled?

ヒント

広い質問から始めて、特定の領域へ絞ります。プロジェクトのコーディング規約やパターンを尋ねたり、プロジェクト固有の用語集を頼んだりできます。大きなリポジトリの設定は コンテキストとプロンプトキャッシュ と 上手に使うコツ を見てください。

関連するコードを探す#

text
find the files that handle user authentication
how do these authentication files work together?
trace the login process from front-end to database

ヒント

探しているものを具体的に言い、プロジェクトの用語を使います。言語用のコードインテリジェンスのプラグインを入れると、「定義へ移動」「参照の検索」が正確になります(プラグインを使う)。

ノートや非コードのフォルダーで使う#

Claude Code はどのディレクトリでも動きます。ノートの保管庫・ドキュメントのフォルダー・Markdown の集まりでも、コードと同じように検索・編集・整理できます。.claude/ と CLAUDE.md は、ほかのツールの設定ディレクトリと衝突せずに並びます。Claude はツール呼び出しのたびにファイルを新しく読むので、別のアプリで加えた編集も、次に読むときに見えます。

バグを直す#

text
I'm seeing an error when I run npm test
suggest a few ways to fix the @ts-ignore in user.ts
update user.ts to add the null check you suggested

ヒント

再現するコマンドとスタックトレースの取り方を伝えます。再現の手順、エラーが毎回か断続的かも伝えます。

リファクタリングする#

  1. 古いコードを見つけます(find deprecated API usage in our codebase)
  2. 方針を提案させます(suggest how to refactor utils.js to use modern JavaScript features)
  3. 振る舞いを保って適用します(refactor utils.js to use ES2024 features while maintaining the same behavior)
  4. テストで確かめます(run tests for the refactored code)

ヒント

新しい方式の利点を説明させます。必要なら後方互換を保つよう頼みます。小さく、テストできる単位で進めます。コードベース全体を別の言語へ移すような大きな移行は、Anthropic のブログ記事「how Anthropic runs large-scale code migrations with Claude Code」が参考になります。

テストを扱う#

  1. テストされていないコードを見つけます(find functions in NotificationsService.swift that are not covered by tests)
  2. テストの雛形を作らせます(add tests for the notification service)
  3. 意味のあるケースを足します(add test cases for edge conditions in the notification service)
  4. 実行して直させます(run the new tests and fix any failures)
  • Claude は既存のテストファイルを見て、使われているスタイル・フレームワーク・アサーションの形に合わせます。確かめたい振る舞いを具体的に伝えます
  • 網羅したいときは、見落としているエッジケースを挙げさせます。エラー条件・境界値・想定外の入力のテストを提案できます

プルリクエストを作る#

「create a pr for my changes」と頼むか、段階を踏みます。

text
summarize the changes I've made to the authentication module
create a pr
enhance the PR description with more context about the security improvements
  • あとからセッションを探すには、claude --from-pr 1234(自分の PR 番号)を実行します。その PR に結びついたセッションだけに絞った選択画面が開きます。PR の URL を /resume の選択画面の検索へ貼る方法もあります
  • セッションが PR に結びつくのは、Claude が gh pr create か glab mr create で作ったとき、または既存の PR に取り組んだときです(エージェントビュー)。選択画面は セッションの再開と管理 を見てください

ヒント

生成された PR は、出す前に見直します。リスクや考慮点を挙げさせます。

ドキュメントを扱う#

  1. 文書化されていないコードを見つけます(find functions without proper JSDoc comments in the auth module)
  2. コメントを生成します(add JSDoc comments to the undocumented functions in auth.js)
  3. 文脈や例を足して改善します
  4. プロジェクトの基準に沿うか確認します(check if the documentation follows our project standards)

ヒント

文書のスタイル(JSDoc・docstring など)と、例を含めるかを指定します。公開 API・インターフェース・複雑なロジックを対象にします。

画像を扱う#

画像を会話へ入れる方法は3つあります。

  1. Claude Code のウィンドウへドラッグ&ドロップする
  2. 画像をコピーして、CLI へ Ctrl+V で貼る(Windows と WSL は Alt+V。対話モードの操作 を見てください)
  3. 画像のパスを渡す(例:Analyze this image: /path/to/your/image.png)
text
What does this image show?
Here's a screenshot of the error. What's causing it?
This is our current database schema. How should we modify it for the new feature?
Generate CSS to match this design mockup

ヒント

文章で説明しにくいときに画像を使います。エラー・UI デザイン・図のスクリーンショットが役立ちます。1つの会話に複数の画像を入れられます。Claude が [Image #1] のように画像を参照したら、Cmd+クリック(Mac)か Ctrl+クリック(Windows・Linux)で、既定のビューアーで開けます。

ファイルとディレクトリを @ で参照する#

@ で、Claude の読み込みを待たずにファイルやディレクトリを会話へ入れます。

書き方 内容
@src/utils/auth.js ファイルの全内容を会話に入れる
@src/components ディレクトリの一覧を見せる(内容ではない)
@github:repos/owner/repo/issues 接続した MCP サーバーのリソースを取得する(@server:resource の形。MCP サーバーをつなぐ)
  • パスは相対でも絶対でも構いません
  • @ を入力するとパスの候補が出ます。Enter か Tab で選び、もう一度 Enter で送ります
  • ファイルを @ で参照すると、そのファイルのディレクトリと親ディレクトリの CLAUDE.md も文脈に加わります
  • 1つのメッセージで複数を参照できます(@file1.js and @file2.js)

長い作業・並列・自動化の進め方#

前の会話を再開する#

bash
claude --continue

現在のディレクトリの直近のセッションを再開します。まだ無ければ No conversation found to continue と出て終了します。一覧から選ぶには claude --resume、実行中のセッションからは /resume を使います。詳しくは セッションの再開と管理 を見てください。

worktree で並列に作業する#

bash
claude --worktree feature-auth

git の worktree は、既存のコミットから作られる、別のブランチのチェックアウトです(リポジトリにコミットが1つは必要です)。別のターミナルで別の名前で同じコマンドを実行すると、独立した並列セッションになります。コミットの無いリポジトリでは Failed to resolve base branch "HEAD": git rev-parse failed で失敗します。後始末・.worktreeinclude・git 以外のバージョン管理への対応は worktree で並行作業、1画面で見張るには エージェントビュー を見てください。

編集の前に計画する#

ディスクに触れる前に確認したい変更は、プランモードにします。Claude はファイルを読んで計画を示し、承認するまで編集しません。有効なあいだ、ステータスバーに ⏸ plan mode on と出ます。

bash
claude --permission-mode plan

セッション中に Shift+Tab で切り替えることもできます。承認の流れは 権限モード を見てください。

調査をサブエージェントに任せる#

大きなコードベースの探索は、ファイルの読み込みで文脈を埋めます。探索を任せて、結果だけ受け取ります。

text
use a subagent to investigate how our auth system handles token refresh

サブエージェントは自分の文脈でファイルを読み、要約を返します。独自のツールとプロンプトを持つエージェントは サブエージェント を見てください。

スクリプトにパイプする#

CI・pre-commit フック・一括処理のために、対話なしで動かせます。標準入出力は、ほかの Unix ツールと同じです。

bash
git log --oneline -20 | claude -p "summarize these recent commits"

出力形式・権限フラグ・並列の展開は ヘッドレス実行(-p) を見てください。

定期実行する#

方法 動く場所 向いている用途
ルーティン クラウド(既定は Anthropic の管理) 自分のマシンが止まっていても動かしたい作業。スケジュールのほか API 呼び出しや GitHub のイベントでも起動できる
デスクトップの定期タスク デスクトップアプリ経由で自分のマシン ローカルのファイル・ツール・未コミットの変更に直接触れたい作業
GitHub Actions CI のパイプライン PR を開いたなどのリポジトリのイベント、ワークフローの設定と並べたい cron
/loop 現在の CLI セッション セッションを開いているあいだの手早いポーリング。--resume と --continue で、期限切れでない固定間隔のループが復元される

ヒント

定期タスクは自動で動き、確認の質問ができません。成功の条件と結果の扱いを具体的に書きます。例:「needs-review のラベルが付いた PR を見て、問題点にインラインコメントを付け、#eng-reviews の Slack チャンネルに要約を投稿する」。

Claude に機能を尋ねる#

Claude は自分のドキュメントを組み込みで参照できます。「can Claude Code create pull requests?」「how does Claude Code handle permissions?」「how do I use MCP with Claude Code?」のように聞けます。答えはドキュメントに基づきます。手を動かして試すなら /powerup で、アニメーション付きの対話式のレッスンが使えます。

プロンプト集#

場面ごとのプロンプトです。{} の中は自分の内容に置き換えます。末尾に注記のあるものは、そのツールが要ります。

  • 「gh」:GitHub CLI が使えること
  • 「トラッカー」:Linear などの課題管理が MCP でつながっていること
  • 「ブラウザ」:ブラウザを操作できること
  • 「DB」:データベースへの接続があること

理解する(Discover)#

場面 プロンプト
新しいリポジトリで全体像をつかむ give me an overview of this codebase: architecture, key directories, and how the pieces connect
見慣れないコードを説明させる explain what {path} does and how data flows through it. write it up as {format}
挙動からコードを探す where do we {behavior}?
削除したときの影響を知る what would break if I deleted {target}?
コードの変遷を追う look through the commit history of {path} and summarize how it evolved and why
変更の範囲を見積もる(企画・デザイン向け) which files would I need to touch to {change}?
自分の役割で仕組みを聞く(企画向け) I am a {role}. walk me through what happens when a user {action}, from the UI down to the result

設計する(Design)#

場面 プロンプト
複数ファイルの変更を計画させる plan how to refactor the {target} to {goal}. list the files you would change, but don't edit anything yet
インタビューで仕様を作る I want to build {feature}. interview me about implementation, UX, edge cases, and tradeoffs until we have covered everything, then write the spec to SPEC.md
議事録からチケットを作る(トラッカー) read {input} and write up the action items, then create a {tracker} ticket for each with acceptance criteria
デザインが扱う状態を洗い出す list the error states, empty states, and edge cases for {feature} that the design needs to cover
モックアップから試作を作る here is a mockup. build a working prototype I can click through, matching the layout and states shown
デザインを実装して見比べる(ブラウザ) implement this design, then take a screenshot of the result, compare it to the original, and fix any differences

作る(Build)#

場面 プロンプト
既存の実装を手本に作る look at how {example} is implemented to understand the pattern, then build {new} the same way
ドキュメントコメントを足す find {scope} without {format} comments and add them, matching the style already used in the file
エンドポイントを足す add a {endpoint} endpoint that returns {payload}
小さなツールを作る create a {tool} using HTML, CSS, and vanilla JavaScript, then open it in my browser
Issue から修正する(gh) read issue #{issue}, implement the fix, and run the tests
文言を一括で置き換える find every place we say "{copy}" or a close variant, show me each one in context, then update them all to "{new}". leave tests and the changelog alone
例を読んで新しい文書を書く read the {examples} in {folder} to learn the structure and voice, then draft a new one for {topic}

テストする#

場面 プロンプト
テストを書いて直す write tests for {path}, run them, and fix any failures
テストを先に書く write tests for {feature} first, then implement it until they pass
カバレッジを上げる read {report} and add tests for the lowest-covered files until each is above {target}%

リファクタリングする#

場面 プロンプト
全体を移行する migrate everything from {from} to {to}: identify every place that needs to change, then make the changes
別の言語へ移す port {source} to {target}, keeping the same {keep}
性能を改善する(データ向け) optimize {target} to bring {metric} from {current} down to under {goal}
表示崩れを直す(デザイン向け) the {element} extends {amount} beyond the {container} on {viewport}. fix it.

レビューする#

場面 プロンプト
コミット前に変更を見直す review my uncommitted changes and flag anything that looks risky before I commit
PR を要約して懸念を挙げる(gh) review PR #{pr} and summarize what changed, then list any concerns
Terraform の計画を読む(セキュリティ・運用向け) here is my Terraform plan output. what is this going to do, and is anything here going to cause problems?
サブエージェントでセキュリティを見る use a subagent to review {path} for security issues and report what it finds
公開前の文書を点検する(マーケティング・文書向け) review {file} for {concerns} and list anything I should fix before it goes to {reviewer}

軌道を修正する#

場面 プロンプト
やり直させる that is not right: {feedback}. try a different approach
やりすぎを戻す that is too much. keep only the changes to {scope} and undo your other edits
繰り返す間違いをルールにする you keep {mistake}. add a rule to CLAUDE.md so this stops happening

出す(Ship)#

場面 プロンプト
マージ競合を解消する resolve the merge conflicts in this branch and explain what you kept from each side
コミットする commit these changes with a message that summarizes what I did
チケットから PR を作る(トラッカー) find the {tracker} ticket about {topic} and open a PR that implements it
リリースノートを書く compare {from} to {to} and draft release notes grouped by feature, fix, and breaking change
CI のワークフローを書く(運用向け) write a GitHub Actions workflow that {steps} on every push to {branch}

運用する(Operate)#

場面 プロンプト
失敗したテストを直す the {test} test is failing, find out why and fix it
本番の症状を調べる(運用向け) users are seeing {symptom} on {where}. investigate and tell me what is going on
ビルドエラーを直す here is a build error. fix the root cause and verify the build succeeds
障害の原因を絞る {symptom}. check the logs, recent deploys, and config changes, then tell me the most likely cause
コンソールのスクリーンショットから対処する here is a screenshot of {console}. walk me through why {resource} is failing and give me the exact commands to fix it
ログをクエリで調べる(DB) show me all {events} for {scope} over {timeframe}. write the query, run it, and tell me what stands out
データを読んで要約する read {file}, summarize the key patterns, and write the results to {output}
成果の悪いものの代案を作る(マーケティング・データ向け) read {file}, find the underperforming {items}, and generate {n} new variations that stay under {limit} characters
スキルを作る create a /{name} skill for this project that {steps}
フックを書く write a hook that {action} after every {event}
MCP サーバーをつなぐ set up the {server} MCP server so you can read my {data} directly
セッションを CLAUDE.md に残す summarize what we did this session and suggest what to add to CLAUDE.md

スキル・フック・MCP・CLAUDE.md を作るプロンプトの詳細は、スキル、フックの使い方、MCP サーバーをつなぐ、CLAUDE.md とメモリ を見てください。

効くプロンプトの型#

上のプロンプトは、いくつかの型を共有しています。

型 内容 例
手順でなく結果を言う やりたいことを言い、ファイルは Claude に探させる add rate limiting to the public API and make sure existing tests still pass
自分で確かめさせる 実行・テスト・比較・検証を同じプロンプトに入れ、1回で止まらせない write the migration, run it against the dev database, and confirm the schema matches
手本を示す 既存のファイル・テスト・パターンを名指しして揃えさせる add a settings page that follows the same layout as the profile page
測れる目標を言う 指標としきい値を与え、完了を曖昧にしない get the bundle size under 200KB and show me what you removed
実物を渡す エラー・ログ・スクリーンショット・計画の出力を貼るか @ で参照する why is the build failing? @build.log
答えの形を言う 形式・長さ・読み手を指定する explain how the payment retry logic works as an HTML page with a diagram, then open it in my browser

ヒント

完成した変更を、動いているアプリに対して確かめるには /verify を使います(スキル)。答えの形を毎回の既定にしたいときは、出力スタイル を設定します。

使えるプロンプトができたら、スキルにして /コマンド として呼べるようにし、Claude が学んだ規約は CLAUDE.md に書くと、毎回の説明が要りません。大きな変更や危険な変更では、プランモードが編集の前にファイルの一覧を見せてくれます(権限モード)。チームへの導入は 組織への導入と管理設定、課金は コストを抑える を見てください。

公式ドキュメント(英語)

2026年10月5日時点の内容をもとに、日本語でまとめています。

ページの一覧