LESSON 4 of 5//Agentic CLI & MCP
Piping stdout to LLM context windows
One of the most powerful patterns in agentic CLI usage is piping command output directly into an LLM's context. This lets AI agents analyze logs, review code, process data, and make decisions based on real system state.
Piping data to agentszsh // interactive
# Pipe git diff to an agent for code review
➜~git diff HEAD~3 | llm 'Review these changes for bugs'
# Analyze error logs
➜~cat /var/log/app.log | grep ERROR | llm 'Categorize these errors'
# Generate documentation from code
➜~cat src/api.ts | llm 'Generate API documentation in markdown'
# Complex pipeline: find, filter, analyze
➜~find . -name '*.test.ts' -exec grep -l 'skip' {} \; | llm 'Why might these tests be skipped?'
CLI LLM tools
Tools like Simon Willison's llm CLI, mods, and sgpt let you pipe data directly to AI models from the terminal. Install with brew install llm or pip install llm.
This pattern — using Unix pipes to feed real data into AI analysis — is the foundation of agentic CLI workflows. The command line becomes the bridge between your system's data and the AI's reasoning.
PRACTICE//Try the commands from this lesson
INTERACTIVE_TERMINAL//sandbox
Practice terminal — try the commands from this lesson!
Type 'help' for available commands. Tab completion not available in simulator.
Try: