The Deska blog
CLI Error Messages That Say What to Do
Learn how to design CLI error messages that say what to do. Improve developer experience with actionable feedback and clear recovery paths in terminal tools.
10 min read
The quality of a developer tool is often measured not by its success state, but by its failure state. When a command fails, the user is interrupted and frustrated. The best tools bridge this gap by providing CLI error messages that say what to do rather than just reporting what went wrong. An actionable error message transforms a technical roadblock into a simple instruction, reducing the cognitive load required to get back to work.
The Anatomy of a Great Error Message
A standard error message usually contains a code or a brief description of the failure. However, a high quality CLI tool provides much more context. To move from a basic log to an actionable message, consider these four components.
- The Context: What exactly was the tool trying to do when it failed?
- The Problem: What went wrong in plain language?
- The Solution: What specific command or configuration change will fix this?
- The Documentation: Where can the user find more details if the solution fails?
For example, instead of saying Error: Authentication failed, a better message would be Error: Could not connect to the registry because your token is expired. Run 'auth login' to refresh your credentials. This gives the user an immediate path forward.
Designing for Clarity and Action
Visual hierarchy matters in a terminal. When a developer sees a wall of white text, the important details get lost. Using color and spacing can help highlight the actionable part of the message.
Using ANSI Colors Effectively
Use red for the error prefix to draw attention, but use yellow or cyan for the suggested command. This makes the solution stand out from the problem description. Ensure that your tool respects the NO_COLOR environment variable to remain accessible for users who prefer plain text outputs.
Providing Direct Commands
If your tool detects a missing configuration file, do not just say the file is missing. Provide the exact command to generate it. If a flag is misspelled, use a Levenshtein distance algorithm to suggest the closest valid flag. For instance, if a user types --confg, the error should say Unknown flag --confg. Did you mean --config?
Contextual Debugging in Modern Workspaces
The environment where a developer runs a command significantly impacts how they handle errors. In a traditional terminal, the user must scroll back through history to find the start of an error trace. In more expansive environments, such as a large canvas, the error can stay visible alongside the code that caused it.
When you use terminals within a spatial workspace like Deska, you can keep multiple sessions open. This allows you to compare the error output in one panel while viewing your code and files in another. Because the workspace is local-first, these logs and sessions remain on your machine, ensuring that sensitive error traces containing path names or environment variables are never uploaded to a third party server.
Integrating AI Assistance for Error Resolution
Sometimes an error is too complex for a hardcoded suggestion. This is where AI coding agents become useful. Instead of manually searching for a stack overflow solution, a developer can use agents to analyze the logs.
In Deska, you can run tools like Claude Code or Codex CLI in panels next to your terminal. If a command fails with a cryptic C++ compiler error, you can use Ask Deska to read the terminal session and suggest a fix. The assistant can even drive the workspace to open the relevant file and highlight the line causing the issue. This creates a loop where the CLI tool provides the error, and the workspace provides the intelligence to resolve it.
Common CLI Error Patterns
Different types of failures require different communication strategies. Here is a guide on how to handle common scenarios.
| Error Type | Traditional Message | Actionable Message |
|---|---|---|
| Missing Dependency | Command 'gcc' not found | gcc is required. Install it via 'brew install gcc' or 'sudo apt install gcc'. |
| Permission Denied | EACCES: permission denied | Cannot write to /usr/local/bin. Run this command with sudo or check folder permissions. |
| Invalid Argument | Invalid value for --port | --port must be a number between 1024 and 65535. You provided 'abc'. |
| Network Timeout | Timeout reached | Connection to api.example.com failed. Check your internet or status.example.com for outages. |
Monitoring Errors Remotely
Development does not always happen at the desk. Sometimes a long running build or a deployment script fails while you are away. In these cases, getting the error message to the right place is vital. Using the Deska mobile app, you can monitor your active terminal sessions through a secure relay. If a command fails, you see the exact error message on your phone. Because the devices pair directly, you do not have to expose any ports on your local machine to keep an eye on your work.
Frequently Asked Questions
How to make CLI errors more readable for beginners?
Focus on removing technical jargon and providing a clear "How to fix" section. Use bold text for commands and ensure there is enough padding between the error message and the previous terminal output.
Should CLI tools always return a non-zero exit code?
Yes. Every failure must return a non-zero exit code so that scripts and CI pipelines can detect the failure. However, the human readable output should remain the priority for interactive terminal use.
What is the best way to handle long stack traces?
By default, show only the most relevant error and the immediate solution. Provide a --verbose or --debug flag for users who need to see the full stack trace for deep debugging.
Get Started with a Better Workspace
Improving your CLI craft is about more than just writing code. It is about building a workflow that supports your productivity. Deska provides a free desktop app for Mac, Windows and Linux that helps you organize your tools, terminals, and AI agents in a single infinite canvas. You can download the app today to start building your ideal development environment. If you want to customize your experience further, check out the settings to configure your panels and voice commands.