Agent Skill
2/7/2026prompt-engineering
Optimize prompts for LLMs - structure, clarity, and effectiveness. Use when writing system prompts, designing AI features, or improving LLM interactions.
A
allanninal
0GitHub Stars
1Views
npx skills add allanninal/claude-code-skills
SKILL.md
| Name | prompt-engineering |
| Description | Optimize prompts for LLMs - structure, clarity, and effectiveness. Use when writing system prompts, designing AI features, or improving LLM interactions. |
name: prompt-engineering description: Optimize prompts for LLMs - structure, clarity, and effectiveness. Use when writing system prompts, designing AI features, or improving LLM interactions.
Prompt Engineering
When to Use This Skill
- Writing system prompts for AI applications
- Designing AI-powered features
- Optimizing existing prompts for better results
- Reducing hallucinations and improving accuracy
- Building RAG systems or AI agents
Core Principles
1. Be Specific and Clear
ā Bad: "Summarize this"
ā
Good: "Summarize this article in 3 bullet points, focusing on:
- The main argument
- Key supporting evidence
- The conclusion
Keep each bullet under 25 words."
2. Provide Context
ā Bad: "Fix this code"
ā
Good: "You are a senior Python developer reviewing code for a production API.
The following function handles user authentication.
Review for security vulnerabilities and suggest fixes with explanations."
3. Use Examples (Few-Shot)
Convert product descriptions to JSON format.
Example 1:
Input: "Blue cotton t-shirt, size M, $29.99"
Output: {"color": "blue", "material": "cotton", "type": "t-shirt", "size": "M", "price": 29.99}
Example 2:
Input: "Red leather wallet, $45"
Output: {"color": "red", "material": "leather", "type": "wallet", "price": 45}
Now convert:
Input: "Black wool sweater, size L, $89.50"
4. Structured Output
Analyze the following customer feedback and respond in this exact format:
SENTIMENT: [positive/negative/neutral]
TOPICS: [comma-separated list]
URGENCY: [low/medium/high]
SUGGESTED_ACTION: [one sentence]
SUMMARY: [2-3 sentences]
Prompt Patterns
Role Pattern
You are an expert [ROLE] with [EXPERIENCE/QUALIFICATIONS].
Your task is to [SPECIFIC TASK].
Consider [CONSTRAINTS/REQUIREMENTS].
Example:
You are a senior security engineer with 10 years of experience in web application security.
Your task is to review this authentication code for vulnerabilities.
Consider OWASP Top 10, common attack vectors, and secure coding best practices.
Chain of Thought
Solve this step by step:
1. First, identify [X]
2. Then, analyze [Y]
3. Consider [Z]
4. Finally, conclude with [ANSWER]
Show your reasoning for each step.
Self-Consistency
Approach this problem from three different angles:
1. [Approach A]
2. [Approach B]
3. [Approach C]
Then synthesize the insights into a final answer.
Reflection Pattern
After generating your response:
1. Review your answer for accuracy
2. Check for any logical errors
3. Verify all facts mentioned
4. If you find issues, correct them
Mark corrections with [CORRECTED].
System Prompt Structure
# Role
You are [ROLE DESCRIPTION].
# Context
[BACKGROUND INFORMATION]
[CONSTRAINTS]
[USER CONTEXT]
# Instructions
[PRIMARY TASK]
[SPECIFIC REQUIREMENTS]
[OUTPUT FORMAT]
# Guidelines
- [GUIDELINE 1]
- [GUIDELINE 2]
- [GUIDELINE 3]
# Examples
[EXAMPLE INPUT/OUTPUT PAIRS]
# Edge Cases
- If [CONDITION], then [ACTION]
- Never [PROHIBITED ACTION]
Reducing Hallucinations
Ground in Facts
Answer based ONLY on the provided context.
If the information is not in the context, say "I don't have enough information to answer this."
Context:
[PROVIDED DOCUMENTS/DATA]
Question: [USER QUESTION]
Require Citations
For each claim you make, cite the source from the provided documents.
Format: [CLAIM] (Source: [DOCUMENT NAME], Section: [SECTION])
If you cannot cite a source, prefix with "Based on general knowledge:" or don't include it.
Confidence Levels
Rate your confidence in each statement:
- HIGH: Directly stated in sources
- MEDIUM: Reasonably inferred from sources
- LOW: Extrapolated or uncertain
Format: [STATEMENT] [CONFIDENCE: HIGH/MEDIUM/LOW]
Output Control
Length Control
Respond in exactly:
- One sentence (for simple queries)
- One paragraph (for explanations)
- 3-5 bullet points (for lists)
- No more than 200 words (for summaries)
Format Control
Respond using this JSON schema:
{
"answer": string,
"confidence": number (0-1),
"sources": string[],
"follow_up_questions": string[]
}
Tone Control
Write in a [TONE] tone:
- Professional: Formal language, third person
- Friendly: Conversational, second person
- Technical: Precise terminology, detailed
- Simple: Plain language, no jargon
RAG-Specific Prompts
Document QA
You are a helpful assistant that answers questions based on provided documents.
Instructions:
1. Read the provided context carefully
2. Answer ONLY based on the context
3. If the answer isn't in the context, say "I cannot find this information in the provided documents"
4. Quote relevant passages when helpful
5. If multiple documents conflict, note the discrepancy
Context:
{context}
Question: {question}
Answer:
Multi-Document Synthesis
Synthesize information from the following sources to answer the question.
Requirements:
- Combine insights from all relevant sources
- Note any contradictions between sources
- Cite sources for key claims
- Indicate gaps in available information
Sources:
{documents}
Question: {question}
Agent Prompts
Tool Use
You have access to these tools:
{tool_descriptions}
To use a tool, format your response as:
THOUGHT: [Your reasoning about what to do]
ACTION: [tool_name]
INPUT: [tool input]
After receiving tool output:
OBSERVATION: [What you learned]
THOUGHT: [Next step reasoning]
...
When you have the final answer:
THOUGHT: I now have enough information
FINAL_ANSWER: [Your response to the user]
Planning
Before taking action, create a plan:
1. UNDERSTAND: What is the user asking for?
2. DECOMPOSE: Break into subtasks
3. SEQUENCE: Order the subtasks
4. EXECUTE: Complete each subtask
5. VERIFY: Check the result
6. RESPOND: Provide the answer
Optimization Tips
| Issue | Solution |
|---|---|
| Too verbose | Add "Be concise" or word limits |
| Missing details | Add "Explain your reasoning" |
| Wrong format | Provide explicit format example |
| Inconsistent | Add more examples |
| Hallucinating | Ground with "Based only on..." |
| Off-topic | Add role constraints |
| Too generic | Add specific context |
Testing Prompts
- Edge cases: Test with unusual inputs
- Adversarial: Try to break the prompt
- Consistency: Same input multiple times
- Length: Short and long inputs
- Ambiguity: Unclear requests
Skills Info
Original Name:prompt-engineeringAuthor:allanninal
Download