Salesforce DX プロジェクト(Salesforce の開発環境)を一から構築します。テンプレートを選び、プロジェクトを生成し、このセッションをそこに移動させ、組織を認証して、デフォルト設定にし、ソースの追跡機能を有効にします。 **次のような場合に使用:** ユーザーが「新しい Salesforce プロジェクトを作成したい」「新しいプロジェクトをセットアップしてほしい」「Salesforce プロジェクトを始めたい」「新しい SFDX プロジェクトが欲しい」「プロジェクトをスキャフォルディング(雛形から生成)したい」「sf project generate」「一から新しい組織プロジェクトをセットアップしたい」などと言った場合。 **使用しない場合:** - 既存プロジェクトのツール検証(platform-environment-validate または /salesforce-development:setup を使用) - 既に存在するプロジェクトの組織認証(/salesforce-development:login を使用) - 既存プロジェクトのメタデータ統計情報の表示(/salesforce-development:project を使用) - 既存プロジェクトでのスクラッチ組織(一時的な開発用組織)の作成(dx-org-manage を使用)
Scaffold a brand-new Salesforce DX project from scratch — pick a template, generate the project, relocate this session into it, authenticate an org, set it as default, and enable source tracking. TRIGGER when the user asks to 'create a new Salesforce project', 'create a new project for me', 'start a new Salesforce project', 'new SFDX project', 'scaffold a project', 'sf project generate', or 'set up a new org project from scratch'. DO NOT TRIGGER for: validating tools on an existing project (use platform-environment-validate or /salesforce-development:setup), org authentication on a project that already exists (use /salesforce-development:login), showing an existing project's metadata stats (use /salesforce-development:project), or creating scratch orgs in an existing project (use dx-org-manage).
ウィザード形式の対話を通じてユーザーを案内し、新しい Salesforce DX(開発環境)プロジェクトのひな形を生成し、このセッションをその新しいプロジェクトに移動させ、組織に接続し、開発用に設定します。各ステップを順番に実行し、環境に変化をもたらす操作の前には必ずユーザーに確認を取ってください。
salesforce-development プラグインの MCP サーバー(salesforce-api-context、salesforce-metadata-experts、salesforce-lsp)は、プロジェクトではなくインストール済みのプラグインから提供されます。そのため、セッションが新しいプロジェクトに移動すれば、自動的に利用可能な状態が続きます。プロジェクトごとの .mcp.json をコピーする必要はありません。
テンプレートを選ぶようユーザーに促してください。特に希望がなければ standard をデフォルトにしてください。
| テンプレート | 用途 |
|---|---|
standard(デフォルト) |
一般用途の SFDX プロジェクト(従来の force-app ディレクトリ構成) |
empty |
最小限の構成のみのプロジェクト |
analytics |
CRM Analytics(Tableau CRM)の開発 |
reactinternalapp |
React ベースの社内向けアプリ |
reactexternalapp |
React ベースの外部・体験版アプリ |
agent |
Agentforce エージェントの開発 |
プロジェクト名の入力をユーザーに促してください。これが新しいディレクトリの名前になるため、有効なディレクトリ名である必要があります(スペースやパス区切り文字は不可)。
現在の作業ディレクトリで以下を実行します:
sf project generate -t {template} -n {name}
これにより、現在の作業ディレクトリの下に新しい {name}/ ディレクトリが作成されます。
最新の Claude Code(v2.1.169 以降)では、現在のセッションを新しいディレクトリにそのまま移動できます。新しいターミナルを起動したり、再起動したりする必要がなく、会話履歴も保持されます。ユーザーに以下を実行するよう案内してください:
/cd {name}
これでセッションが移動します:新しいディレクトリの CLAUDE.md が読み込まれ、プロジェクト用のデータストレージがそこに移動し(--resume/--continue がそこから見つかる)、カレントディレクトリがプロジェクトルートになるため、以降の sf コマンドはすべてパス指定なしで sf ... として実行されます。
/cd はクライアント側で実行される操作です:サーバー側の処理を発動させず、ユーザーの次のターンも待たないため、実行した直後にセッションは静かになります。これは異常ではなく、予想された動作です。ただし /cd を渡すメッセージが最後の言葉となるため、そのメッセージは必ずユーザーがどうやってセッションを再開するかを示す案内で終わる必要があります。以下のような行で閉じてください:
移動したら、「what's next」(または「connect an org」)とお声がけください。そこからステップ 5 を進めます。
「what's next」と言うことでセッションが再開され、位置インジケータ(次のステップは組織の認証)が表示されます。/cd の後、セッションが自動的に続くことがあるかのような印象は与えないでください。続きません。
ユーザーが再度話しかけたら、移動を短く確認し(例:「{name} に移動しました。」)ステップ 5 に進んでください。sf-context detect を実行したり check-tools を呼び出したりして、バナーを「再表示」しようとしないでください。detect をツールとして呼び出すと生の JSON フック情報が出力され(レンダリングされたバナーではなく)、プラグインはバナーを自分自身で表示します。バナーは、ユーザーが最初に Salesforce 関連の質問をするか、セッション開始時か、最初の方向確認質問をするときに、セッションあたり 1 回だけ HEADLESS ID とともに表示されます。また、「どこにいるのか」「次は何か」と聞かれたときはいつでも位置インジケータが表示されます。開発環境のヘルスチェックは /salesforce-development:setup でオンデマンドで利用できます。
古い Claude Code(v2.1.169 以前)の場合のフォールバック: /cd が Unknown command と報告された場合、ユーザーは新しいディレクトリで再起動する必要があります:
cd {name} && claude
salesforce-development プラグインはグローバルにインストール済み(マーケットプレイス経由)なので、新しいディレクトリでの新しいセッションが自動的にロードされ SessionStart が発動します。バナーとヘルスチェックは自動的に表示され、sf-context を手動で呼び出す必要はありません。以降のステップは、プロジェクト内から実行されます。
このプロジェクトがデプロイする対象の組織に認証します:
sf org login web --alias {alias}
--alias(後で参照できるようにするための組織の別名)を入力するよう促してください。--instance-url https://test.salesforce.com を追加してください。--instance-url を省略してください(デフォルトは login.salesforce.com)。ユーザーがすでにその組織を認証済みの場合は、ログインをスキップし、既存の別名を確認するだけで構いません。
認証したばかりの組織をプロジェクトのデフォルト対象として設定します:
sf config set target-org {alias}
デプロイ予览(ソース追跡の軽量で読み取り専用の確認方法)を使って、その組織でソース追跡が機能するかどうかを確認します:
sf project deploy preview --target-org {alias} --json
ソース追跡がサポートされていない、または有効になっていないというエラーで失敗した場合は、有効にするよう提案してください:
sf org enable tracking --target-org {alias}
有効化コマンドを実行する前にユーザーに確認してください。
すべてのステップが完了したら、ユーザーに以下を伝えてください:
プロジェクトの準備ができました!以下が設定されています:
✅ プロジェクト生成完了: {name}/
✅ セッション移動完了: {name}/(/cd 経由)
✅ デフォルト組織: {alias}
✅ ソース追跡: 有効(またはステータス)
すでにこの新しいプロジェクト内で作業を進めています —
このセッション自体が /cd で移動してきたので、そのまま進められます。
開発環境を確認したいときは、いつでも
/salesforce-development:setup を実行してください。
ユーザーが古いバージョンのフォールバック(/cd ではなく cd {name} && claude で再起動)を選んだ場合、プロジェクト内で新しいセッションが開始され、SessionStart バナーがすでに環境を案内しています。再度チェックするには /salesforce-development:setup を案内してください。
.mcp.json を作成またはコピーしないでください(プラグイン設定は ${CLAUDE_PLUGIN_ROOT} を使用し、これはプロジェクト レベルのファイルでは解決されません)。/cd {name} を優先してください(Claude Code v2.1.169 以降)。スキルはユーザーの代わりにセッションを移動できないため、実行するよう指示してください。/cd が古いビルドで Unknown command と報告された場合のみ、cd {name} && claude(再起動)にフォールバックしてください。/cd {name} をユーザーに渡すメッセージは、ユーザーが再度話しかけるまで最後のターンです(/cd はサーバー側の処理を発動させません)。そのため、必ず再開方法を示す案内で終わる必要があります(例:「移動したら『what's next』と言ってください」)。/cd の後、セッションが組織を接続したり自動的に続いたりすることがあるかのような約束はしないでください。ユーザーが再度話しかけるまで、セッションは静かなままです。/cd の後は、sf-context detect を実行したり check-tools を呼び出したりして、バナーを「表示」しようとしないでください。detect をツールとして呼び出すと生の JSON が出力され、プラグインはバナーを自分で表示します(セッションあたり 1 回;方向確認の質問時には位置インジケータ)。ヘルスチェックはオンデマンドで /salesforce-development:setup 経由で利用可能です。--instance-url https://test.salesforce.com が必須です(CLI デフォルトは本番環境を指しています)。platform-environment-validate(または /salesforce-development:setup)を使用してください。既存プロジェクトの組織認証の場合は /salesforce-development:login を使用してください。Walk the user through a wizard that scaffolds a new Salesforce DX project, relocates this session into the new project, connects it to an org, and configures it for development. Run each step in order, confirming with the user before any environment-changing action.
The salesforce-development plugin's MCP servers (salesforce-api-context, salesforce-metadata-experts, salesforce-lsp) are provided by the installed plugin, not by the project — so they stay available in the new project automatically once the session relocates. There is no per-project .mcp.json to copy.
Prompt the user to pick a template. Default to standard if they don't have a preference.
| Template | Use for |
|---|---|
standard (default) |
General-purpose SFDX project with the conventional force-app layout |
empty |
Bare project with minimal scaffolding |
analytics |
CRM Analytics (Tableau CRM) development |
reactinternalapp |
React-based internal app |
reactexternalapp |
React-based external/experience app |
agent |
Agentforce agent development |
Prompt the user for a project name. This becomes the new directory name, so it must be a valid directory name (no spaces or path separators).
Run in the current working directory:
sf project generate -t {template} -n {name}
This creates a new {name}/ directory under the current working directory.
Modern Claude Code (v2.1.169+) can move the current session into the new directory in place — no new terminal, no relaunch, conversation history preserved. Tell the user to run:
/cd {name}
This relocates the session: the new directory's CLAUDE.md is loaded, project storage moves there (so --resume/--continue find it), and the cwd becomes the project root, so all remaining sf commands run as plain sf ... with no path prefix.
/cd is a client-side move: it fires no hook and gives you no turn, so the session goes quiet the instant they run it — expected, not a hang. But it also means the message in which you hand them /cd is your last word until they speak again, so that message MUST end with an affordance telling them how to resume. Close it with a line like:
Once you're in, just say "what's next" (or "connect an org") and I'll pick up from there.
Saying "what's next" re-engages this session and paints the position rail, which points at the next step (authenticating an org). Never imply the session will continue on its own after /cd — it won't.
When they re-engage, confirm the move in one short line (e.g. "You're in {name} now.") and continue to Step 5. Do not run sf-context detect or check-tools to "re-surface" the banner: detect invoked as a tool prints the raw hook JSON (not a rendered banner), and the plugin already surfaces the banner on its own — it shows the HEADLESS identity once per session (at the user's first Salesforce ask, at session start, or on their first orientation question), and paints the position rail whenever they ask "where am I" / "what's next". A dev-environment health check is available on demand via /salesforce-development:setup.
Fallback for older Claude Code (before v2.1.169): /cd reports Unknown command. In that case the user must relaunch in the new directory instead:
cd {name} && claude
The salesforce-development plugin is installed globally (via the marketplace), so a fresh session in the new directory loads it automatically and fires SessionStart — the banner and health check appear on their own, no manual sf-context calls needed. The remaining steps below then run from inside the project.
Authenticate the org this project will deploy to:
sf org login web --alias {alias}
--alias so later steps can reference the org by name.--instance-url https://test.salesforce.com.--instance-url (defaults to login.salesforce.com).If the user already has the org authenticated, skip the login and just collect the existing alias.
Set the freshly authenticated org as the project's default target:
sf config set target-org {alias}
Check whether source tracking works against the org using a deploy preview (the lightest read-only source-tracking probe):
sf project deploy preview --target-org {alias} --json
If this fails with an error mentioning source tracking not supported or not enabled, offer to enable it:
sf org enable tracking --target-org {alias}
Confirm with the user before running the enable command.
Once all steps are complete, tell the user:
Your project is ready! Here's what was set up:
✅ Project generated: {name}/
✅ Session relocated into {name}/ (via /cd)
✅ Default org: {alias}
✅ Source tracking: enabled (or status)
You're already working inside the new project — this same session moved
here with /cd, so just keep going. Run /salesforce-development:setup
anytime to re-check your dev environment.
If the user took the older-version fallback (relaunched with cd {name} && claude instead of /cd), they're in a fresh session in the project and the SessionStart banner already walked them through the environment — point them to /salesforce-development:setup to re-check tools.
.mcp.json into the new project (the plugin's config uses ${CLAUDE_PLUGIN_ROOT}, which does not resolve in a project-level file)./cd {name} to relocate the session in place (Claude Code v2.1.169+) — a skill can't relocate the session on the user's behalf, so instruct the user to run it. Only fall back to cd {name} && claude (relaunch) when /cd reports Unknown command on an older build./cd {name} is your last turn until they speak again (/cd fires no hook), so it MUST end with a resume affordance — e.g. 'once you're in, just say "what's next".' Never promise the session will connect an org or continue on its own after /cd; it stays silent until the user re-engages./cd, do NOT run sf-context detect or check-tools to "show" the banner — detect as a tool prints raw JSON, and the plugin surfaces the banner itself (once per session; the position rail on orientation questions). Just confirm the move in one line and continue. Health is available on demand via /salesforce-development:setup.--instance-url https://test.salesforce.com is REQUIRED (the CLI default points at production).platform-environment-validate (or /salesforce-development:setup); for org auth on an existing project, use /salesforce-development:login.原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。