agentsclimarketplace

Tech prompt engineering

Skill charlieviettq/awesome-agent-skill/.claude/skills/tech-prompt-engineering

Curated skill pack for LLM agents in engineer and science workflow (Cursor & Claude ready).

Install
npx -y skills add charlieviettq/awesome-agent-skill --skill tech-prompt-engineering

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 22 stars22 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

"Debug and harden production LLM prompts — handle prompt injection, output format drift, instruction forgetting in long contexts, and cross-model portability issues. Use this skill when the user ships an LLM-powered feature to production and needs to diagnose why outputs are inconsistent, unsafe, or regressed after model updates — NOT for basic 'write a better prompt' questions.".

SKILL.md

6.2 KB, as published. Nobody here has run it

Production Prompt Engineering

Overview

This skill addresses the failure modes that appear ONLY in production LLM applications: prompt injection, output format drift, silent regression across model versions, instruction decay in long contexts, and hallucination under pressure. It is NOT a tutorial on few-shot or chain-of-thought — assume the agent already knows basic prompting techniques.

When to Use

Trigger conditions:

  • A production LLM feature is misbehaving (inconsistent, unsafe, format-drifting)
  • Designing a system prompt for a multi-tenant application
  • Hardening prompts against injection or jailbreak attempts
  • Diagnosing regression after a model version update

When NOT to use:

  • Basic "how do I write a prompt" — the agent already knows few-shot, CoT, role-play
  • One-off content generation (just write the prompt directly)
  • RAG architecture design (use a RAG-specific skill)

Framework

IRON LAW: Treat User Input as Hostile by Default

In production, user input WILL be used to attempt prompt injection.
The only reliable defense is structural separation:
1. System prompt carries ALL rules and behavior (never trust user input to override)
2. User input is NEVER concatenated directly into instructions
3. Output is validated against an expected schema BEFORE being used downstream
A prompt that works in dev with clean input will fail in production with adversarial input.

Production Failure Modes

Failure ModeObservable SymptomRoot CauseFix
Prompt injectionUser input overrides system instructionsInstructions concatenated with untrusted inputStructural separation: use ChatML roles; validate outputs against schema; never use "ignore previous instructions" susceptible templates
Format driftJSON response breaks 1/1000 callsModel temperature > 0 + unconstrained outputConstrained decoding (JSON mode, grammar), schema validation + retry, lower temperature
Instruction decayRules followed early, ignored after N turnsLong context pushes system prompt out of attentionReinforce critical rules in EACH user message; use model's native tool/system role; shorter contexts
Silent regressionSame prompt, worse output after model updateProvider updated model weightsPin model version; maintain regression test suite; A/B test before rolling upgrades
Hallucination under pressureModel invents facts when uncertainNo explicit "I don't know" escape hatchAdd "If uncertain, respond with {null}. Do not guess." + grounding constraint
Cross-model portabilityWorks on GPT-4, fails on Claude/GeminiModel-specific prompt conventionsTest on all target models; avoid model-specific jailbreaks; use common-denominator patterns

Methodology

Phase 1: Reproduce the Failure

Collect: exact input, exact output, expected output, model + version, temperature. Reproduce in isolation (outside the app) to rule out application bugs. Gate: Failure reproduces consistently in a minimal test case.

Phase 2: Classify the Failure Mode

Match against the table above. Most production failures fall into one of 6 categories. Don't guess — identify which mode applies. Gate: Failure mode classified with evidence.

Phase 3: Apply the Targeted Fix

Fix the SPECIFIC failure mode. Don't rewrite the whole prompt. Generic rewrites often introduce new failure modes. Gate: Fix addresses root cause, not symptom.

Phase 4: Build a Regression Test

Add the failing case to a regression test suite. Run the suite before every prompt change or model version update. Gate: Test suite catches the original failure AND any reintroduction.

Output Format

# Prompt Debug Report: {Feature Name}

## Failure Reproduction
- Input: {exact input}
- Observed: {what happened}
- Expected: {what should have happened}
- Model: {name + version + temperature}

## Failure Mode
{One of: injection, format drift, instruction decay, silent regression, hallucination, cross-model}

## Root Cause
{Specific mechanism, not generic "prompt was bad"}

## Fix
{Targeted change with before/after prompt diff}

## Regression Test
{Test case added to prevent reintroduction}

Gotchas

  • "Ignore previous instructions" is only the beginning: Modern injection uses role-play ("Pretend you are DAN..."), language switching, Unicode tricks, and encoded payloads. Defense requires input validation AND output validation, not just instruction phrasing.
  • Temperature 0 is not deterministic across calls: Even at T=0, outputs can vary across API calls due to backend GPU non-determinism (batch effects). Don't rely on exact string equality in tests; use semantic or schema equality.
  • Few-shot examples override your instructions: If your examples show 500-word responses and you say "be concise", the model follows the examples. Examples are STRONGER than instructions.
  • System prompts are NOT absolute: Even with a system prompt, sufficiently adversarial user input can override behavior. System prompts are a strong hint, not a security boundary. For real security, use output validation and sandboxing.
  • Provider model updates are silent: OpenAI's "gpt-4" alias changes weights without notice. Pin to dated versions (gpt-4-0613) for stability. Rerun regression tests after every update.
  • Context window size ≠ effective context: A 128K context model may only attend well to the first 32K and last 4K. Put critical instructions at START and END, not in the middle ("lost in the middle" effect).

References

  • For prompt injection attack patterns, see references/injection-patterns.md
  • For regression testing frameworks, see references/regression-testing.md
  • For cross-model prompt portability, see references/cross-model-testing.md

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.