# howdoi: Instant Coding Answers from the Command Line

> howdoi is a Python command-line tool that fetches coding answers from Stack Overflow by passing a natural-language query directly in the terminal. It is built for developers who want a quick snippet without switching to a browser.

**gleitz/howdoi** — instant coding answers via the command line

- Repository: https://github.com/gleitz/howdoi
- Website: http://blog.gleitzman.com/post/43330157197/howdoi-instant-coding-answers-via-the-command-line
- Stars: 10,845 · Forks: 860
- Language: Python
- License: MIT
- Published: 2026-09-21 · Updated: 2026-09-21 · Language: en
- Canonical page: https://hysenlabs.com/projects/gleitz-howdoi

## Staying in the Terminal to Look Up Code Syntax

Every developer who works from a terminal faces the same interruption: a missing syntax detail, a forgotten flag, or a command that almost but does not quite come to mind. The usual path is to open a browser, search, navigate to a Stack Overflow thread, find the answer, and return to the terminal. howdoi eliminates that path by making the lookup itself a terminal command.

The README describes the tool as being for developers who constantly search for basic programming tasks, positioning it explicitly as a way to never open the browser for a coding question. The core interaction is a plain-English query typed in the same session where the work is happening. The tool queries Stack Overflow and prints the relevant code or command to standard output. For example, to look up how to format a date in bash, the developer types the question and gets a one-liner back, without leaving the console.

This makes howdoi most valuable during the kind of work where context-switching is costly: debugging sessions, writing configuration files, or any task where a break in focus produces real friction. It targets the Stack Overflow network by default, so the source of the answers is the same one most developers already use.

## From Query to Answer: How the Lookup Works

When a query is run, howdoi passes it to a search engine, takes the top Stack Overflow link from the results, and extracts the accepted or highest-voted answer from that page. The default search engine is Google, but the `HOWDOI_SEARCH_ENGINE` environment variable accepts `google`, `bing`, or `duckduckgo`, and the `-e` flag overrides it for a single query.

Answers are cached locally after the first request. Running the same query a second time returns the stored result immediately, with no network call. The cache can be cleared by passing `-C` on the command line, or disabled entirely by setting `HOWDOI_DISABLE_CACHE=1` as an environment variable.

The target site defaults to Stack Overflow, but `HOWDOI_URL` changes it. Setting that variable to any domain in the StackExchange network redirects the search to that community instead. The lookup mechanism is the same regardless of which site is targeted: a search engine query, a page extraction, and a printout to stdout.

SSL verification can be disabled with `HOWDOI_DISABLE_SSL=1`. This is documented as a workaround for environments where corporate proxies intercept HTTPS traffic, not as a recommended default.

## Installing howdoi and Running the First Query

howdoi is available through pip for any Python 3.7 or later environment:

```bash
pip install howdoi
```

macOS users who prefer Homebrew can install it with:

```bash
brew install howdoi
```

After installation, the README suggests starting with this query to confirm the setup works:

```bash
howdoi howdoi
```

That command fetches an explanation of how to use howdoi from Stack Overflow, which also verifies the network connection and the search engine integration.

For a more practical first run, to get the command for creating a tar archive:

```bash
howdoi create tar archive
```

By default, howdoi prints a single short answer, typically a code snippet. To see the full text of the answer including any surrounding explanation, add `-a`. To get five candidate answers instead of one, add `-n 5`:

```bash
howdoi -a format date bash
```

For developers who always want colorized output and multiple results, the README provides an alias for `.bash_profile`:

```bash
alias h='function hdi(){ howdoi $* -c -n 5; }; hdi'
```

With that alias in place, `h format date bash` runs the query with color enabled and returns five answers. The alias name and parameters can be changed to match personal preferences.

## Command Flags and Environment Variables for Custom Workflows

The full command signature exposes the range of controls:

```bash
usage: howdoi [-h] [-p POS] [-n NUM] [-a] [-l] [-c] [-x] [-C] [-j] [-v] [-e [ENGINE]]
[--save] [--view] [--remove] [--empty] [QUERY ...]
```

The `-p POS` flag selects an answer by position. When the first result is not the right one, `-p 2` fetches the second-ranked answer without re-running the full search. This is useful for common queries where multiple valid approaches exist and the top Stack Overflow answer is not the one the developer needs.

The `-l` flag prints only the URL of the source page rather than the answer text. It is useful when a developer wants to open the full thread for context, votes, and comments, rather than reading a stripped-down snippet.

The `-j` flag returns output as raw JSON. This allows piping into `jq` or other processing tools, which is practical when howdoi is being called from a shell script that needs to parse the result.

The `-x` flag prints an explanation of how the answer was chosen, including the source URL alongside the answer text.

The environment variables complement the flags for persistent configuration:

```bash
HOWDOI_COLORIZE=1
HOWDOI_DISABLE_CACHE=1
HOWDOI_DISABLE_SSL=1
HOWDOI_SEARCH_ENGINE=google
HOWDOI_URL=serverfault.com
```

Setting `HOWDOI_COLORIZE=1` enables color permanently. Setting `HOWDOI_URL=serverfault.com` redirects every query to Server Fault rather than Stack Overflow, which is more relevant for system administration questions.

## Stashing Answers and Searching Other StackExchange Properties

The stash feature allows saving an answer for later reference. To save a result:

```bash
howdoi --save create tar archive
```

Stashed entries are reviewed with `--view`, removed individually with `--remove` (which prompts for the specific entry to delete), and cleared entirely with `--empty`. The stash is backed by the keep library (github.com/OrkoHunter/keep), and the README links to the keep documentation for advanced stash operations.

To search a different StackExchange property, set `HOWDOI_URL` in the command:

```bash
HOWDOI_URL=cooking.stackexchange.com howdoi make pesto
```

This directs the query at Cooking Stack Exchange rather than Stack Overflow. The same result is available through a permanent alias:

```bash
alias hcook='function hcook(){ HOWDOI_URL=cooking.stackexchange.com howdoi $* ; }; hcook'
```

With this alias, `hcook make pesto` performs the lookup on the cooking community. The `HOWDOI_URL` value can be any StackExchange property, which covers communities for mathematics, security, DevOps, database administration, and many others, each with their own set of accepted answers.

## Cases Where howdoi Gives Wrong or Outdated Results

howdoi has no version awareness. It retrieves the top-voted answer on Stack Overflow, which may have been written years before the library version the developer is using. When an API changes between releases, the code snippet howdoi returns may reference a function that no longer exists, a parameter that was renamed, or an import path that has been restructured. The tool offers no indication of when the answer was written or which library version it applies to.

For niche or recently released frameworks, howdoi frequently returns poor results simply because there are not enough high-quality answers on Stack Overflow to work from. Queries about unusual compiler errors, environment-specific configuration failures, or complex debugging tasks that require reading a full stack trace are unlikely to produce a useful one-line answer.

There is a privacy concern that affects some environments. Every query passes through a third-party search engine. Developers in environments with strict information security requirements should consider whether passing internal tool names, internal domain vocabulary, specific error messages, or product codenames through Google or Bing is acceptable. The tool does not offer an option to use a self-hosted search backend.

## License, Integrations, and Maintenance

The last push to the repository was on September 12, 2026. The project requires Python 3.7 or newer, and the README states that Python 2.7 support has been discontinued.

The repository lists six independent integrations: Slack, Telegram, Discord, Emacs, VSCode (available on the VS Code marketplace), and Alfred. Each is maintained as a separate project by different contributors and has its own repository and update cadence.

howdoi is released under the MIT license. MIT permits use, modification, and redistribution in any context, including commercial use, as long as the license notice is retained. The project's dependencies, listed in requirements/prod.txt, determine whether any additional license terms apply when distributing a bundled application.

The practical alternative to howdoi for in-terminal lookups is a browser search with a site filter: running `site:stackoverflow.com format date bash` in a browser tab gives the same source material with full thread context, vote counts, and dated comments. The difference is that howdoi eliminates the browser window entirely and returns the extracted answer in the current shell, trading full context for speed. For developers who only need the code snippet, that trade is straightforward. For those who need to evaluate the answer's age or the quality of its surrounding discussion, the browser view is necessary.

## Conclusion

howdoi suits developers who need quick syntax answers for well-documented programming tasks and want those answers without switching to a browser. It does not suit workflows where the safety of pasted code must be verified, where questions involve proprietary terminology that should not pass through a third-party search engine, or where the target technology lacks a strong Stack Overflow presence. Before adopting it as a default lookup tool, verify that the primary language and framework have sufficient Stack Overflow coverage and that running queries through Google, Bing, or DuckDuckGo is acceptable under your organization's policies.

## FAQ

### How does howdoi retrieve answers from Stack Overflow?

howdoi passes the query to a search engine (Google by default), takes the top Stack Overflow result, and extracts the accepted or top-voted answer text from that page. A local cache stores previous answers so the same query does not require a repeated network call.

### Can howdoi search sites other than Stack Overflow?

Yes. Setting the HOWDOI_URL environment variable to any StackExchange property redirects queries there instead. The README demonstrates this with HOWDOI_URL=cooking.stackexchange.com to search Cooking Stack Exchange.

### What Python version does howdoi require?

The README states that howdoi works with Python 3.7 and newer. Python 2.7 support has been discontinued.

## Sources

- [gleitz/howdoi on GitHub](https://github.com/gleitz/howdoi)
- [Issues](https://github.com/gleitz/howdoi/issues)
- [License: MIT](https://github.com/gleitz/howdoi/blob/master/LICENSE)
- [Project website](http://blog.gleitzman.com/post/43330157197/howdoi-instant-coding-answers-via-the-command-line)
- [README](https://github.com/gleitz/howdoi/blob/master/README.md)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/gleitz-howdoi
