Skip to main content
Welcome to the OpenHands tutorial library. These tutorials show you how to use OpenHands for common development tasks, from testing to feature development. Each tutorial includes example prompts, expected workflows, and tips for success.

Categories Overview

CategoryBest ForComplexity
TestingAdding tests, improving coverageSimple to Medium
Data AnalysisProcessing data, generating reportsSimple to Medium
Web ScrapingExtracting data from websitesMedium
Code ReviewAnalyzing PRs, finding issuesSimple
Bug FixingDiagnosing and fixing errorsMedium
Feature DevelopmentBuilding new functionalityMedium to Complex
For in-depth guidance on specific use cases, see our Use Cases section which includes detailed workflows for Code Review, Incident Triage, and more.

Task Complexity Guidance

Before starting, assess your task’s complexity: Simple tasks (5-15 minutes):
  • Single file changes
  • Clear, well-defined requirements
  • Existing patterns to follow
Medium tasks (15-45 minutes):
  • Multiple file changes
  • Some discovery required
  • Integration with existing code
Complex tasks (45+ minutes):
  • Architectural changes
  • Multiple components
  • Requires iteration
Start with simpler tutorials to build familiarity with OpenHands before tackling complex tasks.

Best Use Cases

OpenHands excels at:
  • Repetitive tasks: Boilerplate code, test generation
  • Pattern application: Following established conventions
  • Analysis: Code review, debugging, documentation
  • Exploration: Understanding new codebases

Example Tutorials by Category

Testing

Tutorial: Add Unit Tests for a Module

Goal: Achieve 80%+ test coverage for a service module Prompt:
What OpenHands does:
  1. Analyzes the UserService class
  2. Identifies untested code paths
  3. Creates test file with comprehensive tests
  4. Mocks dependencies appropriately
  5. Runs tests to verify they pass
Tips:
  • Provide existing test files as examples
  • Specify the testing framework
  • Mention any mocking conventions

Tutorial: Add Integration Tests for an API

Goal: Test API endpoints end-to-end Prompt:

Data Analysis

Tutorial: Create a Data Processing Script

Goal: Process CSV data and generate a report Prompt:
What OpenHands does:
  1. Creates a Python script with proper structure
  2. Implements data loading with validation
  3. Calculates requested metrics
  4. Generates formatted report
  5. Creates and saves visualizations

Tutorial: Database Query Analysis

Goal: Analyze and optimize slow database queries Prompt:

Web Scraping

Tutorial: Build a Web Scraper

Goal: Extract product data from a website Prompt:
Tips:
  • Specify rate limiting requirements
  • Mention error handling expectations
  • Request logging for debugging

Code Review

For comprehensive code review guidance, see the Code Review Use Case page. For automated PR reviews using GitHub Actions, see the PR Review SDK Guide.

Tutorial: Security-Focused Code Review

Goal: Identify security vulnerabilities in a PR Prompt:

Tutorial: Performance Review

Goal: Identify performance issues in code Prompt:

Bug Fixing

For production incident investigation and automated error analysis, see the Incident Triage Use Case which covers integration with monitoring tools like Datadog.

Tutorial: Fix a Crash Bug

Goal: Diagnose and fix an application crash Prompt:
What OpenHands does:
  1. Analyzes the stack trace
  2. Reviews recent changes
  3. Identifies the null reference issue
  4. Implements a defensive fix
  5. Creates test to prevent regression

Tutorial: Fix a Memory Leak

Goal: Identify and fix a memory leak Prompt:

Feature Development

Tutorial: Add a REST API Endpoint

Goal: Create a new API endpoint with full functionality Prompt:
What OpenHands does:
  1. Creates route handler following existing patterns
  2. Implements validation middleware
  3. Creates or updates the service layer
  4. Adds error handling
  5. Generates API documentation
  6. Creates comprehensive tests

Tutorial: Implement a Feature Flag System

Goal: Add feature flags to the application Prompt:

Contributing Tutorials

Have a great use case? Share it with the community! What makes a good tutorial:
  • Solves a common problem
  • Has clear, reproducible steps
  • Includes example prompts
  • Explains expected outcomes
  • Provides tips for success
How to contribute:
  1. Create a detailed example following this format
  2. Test it with OpenHands to verify it works
  3. Submit via GitHub pull request to the docs repository
  4. Include any prerequisites or setup required
These tutorials are starting points. The best results come from adapting them to your specific codebase, conventions, and requirements.