Skip to content

Home / Glossary / System Prompt

Definition

System Prompt

A system prompt is a set of instructions provided to an AI model before the user's message that defines the model's behavior, persona, constraints, and capabilities. It acts as a configuration layer that shapes every response the model produces, without the user needing to repeat these instructions in each message.

How system prompts shape AI behavior

When you interact with an AI model, there are typically three roles in the conversation: system, user, and assistant. The system prompt is set by the application developer and defines ground rules—what the model should do, how it should respond, what it should refuse, and what persona it should adopt. For AI coding tools, the system prompt configures the model to be a coding assistant: it defines available tools, sets code quality standards, and establishes output formats.

System prompts in AI coding tools

Tools like Claude Code use extensive system prompts to define the agent's capabilities. The system prompt tells the model about available tools (Read, Edit, Bash), project context, permission rules, and behavioral guidelines. Your CLAUDE.md file is effectively an extension of the system prompt—project-specific instructions that get prepended to every conversation. This is why CLAUDE.md is so powerful: it directly influences the model's behavior at the system prompt level.

typescript
// Example: system prompt for a code review assistant
const systemPrompt = `You are a senior code reviewer.
Review code changes for:
- Security vulnerabilities (SQL injection, XSS, CSRF)
- Error handling (missing try/catch, unhandled promises)
- Performance (N+1 queries, unnecessary re-renders)
- Style (naming conventions, code organization)

Format each issue as:
[SEVERITY] file:line - description

Severity levels: CRITICAL, WARNING, SUGGESTION
Do not flag stylistic preferences unless they affect readability.
Always explain WHY something is an issue, not just WHAT.`;

const response = await anthropic.messages.create({
  model: "claude-sonnet-4-20250514",
  system: systemPrompt,
  messages: [{ role: "user", content: codeDiff }]
});

CLAUDE.md is essentially a user-editable system prompt extension. The instructions you put in CLAUDE.md get the same priority as system-level instructions, which is why they are so effective at controlling agent behavior.

Can users see the system prompt?+
In most applications, the system prompt is hidden from end users. However, it is not a security mechanism—determined users can sometimes extract it through prompt injection techniques. Never put secrets or sensitive logic in a system prompt.
How long should a system prompt be?+
As long as needed but as short as possible. System prompts consume tokens from the context window on every message. For coding tools, system prompts typically range from 500 to 5,000 tokens. Prioritize the most impactful instructions and keep them clear.
What is the difference between a system prompt and CLAUDE.md?+
The system prompt is set by the tool developer (Anthropic, for Claude Code) and defines core behavior. CLAUDE.md is set by the user and provides project-specific context. Both influence the model, but CLAUDE.md lets you customize behavior without modifying the tool itself.

Related terms

CLAUDE.mdPrompt Engineering for CodeLarge Language Model (LLM)Temperature

Related comparisons

Claude Code vs CursorClaude Code vs GitHub Copilot

Master Claude Code in days, not months

37 hands-on lessons from beginner to CI/CD automation. Module 1 is free.

START FREE →
← ALL TERMS