Claude Code system prompt: what is in it, and how to append to it or replace it
What Claude Code's system prompt holds, how to add to it with --append-system-prompt or replace it, where CLAUDE.md and output styles fit, and per-project use.
Claude Code sends Claude a system prompt of its own — how to behave, how to use its tools, safety rules — that you never see in the session. You change it at launch: --append-system-prompt adds your text after it, --system-prompt replaces it. CLAUDE.md is not part of it; Claude Code sends that as a message after the system prompt.
What is in Claude Code's system prompt
Anthropic describes it, in the Agent SDK docs, as the prompt the CLI uses, "with tool usage instructions and security and safety instructions", written for a coding agent in a repository with a human watching and steering. The docs describe it; they do not print it.
Two things often taken for it are not:
- Anthropic's "System prompts" release notes cover claude.ai and the Claude phone apps. They "do not apply to the Claude API", and they are not Claude Code's prompt.
- The Piebald-AI/claude-code-system-prompts repository (MIT) extracts the prompt's parts from each Claude Code release — on 20 October 2026 its README was at v2.1.304 and counted more than 500 strings: the main prompt in pieces, tool descriptions, the Plan and Explore agents' prompts, the compaction prompt. It is read out of the program, not Anthropic's documentation.
To see how much room it takes in your own session, run /context: the system prompt is one of the rows in what fills the context window.
The five system prompt flags
| Flag | Does |
|---|---|
--append-system-prompt | adds text after the default prompt |
--append-system-prompt-file | adds a file's contents after it |
--system-prompt | replaces the whole prompt |
--system-prompt-file | replaces it with a file's contents |
--system-prompt-snapshot off | rebuilds the prompt on every request |
claude --append-system-prompt "Write commit messages in Conventional Commits" claude --append-system-prompt-file ./team-rules.md
You can combine them: a replacement plus an appended file, or, from Claude Code 2.1.283, a flag together with its own file form. With --append-system-prompt-file and --append-system-prompt together, the file's contents come first whatever order you type them in.
Append or replace?
Append, for coding work. Replacing removes the instructions Claude Code relies on — in the SDK docs' words, you "take responsibility for replacing the tool guidance and safety instructions your agent still needs". Anthropic's own table calls the append route "the lowest-risk customization": "Nothing is removed."
Replace when the agent is not Claude Code any more: a different name, a non-coding job, no human in the loop.
Why a resumed session ignores the new text
Claude Code builds the system prompt once, on a conversation's first request, and records it. Every later request reuses that recording — after --resume and --continue too — until the conversation is compacted. So new flag text, or none, reaches an old conversation only after /compact or in a new one.
While you are still tuning the wording, --system-prompt-snapshot off rebuilds the prompt on every request (Claude Code 2.1.257 or later).
System prompt, CLAUDE.md, output style: which one
| You want | Use |
|---|---|
| project conventions everyone shares | CLAUDE.md |
| a different voice, length or role for every reply | an output style |
| text added for one launch, or by a script | --append-system-prompt |
| a whole new agent, not Claude Code | --system-prompt |
| something enforced every time | a hook |
- CLAUDE.md "is delivered as a user message after the system prompt, not as part of the system prompt itself". The project-root file reloads from disk after compaction. What to put in it: CLAUDE.md.
- Output styles change the instructions Claude Code sends with every request. A custom style drops Claude Code's software engineering instructions unless its frontmatter has
keep-coding-instructions: true. Pick one with/output-style, or"outputStyle"in settings. - Subagents run their own system prompt; output styles and the main session's auto memory do not reach them, except a fork of the conversation, which inherits both.
--append-subagent-system-promptadds to theirs, with-ponly.
A system prompt per project: Caprock
The flags are per launch, so a project's own rules mean retyping them or wrapping claude in a script. Caprock's desktop app keeps them with the project instead. Write them as you add a project, or later on the New agent sheet under Project instructions. Every session Caprock starts in that project then gets them:
- Claude Code through
--append-system-prompt, after Claude Code's own prompt, which stays in place. Since 0.81.0. - Codex as its developer instructions,
-c developer_instructions=…— Codex's own setting for "additional developer instructions injected into the session" — beside the repository'sAGENTS.md. Since 0.82.0. - Grok Build through
--rules, which appends to Grok's system prompt. Since 0.99.0.
What to expect:
- Up to 16 KB, since they travel on the command line.
- Kept by Caprock, on your machine, not in the repository: CLAUDE.md is untouched, and teammates do not get them.
- Only sessions Caprock starts, from the app or a paired phone. A
claudeyou start in your own terminal does not get them, and neither do OpenCode, Gemini CLI and Hermes Agent. - The recording rule still holds. Caprock passes the flag when it continues a session too, but a conversation keeps the prompt it started with until it is compacted, so edited instructions reach the next new one.
Install Caprock to set them per project.
Questions people ask
- How do I add to Claude Code's system prompt?
- Start Claude Code with --append-system-prompt "your text", or --append-system-prompt-file ./rules.md for longer text. Claude Code keeps its own prompt and puts yours after it.
- How do I replace Claude Code's system prompt?
- Use --system-prompt "text" or --system-prompt-file ./prompt.txt. That removes Claude Code's own instructions, including its tool guidance and safety rules, so appending is the safer choice for coding work.
- Is CLAUDE.md part of the system prompt?
- No. Anthropic's docs say CLAUDE.md content is delivered as a user message after the system prompt. For instructions at the system-prompt level, they point to --append-system-prompt.
- Can I see Claude Code's system prompt?
- Claude Code has no documented command that prints it, and Anthropic's docs describe it without printing it. The open-source Piebald-AI/claude-code-system-prompts repository extracts its parts from each release. /context shows how much of the context window it takes.
- Why did my new --append-system-prompt text not apply to a resumed session?
- Claude Code records the system prompt on a conversation's first request and reuses it, through --resume and --continue, until the conversation is compacted. Start a new conversation, compact, or pass --system-prompt-snapshot off.
- Can I set a system prompt per project?
- There is no per-project append flag. The nearest setting is a project output style (.claude/output-styles/ plus outputStyle in the project's settings), which replaces Claude Code's coding instructions unless its frontmatter sets keep-coding-instructions: true. Caprock's desktop app keeps instructions per project and appends them to every Claude Code session it starts there, and passes them to Codex as developer instructions.
Sources
- Claude Code docs — CLI reference: system prompt flags, and system prompt flags in resumed conversations, read 20 October 2026
- Claude Code docs — Output styles, read 20 October 2026
- Claude Code docs — How Claude remembers your project (CLAUDE.md is a user message after the system prompt), read 20 October 2026
- Claude Code docs — Agent SDK: modifying system prompts (the claude_code preset), read 20 October 2026
- Claude Code docs — Context window (what survives compaction), read 20 October 2026
- Claude Platform docs — System prompts release notes (claude.ai and the Claude apps, not the API), read 20 October 2026
- Piebald-AI/claude-code-system-prompts on GitHub, read 20 October 2026
- OpenAI Codex docs — Configuration reference: developer_instructions, read 20 October 2026
- Caprock docs — project instructions in the desktop app (docs/app.md)
- Caprock source — --append-system-prompt for Claude Code, developer_instructions for Codex (internal/agents/argv.go)
- Caprock source — instructions capped at 16 KB, kept with the project (internal/projects/projects.go)
- Caprock source — --rules for Grok Build (internal/agents/grok.go)
- Caprock changelog — 0.81.0 project instructions; 0.82.0 for Codex too; 0.99.0 Grok Build
Try it
The record of every coding agent you run, the sessions it did not start included. Free, open source; nothing leaves your machine.
Notarized by Apple. One file for Apple silicon and Intel, macOS 13 or later.
Or run it yourself:
Paste in Terminal: it installs Caprock and opens it.Or with Homebrew: brew install --cask dspv/tap/caprock-app