Understanding system prompts
A system prompt is the initial instruction set that shapes how Claude behaves throughout a conversation. Claude Code’s default system prompt includes:- Tool usage instructions and available tools
- Code style and formatting guidelines
- Response tone and verbosity settings
- Security and safety instructions
- Context about the current working directory and environment
Methods of modification
Method 1: Output styles (persistent configurations)
Output styles are saved configurations that modify Claude’s system prompt. They’re stored as markdown files and can be reused across sessions and projects.Creating an output style
Using output styles
Once created, activate output styles via:- CLI:
/output-style [style-name]
- Settings:
.claude/settings.local.json
- Create new:
/output-style:new [description]
Method 2: Using appendSystemPrompt
The appendSystemPrompt
option adds your custom instructions to the default system prompt while preserving all built-in functionality.
Method 3: Using customSystemPrompt
The customSystemPrompt
option replaces the entire default system prompt with your custom instructions.
Comparison of all three approaches
Feature | Output Styles | appendSystemPrompt | customSystemPrompt |
---|---|---|---|
Persistence | ✅ Saved as files | ❌ Session only | ❌ Session only |
Reusability | ✅ Across projects | ❌ Code duplication | ❌ Code duplication |
Management | ✅ CLI + files | ⚠️ In code | ⚠️ In code |
Default tools | ✅ Preserved | ✅ Preserved | ❌ Lost (unless included) |
Built-in safety | ✅ Maintained | ✅ Maintained | ❌ Must be added |
Environment context | ✅ Automatic | ✅ Automatic | ❌ Must be provided |
Customization level | ⚠️ Replace default | ⚠️ Additions only | ✅ Complete control |
Version control | ✅ Yes | ✅ With code | ✅ With code |
Discovery | ✅ /output-style | ❌ Not discoverable | ❌ Not discoverable |
Use cases and best practices
When to use output styles
Best for:- Persistent behavior changes across sessions
- Team-shared configurations
- Specialized assistants (code reviewer, data scientist, DevOps)
- Complex prompt modifications that need versioning
- Creating a dedicated SQL optimization assistant
- Building a security-focused code reviewer
- Developing a teaching assistant with specific pedagogy
When to use appendSystemPrompt
Best for:
- Adding specific coding standards or preferences
- Customizing output formatting
- Adding domain-specific knowledge
- Modifying response verbosity
When to use customSystemPrompt
Best for:
- Complete control over Claude’s behavior
- Specialized single-session tasks
- Testing new prompt strategies
- Situations where default tools aren’t needed
Combining approaches
You can combine these methods for maximum flexibility:Example: Output style with session-specific additions
See also
- Output styles - Complete output styles documentation
- TypeScript SDK guide - Complete SDK usage guide
- TypeScript SDK reference - Full API documentation
- Configuration guide - General configuration options