Code Review Assistant
System Prompt: Define review criteria, coding standards, security checks
Best for: Pull request reviews, code quality assessment, best practices
Set system instructions that define the agent’s behavior of the model. System prompts establish the foundation how the agent will respond to user inputs.
systemPrompt(prompt: string): AgentForceAgent
prompt
string
undefined
Returns the AgentForceAgent
instance for method chaining.
import { AgentForceAgent } from '@agentforce/adk';
const agent = new AgentForceAgent({ name: "AnalystAgent"}) .systemPrompt("You are a data analyst specializing in sales metrics") .useLLM("ollama", "gemma3:4b") .prompt("Analyze quarterly sales data");
const response = await agent.output("json");
import { AgentForceAgent } from '@agentforce/adk';
// system-prompt.md contains detailed instructionsconst agent = new AgentForceAgent({ name: "CodeReviewer"}) .systemPrompt("./prompts/code-reviewer.md") .useLLM("openrouter", "mistralai/mistral-small") .prompt("Review this TypeScript code of my react app");
const response = await agent.output("text");
import { AgentForceAgent } from '@agentforce/adk';
// Uses Handlebars template for dynamic promptsconst agent = new AgentForceAgent({ name: "PersonalizedAgent"}) .systemPrompt("./prompts/personalized.hbs", { userName: "Alice", task: "help with project planning" }) .prompt("Help me with my task");
const response = await agent.output("text");
Define specific roles and behaviors for different use cases:
const techAgent = new AgentForceAgent({ name: "TechExpert" }) .systemPrompt(`You are a senior software engineer with expertise in:- TypeScript and JavaScript- Node.js and modern web frameworks- Database design and optimization- Code review and best practices
Always provide practical, actionable advice with code examples.`) .useLLM("google", "gemini-1.5-flash");
const writerAgent = new AgentForceAgent({ name: "CreativeWriter" }) .systemPrompt(`You are a creative writing assistant specializing in:- Storytelling and narrative structure- Character development- Dialogue and voice- Genre conventions
Write in an engaging, imaginative style that captivates readers.`) .useLLM("ollama", "phi4-mini:latest", { temperature: 0.8 });
const businessAgent = new AgentForceAgent({ name: "BusinessAnalyst" }) .systemPrompt(`You are a business analyst focused on:- Market research and competitive analysis- Financial modeling and forecasting- Strategic planning and decision support- Data-driven insights and recommendations
Provide structured, analytical responses with clear reasoning.`) .useLLM("openrouter", "moonshotai/kimi-k2:free");
const agent = new AgentForceAgent({ name: "SupportAgent" }) .systemPrompt("./prompts/customer-service.md") .prompt("Help customer with billing issue");
customer-service.md:
# Customer Service Agent
You are a professional customer service representative with these qualities:
## Tone and Communication- Always polite, empathetic, and helpful- Use clear, jargon-free language- Acknowledge customer concerns immediately
## Problem Resolution Process1. Listen and understand the issue completely2. Acknowledge the customer's frustration3. Provide clear, step-by-step solutions4. Follow up to ensure satisfaction
## Escalation Guidelines- Escalate billing issues over $500- Escalate technical problems requiring developer intervention- Always offer alternatives when initial solution isn't possible
const agent = new AgentForceAgent({ name: "CodeReviewer" }) .systemPrompt("./prompts/code-reviewer.txt") .prompt("Review this pull request");
code-reviewer.txt:
You are an experienced code reviewer focusing on:
SECURITY:- Check for potential vulnerabilities- Validate input sanitization- Review authentication and authorization
PERFORMANCE:- Identify inefficient algorithms- Check for memory leaks- Review database query optimization
CODE QUALITY:- Ensure consistent formatting- Validate error handling- Check for proper documentation
const contextualAgent = new AgentForceAgent({ name: "ContextualAgent" }) .systemPrompt(`You are assisting a ${process.env.USER_ROLE || 'user'} with ${process.env.PROJECT_TYPE || 'general'} tasks.
Current environment: ${process.env.NODE_ENV || 'development'}Timestamp: ${new Date().toISOString()}
Adapt your responses to the user's role and project context.`) .useLLM("google", "gemini-1.5-pro");
The method automatically detects and loads files with these extensions:
.md
Markdown
Rich formatted prompts with headers, lists, and structure
.txt
Plain Text
Simple text prompts without formatting
.hbs
Handlebars
Dynamic templates with variables and conditionals
.md
, .txt
, or .hbs
The systemPrompt()
method supports fluent chaining with other AgentForceAgent methods:
const agent = new AgentForceAgent({ name: "ChainedAgent" }) .systemPrompt("You are a helpful coding assistant") .useLLM("ollama", "gemma3:4b") .prompt("Explain async/await in JavaScript") .debug();
const response = await agent.output("text");
Code Review Assistant
System Prompt: Define review criteria, coding standards, security checks
Best for: Pull request reviews, code quality assessment, best practices
Customer Support
System Prompt: Set tone, escalation rules, company policies
Best for: Automated support, FAQ responses, issue triage
Content Creator
System Prompt: Define writing style, target audience, content guidelines
Best for: Blog posts, documentation, marketing copy
Data Analyst
System Prompt: Set analytical approach, output format, visualization preferences
Best for: Report generation, data insights, trend analysis
// Clear role definition.systemPrompt(`You are a TypeScript expert who:- Writes type-safe, maintainable code- Follows modern ES6+ conventions- Provides clear explanations with examples- Suggests performance optimizations when relevant`)
// Specific behavior guidelines.systemPrompt(`Guidelines:1. Always validate inputs2. Use descriptive variable names3. Include error handling4. Add inline comments for complex logic`)
// Context-aware instructions.systemPrompt(`Project Context:- React TypeScript application- Using Tailwind CSS for styling- Following clean architecture principles- Target audience: intermediate developers`)
// Too vague.systemPrompt("Be helpful")
// Too restrictive.systemPrompt("Only answer with yes or no")
// Conflicting instructions.systemPrompt("Be creative but stick strictly to facts")
// Missing context.systemPrompt("Review this code") // What kind of review?
// If file doesn't exist or can't be read, treats as literal textconst agent = new AgentForceAgent({ name: "SafeAgent" }) .systemPrompt("./nonexistent-file.md") // Shows warning, uses as literal text .prompt("Test prompt");
try { const response = await agent.output("text");} catch (error) { console.error("Agent Error:", error.message);}
Console Warnings:
Warning: File './prompts/missing.md' not found, treating as regular prompt text
Warning: Failed to read file './prompts/locked.md': Permission denied. Treating as regular prompt text.
.useLLM()
- Configure LLM provider and model.prompt()
- Set the main user prompt.output()
- Execute and get response.debug()
- Enable debug logging