agentleFS
jamestorrevillasjamestorrevillas/dev-skills/.github/skills/prompt-engineering/SKILL.md

prompt-engineering

Skill4 starsChanged 9 months agoMITView on GitHub

Use this skill when writing, improving, or debugging prompts for any AI model — Claude, GPT, Gemini, or Copilot. Also use when designing plan-before-execute workflows, verification patterns, self-improvement loops, or structuring AI instructions for maximum clarity and output quality. Trigger on keywords: prompt, prompt engineering, instruct AI, system prompt, few-shot, chain-of-thought, AI instruction, prompt template, prompt pattern.

98 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use security-checklist, multi-agent-orchestration 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.
  • atuljha23Skill

    security-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

  • javalenciacaiSkill

    multi-agent-orchestration

    Design and coordinate multi-agent systems where specialized agents work together to solve complex problems. Covers agent communication, task delegation, workflow orchestration, and result aggregation. Use when building coordinated agent teams, complex workflows, or systems requiring specialized expertise across domains.

    Also in 4 projects that use this

  • xfstudioSkill

    llm-evaluation

    Implement comprehensive evaluation strategies for LLM applications using automated metrics, human feedback, and benchmarking. Use when testing LLM performance, measuring AI application quality, or establishing evaluation frameworks.

    Also in 3 projects that use this

  • MicrosoftSkill

    cost-optimization

    Optimize existing Azure resources and analyze Reservations or Savings Plans. WHEN: \"optimize Azure costs\", \"reduce cloud spending\", \"rightsize resources\", \"find idle resources\", \"orphaned disk\", \"deleted VM still charged\", \"public IP still charging\", \"reservation utilization\", \"Savings Plan coverage\", \"commitment recommendation\", \"why is pay-as-you-go still charged\". DO NOT USE FOR: cost spikes, forecasts, pricing estimates, budgets, or governance.

    Also in 3 projects that use this

  • GoogleSkill

    coding-principles

    Enforces engineering, architecture, public API, and code quality standards distilled from human reviewer feedback across A2UI pull requests. Use when authoring new code, refactoring, addressing review feedback, or reviewing PR diffs. Don't use for release publishing or spec blueprint generation without code or PR changes.

    Also in 3 projects that use this

  • pproencaSkill

    refactoring

    Code refactoring best practices based on Martin Fowler's catalog and Clean Code principles. This skill should be used when refactoring existing code, improving code structure, reducing complexity, eliminating code smells, or reviewing code for maintainability. Triggers on tasks involving extract method, rename, decompose conditional, reduce coupling, or improve readability.

    Also in 6 projects that use this

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 8 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 86 edited versions we read keep these.

  • 8

    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
  1. Distinctive:

    The Golden Rule: If the output isn't what you wanted, the problem is almost always in the prompt — not the model.

    line 12
  2. Distinctive:

    Every effective prompt has four components:

    line 18
  3. Distinctive:

    Ask directly with no examples.

    line 42
  4. Distinctive:

    Use clear separators to prevent the model from confusing instructions with content.

    line 71
  5. Distinctive:

    Ask the model to critique its own output before finalizing.

    line 105
  6. Distinctive:

    Always instruct the AI to verify its own work before presenting it.

    line 151
  7. Distinctive:

    When the AI makes a mistake, don't just fix it — extract the lesson:

    line 175
  8. Very specific:

    Delimiter Protection: Use """ or XML tags to clearly separate instructions from user content.

    line 220
  9. Distinctive:

    Principle of Least Privilege: Don't give the AI more context or permissions than it needs for the task.

    line 221

“Common” is measured: kept by at least 6 in 10 of the 86 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Prompt Engineering

Core Philosophy

A great prompt is not a magic spell — it's a specification. The more precisely you define the goal, context, constraints, and output format, the more reliably the AI performs. Think of prompting like writing a function signature: the model is the implementation, you are the interface designer.

The Golden Rule: If the output isn't what you wanted, the problem is almost always in the prompt — not the model.


Prompt Anatomy (4-Part Structure)

Every effective prompt has four components:

ROLE:    Who the AI should be (expertise, perspective, voice)
GOAL:    What you want done (specific, unambiguous task)
CONTEXT: Relevant background, data, constraints, examples
OUTPUT:  Exact format, length, structure of the response

Example

ROLE: You are a senior TypeScript developer with expertise in React and Next.js.
GOAL: Review this component for performance issues and suggest specific improvements.
CONTEXT: This is a client component in Next.js 15 App Router. 
         Performance is critical — this renders on every keystroke.
         [paste code here]
OUTPUT: List issues as BLOCKER / WARNING / SUGGESTION with specific fix for each.

Core Techniques

Zero-Shot

Ask directly with no examples. Works for well-understood tasks.

Write a conventional commit message for this diff: [diff]

Few-Shot

Provide 2–3 examples before the real task. Best for format-sensitive or pattern-matching tasks.

Examples:
Input: Added login form → Output: feat(auth): add login form with email/password
Input: Fixed null crash → Output: fix(api): handle null response from user endpoint

Now write a commit message for: [diff]

Chain-of-Thought (CoT)

Force step-by-step reasoning. Add "Think step by step" or "Reason through this before answering."

Is this API design RESTful? Think step by step before answering.

Role / Persona Assignment

Set expertise level and perspective upfront.

You are a security engineer specializing in OWASP Top 10.
Review this authentication code for vulnerabilities.

Delimiters

Use clear separators to prevent the model from confusing instructions with content.

Refactor the following code:
"""
[code here]
"""
Rules: No external dependencies. TypeScript only. Preserve existing tests.

Advanced Techniques

Self-Consistency

For critical decisions, run the same prompt 3 times and take the majority answer. Reduces variance on high-stakes reasoning.

Tree of Thought (ToT)

Force the model to explore multiple approaches before committing.

Propose three different approaches to solve this problem.
For each approach, list pros, cons, and implementation complexity.
Then recommend the best one with justification.

ReAct (Reason + Act)

Interleave reasoning with action steps. Best for agentic or multi-step tasks.

Thought: What do I need to understand before solving this?
Action: [tool or analysis]
Observation: [result]
Thought: Based on this, the next step is...

Metacognitive Prompting

Ask the model to critique its own output before finalizing.

After generating your answer, critically evaluate it:
- Are all steps logically valid?
- Are there unsupported assumptions?
- What could go wrong with this approach?
Correct any issues before presenting the final answer.

COSTAR Framework

Structured template for complex prompts:

  • Context — background information
  • Objective — what you want done
  • Style — tone and voice
  • Tone — formal, casual, direct
  • Audience — who will read this
  • Response format — structure of output

Plan-Before-Execute Pattern

Never let AI jump straight to implementation for non-trivial tasks.

Step 1 — Plan: Outline your approach step by step. 
         Do NOT write any code yet.
Step 2 — Review: I will confirm the plan before you proceed.
Step 3 — Execute: Implement each step from the approved plan.

When to Use Plan Mode

  • Task spans multiple files or components
  • Architectural decisions are involved
  • Uncertainty exists about requirements
  • Task has 3+ steps

When to Skip It

  • Single-file, well-defined change
  • Bug fix with obvious cause and solution
  • Formatting or style-only change

Verification Patterns

Always instruct the AI to verify its own work before presenting it.

Before finalizing your answer:
1. Check that all steps are logically sound
2. Verify no assumptions were made that weren't stated
3. Confirm the output matches the requested format
4. Correct any issues you find
Then present the final answer.

For code specifically:

After writing the code:
1. Trace through it mentally with a simple test case
2. Check all edge cases (null, empty, boundary values)
3. Verify error handling is present
4. Confirm it matches the requirements exactly

Self-Improvement Loop

When the AI makes a mistake, don't just fix it — extract the lesson:

I noticed an error in your previous response: [describe error]
1. Explain why this error occurred
2. State the general rule that would prevent it
3. Apply that rule to the corrected answer

For long sessions, maintain a lessons log:

Update your working notes with this lesson:
[lesson from the correction]
Apply this to all remaining tasks in this session.

Model-Specific Tips

ModelStrengthsBest Practices
ClaudeLong context, nuanced reasoning, following complex instructionsUse XML-style tags for structure, provide CLAUDE.md for project context, explicit role assignment
GPT-4/4oStrict format adherence, JSON output, code generationPut instructions at top, use delimiters, hint at language with imports
GeminiResearch, citations, massive context windows, multi-modalRequest citations explicitly, define scope and time range, specify how to handle uncertainty
CopilotIn-editor context awareness, code completionUse .github/copilot-instructions.md for project context, be explicit about stack

Anti-Patterns (What to Avoid)

Anti-PatternProblemFix
"Write code for X"Too vagueAdd role, constraints, output format
Treating first answer as finalMisses errorsAlways include verification step
No examples for format-sensitive tasksWrong formatAdd 2–3 few-shot examples
Skipping role assignmentGeneric tone/depthAlways assign a specific expertise persona
Concatenating user input into system promptPrompt injection riskUse delimiters, validate input, separate concerns
Over-prompting simple tasksWastes tokensMatch prompt complexity to task complexity

Prompt Security

  • Prompt Injection: User input that hijacks the model's behavior. Never concatenate raw user input into system prompts.
  • Delimiter Protection: Use """ or XML tags to clearly separate instructions from user content.
  • Principle of Least Privilege: Don't give the AI more context or permissions than it needs for the task.
  • Input Validation: Sanitize user inputs before they reach the model in production systems.

See Also

  • references/prompt-templates.md — Ready-to-use prompt templates for common dev tasks
  • ai-prompting-patterns skill — Agent communication and intent clarification patterns
  • ai-agent-design skill — Building full agentic systems

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.