Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Claude Code agentic coding tool — terminal-based assistant for coding, git workflows, and codebase understanding.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/system-prompt-design.md
1# System Prompt Design Patterns23Complete guide to writing effective agent system prompts that enable autonomous, high-quality operation.45## Core Structure67Every agent system prompt should follow this proven structure:89```markdown10You are [specific role] specializing in [specific domain].1112**Your Core Responsibilities:**131. [Primary responsibility - the main task]142. [Secondary responsibility - supporting task]153. [Additional responsibilities as needed]1617**[Task Name] Process:**181. [First concrete step]192. [Second concrete step]203. [Continue with clear steps]21[...]2223**Quality Standards:**24- [Standard 1 with specifics]25- [Standard 2 with specifics]26- [Standard 3 with specifics]2728**Output Format:**29Provide results structured as:30- [Component 1]31- [Component 2]32- [Include specific formatting requirements]3334**Edge Cases:**35Handle these situations:36- [Edge case 1]: [Specific handling approach]37- [Edge case 2]: [Specific handling approach]38```3940## Pattern 1: Analysis Agents4142For agents that analyze code, PRs, or documentation:4344```markdown45You are an expert [domain] analyzer specializing in [specific analysis type].4647**Your Core Responsibilities:**481. Thoroughly analyze [what] for [specific issues]492. Identify [patterns/problems/opportunities]503. Provide actionable recommendations5152**Analysis Process:**531. **Gather Context**: Read [what] using available tools542. **Initial Scan**: Identify obvious [issues/patterns]553. **Deep Analysis**: Examine [specific aspects]:56- [Aspect 1]: Check for [criteria]57- [Aspect 2]: Verify [criteria]58- [Aspect 3]: Assess [criteria]594. **Synthesize Findings**: Group related issues605. **Prioritize**: Rank by [severity/impact/urgency]616. **Generate Report**: Format according to output template6263**Quality Standards:**64- Every finding includes file:line reference65- Issues categorized by severity (critical/major/minor)66- Recommendations are specific and actionable67- Positive observations included for balance6869**Output Format:**70## Summary71[2-3 sentence overview]7273## Critical Issues74- [file:line] - [Issue description] - [Recommendation]7576## Major Issues77[...]7879## Minor Issues80[...]8182## Recommendations83[...]8485**Edge Cases:**86- No issues found: Provide positive feedback and validation87- Too many issues: Group and prioritize top 1088- Unclear code: Request clarification rather than guessing89```9091## Pattern 2: Generation Agents9293For agents that create code, tests, or documentation:9495```markdown96You are an expert [domain] engineer specializing in creating high-quality [output type].9798**Your Core Responsibilities:**991. Generate [what] that meets [quality standards]1002. Follow [specific conventions/patterns]1013. Ensure [correctness/completeness/clarity]102103**Generation Process:**1041. **Understand Requirements**: Analyze what needs to be created1052. **Gather Context**: Read existing [code/docs/tests] for patterns1063. **Design Structure**: Plan [architecture/organization/flow]1074. **Generate Content**: Create [output] following:108- [Convention 1]109- [Convention 2]110- [Best practice 1]1115. **Validate**: Verify [correctness/completeness]1126. **Document**: Add comments/explanations as needed113114**Quality Standards:**115- Follows project conventions (check CLAUDE.md)116- [Specific quality metric 1]117- [Specific quality metric 2]118- Includes error handling119- Well-documented and clear120121**Output Format:**122Create [what] with:123- [Structure requirement 1]124- [Structure requirement 2]125- Clear, descriptive naming126- Comprehensive coverage127128**Edge Cases:**129- Insufficient context: Ask user for clarification130- Conflicting patterns: Follow most recent/explicit pattern131- Complex requirements: Break into smaller pieces132```133134## Pattern 3: Validation Agents135136For agents that validate, check, or verify:137138```markdown139You are an expert [domain] validator specializing in ensuring [quality aspect].140141**Your Core Responsibilities:**1421. Validate [what] against [criteria]1432. Identify violations and issues1443. Provide clear pass/fail determination145146**Validation Process:**1471. **Load Criteria**: Understand validation requirements1482. **Scan Target**: Read [what] needs validation1493. **Check Rules**: For each rule:150- [Rule 1]: [Validation method]151- [Rule 2]: [Validation method]1524. **Collect Violations**: Document each failure with details1535. **Assess Severity**: Categorize issues1546. **Determine Result**: Pass only if [criteria met]155156**Quality Standards:**157- All violations include specific locations158- Severity clearly indicated159- Fix suggestions provided160- No false positives161162**Output Format:**163## Validation Result: [PASS/FAIL]164165## Summary166[Overall assessment]167168## Violations Found: [count]169### Critical ([count])170- [Location]: [Issue] - [Fix]171172### Warnings ([count])173- [Location]: [Issue] - [Fix]174175## Recommendations176[How to fix violations]177178**Edge Cases:**179- No violations: Confirm validation passed180- Too many violations: Group by type, show top 20181- Ambiguous rules: Document uncertainty, request clarification182```183184## Pattern 4: Orchestration Agents185186For agents that coordinate multiple tools or steps:187188```markdown189You are an expert [domain] orchestrator specializing in coordinating [complex workflow].190191**Your Core Responsibilities:**1921. Coordinate [multi-step process]1932. Manage [resources/tools/dependencies]1943. Ensure [successful completion/integration]195196**Orchestration Process:**1971. **Plan**: Understand full workflow and dependencies1982. **Prepare**: Set up prerequisites1993. **Execute Phases**:200- Phase 1: [What] using [tools]201- Phase 2: [What] using [tools]202- Phase 3: [What] using [tools]2034. **Monitor**: Track progress and handle failures2045. **Verify**: Confirm successful completion2056. **Report**: Provide comprehensive summary206207**Quality Standards:**208- Each phase completes successfully209- Errors handled gracefully210- Progress reported to user211- Final state verified212213**Output Format:**214## Workflow Execution Report215216### Completed Phases217- [Phase]: [Result]218219### Results220- [Output 1]221- [Output 2]222223### Next Steps224[If applicable]225226**Edge Cases:**227- Phase failure: Attempt retry, then report and stop228- Missing dependencies: Request from user229- Timeout: Report partial completion230```231232## Writing Style Guidelines233234### Tone and Voice235236**Use second person (addressing the agent):**237```238✅ You are responsible for...239✅ You will analyze...240✅ Your process should...241242❌ The agent is responsible for...243❌ This agent will analyze...244❌ I will analyze...245```246247### Clarity and Specificity248249**Be specific, not vague:**250```251✅ Check for SQL injection by examining all database queries for parameterization252❌ Look for security issues253254✅ Provide file:line references for each finding255❌ Show where issues are256257✅ Categorize as critical (security), major (bugs), or minor (style)258❌ Rate the severity of issues259```260261### Actionable Instructions262263**Give concrete steps:**264```265✅ Read the file using the Read tool, then search for patterns using Grep266❌ Analyze the code267268✅ Generate test file at test/path/to/file.test.ts269❌ Create tests270```271272## Common Pitfalls273274### ❌ Vague Responsibilities275276```markdown277**Your Core Responsibilities:**2781. Help the user with their code2792. Provide assistance2803. Be helpful281```282283**Why bad:** Not specific enough to guide behavior.284285### ✅ Specific Responsibilities286287```markdown288**Your Core Responsibilities:**2891. Analyze TypeScript code for type safety issues2902. Identify missing type annotations and improper 'any' usage2913. Recommend specific type improvements with examples292```293294### ❌ Missing Process Steps295296```markdown297Analyze the code and provide feedback.298```299300**Why bad:** Agent doesn't know HOW to analyze.301302### ✅ Clear Process303304```markdown305**Analysis Process:**3061. Read code files using Read tool3072. Scan for type annotations on all functions3083. Check for 'any' type usage3094. Verify generic type parameters3105. List findings with file:line references311```312313### ❌ Undefined Output314315```markdown316Provide a report.317```318319**Why bad:** Agent doesn't know what format to use.320321### ✅ Defined Output Format322323```markdown324**Output Format:**325## Type Safety Report326327### Summary328[Overview of findings]329330### Issues Found331- `file.ts:42` - Missing return type on `processData`332- `utils.ts:15` - Unsafe 'any' usage in parameter333334### Recommendations335[Specific fixes with examples]336```337338## Length Guidelines339340### Minimum Viable Agent341342**~500 words minimum:**343- Role description344- 3 core responsibilities345- 5-step process346- Output format347348### Standard Agent349350**~1,000-2,000 words:**351- Detailed role and expertise352- 5-8 responsibilities353- 8-12 process steps354- Quality standards355- Output format356- 3-5 edge cases357358### Comprehensive Agent359360**~2,000-5,000 words:**361- Complete role with background362- Comprehensive responsibilities363- Detailed multi-phase process364- Extensive quality standards365- Multiple output formats366- Many edge cases367- Examples within system prompt368369**Avoid > 10,000 words:** Too long, diminishing returns.370371## Testing System Prompts372373### Test Completeness374375Can the agent handle these based on system prompt alone?376377- [ ] Typical task execution378- [ ] Edge cases mentioned379- [ ] Error scenarios380- [ ] Unclear requirements381- [ ] Large/complex inputs382- [ ] Empty/missing inputs383384### Test Clarity385386Read the system prompt and ask:387388- Can another developer understand what this agent does?389- Are process steps clear and actionable?390- Is output format unambiguous?391- Are quality standards measurable?392393### Iterate Based on Results394395After testing agent:3961. Identify where it struggled3972. Add missing guidance to system prompt3983. Clarify ambiguous instructions3994. Add process steps for edge cases4005. Re-test401402## Conclusion403404Effective system prompts are:405- **Specific**: Clear about what and how406- **Structured**: Organized with clear sections407- **Complete**: Covers normal and edge cases408- **Actionable**: Provides concrete steps409- **Testable**: Defines measurable standards410411Use the patterns above as templates, customize for your domain, and iterate based on agent performance.412