TUTORIALS 13 min read

Build an AI Interview Prep Tool: Practice With an AI That Fights Back

Build an interview practice tool with AI interviewers that adapt difficulty, give real-time feedback, and score your performance.

By EgoistAI ·
Build an AI Interview Prep Tool: Practice With an AI That Fights Back

Job interviews are stressful because they’re unpredictable. You don’t know what questions you’ll face, you can’t practice with honest feedback, and the stakes are high. Mock interviews with friends are limited by their availability and willingness to be critical. Interview coaching costs $100-300 per hour.

An AI interview prep tool solves these problems. It generates relevant questions based on the role and company, conducts realistic mock interviews, gives brutally honest feedback, and adapts difficulty based on your performance. This tutorial builds one that covers behavioral, technical, and case interviews.

What We’re Building

Chapter 1: What We're Building

An interview preparation tool that:

  1. Generates role-specific interview questions
  2. Conducts interactive mock interviews with follow-up questions
  3. Evaluates responses on content, structure, and delivery
  4. Provides specific improvement suggestions with example answers
  5. Tracks performance across practice sessions
  6. Supports behavioral, technical, and case interview formats

Tech Stack

  • Python 3.11+
  • Streamlit for the web interface
  • Claude API for question generation, interviewing, and evaluation
  • SQLite for session tracking

Step 1: Interview Configuration

Chapter 2: Configuration

INTERVIEW_TYPES = {
    "behavioral": {
        "description": "STAR method behavioral questions",
        "frameworks": ["STAR", "CAR"],
        "evaluation_criteria": ["specificity", "relevance", "impact_quantification", "self_awareness"]
    },
    "technical": {
        "description": "Technical knowledge and problem-solving",
        "frameworks": ["problem_decomposition", "trade_off_analysis"],
        "evaluation_criteria": ["accuracy", "depth", "communication", "problem_solving"]
    },
    "case": {
        "description": "Business case and estimation questions",
        "frameworks": ["hypothesis_driven", "MECE"],
        "evaluation_criteria": ["structure", "creativity", "quantitative_reasoning", "business_sense"]
    },
    "system_design": {
        "description": "System design and architecture",
        "frameworks": ["requirements_gathering", "trade_off_analysis"],
        "evaluation_criteria": ["scalability", "clarity", "trade_offs", "depth"]
    }
}

Step 2: Question Generation

Chapter 3: Questions

from anthropic import Anthropic
import json

client = Anthropic()

def generate_questions(role: str, company: str, interview_type: str,
                       difficulty: str = "medium", count: int = 5) -> list:
    config = INTERVIEW_TYPES[interview_type]

    response = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=1024,
        system=f"""Generate {count} {interview_type} interview questions for a
{role} position at {company}. Difficulty: {difficulty}.

For behavioral: use common competency areas (leadership, conflict, failure, teamwork)
For technical: focus on relevant technologies and concepts
For case: create realistic business scenarios
For system design: choose appropriate scale challenges

Return JSON array of objects: [{{"question": "...", "category": "...", "difficulty": "easy|medium|hard", "what_interviewer_looks_for": "..."}}]""",
        messages=[{"role": "user", "content": f"Generate {interview_type} questions for {role} at {company}"}]
    )

    text = response.content[0].text
    if "```json" in text:
        text = text.split("```json")[1].split("```")[0]
    return json.loads(text.strip())

Step 3: Mock Interview Engine

Chapter 4: Interview Engine

class MockInterview:
    def __init__(self, role: str, company: str, interview_type: str):
        self.role = role
        self.company = company
        self.interview_type = interview_type
        self.messages = []
        self.current_question = 0
        self.questions = generate_questions(role, company, interview_type)

    def get_interviewer_response(self, candidate_answer: str) -> dict:
        self.messages.append({"role": "user", "content": candidate_answer})

        response = client.messages.create(
            model="claude-sonnet-4-20250514",
            max_tokens=1024,
            system=f"""You are a senior interviewer at {self.company} interviewing
for a {self.role} position. You are conducting a {self.interview_type} interview.

Current question: {self.questions[self.current_question]['question']}

Respond naturally as an interviewer would:
- If the answer is vague, ask a follow-up to dig deeper
- If the answer is good, acknowledge and move to the next question
- Maintain a professional but conversational tone
- Don't give feedback during the interview (save it for the debrief)

Return JSON: {{"response": "your spoken response", "follow_up": true/false,
"move_to_next": true/false, "internal_notes": "evaluation notes not shared with candidate"}}""",
            messages=self.messages
        )

        text = response.content[0].text
        if "```json" in text:
            text = text.split("```json")[1].split("```")[0]
        result = json.loads(text.strip())

        self.messages.append({"role": "assistant", "content": result["response"]})

        if result.get("move_to_next"):
            self.current_question += 1

        return result

Step 4: Response Evaluation

Chapter 5: Evaluation

def evaluate_response(question: str, answer: str, interview_type: str) -> dict:
    config = INTERVIEW_TYPES[interview_type]

    response = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=1024,
        system=f"""Evaluate this interview response. Be honest and constructive.

Evaluation criteria: {', '.join(config['evaluation_criteria'])}

Return JSON:
{{
    "overall_score": 1-10,
    "criteria_scores": {{"criterion": score}},
    "strengths": ["what was done well"],
    "weaknesses": ["what needs improvement"],
    "improved_answer": "how a strong candidate would answer this",
    "tips": ["specific, actionable tips"]
}}""",
        messages=[{"role": "user", "content": f"Question: {question}\n\nCandidate's answer: {answer}"}]
    )

    text = response.content[0].text
    if "```json" in text:
        text = text.split("```json")[1].split("```")[0]
    return json.loads(text.strip())

Step 5: Streamlit Interface

Chapter 6: Interface

Build an interactive interface with:

  • Role and company input with interview type selection
  • Chat-style mock interview with the AI interviewer
  • Real-time follow-up questions that adapt to answers
  • Post-interview debrief with scores and feedback
  • Example strong answers for each question
  • Session history showing improvement over time

Step 6: Performance Tracking

Chapter 7: Tracking

Track performance across sessions:

  • Overall score trends
  • Strengths and weaknesses by category
  • Most improved areas
  • Persistent weak spots that need focused practice
  • Time spent per question (too long = needs conciseness, too short = needs depth)

Step 7: Advanced Features

Chapter 8: Advanced

Company-Specific Preparation

Feed the tool information about the company’s values, recent news, and culture. The AI tailors questions and evaluates cultural fit alignment.

Difficulty Adaptation

After each session, adjust difficulty based on performance. Scoring consistently high? The next session uses harder questions, deeper follow-ups, and stricter evaluation.

Audio Mode

Integrate with speech-to-text for verbal practice. Speaking answers aloud is fundamentally different from typing them, and interview performance improves with verbal practice.

Question Bank

Build a personal question bank of questions you’ve encountered in real interviews. The tool generates variations and helps you prepare comprehensive answers.

The Bottom Line

Interview preparation is one of the highest-ROI applications of AI. A single successful interview can change your career trajectory and compensation by tens of thousands of dollars. An AI interview coach that’s available 24/7, gives honest feedback, and adapts to your skill level is worth far more than its minimal cost.

Build time: 4-5 hours. Cost: $10-20/month for regular practice. Value: the difference between “I think the interview went okay” and “I knew exactly what they were looking for and nailed every answer.”

Share this article

> Want more like this?

Get the best AI insights delivered weekly.

> Related Articles

Tags

interview prepAI practicePythoncareer toolstutorial

> Stay in the loop

Weekly AI tools & insights.