Skip to main content

A CLI tool to generate contextual interview questions from Python codebases using AI

Project description

🎯 Interview Question Generator

A powerful CLI tool that analyzes Python codebases and automatically generates contextual technical interview questions using AI. Perfect for hiring managers, technical interviewers, and educators who want to create relevant, code-specific interview questions.

✨ Features

  • 🔍 Intelligent Code Analysis: Deep analysis of Python code structure, patterns, and complexity
  • 🤖 AI-Powered Question Generation: Uses OpenAI's GPT models to generate contextual questions
  • 📊 Multiple Question Categories: Comprehension, debugging, optimization, design, edge cases, and more
  • 🎚️ Difficulty Levels: Beginner, intermediate, advanced, and expert questions
  • 📄 Multiple Output Formats: JSON, Markdown, structured reports
  • ⚡ Fast Processing: Efficient analysis with progress tracking
  • 🛠️ Configurable: Flexible configuration options and CLI parameters

🚀 Installation

Install from GitHub

pip install git+https://github.com/your-username/interview-generator.git

Install for Development

git clone https://github.com/your-username/interview-generator.git
cd interview-generator
pip install -e .

Install with Development Dependencies

pip install -e ".[dev,test]"

📋 Prerequisites

  • Python 3.8 or higher
  • OpenAI API key (get one at OpenAI)

🔧 Quick Start

1. Set up your API key

export OPENAI_API_KEY="your-api-key-here"

Or create a configuration file:

interview-generator config create --interactive

2. Analyze your code

# Basic analysis
interview-generator analyze /path/to/your/project

# Save as Markdown
interview-generator analyze /path/to/your/project --format markdown --output questions.md

# Generate specific question types
interview-generator analyze /path/to/your/project \
  --categories comprehension debugging optimization \
  --difficulty intermediate advanced \
  --max-questions 15

📖 Usage Examples

Basic Analysis

# Analyze a directory with default settings
interview-generator analyze ./src

# Analyze and save to a specific file
interview-generator analyze ./src --output interview_questions.json

Advanced Filtering

# Generate only comprehension and debugging questions
interview-generator analyze ./src -c comprehension -c debugging

# Filter by difficulty level
interview-generator analyze ./src -d intermediate -d advanced

# Limit the number of questions
interview-generator analyze ./src --max-questions 20

Different Output Formats

# Export as Markdown
interview-generator analyze ./src --format markdown --output questions.md

# Create structured output with reports
interview-generator analyze ./src --format structured --output ./results

# Export both JSON and Markdown
interview-generator analyze ./src --format both --output questions

Configuration Management

# Create interactive configuration
interview-generator config create --interactive

# Validate your setup
interview-generator validate setup

# Test API connectivity
interview-generator validate api

# Show current configuration
interview-generator config show

🎯 Question Categories

The tool generates questions in several categories:

  • 🧠 Comprehension: Understanding code purpose and functionality
  • 🐛 Debugging: Identifying and fixing issues
  • ⚡ Optimization: Performance improvements and efficiency
  • 🏗️ Design: Architecture and design patterns
  • 🔍 Edge Cases: Boundary conditions and error handling
  • 🧪 Testing: Test strategies and coverage
  • ♻️ Refactoring: Code improvement and maintainability
  • 🔒 Security: Security vulnerabilities and best practices

🎚️ Difficulty Levels

  • 🟢 Beginner: Basic concepts and simple implementations
  • 🟡 Intermediate: Moderate complexity and common patterns
  • 🟠 Advanced: Complex algorithms and advanced concepts
  • 🔴 Expert: Highly sophisticated and specialized knowledge

⚙️ Configuration

Environment Variables

  • OPENAI_API_KEY: Your OpenAI API key
  • INTERVIEW_GENERATOR_CONFIG: Path to custom config file

Configuration File

Create a configuration file for persistent settings:

interview-generator config create --interactive

Example configuration:

{
  "llm_api_key": "your-api-key",
  "llm_model": "gpt-3.5-turbo",
  "max_questions_per_category": 5,
  "output_format": "json",
  "include_hints": true,
  "quality_threshold": 0.7
}

🔍 CLI Reference

Main Commands

  • analyze: Analyze code and generate questions
  • config: Manage configuration settings
  • validate: Validate setup and test components

Global Options

  • --verbose, -v: Enable verbose output
  • --help: Show help information
  • --version: Show version information

Analyze Command Options

interview-generator analyze [OPTIONS] DIRECTORY

Options:
  -o, --output PATH           Output file or directory path
  -f, --format [json|markdown|both|structured]
                             Output format (default: json)
  -c, --categories [comprehension|debugging|optimization|design|edge_cases|testing|refactoring|security]
                             Question categories (can be used multiple times)
  -d, --difficulty [beginner|intermediate|advanced|expert]
                             Difficulty levels (can be used multiple times)
  -n, --max-questions INTEGER RANGE
                             Maximum number of questions (1-50, default: 10)
  --config PATH              Path to configuration file
  --dry-run                  Show what would be analyzed without API calls
  -q, --quiet                Suppress progress output
  --help                     Show this message and exit

🧪 Development

Running Tests

pytest

Code Formatting

black src tests
isort src tests

Type Checking

mypy src

Pre-commit Hooks

pre-commit install
pre-commit run --all-files

📊 Example Output

JSON Format

{
  "questions": [
    {
      "id": "q1",
      "category": "comprehension",
      "difficulty": "intermediate",
      "question_text": "Explain the purpose of the UserManager class...",
      "code_snippet": "class UserManager:\n    def authenticate(self, username, password):\n        ...",
      "expected_answer": "The UserManager class handles user authentication...",
      "hints": ["Focus on the authentication method", "Consider security implications"],
      "context_references": ["Domain: web", "Pattern: authentication"]
    }
  ],
  "metadata": {
    "total_questions": 10,
    "processing_time": 15.2,
    "files_analyzed": 5,
    "model_used": "gpt-3.5-turbo"
  }
}

Markdown Format

# Interview Questions

## Question 1: Code Comprehension (Intermediate)

**Question:** Explain the purpose and functionality of the UserManager class.

**Code:**
```python
class UserManager:
    def authenticate(self, username, password):
        # Implementation details...

Expected Answer: The UserManager class handles user authentication...

Hints:

  • Focus on the authentication method
  • Consider security implications

## 🤝 Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Run tests (`pytest`)
5. Commit your changes (`git commit -m 'Add amazing feature'`)
6. Push to the branch (`git push origin feature/amazing-feature`)
7. Open a Pull Request

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- OpenAI for providing the GPT models
- The Python community for excellent tooling and libraries
- Contributors and users who help improve this tool

## 📞 Support

- 📖 [Documentation](https://github.com/your-username/interview-generator#readme)
- 🐛 [Issue Tracker](https://github.com/your-username/interview-generator/issues)
- 💬 [Discussions](https://github.com/your-username/interview-generator/discussions)

---

Made with ❤️ for the developer community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

interview_generator-1.0.0.tar.gz (105.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

interview_generator-1.0.0-py3-none-any.whl (119.5 kB view details)

Uploaded Python 3

File details

Details for the file interview_generator-1.0.0.tar.gz.

File metadata

  • Download URL: interview_generator-1.0.0.tar.gz
  • Upload date:
  • Size: 105.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for interview_generator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 19208b9211b27a5696cb02672f3b5d5cb4c716999fa8158797918a9663aebbc3
MD5 52bc74ad70619a4b84fd40f59c75f2b0
BLAKE2b-256 60354b3f5f2594f56b6bc449c76d9fac1e3ba8b1baad2d35ff88f371a9dd1354

See more details on using hashes here.

File details

Details for the file interview_generator-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for interview_generator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e46e544dfdfaebe4a5aeb4de4f5de04014928c191c13bc910fd625f4170ec0b9
MD5 03a01939f5a85fc72420a060f5f4af69
BLAKE2b-256 528d8615845a1960fceab3dc90eab571d359bfca951b1ee3e6c561b8de65411f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page