agentleFS
liqiongyuliqiongyu/my-agents/skills/prompt-engineering/SKILL.md

prompt-engineering

Skill29 starsChanged 9 months agoMITView on GitHub

Manual-first workflow skill for redesigning, debugging, hardening, or productionizing LLM prompts and system prompts. Use when the user needs end-to-end prompt work such as stabilizing behavior, migrating across models, or preparing a prompt for production. Do not use for quick technique lookup or for general LLM-powered coding tasks.

63 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use security-checklist, nextjs-app-router and 10 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

  • desilokesh1Skill

    nextjs-app-router

    Next.js App Router best practices, Server Components, Server Actions, routing patterns, and data fetching strategies. Use when building Next.js applications with the App Router.

    Also in 3 projects that use this

  • stefan-jansenSkill

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

  • rohitg00Skill

    data-engineering

    Data engineering patterns for ETL pipelines, data warehousing, Apache Spark, and data quality validation

    Also in 3 projects that use this

  • qodex-aiSkill

    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 3 projects that use this

  • mrgoonieSkill

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

The file

Show its rules and text

We split this skill into the rules it gives an agent

20 rules. 0 are common, 19 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 56 edited versions we read keep these.

  • 19

    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:

    Use this skill when prompt work needs an actual workflow: define success, draft or repair the prompt, test it on real inputs, and harden it …

    line 15
  2. Distinctive:

    Keep the main workflow lean.

    line 59
  3. Distinctive:

    Before rewriting anything, pin down:

    line 73
  4. Distinctive:

    Always collect at least:

    line 81
  5. Distinctive:

    If you cannot explain what success means, do not jump into fancy prompting techniques yet.

    line 87
  6. Distinctive:

    Start with the smallest change that could plausibly fix the problem, then escalate only if the evidence says you need more structure.

    line 92
  7. Distinctive:

    Use this structure by default:

    line 103
  8. Distinctive:

    Keep model-specific features explicit and removable.

    line 113
  9. Distinctive:

    Treat prompt changes like code changes:

    line 119
  10. Distinctive:

    Keep notes on what changed, why, and what improved

    line 129
  11. Distinctive:

    If the task involves model migration, re-test on the target model directly.

    line 131
  12. Distinctive:

    When the prompt is headed toward repeated or user-facing use:

    line 136
  13. Distinctive:

    prefer API-level structure enforcement when the platform supports it

    line 139
  14. Distinctive:

    Use the lightest tool that matches the problem.

    line 148
  15. Distinctive:

    When updating the canonical skill in this repo, validate the package and eval fixture before projecting:

    line 163
  16. Very specific:

    Treat skills/prompt-engineering/ as the canonical package.

    line 182
  17. Distinctive:

    Start with the smallest prompt change that could fix the failure.

    line 196
  18. Distinctive:

    Keep model-specific tricks explicit and easy to remove.

    line 198
  19. Distinctive:

    Prefer API-level structure enforcement over prompt-only formatting when the platform supports it.

    line 199
  20. Distinctive:

    Treat prompts as versioned artifacts, not disposable chat snippets.

    line 201

“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.

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

Prompt Engineering

Use this skill when prompt work needs an actual workflow: define success, draft or repair the prompt, test it on real inputs, and harden it for the target model and operating environment.

This skill is intentionally workflow-first. It is for prompt jobs with real tradeoffs, failure modes, or rollout concerns. It is not meant to be a general prompt encyclopedia.

Invocation posture: manual-first. This skill is broad and relatively heavy, so false positives are more harmful than occasional misses.

When Not To Use

  • Quick technique lookup such as "what is chain-of-thought?" or "show me a few-shot template"
  • Explaining an existing prompt line by line without redesigning or validating it
  • General coding, product, or research work that only happens to involve an LLM somewhere in the stack
  • Tiny one-off prompt tweaks where no real evaluation, migration, or hardening decision is needed

When To Activate

  • Drafting a new prompt or system prompt from requirements
  • Debugging a prompt that is inconsistent, verbose, unsafe, or hard to steer
  • Migrating prompt behavior between Claude, GPT, Gemini, or open-source models
  • Hardening an agent prompt against injection, tool misuse, or output drift
  • Turning an ad hoc prompt into a reusable template, chain, or production asset
  • Setting up a realistic evaluation plan for prompt quality, format adherence, latency, or cost

Outputs

Depending on the request, produce one or more of:

  • a revised prompt or system prompt
  • a failure-mode diagnosis with targeted fixes
  • a cross-model migration checklist
  • a prompt evaluation plan with representative test cases
  • a production hardening checklist for output control, safety, and monitoring

Reference Files

Keep the main workflow lean. Read deeper references only when the task needs them.

ReferenceWhen to read
references/advanced-reasoning.mdYou need structured reasoning patterns such as CoT, ToT, ReAct, self-consistency, or self-refine
references/cross-model-guide.mdYou are migrating prompts across Claude, GPT, Gemini, or open-source models
references/production-patterns.mdYou need versioning, evaluation, caching, rollout, monitoring, or prompt-chain design
references/security-patterns.mdYou are handling untrusted input, tool use, prompt injection, or output validation

Core Workflow

Workflow 1: Scope The Prompt Job

Before rewriting anything, pin down:

  1. The task and the exact output shape
  2. What "good" looks like with 3-5 representative examples
  3. The constraints: model, context budget, latency, cost, determinism, safety
  4. The current failure modes: wrong format, wrong content, instability, unsafe behavior, or cross-model drift

Always collect at least:

  • one happy-path input
  • one edge case
  • one adversarial or malformed case

If you cannot explain what success means, do not jump into fancy prompting techniques yet.

Workflow 2: Draft Or Repair With Minimum Necessary Complexity

Start with the smallest change that could plausibly fix the problem, then escalate only if the evidence says you need more structure.

LevelDefault moveUse when
L1Clear direct instructionFirst pass for almost every task
L2Add explicit constraints and output formatThe model drifts on brevity, style, or schema
L3Add examplesThe model still misclassifies, misformats, or misses edge cases
L4Add reasoning scaffoldThe task needs multi-step analysis or error checking
L5Split into a chain or reusable templateIntermediate validation or multi-stage processing matters

Use this structure by default:

[Role or system context]
[Task instructions]
[Examples, if needed]
[Input data]
[Output format]

Keep model-specific features explicit and removable. Do not bury XML tags, prefilling tricks, or vendor-specific schema APIs inside a supposedly model-agnostic prompt.

Workflow 3: Evaluate On Real Work

Treat prompt changes like code changes:

  1. Record a baseline on representative inputs
  2. Change one variable at a time when possible
  3. Re-run the same cases on the revised prompt
  4. Compare:
    • task accuracy or usefulness
    • format compliance
    • consistency across repeated runs
    • latency and token cost
  5. Keep notes on what changed, why, and what improved

If the task involves model migration, re-test on the target model directly. Do not assume prompt portability just because two models are both strong.

Workflow 4: Productionize And Harden

When the prompt is headed toward repeated or user-facing use:

  • version the prompt and template variables
  • prefer API-level structure enforcement when the platform supports it
  • isolate untrusted input from instructions
  • restate critical boundaries when injection risk exists
  • validate outputs before downstream actions depend on them
  • define rollback or fallback behavior for high-impact uses
  • monitor drift, edge cases, and cost regressions over time

Technique Selection Guide

Use the lightest tool that matches the problem.

NeedDefault moveRead next
Reliable structured outputShow the exact format first; use schema enforcement when availablereferences/production-patterns.md, references/cross-model-guide.md
Stronger analytical reasoningPrefer model-native reasoning first; add a structured scaffold only if neededreferences/advanced-reasoning.md
Cross-model migrationRemove vendor-specific tricks, normalize delimiters, then re-test on the target modelreferences/cross-model-guide.md
Injection resistanceIsolate data, repeat critical constraints, and validate outputsreferences/security-patterns.md
Multi-step pipelineSplit into a chain only when intermediate validation adds valuereferences/production-patterns.md

Validate And Evaluate

This canonical package ships a lightweight eval suite under eval/ for realistic prompt-work scenarios.

When updating the canonical skill in this repo, validate the package and eval fixture before projecting:

uv run python skills/skill-lifecycle-manager/scripts/quick_validate.py skills/prompt-engineering
uv run python skills/skill-lifecycle-manager/scripts/validate_eval_suite.py skills/prompt-engineering/eval/eval-cases.json

For behavioral review, run the cases in eval/eval-cases.json as realistic tasks and check whether the response:

  • defines success before rewriting
  • proposes the smallest effective prompt change
  • calibrates advice to the target model or runtime
  • includes a concrete validation plan
  • treats safety and output control explicitly when risk is present

Projection And Install Notes

Treat skills/prompt-engineering/ as the canonical package. Generate runtime surfaces from it rather than hand-editing copies:

uv run python skills/skill-lifecycle-manager/scripts/project_skill.py skills/prompt-engineering --platform all
uv run python skills/skill-lifecycle-manager/scripts/validate_projection.py skills/prompt-engineering --platform all

projection.json excludes author-only evaluation artifacts from runtime projections so Codex and Claude Code only receive the execution-relevant package.

Best Practices

  1. Start with the smallest prompt change that could fix the failure.
  2. Measure on representative inputs before and after edits.
  3. Keep model-specific tricks explicit and easy to remove.
  4. Prefer API-level structure enforcement over prompt-only formatting when the platform supports it.
  5. Treat prompts as versioned artifacts, not disposable chat snippets.

Common Pitfalls

PitfallWhy it hurtsFix
Jumping to exotic techniques too earlyComplexity hides the real failure modeDefine success and start at the lowest effective level
Shipping without negative casesEdge failures appear only in productionTest happy-path, edge, and adversarial inputs
Assuming prompt portabilityVendor behaviors diverge in subtle waysRe-test on the target model and remove model-specific tricks
Mixing trusted instructions with untrusted dataInjection risk rises sharplyDelimit, isolate, and restate boundaries
Changing many variables at onceYou cannot tell what improvedRun one targeted fix at a time where practical

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.