prompt-engineering
Skill4 starsChanged 9 months agoMITView on GitHub
Prompt engineering patterns for Claude including system prompts, few-shot examples, chain-of-thought, structured output, templates, and prefilling. Use when the user is writing prompts, designing system instructions, extracting structured data, building prompt templates, or optimizing Claude responses for quality and consistency.
63 other projects use a version of this.
Adopted by
Most recently taken up by
- niki914/zafirotheir own version, first seen Oct 3, 2026
- dimitritholen/1337-claudetheir own version, first seen Sep 23, 2026
- ZeroTokenClaw/agents-skillstheir own version, first seen Sep 21, 2026
- nahid-sparktales/agent-dispatchertheir own version, first seen Sep 21, 2026
- emtcmca/guildprooftheir own version, first seen Sep 20, 2026
- sabahattink/antigravity-fullstack-hqtheir own version, first seen Sep 20, 2026
Used with
Projects with it also use security-checklist, llm-evaluation and 7 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
atuljha23Skillsecurity-checklist
OWASP-style quick reference — authn/authz, injection, secrets, sessions, crypto, dependencies. Use during code review and before committing security-sensitive changes.
Also in 3 projects that use this
stefan-jansenSkillllm-evaluation
LLM evaluation and testing patterns including prompt testing, hallucination detection, benchmark creation, and quality metrics. Use when testing LLM applications, validating prompt quality, implementing systematic evaluation, or measuring LLM performance.
Also in 3 projects that use this
rohitg00Skilldata-engineering
Data engineering patterns for ETL pipelines, data warehousing, Apache Spark, and data quality validation
Also in 3 projects that use this
mrgoonieSkillcontext-engineering
Master context engineering for AI agent systems. Use when designing agent architectures, debugging context failures, optimizing token usage, implementing memory systems, building multi-agent coordination, evaluating agent performance, or developing LLM-powered pipelines. Covers context fundamentals, degradation patterns, optimization techniques (compaction, masking, caching), compression strategies, memory architectures, multi-agent patterns, LLM-as-Judge evaluation, tool design, and project development.
Also in 7 projects that use this
CloudAI-XSkilldatabase-design
Designs database schemas, indexing strategies, query optimization, and migration patterns for SQL and NoSQL databases. Use when designing tables, optimizing queries, fixing N+1 problems, planning migrations, or when asked about database performance, normalization, ORMs, or data modeling.
Also in 4 projects that use this
dylantarreSkillperformance-optimization
Use when animation runs slow, janky, or causes frame drops
Also in 4 projects that use this
Other versions63 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 63
- rohitg00/awesome-claude-code-toolkit★ 2.7ksame name
- NeoLabHQ/context-engineering-kit★ 1.7ksame name
- niki914/zafiro★ 221same name
- CodeAlive-AI/ai-driven-development★ 153same name
- nahid-sparktales/agent-dispatcher★ 59same name
- martinholovsky/claude-skills-generator★ 47same name
- Bbar0n234/learnflow-ai★ 35same name
- geekatron/jerry★ 35same name
- sabahattink/antigravity-fullstack-hq★ 30same name
- liqiongyu/my-agents★ 29same name
53 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository78 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rules/agents.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/claude-initial-setup.mdcCursor rule
- parallel-task-executionSkill
- subagent-patternsSkill
- task-coordinationSkill
- agent-communicationSkill
- context-managementSkill
- multi-agent-orchestrationSkill
- deploy-strategiesSkill
- github-actions-guideSkill
- pipeline-patternsSkill
- anthropic-sdk-guideSkill
- tool-use-patternsSkill
- automated-review-setupSkill
- pr-standardsSkill
- review-checklistSkill
- file-organizationSkill
- immutability-patternsSkill
- naming-conventionsSkill
- branching-strategySkill
- commit-conventionsSkill
- pr-workflowSkill
- migration-patternsSkill
- query-optimizationSkill
- schema-design-guideSkill
- error-tracingSkill
- log-analysisSkill
- systematic-debuggingSkill
- django-admin-customizationSkill
- django-orm-masterySkill
- drf-api-patternsSkill
- docker-compose-guideSkill
- dockerfile-best-practicesSkill
- multi-stage-buildsSkill
- express-error-handlingSkill
- middleware-patternsSkill
- rest-api-nodeSkill
- async-fastapiSkill
- dependency-injection-fastapiSkill
- pydantic-validationSkill
- concurrency-patterns-goSkill
- error-handling-goSkill
- idiomatic-goSkill
- automation-triggersSkill
- hook-recipesSkill
- pre-post-hooksSkill
- junit-testingSkill
- maven-gradle-guideSkill
- spring-boot-patternsSkill
- mcp-resource-patternsSkill
- mcp-server-creationSkill
- mcp-tool-designSkill
- context-optimizationSkill
- knowledge-persistenceSkill
- memory-patternsSkill
- caching-strategiesSkill
- lazy-loading-patternsSkill
- profiling-guideSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 4 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 56 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 45
Use the messages array with alternating user/assistant turns.
- Distinctive: line 65
Ask Claude to reason step-by-step before giving a final answer.
- Distinctive: line 192
Not using XML tags to delimit sections in complex prompts
- Distinctive: line 210
Put the most important instructions at the beginning and end of the system prompt.
- Very specific: line 211
Use XML tags (<context>, <instructions>, <examples>) for clear prompt structure.
“Common” is measured: kept by at least 6 in 10 of the 56 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Prompt Engineering
Patterns and techniques for crafting effective Claude prompts. Covers system prompts, few-shot learning, chain-of-thought reasoning, structured output, and prefilling.
When to Use
- User is writing or optimizing prompts for Claude
- User needs structured JSON output from Claude
- User is designing system prompts or instructions
- User wants chain-of-thought reasoning or few-shot examples
- User is building prompt templates for reuse
Core Patterns
System Prompts
System prompts set Claude's persona, constraints, and output format. Place stable instructions here; they are cached separately and can use prompt caching.
message = client.messages.create(
model="claude-sonnet-4-6-20250514",
max_tokens=1024,
system="""You are a senior code reviewer. Follow these rules:
1. Focus on bugs, security issues, and performance problems.
2. Rate severity as CRITICAL, HIGH, MEDIUM, or LOW.
3. Provide a fix for each issue found.
4. If the code is clean, say "No issues found." and nothing else.""",
messages=[{"role": "user", "content": f"Review this code:\n```\n{code}\n```"}]
)Few-Shot Examples
Provide 2-4 input/output examples to demonstrate the exact format and reasoning you expect. Use the messages array with alternating user/assistant turns.
messages = [
{"role": "user", "content": "Classify: 'My order never arrived and nobody responds to emails'"},
{"role": "assistant", "content": '{"category": "shipping", "sentiment": "negative", "priority": "high"}'},
{"role": "user", "content": "Classify: 'Love the new feature update, works great!'"},
{"role": "assistant", "content": '{"category": "feedback", "sentiment": "positive", "priority": "low"}'},
{"role": "user", "content": f"Classify: '{user_input}'"}
]
message = client.messages.create(
model="claude-sonnet-4-6-20250514",
max_tokens=256,
messages=messages
)Chain-of-Thought Reasoning
Ask Claude to reason step-by-step before giving a final answer. Use extended thinking for complex problems that benefit from deep reasoning.
# Extended thinking (built-in chain-of-thought)
message = client.messages.create(
model="claude-sonnet-4-6-20250514",
max_tokens=16000,
thinking={
"type": "enabled",
"budget_tokens": 10000 # tokens allocated for reasoning
},
messages=[{"role": "user", "content": "Debug this function and explain the root cause:\n" + code}]
)
# Access thinking and response separately
for block in message.content:
if block.type == "thinking":
print("Reasoning:", block.thinking)
elif block.type == "text":
print("Answer:", block.text)# Manual chain-of-thought via prompt
message = client.messages.create(
model="claude-sonnet-4-6-20250514",
max_tokens=2048,
system="Think step-by-step. Show your reasoning in <reasoning> tags, then give the final answer.",
messages=[{"role": "user", "content": "What is the time complexity of merge sort and why?"}]
)Structured Output (JSON Mode)
Force Claude to return valid JSON by combining system instructions with prefilling.
message = client.messages.create(
model="claude-sonnet-4-6-20250514",
max_tokens=1024,
system="""Extract entities from the text. Return a JSON object with this exact schema:
{
"people": [{"name": string, "role": string}],
"organizations": [{"name": string, "type": string}],
"locations": [{"name": string, "context": string}]
}
Return ONLY valid JSON, no other text.""",
messages=[
{"role": "user", "content": f"Extract entities from: {text}"},
{"role": "assistant", "content": "{"} # Prefill forces JSON start
]
)
# Reconstruct the full JSON (prefill is not included in response)
import json
result = json.loads("{" + message.content[0].text)Prefilling Assistant Responses
Prefill the assistant turn to control output format, language, or starting point.
# Force a specific output format
message = client.messages.create(
model="claude-sonnet-4-6-20250514",
max_tokens=1024,
messages=[
{"role": "user", "content": "Translate to French: 'Hello, how are you?'"},
{"role": "assistant", "content": "Bonjour"} # Forces French output
]
)
# Force code-only output
message = client.messages.create(
model="claude-sonnet-4-6-20250514",
max_tokens=2048,
messages=[
{"role": "user", "content": "Write a Python function to calculate fibonacci numbers."},
{"role": "assistant", "content": "```python\n"} # Forces code block
]
)Prompt Templates
Build reusable prompt templates with clear variable boundaries using XML tags.
REVIEW_TEMPLATE = """Review the following pull request diff.
<diff>
{diff}
</diff>
<context>
Repository: {repo_name}
Language: {language}
PR Description: {pr_description}
</context>
<instructions>
1. Identify bugs, security issues, and performance problems.
2. Suggest improvements with code examples.
3. Rate overall quality: APPROVE, REQUEST_CHANGES, or COMMENT.
</instructions>"""
message = client.messages.create(
model="claude-sonnet-4-6-20250514",
max_tokens=4096,
messages=[{
"role": "user",
"content": REVIEW_TEMPLATE.format(
diff=diff_text,
repo_name="my-app",
language="TypeScript",
pr_description="Add user authentication"
)
}]
)Anti-Patterns
- Using vague instructions like "be helpful" instead of specific behavioral rules
- Putting variable content in the system prompt (defeats prompt caching)
- Providing more than 5 few-shot examples (diminishing returns, wastes tokens)
- Not using XML tags to delimit sections in complex prompts
- Asking Claude to "never" do something instead of stating what it should do
- Using temperature=1.0 for structured output (use 0.0 for deterministic JSON)
- Prefilling with invalid syntax that forces Claude into a broken output format
Quick Reference
| Technique | When to Use |
| System prompt | Stable instructions, persona, output format |
| Few-shot | Classification, formatting, style matching |
| Chain-of-thought | Math, logic, debugging, multi-step reasoning |
| Extended thinking | Complex analysis, deep reasoning tasks |
| Prefilling | Force output format, language, code blocks |
| XML tags | Delimit sections in complex prompts |
| JSON mode | Structured data extraction, API responses |
Key tips:
- Put the most important instructions at the beginning and end of the system prompt.
- Use XML tags (
<context>,<instructions>,<examples>) for clear prompt structure. - Set temperature=0 for deterministic tasks, temperature=0.5-1.0 for creative tasks.
- Prefilled content is NOT included in the response -- prepend it when parsing.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

