Building in Public: A Python CLI Tool That Generates and Explains Linux Commands

python dev.to

devops-ai

An AI-powered command-line tool that converts plain English into Linux and DevOps shell commands Built with Python and the Google Gemini API.


What It Does

  • Converts plain English descriptions into shell commands
  • Explains what any shell command does with the --explain flag
  • Retries automatically on network failures
  • AI model is configurable via a single config file

Demo

$ python3 devops_ai.py "find all files larger than 100mb"
Command: find / -type f -size +100M

$ python3 devops_ai.py --explain "ps aux | grep python"
The ps aux command lists all currently running processes with details
like CPU and memory usage. The output is piped into grep which filters
and shows only lines containing the word python.
Enter fullscreen mode Exit fullscreen mode

Tech Stack

  • Python 3
  • Google Gemini API (gemini-2.5-flash-lite)
  • python-dotenv
  • argparse

Setup

1. Clone the repository

git clone https://github.com/Adejuwonvictor/AI-Powered-CLI-Tool
cd devops-ai
Enter fullscreen mode Exit fullscreen mode

2. Create and activate a virtual environment

python3 -m
Enter fullscreen mode Exit fullscreen mode

Source: dev.to

arrow_back Back to Tutorials