> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # buildBasePrompt() `buildBasePrompt()` は、Coding Agent を優れたコーディングアシスタントとして動作させるための指示である、共通のベースシステムプロンプトを構築します。現在の環境(プロジェクト、プラットフォーム、Git ブランチ、モード、モデル)を記述する `PromptContext` を受け取り、プロンプトを文字列として返します。 製品固有の文字列は `productName`、`coAuthorName`、`coAuthorEmail` によってパラメーター化されているため、フォークせずにプロンプトやコミットトレーラーのブランドを変更できます。デフォルトは `"Mastra Code"` / `"noreply@mastra.ai"` なので、既存の呼び出し元では同一の出力が維持されます。 Agent の指示を実行時に定義して構築する場合は、[`createCodingAgent()`](https://mastra.zisheng.pro/ja/reference/coding-agent/create-coding-agent) と組み合わせて使用します。 ## 使用例 `PromptContext` からベースプロンプトを構築します。 ```typescript import { buildBasePrompt } from '@mastra/core/coding-agent' const prompt = buildBasePrompt({ projectPath: process.cwd(), projectName: 'my-app', gitBranch: 'main', platform: process.platform, date: new Date().toDateString(), mode: 'build', modelId: 'openai/gpt-5', toolGuidance: '', }) ``` プロンプトのブランドを変更するには、製品と共同作成者のフィールドを渡します。 ```typescript const prompt = buildBasePrompt({ // ...environment fields productName: 'Acme Coder', coAuthorName: 'Acme Bot', coAuthorEmail: 'bot@acme.dev', }) ``` ## パラメーター `buildBasePrompt()` は 1 つの `PromptContext` オブジェクトを受け取ります。 **projectPath** (`string`): プロジェクトルートの絶対パス。 **projectName** (`string`): プロジェクトの表示名。 **gitBranch** (`string`): プロジェクトが Git リポジトリの場合の、現在の Git ブランチ。 **platform** (`string`): オペレーティングシステムのプラットフォーム(例: process.platform の値)。 **commonBinaries** (`{ name: string; path: string | null }[]`): システムで検出された一般的なバイナリ。それぞれに名前と解決済みのパス(見つからない場合は null)が含まれます。 **date** (`string`): プロンプトに挿入する現在の日付文字列。 **mode** (`string`): アクティブな Agent モード(例: "build"、"plan")。 **modelId** (`string`): アクティブなモデルの識別子。指定すると、コミットの Co-Authored-By 行に含まれます。 **activePlan** (`{ title: string; plan: string; approvedAt: string } | null`): 現在承認されている計画(存在する場合)。 **toolGuidance** (`string`): プロンプトに追加する Tool 使用ガイダンスのセクション。 **productName** (`string`): プロンプトのヘッダーで使用する表示名。 (Default: `Mastra Code`) **coAuthorName** (`string`): コミットの Co-Authored-By 行で使用する名前。 (Default: `Mastra Code`) **coAuthorEmail** (`string`): コミットの Co-Authored-By 行で使用するメールアドレス。 (Default: `noreply@mastra.ai`) ## 戻り値 **prompt** (`string`): Coding Agent のベースシステムプロンプト。 ## 関連項目 - [`createCodingAgent()`](https://mastra.zisheng.pro/ja/reference/coding-agent/create-coding-agent)