home/writing/project2-prompt-anatomy

Project2 Prompt Anatomy

GPTClaudeGemini··622 copies·updated 2026-07-14
project2-prompt-anatomy.prompt
# Prompt Anatomy: Structural Patterns of Excellent Prompts

**Author**: Karsten Huttelmaier — co-authored with Claude
**Date**: February 2026

---

## Section 1: Structural Patterns (The Core Finding)

After analyzing leaked production system prompts (Cursor, Claude Code, v0, Devin, Bolt), academic research on prompt formatting and ordering, Anthropic/OpenAI/Google prompting guides, and practitioner analyses, the following structural elements emerge as convergent across sources. They are listed in the order they most commonly appear.

### 1.1 Identity & Role Declaration
**What it is:** A concise statement establishing who the model is, what it does, and the operational context. Typically 2–5 sentences.

**Why it works:** Role framing narrows the model's probability space immediately, biasing token generation toward domain-appropriate vocabulary and reasoning patterns. Anthropic's own docs note that models "mirror your tone and style" and that role-setting helps the model "understand the boundaries of the task." The GPT-4.1 Prompting Guide similarly recommends framing the model as an agent with "well-defined responsibilities." Every leaked production prompt opens with identity.

**How it's formatted:** Usually plain text or a short paragraph. In Cursor: `"You are an AI coding assistant, powered by GPT-4.1. You operate in Cursor."` In Claude Code: `"You are Claude, an AI assistant made by Anthropic."` In v0: `"v0 responds using the MDX format..."` The identity is tight — no lengthy backstory.

**Universal or context-dependent:** Universal. Every production prompt examined starts with identity. However, Anthropic's latest guidance (late 2025) suggests that for modern models, being explicit about the *perspective* you want may be more effective than ornate role-playing: "Analyze this portfolio focusing on risk tolerance" outperforms "You are a world-renowned financial expert."

---

### 1.2 Behavioral Constraints & Ground Rules
**What it is:** A set of high-level behavioral rules — what the model must always do, what it must never do, and how it should handle ambiguity. This is the "constitution" of the prompt.

**Why it works:** Constraints function as invariants (a concept you'll appreciate, Karsten). They create hard boundaries that prevent the model from drifting across a wide conversation. The Cursor prompt includes rules like "never lie or make things up," "bias towards not asking the user for help," and "generated code can be run immediately." These are credited with being core to Cursor's $10B valuation — they force the model to produce *complete, runnable solutions* rather than partial sketches.

**How it's formatted:** Almost universally as a bulleted or numbered list, often inside XML tags (`<rules>`, `<guidelines>`, `<instructions>`) or under markdown headers (`# Instructions`, `## Rules`). Key constraints are often in ALL CAPS for emphasis. Cursor's 2025 prompt: `"NEVER generate an extremely long hash or any non-textual code."` OpenAI's GPT-4.1 guide notes that the model is "highly steerable and responsive to well-specified prompts" and that "a single sentence firmly and unequivocally clarifying your desired behavior is almost always sufficient."

**Universal or context-dependent:** Universal in structure, context-dependent in content. Every production prompt has this section. The *specific* rules are domain-specific.

---

### 1.3 Context Injection / Domain Knowledge
**What it is:** The long-form data the model needs to do its job — documents, codebase state, tool definitions, environment details. This is the "grounding data" section.

**Why it works:** This is where the "Lost in the Middle" research (Liu et al., 2024, TACL) becomes directly actionable. The Stanford research demonstrated a U-shaped performance curve: LLMs attend most strongly to information at the *beginning* and *end* of the context, with performance degrading by 30%+ for information positioned in the middle. Anthropic's own documentation explicitly recommends: "Put longform data at the top of your prompt, above your query, instructions, and examples. Queries at the end can improve response quality by up to 30%."

**How it's formatted:** In production prompts, context is wrapped in XML tags for clear delineation: `<codebase_context>`, `<document>`, `<user_uploaded_content>`. Cursor injects file state, linter errors, and edit history in tagged blocks. Claude Code uses `<CLAUDE.md>` content and git status. v0 wraps domain knowledge in nested XML sections. The key principle is *separation*: context is clearly fenced off from instructions.

**Universal or context-dependent:** Universal pattern (separate context from instructions). The positioning is important: place it early if long, or use XML tags to create clear boundaries regardless of position.

---

### 1.4 Detailed Task Instructions & Workflow
**What it is:** The specific, step-by-step operational instructions for how to carry out the task. This includes decision trees, conditional logic, and multi-step workflows.

**Why it works:** Specificity drives quality. The research paper "Does Prompt Formatting Have Any Impact on LLM Performance?" (Rungta et al., 2024) found that GPT-3.5-turbo's performance varied by up to 40% depending on the prompt template — and the key differentiator was structural clarity, not cleverness. The GPT-5 prompting guide reports that Cursor found "structured, scoped prompts yield the most reliable results" and that using structured XML specs like `<instruction_spec>` improved instruction adherence.

**How it's formatted:** This is where production prompts get architecturally sophisticated. Cursor 2025 uses nested tagged sections:

when to use it

Community prompt sourced from the open-source GitHub repo kphutt/prompt-lenses (MIT). A "Project2 Prompt Anatomy" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

writingcommunitygeneral

source

kphutt/prompt-lenses · MIT