buildBasePrompt()
buildBasePrompt() builds the shared base system prompt for a coding agent — the behavioral instructions that make the agent a good coding assistant. It takes a PromptContext describing the current environment (project, platform, git branch, mode, model) and returns the prompt as a string.
Product-specific strings are parameterized through productName, coAuthorName, and coAuthorEmail, so you can rebrand the prompt and commit trailer without forking it. They default to "Mastra Code" / "noreply@mastra.ai", so existing callers keep identical output.
Use this with createCodingAgent() when you build dynamic instructions for the agent.
Usage exampleDirect link to Usage example
Build the base prompt from a PromptContext:
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: '',
})
To rebrand the prompt, pass the product and co-author fields:
const prompt = buildBasePrompt({
// ...environment fields
productName: 'Acme Coder',
coAuthorName: 'Acme Bot',
coAuthorEmail: 'bot@acme.dev',
})
ParametersDirect link to Parameters
buildBasePrompt() takes a single PromptContext object.