Guide for writing effective system prompts for LLM agents. Use when creating or editing system prompts for applications, agent configurations, or development tools.
Write effective system prompts for LLM agents and applications.
LLMs are intelligent by default. They will take reasonable steps without explicit instruction. A system prompt exists to set direction and impose constraints, not to explain how to think or reason.
Start with an empty or minimal prompt. Observe what the agent does wrong. Add instructions only for behaviors that need correction. Every line in a prompt should justify its presence by fixing a real observed problem.
Avoid:
Use markdown with sections and paragraphs. Each section describes a specific behavior or constraint.
Each section should:
Examples are the most effective way to communicate behavior. Wrap each example in <example> tags with user: and assistant: prefixes.
<example>
user: What's the capital of France?
assistant: Paris
</example>
For complex behaviors, use separate example tags for each case:
<example>
user: Explain how authentication works in this codebase
assistant: [reads relevant files, then provides explanation]
</example>
<example>
user: Fix the bug in the login form
assistant: [investigates the issue, makes the fix, verifies it works]
</example>
When behavior involves tool use or multiple steps, describe actions in brackets rather than showing tool invocations:
<example>
user: Find all TODO comments
assistant: [searches codebase for TODO patterns]
Found 3 TODOs:
- src/auth.ts:45: TODO: add rate limiting
- src/api.ts:120: TODO: handle edge case
- src/db.ts:89: TODO: add index
</example>
Each user/assistant pair gets its own example tag:
<example>
user: 4 + 4
assistant: 8
</example>
<example>
user: What's the time complexity of binary search?
assistant: O(log n)
</example>
Include instructions for:
Do not include:
Prompt development is empirical:
Track which instructions address which problems. If you cannot point to a specific failure that an instruction prevents, consider removing it.
Different models have different default behaviors and respond to different prompting patterns. Consult the relevant guide when writing prompts for a specific model:
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer