Advanced prompting and adversarial testing

From samarv/Shanon · View interactive version

Advanced prompting and adversarial testing is an AI agent skill from the GitHub repository samarv/Shanon. Use these research-backed techniques to maximize LLM performance and secure AI agents. Apply this skill when designing system prompts for AI products, troubleshooting low-accuracy outputs, or testing model vulnerabilities against prompt injection.

How to use this skill

Skill file

Based on the research from The Prompt Report (co-authored by OpenAI, Microsoft, and Google), prompt engineering is about "artificial social intelligence"—knowing how to elicit the best performance from a model through specific structural patterns.

Core Prompting Techniques

1. Few-Shot Prompting (The Highest Value Technique)

Do not describe your requirements in prose; provide 3–5 concrete examples of input/output pairs.

2. Task Decomposition

For complex logic, prevent the model from jumping to a conclusion. Force it to map the problem space first.

1. Ask for sub-problems.

2. Have the model solve each sub-problem individually.

3. Synthesize the final answer from those components.

3. Self-Criticism (Iterative Refinement)

Boost accuracy by forcing the model to verify its own logic.

4. Additional Information (Top-Loading Context)

Provide the model with all relevant "biographical" or domain data before the task.

1. Caching: Most providers (like OpenAI/Anthropic) cache the beginning of prompts, making subsequent calls cheaper and faster.

2. Attention: Models lose focus on instructions placed in the middle of a long context.

5. Ensembling (Mixture of Reasoning Experts)

For mission-critical accuracy, do not rely on a single output.


Adversarial Testing (Red Teaming)

If you are building an agent (an AI that can take actions), you must test for prompt injection using these common bypass techniques:


Common Pitfalls


Examples

Example 1: Medical Coding Accuracy

Example 2: Car Dealership Support Agent

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.