/ docs / prompt_construction.md
prompt_construction.md
  1  # Prompt Engineering Strategy for Claude AI
  2  
  3  This document outlines the core principles and techniques for constructing effective prompts for Anthropic's Claude models within the AI-enhanced CV system. It builds upon the foundational concepts detailed in `docs/research/claude-prompt-engineering-framework.md`.
  4  
  5  Our prompt engineering strategy focuses on ensuring clarity, control, and consistency in Claude's outputs, enabling reliable and strategically effective content generation.
  6  
  7  ## 1. Foundational Prompting Architecture
  8  
  9  The following principles are fundamental to all Claude prompts in this system:
 10  
 11  ### 1.1. The Primacy of Clear and Direct Instructions
 12  
 13  Prompts must be explicit, specific, and direct. Avoid ambiguity by clearly stating *what* Claude should do and *how* it should do it. Frame instructions positively, focusing on the desired outcome.
 14  
 15  **Example:**
 16  Instead of: "Improve this resume bullet point."
 17  Use: "Rewrite the following resume bullet point to emphasize quantifiable achievements and align with the skills mentioned in the provided job description. Use the STAR (Situation, Task, Action, Result) method for the structure."
 18  
 19  ### 1.2. Structuring Prompts with XML Tags
 20  
 21  Claude models are fine-tuned to recognize and prioritize information structured within XML tags. This creates explicit boundaries for different parts of the prompt, preventing confusion between instructions and content.
 22  
 23  **Recommended Tags:**
 24  *   `<instructions>`: For the main task description.
 25  *   `<context>`: For providing background information or data.
 26  *   `<examples>`: For few-shot examples.
 27  *   `<input>` or specific content tags like `<resume_text>`, `<job_description>`: For the data Claude needs to process.
 28  *   `<output_format>`: To specify the desired output structure (e.g., JSON schema).
 29  *   `<thinking>`: (For Chain-of-Thought) To instruct Claude to show its reasoning process.
 30  
 31  **Example Structure:**
 32  ```xml
 33  <instructions>
 34    You are an expert career coach. Your task is to analyze the provided resume and job description. Identify the top 5 skills from the job description that are missing from the resume. List them in a JSON array.
 35  </instructions>
 36  
 37  <resume_text>
 38    [...Paste the full text of the resume here...]
 39  </resume_text>
 40  
 41  <job_description>
 42    [...Paste the full text of the job description here...]
 43  </job_description>
 44  ```
 45  
 46  ### 1.3. Guiding Behavior with Few-Shot Prompting (Examples)
 47  
 48  Provide 3-5 diverse and relevant examples within the prompt to show Claude *how* to perform a task. Examples help the model infer patterns, formats, tones, and logical steps, improving accuracy and consistency.
 49  
 50  **Example:**
 51  ```xml
 52  <instructions>
 53    Rewrite the resume bullet points in the <before> tags to be more impactful and quantifiable, following the style of the examples.
 54  </instructions>
 55  
 56  <examples>
 57    <example>
 58      <before>Responsible for managing the company's social media accounts.</before>
 59      <after>Grew social media engagement by 35% across three platforms (Twitter, LinkedIn, Facebook) over 6 months by implementing a data-driven content strategy.</after>
 60    </example>
 61  </examples>
 62  
 63  <task>
 64    <before>[User's bullet point to be improved]</before>
 65    <after>
 66  </task>
 67  ```
 68  
 69  ### 1.4. Establishing Persona and Tone with System Prompts
 70  
 71  Use the `system` parameter in the Messages API to assign a specific role, persona, and tone to Claude. This transforms the model into a domain-specific expert, ensuring outputs are contextually appropriate.
 72  
 73  **Examples of System Prompts:**
 74  *   For resume analysis: `"You are an expert career coach and resume writer with 20 years of experience helping tech professionals land jobs at top-tier companies."`
 75  *   For company research: `"You are a meticulous financial analyst and business strategist. Your task is to analyze company data and provide objective, data-driven insights."`
 76  
 77  ## 2. Advanced Reasoning and Task Decomposition
 78  
 79  For complex tasks, combine foundational principles with advanced frameworks:
 80  
 81  ### 2.1. Chain-of-Thought (CoT) Prompting
 82  
 83  Instruct Claude to "think step-by-step" before providing a final answer. Structured CoT uses XML tags (`<thinking>`) to separate the reasoning process from the final answer, making the AI's logic transparent and debuggable.
 84  
 85  **Example of Structured CoT:**
 86  ```xml
 87  <instructions>
 88    Analyze the following job description and determine the top 3 most critical skills.
 89    Place your reasoning within <thinking> tags and the final answer within <answer> tags.
 90  </instructions>
 91  
 92  <job_description>
 93    ...
 94  </job_description>
 95  
 96  <thinking>
 97    First, I will identify all skills mentioned.
 98    Second, I will categorize them as mandatory or desirable.
 99    Third, I will rank the mandatory skills by frequency and importance.
100  </thinking>
101  
102  <answer>
103    The top 3 most critical skills are: [Skill 1, Skill 2, Skill 3].
104  </answer>
105  ```
106  
107  ### 2.2. Prompt Chaining
108  
109  Break down complex tasks into a sequence of smaller, single-purpose prompts, where the output of one prompt serves as the input for the next. This modular approach increases reliability and manageability for multi-step workflows.
110  
111  ### 2.3. "Tool Use" Paradigm for Enforcing JSON Schema
112  
113  For the most reliable structured data extraction, define "tools" with JSON schemas. Instruct Claude to "call" these tools, populating their arguments with extracted data. This guarantees schema conformity.
114  
115  **Example of Tool Use Schema:**
116  ```json
117  {
118    "name": "extract_job_details",
119    "description": "Extracts key information from a job description.",
120    "input_schema": {
121      "type": "object",
122      "properties": {
123        "job_title": {
124          "type": "string",
125          "description": "The official title of the position."
126        },
127        "company_name": {
128          "type": "string",
129          "description": "The name of the hiring company."
130        }
131      },
132      "required": ["job_title", "company_name"]
133    }
134  }
135  ```
136  
137  ## 3. Ethical Considerations in Prompting
138  
139  Integrate ethical guardrails directly into prompts to mitigate bias and ensure responsible AI outputs:
140  
141  ### 3.1. Prompting for Fairness and Bias Detection
142  
143  Task Claude with reviewing its own output or source data for potential bias or exclusionary language.
144  
145  **Example:**
146  "You are an expert in Diversity, Equity, and Inclusion (DEI). Review the following job description for any language, phrases, or requirements that might unintentionally discourage qualified applicants from underrepresented groups. Suggest more inclusive alternatives for any problematic language you identify."
147  
148  ### 3.2. Allowing for Uncertainty
149  
150  Explicitly give Claude permission to state when it does not know an answer, preventing it from fabricating information.
151  
152  **Example:**
153  "If the Q3 revenue is not mentioned in the report, state 'I don't have enough information to answer the question.'"
154  
155  ## 4. Version-Controlled Prompt Library
156  
157  All prompts should be managed as code within a dedicated library in the project's repository. This ensures consistency, facilitates A/B testing, and allows for systematic iteration and improvement.
158  
159  ---
160  
161  **Reference Document:** `docs/research/claude-prompt-engineering-framework.md`