DEVSAIO

Build your own AI assistant for the terminal

A tiny shell command that explains errors, writes commands and answers questions, using any model.

DEVSAIO team · 2 min read
Share on X

A personal ai command is one of the most useful things you can build in ten minutes.

The script

Save as ~/bin/ai and run chmod +x ~/bin/ai:

bash
#!/usr/bin/env bash
# usage: ai "how do I find large files?"   or   some_command 2>&1 | ai "explain this error"
MODEL="${AI_MODEL:-claude-haiku-5-5}"
INPUT=""
if [ ! -t 0 ]; then INPUT="$(head -c 20000)"; fi
PROMPT="$*"
[ -n "$INPUT" ] && PROMPT="$PROMPT

Input:
$INPUT"

jq -n --arg m "$MODEL" --arg p "$PROMPT" --arg os "$(uname -s)" '{model:$m,max_tokens:700,messages:[
  {role:"system",content:("You are a terminal assistant on " + $os + ". Be brief. When giving commands, put each in its own code block and explain risky flags.")},
  {role:"user",content:$p}]}' \
| curl -s https://devsaio.lol/v1/chat/completions -H "Authorization: Bearer $DEVSAIO_API_KEY" -H "Content-Type: application/json" -d @- \
| jq -r '.choices[0].message.content // .error.message'

Requires curl and jq.

Examples

bash
ai "tar command to compress a folder excluding node_modules"
npm run build 2>&1 | tail -50 | ai "why is this failing and how do I fix it?"
cat nginx.conf | ai "is anything here insecure?"
AI_MODEL=claude-sonnet-4-6 ai "write a bash script that backs up ~/projects daily"

Safety

Read commands before running them. The assistant can be wrong, and anything with rm, sudo or dd deserves a second look. Never pipe its output straight into bash.

Try it with one API key

Claude, GPT, Gemini, DeepSeek, image and video models through one OpenAI- and Anthropic-compatible endpoint. Prepaid, pay only for what you use.

Keep reading