HR Document Analyzer with Claude API
Build a Python CLI tool that analyzes HR documents using Claude AI.
Introduction
30 Second Summary
Every workplace runs on HR documents. Job descriptions, insurance forms, company policies. They pile up fast and take forever to read through carefully.
In this project, you will build a command-line tool that uses the Claude API to instantly analyze any HR document and answer your questions about it.
What You'll Build
A Python script that reads PDF files from your computer and sends them to Claude AI for structured analysis and interactive follow-up questions.
By the end of this project, you'll have:
- PDF document analysis powered by the Claude API that extracts summaries, key points, and action items from any HR document.
- An HR-specific system prompt that gives Claude expert context for analyzing workplace documents.
- An interactive question mode that lets you ask follow-up questions about the same document without re-uploading it.
- Secret Mission: A multi-document comparison mode that analyzes two PDFs side by side and highlights differences.
Are there any prerequisites?
No coding experience is required. You just need a computer with Python and VS Code already installed. Every concept is explained step by step.
Before We Start
Before We Start...
Set Up Your Anthropic API Account
Your HR Document Analyzer will use Claude to read and understand PDF documents. Claude lives in the cloud, so your script needs permission to talk to it.
That permission comes in the form of an API key. In this step, you'll create an Anthropic account, purchase credits, and store your API key so your script can use it automatically.
In this step, get ready to:
- Create an Anthropic Console account and purchase $5 in API credits.
- Generate an API key.
- Store the API key as an environment variable on your computer.
Create your Anthropic Console account
Anthropic is the company behind Claude. Their Console is where you manage your API access and billing.
- Open console.anthropic.com in your browser.
- Click Sign Up and create your account using your email or Google sign-in.
- Once signed in, click Settings in the left sidebar.
- Click Billing.
- Click Add to Credit Balance and purchase $5 in credits.
What are API credits?
API credits are prepaid funds that get spent each time your script sends a document to Claude for analysis. At Claude's pricing, $5 covers 300+ document analyses.
Credits expire 1 year from purchase. There are no recurring charges or subscriptions.
Generate an API key
An API key is a secret password that identifies your account when your script connects to Claude. You'll generate one now and store it safely.
- In the Anthropic Console, click API Keys in the left sidebar.
- Click Create Key.
- Give it a name like hr-analyzer.
- Click Create Key to generate it.
- Copy the key immediately and paste it somewhere safe (like a text file on your Desktop).
Copy your key now
Anthropic only shows you the full API key once. After you close this dialog, you cannot view it again. If you lose it, you'll need to generate a new one.
Set the API key as an environment variable
Your Python script needs to find your API key when it runs. Instead of pasting the key directly into your code (which is a security risk), you'll store it as an environment variable.
What is an environment variable?
An environment variable is a value stored in your operating system that any program can read. It keeps sensitive values like API keys out of your code files.
Windows
- Press the Windows key to open your search bar.
- Type cmd and press Enter to open Command Prompt.
- Set your API key as a persistent environment variable by running this command:
setx ANTHROPIC_API_KEY "your-api-key-here"
- Replace your-api-key-here with the actual API key you copied earlier.
- You should see: SUCCESS: Specified value was saved..
- Close Command Prompt.
Restart VS Code after this
The setx command sets the variable for future sessions, not the current one. You must fully close and reopen VS Code before it can see the new variable.
macOS
- Press Cmd+Space to open Spotlight.
- Type Terminal and press Enter.
- Add your API key to your shell profile by running this command:
echo 'export ANTHROPIC_API_KEY="your-api-key-here"' >> ~/.zshrc
- Replace your-api-key-here with the actual API key you copied earlier.
- Load the updated profile by running:
source ~/.zshrc
- Verify the variable is set by running:
echo $ANTHROPIC_API_KEY
- You should see your API key printed in the terminal.
Restart VS Code after this
VS Code needs to be fully closed and reopened to pick up the new environment variable. Reload the window before moving to the next step.
Variable not showing up?
Make sure you fully closed and reopened your terminal or VS Code. The variable only appears in new sessions.
Double-check that you didn't accidentally include extra spaces around the = sign or around the key value.
On Windows, confirm it was saved by opening a new Command Prompt and running echo %ANTHROPIC_API_KEY%.
help me troubleshoot my ANTHROPIC_API_KEY environment variable
Your account is funded, your API key is generated, and your computer knows where to find it. Next up, you'll create your project folder and verify that everything connects to Claude successfully.
Create Your Project and Install Dependencies
Your Anthropic API account is ready and your API key is stored as an environment variable. Now it's time to create the workspace where you'll write your HR document analyzer.
In this step, you'll set up a project folder, install the one Python package you need, and run a quick test to confirm everything connects to the Claude API properly.
In this step, get ready to:
- Create a project folder with a documents subfolder for storing PDFs.
- Install the anthropic Python package.
- Verify your API connection with a test script.
Create your project folder
Every Python project needs its own folder to keep scripts, dependencies, and data organized. You'll create a folder on your Desktop so it's easy to find.
- Press the Windows key to open your search bar.
- Type VS Code and press Enter to open it.
Why VS Code?
VS Code gives you a code editor and a terminal in one window. You'll write your Python scripts in the editor and run them in the built-in terminal without switching apps.
- Open the terminal inside VS Code by pressing Ctrl+` (the backtick key, above Tab).
Don't see the terminal?
Click Terminal in the top menu bar, then click New Terminal.
- Move to your Desktop by running this command:
cd ~/Desktop
- Create your project folder, move into it, and create a subfolder for documents by running these commands:
mkdir hr-analyzer
cd hr-analyzer
mkdir documents
What does this do?
mkdir hr-analyzer creates a new folder called hr-analyzer on your Desktop.
cd hr-analyzer moves your terminal into that folder. mkdir documents creates a subfolder where you'll store PDF files for analysis.
- Confirm the folders exist by running:
ls
You should see documents listed in the output.
- Now open this folder in VS Code by clicking File in the top menu bar.
- Click Open Folder.
- Navigate to Desktop, select the hr-analyzer folder, and click Select Folder.
The VS Code Explorer sidebar on the left should now show your hr-analyzer folder with a documents subfolder inside it.
Install the anthropic package
The anthropic package is the official Python library for communicating with Claude's API. It handles authentication, request formatting, and response parsing for you.
- In your VS Code terminal, install the package by running:
pip install anthropic
You should see output ending with Successfully installed anthropic-... and a version number.
Seeing 'pip is not recognized'?
Try running pip3 install anthropic instead. If that also fails, Python may not be on your system PATH. Close and reopen VS Code, then try again.
Still stuck? Help me fix my pip installation.
Create a test script to verify your connection
Before building the full analyzer, you'll write a tiny script that sends a single message to Claude. If it responds, your API key and network connection are both working.
- In the VS Code Explorer sidebar, hover over the hr-analyzer folder name and click the New File icon (a page with a plus sign).
- Type test_connection.py and press Enter.
- Paste the following code into test_connection.py:
from anthropic import Anthropic
# Create the client (reads ANTHROPIC_API_KEY from your environment)
client = Anthropic()
# Send a simple test message to verify the connection
response = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=100,
messages=[
{"role": "user", "content": "Say hello in one sentence."}
],
)
print("Connection successful!")
print(f"Claude says: {response.content[0].text}")
What does this code do?
Anthropic() creates an API client that automatically reads your ANTHROPIC_API_KEY environment variable for authentication.
client.messages.create(...) sends a message to Claude and waits for a response. If you see Claude's reply printed in your terminal, everything is wired up correctly.
- Save the file by pressing Ctrl+S.
- Run the test script in your terminal:
python test_connection.py
You should see output like this:
Connection successful!
Claude says: Hello! It's nice to meet you.
What should I see?
The exact words Claude says will vary each time. What matters is that you see Connection successful! followed by any response from Claude.
Seeing an authentication error?
If you see AuthenticationError, your API key is not being found. Make sure you restarted VS Code after setting the ANTHROPIC_API_KEY environment variable in Step 1.
Close VS Code completely and reopen it. The terminal needs a fresh session to pick up new environment variables.
Still stuck? Help me fix my Anthropic API authentication error.
Seeing a model not found error?
If you see an error about an invalid model, try changing the model string in your script to claude-haiku-4-5 (the alias without the date suffix). Save and run again.
Need more help? Help me fix my model not found error.
✔️ Awesome, I've got everything!
Great. Make sure test_connection.py is saved, then you're ready to move on.
ⓧ I'd like to double check the full code
Here's the complete test_connection.py file:
from anthropic import Anthropic
# Create the client (reads ANTHROPIC_API_KEY from your environment)
client = Anthropic()
# Send a simple test message to verify the connection
response = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=100,
messages=[
{"role": "user", "content": "Say hello in one sentence."}
],
)
print("Connection successful!")
print(f"Claude says: {response.content[0].text}")
Your project is wired up and talking to Claude. Next up, you'll build the real document analyzer that reads HR PDFs and returns structured insights.
Build the PDF Document Analyzer
Your API connection is confirmed working. Now it's time to build the actual tool that will analyze HR documents.
Claude's API can process PDF files directly. You send the file as base64-encoded data, and Claude reads the document contents, understands the layout, and answers questions about it. In this step, you'll write a Python script that loads a PDF, sends it to Claude with an HR-specific prompt, and prints a structured analysis.
In this step, get ready to:
- Write a function that reads PDF files and converts them to base64.
- Build an analysis function with an HR-specific system prompt.
- Test the full analyzer with a sample HR document.
Write the PDF loading function
Claude's API doesn't accept raw file uploads. Instead, you read the PDF file as binary data and encode it into a base64 string. This is a standard way to embed binary content (like images or PDFs) inside a text-based API request.
- Create a new file called hr_analyzer.py in your hr-analyzer folder by right-clicking in the VS Code Explorer sidebar and selecting New File.
- Add the following imports and PDF loading function:
import os
import sys
import base64
from anthropic import Anthropic
def load_pdf_as_base64(file_path):
"""Read a PDF file and return its base64-encoded content."""
with open(file_path, "rb") as f:
return base64.standard_b64encode(f.read()).decode("utf-8")
What does this code do?
The imports pull in Python's built-in modules for file paths (os), command-line arguments (sys), and binary-to-text encoding (base64). The Anthropic import is the Claude SDK you installed earlier.
The load_pdf_as_base64 function opens a PDF in binary mode ("rb"), reads its contents, and converts the raw bytes into a base64 string that Claude's API can accept.
- Save hr_analyzer.py.
You won't see a change yet. The next chunk uses this function to send the PDF to Claude.
Add the document analysis function
A system prompt tells Claude what role to play and how to structure its responses. For HR documents, you want Claude to think like an experienced HR professional who flags compliance issues and provides actionable insights.
What is a system prompt?
A system prompt is a set of instructions that shapes how an AI model responds. It runs before the user's message and sets the tone, format, and expertise level for all responses in that conversation.
- In hr_analyzer.py, add the following function below your load_pdf_as_base64 function:
def analyze_document(client, pdf_data, question, conversation_history=None):
"""Send a PDF document to Claude for analysis."""
system_prompt = (
"You are an experienced HR professional and document analyst. "
"When analyzing HR documents (job descriptions, insurance forms, "
"company policies, salary structures, organizational charts, etc.), "
"provide clear, actionable insights. "
"Structure your responses with headings and bullet points. "
"Flag any potential compliance issues or areas that need attention. "
"If asked for recommendations, base them on HR best practices."
)
if conversation_history is None:
messages = [
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": pdf_data,
},
},
{"type": "text", "text": question},
],
}
]
else:
messages = conversation_history + [
{
"role": "user",
"content": question,
}
]
response = client.messages.create(
model="claude-haiku-4-5-20250929",
max_tokens=4096,
system=system_prompt,
messages=messages,
)
return response.content[0].text
What does this function do?
The system_prompt string tells Claude to act as an HR expert. It instructs Claude to use headings and bullet points, flag compliance issues, and base recommendations on HR best practices.
The if conversation_history is None block handles two scenarios. For the first question, it sends the PDF as a document content block alongside the question. For follow-up questions (used in the next step), it appends the new question to existing conversation history.
The API call uses claude-haiku-4-5-20250929, which costs about 1-2 cents per typical HR document analysis.
- Save hr_analyzer.py.
You won't see output yet. The next chunk adds the entry point that ties everything together.
Test the analyzer with a sample HR document
The main() function is the entry point of your script. It accepts a PDF file path from the command line, validates it, loads the document, and sends it to Claude for an initial comprehensive analysis.
- Add the following main() function at the bottom of hr_analyzer.py:
def main():
if len(sys.argv) < 2:
print("Usage: python hr_analyzer.py <path-to-pdf>")
print("Example: python hr_analyzer.py documents/job_description.pdf")
sys.exit(1)
file_path = sys.argv[1]
if not os.path.exists(file_path):
print(f"Error: File not found: {file_path}")
sys.exit(1)
if not file_path.lower().endswith(".pdf"):
print("Error: Please provide a PDF file.")
sys.exit(1)
print(f"Loading document: {file_path}")
pdf_data = load_pdf_as_base64(file_path)
print("Document loaded successfully!\n")
client = Anthropic()
print("Analyzing document...\n")
initial_question = (
"Please provide a comprehensive summary of this HR document. Include:\n"
"1. Document type and purpose\n"
"2. Key points and important details\n"
"3. Any deadlines, requirements, or action items\n"
"4. Potential concerns or areas that need attention"
)
result = analyze_document(client, pdf_data, initial_question)
print(result)
print("\n" + "=" * 60)
if __name__ == "__main__":
main()
What does this code do?
- The argument check (sys.argv < 2) ensures the user provides a file path when running the script. If they don't, it prints a helpful usage example and exits.
- The validation checks confirm the file exists and is a PDF before attempting to process it.
- The initial_question is a structured prompt that asks Claude for a comprehensive document summary covering type, key points, deadlines, and concerns.
- The if __name__ == "__main__" line ensures main() only runs when you execute the script directly.
- Save hr_analyzer.py.
Now you need a sample HR document to test with. Any PDF will work. Job descriptions, company policies, insurance documents, and offer letters are all great choices.
- Find an HR-related PDF on your computer (or download a sample job description PDF from the internet).
- Copy the PDF into your documents/ folder inside hr-analyzer.
- Run the analyzer on your PDF by running this command in your terminal:
python hr_analyzer.py documents/[[PDF_FILENAME="your-document.pdf"]]
Replace the filename
Replace the filename with the actual name of the PDF you placed in the documents/ folder. For example: python hr_analyzer.py documents/job_description.pdf.
You should see Claude's structured analysis printed in your terminal. It will include headings, bullet points, and a breakdown of the document's contents.
Seeing an error?
- If you see Error: File not found, double-check that your PDF is inside the documents/ folder and that the filename in your command matches exactly (including capitalization).
- If you see Error: Please provide a PDF file, make sure your file has a .pdf extension.
- If you see a NotFoundError about the model, try changing claude-haiku-4-5-20250929 to claude-haiku-4-5-20251001 in your analyze_document function. Model date suffixes can change.
- If you see an AuthenticationError, your API key may not be set correctly. Make sure you restarted VS Code after setting the environment variable.
Help me debug my HR analyzer script
✔️ Awesome, I've got everything!
Great. Double check you've saved your file before moving on.
ⓧ I'd like to double check the full code
Here's the complete hr_analyzer.py file so far:
import os
import sys
import base64
from anthropic import Anthropic
def load_pdf_as_base64(file_path):
"""Read a PDF file and return its base64-encoded content."""
with open(file_path, "rb") as f:
return base64.standard_b64encode(f.read()).decode("utf-8")
def analyze_document(client, pdf_data, question, conversation_history=None):
"""Send a PDF document to Claude for analysis."""
system_prompt = (
"You are an experienced HR professional and document analyst. "
"When analyzing HR documents (job descriptions, insurance forms, "
"company policies, salary structures, organizational charts, etc.), "
"provide clear, actionable insights. "
"Structure your responses with headings and bullet points. "
"Flag any potential compliance issues or areas that need attention. "
"If asked for recommendations, base them on HR best practices."
)
if conversation_history is None:
messages = [
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": pdf_data,
},
},
{"type": "text", "text": question},
],
}
]
else:
messages = conversation_history + [
{
"role": "user",
"content": question,
}
]
response = client.messages.create(
model="claude-haiku-4-5-20250929",
max_tokens=4096,
system=system_prompt,
messages=messages,
)
return response.content[0].text
def main():
if len(sys.argv) < 2:
print("Usage: python hr_analyzer.py <path-to-pdf>")
print("Example: python hr_analyzer.py documents/job_description.pdf")
sys.exit(1)
file_path = sys.argv[1]
if not os.path.exists(file_path):
print(f"Error: File not found: {file_path}")
sys.exit(1)
if not file_path.lower().endswith(".pdf"):
print("Error: Please provide a PDF file.")
sys.exit(1)
print(f"Loading document: {file_path}")
pdf_data = load_pdf_as_base64(file_path)
print("Document loaded successfully!\n")
client = Anthropic()
print("Analyzing document...\n")
initial_question = (
"Please provide a comprehensive summary of this HR document. Include:\n"
"1. Document type and purpose\n"
"2. Key points and important details\n"
"3. Any deadlines, requirements, or action items\n"
"4. Potential concerns or areas that need attention"
)
result = analyze_document(client, pdf_data, initial_question)
print(result)
print("\n" + "=" * 60)
if __name__ == "__main__":
main()
Your analyzer can now read any HR PDF and produce a structured summary in seconds. Next up, you'll add an interactive question mode so you can drill into the document with follow-up questions.
Add Interactive Question Mode
Your analyzer gives a solid summary on the first run, but what if you want to dig deeper? Maybe the summary mentions a benefits enrollment deadline and you want to know exactly what forms are required.
In this step, you'll add an interactive question mode that lets you ask follow-up questions about the same document. Claude remembers the conversation context, so each answer builds on what came before.
In this step, get ready to:
- Build a conversation history that preserves document context between questions.
- Add an interactive loop for asking follow-up questions.
- Test the full interactive workflow end-to-end.
Build the conversation history
For Claude to answer follow-up questions intelligently, it needs to remember what document it analyzed and what it already said. The Claude API is stateless, so you need to send the full conversation each time.
- In hr_analyzer.py, find the last two lines of your main() function:
result = analyze_document(client, pdf_data, initial_question)
print(result)
print("\n" + "=" * 60)
- Add the following code directly below print("\n" + "=" * 60) to build the conversation history:
# Store the initial exchange so Claude remembers the document and its analysis
conversation_history = [
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": pdf_data,
},
},
{"type": "text", "text": initial_question},
],
},
{
"role": "assistant",
"content": result,
},
]
print("\nYou can now ask follow-up questions about this document.")
print("Type 'quit' or 'exit' to stop.\n")
What does this code do?
The conversation_history list stores two messages: the original user message (containing the PDF document and the initial question) and Claude's response.
When you ask a follow-up question later, the script sends this full history plus your new question. Claude sees the entire conversation and responds in context, without you needing to resend the PDF file.
- Save hr_analyzer.py.
You won't see a change yet. The next chunk adds the interactive loop that uses this conversation history.
Add the interactive question loop
Now you need a loop that repeatedly asks the user for a question, sends it to Claude with the conversation history, and prints the answer. The loop should exit gracefully when the user is done.
- In hr_analyzer.py, add the following code directly below the two print() statements you just added (still inside the main() function):
# Interactive loop: ask follow-up questions about the same document
while True:
question = input("Your question: ").strip()
# Exit gracefully when the user is done
if question.lower() in ("quit", "exit", "q"):
print("Goodbye!")
break
# Skip empty input
if not question:
continue
# Send the question with full conversation context
answer = analyze_document(client, pdf_data, question, conversation_history)
print(f"\n{answer}\n")
# Append the new exchange to the history for future context
conversation_history.append({"role": "user", "content": question})
conversation_history.append({"role": "assistant", "content": answer})
What does this code do?
- input("Your question: ") pauses the script and waits for the user to type something.
- The if question.lower() in ("quit", "exit", "q") check lets the user stop the script by typing any of those words.
- Each follow-up calls analyze_document() with conversation_history, which triggers the else branch in that function. Claude receives the full conversation context.
- After each answer, both the question and the response are appended to conversation_history so the next question has even more context.
- Save hr_analyzer.py.
Seeing an indentation error?
Make sure the while True: loop is indented at the same level as the rest of the code inside main() (one level of indentation, or 4 spaces). The lines inside the loop need an additional 4 spaces (8 total).
help me fix an indentation error in my Python while loop
✔️ Awesome, I've got everything!
Double check you've saved your file before moving on to testing.
ⓧ I'd like to double check the full code
Here is the complete hr_analyzer.py file at this point:
import os
import sys
import base64
from anthropic import Anthropic
def load_pdf_as_base64(file_path):
"""Read a PDF file and return its base64-encoded content."""
with open(file_path, "rb") as f:
return base64.standard_b64encode(f.read()).decode("utf-8")
def analyze_document(client, pdf_data, question, conversation_history=None):
"""Send a PDF document to Claude for analysis."""
system_prompt = (
"You are an experienced HR professional and document analyst. "
"When analyzing HR documents (job descriptions, insurance forms, "
"company policies, salary structures, organizational charts, etc.), "
"provide clear, actionable insights. "
"Structure your responses with headings and bullet points. "
"Flag any potential compliance issues or areas that need attention. "
"If asked for recommendations, base them on HR best practices."
)
if conversation_history is None:
messages = [
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": pdf_data,
},
},
{"type": "text", "text": question},
],
}
]
else:
messages = conversation_history + [
{
"role": "user",
"content": question,
}
]
response = client.messages.create(
model="claude-haiku-4-5-20250929",
max_tokens=4096,
system=system_prompt,
messages=messages,
)
return response.content[0].text
def main():
if len(sys.argv) < 2:
print("Usage: python hr_analyzer.py <path-to-pdf>")
print("Example: python hr_analyzer.py documents/job_description.pdf")
sys.exit(1)
file_path = sys.argv[1]
if not os.path.exists(file_path):
print(f"Error: File not found: {file_path}")
sys.exit(1)
if not file_path.lower().endswith(".pdf"):
print("Error: Please provide a PDF file.")
sys.exit(1)
print(f"Loading document: {file_path}")
pdf_data = load_pdf_as_base64(file_path)
print("Document loaded successfully!\n")
client = Anthropic()
print("Analyzing document...\n")
initial_question = (
"Please provide a comprehensive summary of this HR document. Include:\n"
"1. Document type and purpose\n"
"2. Key points and important details\n"
"3. Any deadlines, requirements, or action items\n"
"4. Potential concerns or areas that need attention"
)
result = analyze_document(client, pdf_data, initial_question)
print(result)
print("\n" + "=" * 60)
conversation_history = [
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": pdf_data,
},
},
{"type": "text", "text": initial_question},
],
},
{
"role": "assistant",
"content": result,
},
]
print("\nYou can now ask follow-up questions about this document.")
print("Type 'quit' or 'exit' to stop.\n")
while True:
question = input("Your question: ").strip()
if question.lower() in ("quit", "exit", "q"):
print("Goodbye!")
break
if not question:
continue
answer = analyze_document(client, pdf_data, question, conversation_history)
print(f"\n{answer}\n")
conversation_history.append({"role": "user", "content": question})
conversation_history.append({"role": "assistant", "content": answer})
if __name__ == "__main__":
main()
Test the full interactive workflow
Time to see the interactive mode in action. You'll run the script, let it generate the initial summary, then ask follow-up questions and verify that Claude remembers the document context.
- Run your analyzer against your sample PDF by running this command:
python hr_analyzer.py [[PDF_PATH="path/to/your-document.pdf"]]
- Wait for the initial summary to appear (this takes a few seconds while Claude analyzes the document).
- After the summary and the ==== divider, you should see the message: "You can now ask follow-up questions about this document."
- At the Your question: prompt, type a follow-up question about your document. For example:
What are the most important deadlines mentioned?
- Verify that Claude answers specifically about your document (not a generic response).
- Ask a second follow-up question that references something from Claude's first answer. This confirms conversation history is working.
- Type quit and press Enter to exit. You should see "Goodbye!" and the script ends cleanly.
What should I see?
After the initial summary, the script waits at the Your question: prompt. Each answer takes a few seconds as Claude processes your question with the full conversation context. Each response should be specific to your document, not generic HR advice.
Claude gives a generic answer instead of referencing your document?
Make sure your conversation_history list is defined before the while True loop and includes the document block in the first user message. If the PDF data is missing from the history, Claude has no context.
help me debug why Claude isn't referencing my document in follow-up questions
Your HR Document Analyzer is fully functional. You can load any PDF, get an instant summary, and drill into the details with follow-up questions. Next up, the Secret Mission challenges you to compare two documents side by side.
Secret mission
Multi-Document Comparison Mode
Your analyzer handles one document at a time. But what if you need to compare two job descriptions, two versions of a policy, or an old vs. new insurance plan? In this secret mission, you'll add a comparison mode that sends two PDFs to Claude in a single request and gets a structured side-by-side analysis.
Clean Up Your Resources
Clean Up Your Resources
Your Anthropic API credits ($5) will last for 300+ document analyses. There are no recurring charges or background services running.
No ongoing costs
This project uses prepaid API credits. You are only charged when you run the script. Credits expire 1 year from purchase.
Resources you used:
- Anthropic API credits ($5 prepaid on console.anthropic.com).
- ANTHROPIC_API_KEY environment variable (Windows system variable).
- hr_analyzer.py script (local file in your project folder).
- anthropic Python package (installed via pip).
Keep everything running
No action needed. Choose this if you plan to keep analyzing HR documents.
- Your script, environment variable, and API credits stay in place.
- You can run the analyzer anytime by opening a terminal and running the script.
- Credits are only consumed when you actively run an analysis.
Pause - I'll come back to this later
There is nothing to pause. Your API credits sit idle until you run the script again. No background processes are running.
- Your credits remain available for up to 1 year from purchase.
- Your script and environment variable stay in place for whenever you return.
Delete - I don't want to use this again
Remove all project resources from your computer.
- Delete your project folder from the Desktop.
- Remove the ANTHROPIC_API_KEY environment variable by opening System Properties, clicking Environment Variables, selecting ANTHROPIC_API_KEY, and clicking Delete.
- Uninstall the anthropic package by running:
pip uninstall anthropic
- Your remaining API credits cannot be refunded. They will expire after 1 year if unused.
Nice Work!
Nice Work!
You just built a real AI-powered tool that solves a real problem. Your HR Document Analyzer can take any PDF and turn it into actionable insights in seconds using the Claude API.
Here's what you accomplished:
- Built a Python script that sends PDFs to the Claude API using base64 encoding for instant document analysis.
- Created an HR-specific system prompt that gives Claude expert context for analyzing job descriptions, policies, and insurance forms.
- Added an interactive question mode that uses conversation history to let you drill into document details without re-uploading the file.
- Added a multi-document comparison mode that analyzes two PDFs side by side and highlights key differences.
Ready to quiz yourself?