From Leak to Logic: Customizing LLM Behavior with System Prompt Insights
This repository is a collection of extracted System Prompts from popular Large Language Models (LLMs) like ChatGPT, Claude, and others.
For a software engineer, this repository is a goldmine for understanding and improving how we interact with LLMs in applications. Here's how it helps
Learning the "Secrets"
System prompts are the "internal rules" that define an LLM's personality, constraints, safety measures, and overall behavior. By seeing the official prompts, you can learn best practices for structuring your own system messages, roles, and instructions.
Reverse Engineering Behavior
If a model behaves in a certain way (e.g., always uses a specific tone, avoids controversial topics), its system prompt is likely the reason. Analyzing these leaked prompts helps you understand why a model performs certain actions, allowing you to design more effective and predictable prompts for your own application's specific needs.
Understanding Vulnerabilities
The primary risk of system prompt leaks is that malicious actors can find "gaps" or "escape routes" to bypass the model's safety and behavioral constraints (i.e., Prompt Injection attacks).
Building Defenses
As a defensive engineer, this repository provides the "attack vector." You can use this knowledge to
Test your own applications against injection attempts that exploit the revealed constraints.
Design more robust prompt sanitization and validation layers before sending user input to the LLM.
Creating Custom LLM Personas
If you're fine-tuning an open-source model or developing an internal one, these prompts serve as expert templates. You can adapt the structure and complexity of the leaked prompts to create highly specific, reliable, and consistent "system rules" for your own AI agents.
Tool Use and API Integration
Many modern system prompts include instructions on how the LLM should use external tools (like a calculator, web search, or a custom API). Seeing how major providers instruct their models on tool-use is invaluable for integrating LLMs into complex software architectures.
Since this is a GitHub repository, the introduction is super straightforward!
Go to the Repository
Navigate to the GitHub page
https://github.com/asgeirtj/system_prompts_leaks.
Clone or Download
Clone (Recommended)
Use git to clone the repository to your local machine
git clone https://github.com/asgeirtj/system_prompts_leaks.git
cd system_prompts_leaks
Download
You can also click the green "Code" button on GitHub and choose "Download ZIP."
Browse the Files
The repository is organized into folders by the AI vendor (e.g., Anthropic, Google, OpenAI). Dive into the Markdown (.md) or text (.txt) files to read the actual leaked system prompts.
You won't directly use the leaked system prompt text in your application. Instead, you'll use the insights gained from them to improve your own code's prompt structure.
Let's imagine you've learned from a leaked prompt that clear instructions on output format are crucial. You'll apply that knowledge to your own new system prompt.
# A hypothetical LLM client library (e.g., OpenAI, Anthropic, or an internal one)
def generate_code_snippet(user_request):
# INSIGHT APPLIED: A strict system prompt ensures a consistent,
# developer-friendly output format (JSON).
system_prompt = """
You are an expert Python developer assistant.
Your primary function is to generate clean, idiomatic, and documented Python code.
CRITICAL CONSTRAINT: You MUST respond ONLY with a single JSON object.
The JSON object MUST have two keys:
1. "title": A short, descriptive title for the code.
2. "code": The full, runnable Python code snippet, formatted in a markdown code block.
Do not include any conversational text or explanation outside of the JSON structure.
"""
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_request}
]
try:
# Assume 'llm_client' is initialized elsewhere
response = llm_client.chat.create(messages=messages, model="your-llm-model")
# Further application logic would parse the guaranteed JSON output
return response.json_content
except Exception as e:
print(f"Error during LLM call: {e}")
return None
# Example usage:
request = "Write a function to calculate the factorial of a number."
result = generate_code_snippet(request)
print(result)
# Expected, structured output based on the strict system prompt:
# {
# "title": "Factorial Calculation Function",
# "code": "```python\ndef factorial(n):\n if n == 0:\n return 1\n else:\n return n * factorial(n-1)\n```"
# }