Back/Engineering/Gemini/Claude Code
AdvancedEngineering

Automate Repetitive AI Commands with Custom Shell Aliases and CLIs

Turn repeated AI commands into safe shell aliases, then promote a stable multi-step prompt into a small CLI with explicit inputs, visible configuration, and reproducible output.

Automate Repetitive AI Commands with Custom Shell Aliases and CLIs

John turns frequently used Claude flags into short shell aliases, then demonstrates a custom CLI that wraps Gemini prompts in a fast terminal questionnaire for generating design concepts.

Before you start

What you need

  • A repeated terminal command or prompt sequence
  • A shell configuration file
  • An AI API or installed CLI
  • A small scriptable project directory
  • Test inputs and an output location

What you’ll make

A memorable command that runs a repeatable AI task with validated inputs, predictable output, and no hidden destructive flags or secrets.

Tools used

Step by step

The workflow

Follow the sequence once, then adapt the prompts, checks, and handoffs to your own setup.

5 steps

Step01

Create Aliases for Frequent Commands

List commands you use repeatedly and choose only stable, low-risk sequences for aliases. Put complex quoting or project logic in a script rather than a one-line alias.

Example prompt
Review these recent shell commands and identify repeatable, non-destructive candidates for aliases or functions. Exclude credentials, bypass-permission defaults, deletion, publishing, and environment-specific absolute paths. Explain the proposed expansion for each.
Step02

Identify a Repetitive, Multi-Step Task

Choose a repeated AI task with consistent inputs and output, such as producing several design concepts from a website type, page, style, theme, and reference.

Step03

Build a Custom Command-Line Tool

Build a small CLI around the installed AI tool or API. Keep model and prompt templates in versioned configuration, read credentials from the environment, and support help and dry-run output.

Step04

Structure the CLI for Key Inputs

Prompt for only the variables that change the result. Validate required values, constrain enumerated choices, show defaults, and print the output destination before the API call.

Example prompt
Collect: website type, page, visual direction, viewport, theme, optional reference, number of variations, and output directory. Before running, print the chosen model, sanitized prompt summary, variation count, and destination. Require confirmation only when files would be overwritten.
Step05

Execute the Task via API Call

Run the CLI against representative inputs, save outputs with stable filenames and metadata, and return useful errors for authentication, rate limits, invalid inputs, and partial generation.

Example prompt
Generate [count] distinct concepts for a [website type], [page], in a [visual direction] style for [viewport], using [theme] and [reference]. Save each output plus model, prompt version, and input metadata under [directory]. Do not overwrite existing files unless explicitly requested.

What good looks like

  • The alias expands to the intended command in a fresh shell.
  • The CLI asks only for inputs that materially change the task.
  • The resolved model, prompt, and output path can be inspected before execution.
  • Secrets stay in the environment and failures leave actionable error messages.

Build your next product with ChatPRD

Turn an idea into a PRD, user stories, and a plan.

Try ChatPRD free

After the steps

Runbook notes

How to recover when the loop fails and where human judgment helps.

Recover

If it goes sideways

A short alias hides bypass-permission or destructive behavior
Use a descriptive name, display the expansion, and keep dangerous flags out of defaults.
Shell quoting changes the prompt or breaks paths with spaces
Use a script or shell function for complex commands and test representative special characters.
An API key is embedded in the alias, prompt, or repository
Read secrets from the environment or credential store and redact them from logs.
The wrapper silently uses a stale model or prompt
Keep model and prompt configuration versioned, expose them with a dry-run flag, and add a small regression test.

Start shipping
better products.

Join 100,000+ product managers who use ChatPRD to write better docs, align teams faster, and build products users love.

Free to start
No credit card
SOC 2 certified
Enterprise ready