Building a Minimal Command Reference Tool: Inside dufferzafar/cheat
Hook
Man pages average 2,000+ lines of documentation when most developers need exactly three commands. This Go tool cuts through the noise with plain text files and a 10-second lookup time.
Context
The Unix philosophy gives us comprehensive man pages for every command, but in practice, developers repeatedly Google the same tar flags or find themselves reading through screen after screen of documentation for a single use case. The original cheat project by Chris Lane addressed this with Python-based cheatsheets—concise, example-focused references that skip the theory and jump straight to practical usage. But Python dependencies, virtual environments, and distribution complexities introduced their own friction.
dufferzafar/cheat emerges from that frustration as a learning project that became useful. Written in Go, it's a reimplementation that prioritizes simplicity: a single binary, local text files you can edit directly, and a JSON config that fits in five lines. It's not trying to compete with tldr's massive community or navi's interactive features. Instead, it solves a narrow problem exceptionally well—giving you quick command references without leaving your terminal or installing a runtime.
Technical Insight
The architecture is deliberately minimal. At its core, cheat maintains a directory of plain text files (typically ~/.cheats/) where each file represents a command. When you run cheat tar, it does three things: reads ~/.cheatrc for configuration, locates ~/.cheats/tar, and prints the content with syntax highlighting. No database, no caching layer, no complex indexing—just filesystem operations.
The configuration lives in a simple JSON structure:
{
"cheatdir": "/home/user/.cheats",
"editor": "vim",
"highlight": true,
"sources": [
"https://github.com/chrisallenlane/cheat/tree/master/cheat/cheatsheets"
]
}
This simplicity extends to the codebase. The Go implementation uses the standard flag package for CLI parsing and os package for file operations. When you create a new cheatsheet with cheat -e git, it shells out to your configured editor with exec.Command(), editing the file in place. There's no fancy TUI framework—it's the Unix way of composing tools.
The interesting piece is the fetch mechanism. The cheat fetch command pulls cheatsheets from remote Git repositories, parsing GitHub's file listings and downloading individual sheets. This isn't using Git libraries or complex HTTP clients—it's straightforward net/http requests and text parsing. The code walks the configured sources, identifies new sheets, and writes them to your local directory:
func fetchSheet(url, name string) error {
resp, err := http.Get(url)
if err != nil {
return err
}
defer resp.Body.Close()
content, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
path := filepath.Join(config.CheatDir, name)
return ioutil.WriteFile(path, content, 0644)
}
This approach means you're not locked into a single cheatsheet repository. You can point sources at your company's internal Git repo, your personal collection, or mix multiple sources. The tool doesn't care about format consistency—if it's a text file, it displays it.
Syntax highlighting adds polish without complexity. The tool detects common patterns (bash commands starting with $, comments with #, flags with --) and applies ANSI color codes. It's not using a full lexer or parser—just regex patterns that catch 90% of use cases. This pragmatic approach keeps dependencies minimal and compilation fast.
The clipboard integration (cheat -c tar 3 to copy the third example) demonstrates Go's cross-platform strengths. It shells out to xclip on Linux, pbcopy on macOS, and theoretically clip.exe on Windows, wrapping platform differences behind a single interface. You're trading universal compatibility for batteries-included convenience—it assumes you have these tools installed rather than bundling complex clipboard libraries.
Editing sheets inline with cheat -e is where the workflow shines. You discover tar doesn't have a compression example, hit cheat -e tar, add your one-liner, save, and it's immediately available. No pull requests, no waiting for maintainers, no fighting with documentation generators. Your cheatsheets become a personal knowledge base that evolves with your workflow. The implementation is trivial—just exec.Command(editor, filepath), but the ergonomics are excellent.
Gotcha
The project's GitHub TODO list tells the real story: autocomplete is unfinished, multi-directory support is planned but not implemented, and grep functionality for searching across sheets doesn't exist. These aren't minor omissions—they're table stakes for daily use. Without autocomplete, you need to remember exact command names. Without grep, you can't find "that SSH tunneling example" without opening files manually. The 201 stars suggest this tool hasn't achieved critical mass, which means the cheatsheet collection is probably sparse compared to tldr's thousands of community-maintained pages.
Cross-platform support is questionable. While Go compiles everywhere, the reliance on external tools (xclip, pbcopy) and Unix assumptions (file permissions, editor environment variables) suggests this was built for Linux first and maybe macOS second. Windows users will likely hit walls. The fetch mechanism hardcodes GitHub URL patterns, so alternative Git hosts require code changes. And because it's a personal learning project, there's no guarantee of maintenance—your issues might go unanswered, your pull requests unmerged. You're adopting someone's side project, not a supported tool.
Verdict
Use if: you're a Go developer who values hackability over features, you maintain your own cheatsheet collection and want a simple viewer, you prefer editing plain text files to contributing to larger projects, or you're learning Go and want to study a practical CLI tool with clean, readable code. The single-binary deployment and zero-runtime-dependency model make it perfect for Docker containers or minimal environments. Skip if: you need comprehensive cheatsheet coverage from day one (tldr has 1000+ commands), you want active development and community support, you require Windows compatibility, or you depend on features like fuzzy search and interactive selection (navi excels here). This is a weekend project that works well for its narrow scope, not a production-grade knowledge management system.