Introduction
howdoi fetches concise answers to programming questions directly from your terminal. It scrapes top-voted Stack Overflow responses and returns code snippets, saving developers from context-switching to a browser.
What howdoi Does
- Answers free-form programming questions with code snippets from Stack Overflow
- Returns the top-voted answer by default or all answers with the
-aflag - Supports colorized output with syntax highlighting
- Provides a REPL mode for interactive question sessions
- Caches responses locally to speed up repeated queries
Architecture Overview
howdoi is a Python CLI that uses search engines to find relevant Stack Overflow threads, then parses the HTML to extract the highest-scored code blocks. It employs a local cache (file-based or optional Redis) to avoid repeated network calls. The tool can use Google, Bing, or DuckDuckGo as the search backend.
Self-Hosting & Configuration
- Install via
pip install howdoiorpipx install howdoi - Set
HOWDOI_SEARCH_ENGINEto choose between google, bing, or duckduckgo - Configure cache directory with
HOWDOI_CACHEenvironment variable - Use
HOWDOI_COLORIZE=1to enable syntax-highlighted output - Integrate into editors via the included Emacs and Vim plugins
Key Features
- Answers returned as ready-to-paste code snippets
- Multiple search engine backends for reliability
- Local caching reduces latency for repeated lookups
- Colorized terminal output with language detection
- Importable as a Python library for programmatic use
Comparison with Similar Tools
- cheat.sh — serves curated cheat sheets; howdoi searches live Stack Overflow answers
- tldr-pages — short man-page alternatives for commands; howdoi answers arbitrary coding questions
- Stack Overflow CLI — official SO search; howdoi extracts code snippets rather than full pages
- ShellGPT — LLM-powered answers; howdoi uses proven human-written solutions from SO
FAQ
Q: Does howdoi require an API key? A: No. It uses web scraping to retrieve answers without authentication.
Q: How accurate are the answers? A: howdoi returns the top-voted Stack Overflow answer, which reflects community consensus but may not always fit your exact context.
Q: Can I use howdoi in scripts?
A: Yes. Import it as a Python library with from howdoi import howdoi and call howdoi.howdoi(query).
Q: Does it support languages other than English? A: Queries work best in English since it searches English-language Stack Overflow.