Skip to content

Instantly share code, notes, and snippets.

@marciopuga
Last active February 15, 2026 23:31
Show Gist options
  • Select an option

  • Save marciopuga/38b819095a444ce80cabb9e8c339c776 to your computer and use it in GitHub Desktop.

Select an option

Save marciopuga/38b819095a444ce80cabb9e8c339c776 to your computer and use it in GitHub Desktop.
A three-letter shell function that makes Claude Code a first-class Unix citizen. Pipe in logs, diffs, configs, kubectl output — anything. No quotes, no flags, no friction. Just ask and go.

ask — Pipe First, Ask Questions Later

Claude Code already supports piping — but the syntax is a mouthful:

ls -la | claude -p "Help me understand why these build artifacts look wrong"

That's too much typing for something you want to reach for 50 times a day. So I wrapped it in a three-letter shell function and it changed how often I use it.

The Setup

Add this to your ~/.zshrc (or ~/.bashrc):

# Quick Claude prompt shortcut
# -t 0 checks if stdin is a terminal (no pipe); if piped, stdin is read as context
ask() {
  if [ -t 0 ]; then
    claude -p "$*"
  else
    claude -p "$(cat -)" "$*"
  fi
}

Then reload your shell:

source ~/.zshrc

Usage

Ask anything directly:

ask what is the capital of France

Pipe files and ask questions about them:

cat README.md | ask what is this project about

Pipe any command output for instant analysis:

git diff | ask summarize these changes
git log --oneline -20 | ask what has the team been working on
docker ps | ask which containers are using the most ports
cat package.json | ask are any of these dependencies outdated
kubectl get pods | ask are there any pods in a bad state

Chain it into your workflows:

curl -s https://api.example.com/health | ask is everything healthy
cat error.log | tail -50 | ask what went wrong here

Why This Works

The best tools disappear into your workflow. ask turns Claude into a Unix citizen — something you pipe to, chain with, and reach for without thinking. No context switching, no separate app, no ceremony. Just a question, right where you already are.

Note: ask is intentionally simple — it's a shortcut for claude -p, not a replacement for the full CLI. If you need flags like --model, --output-format, or --max-turns, use claude directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment