# ai -- aliases and functions for sophia
# Claude Code, Anthropic API, local models, prompt engineering
# ============================================================================
# ENVIRONMENT
# ============================================================================
export PI_CODING_AGENT_DIR="$HOME/src/sophia"
# ============================================================================
# CLAUDE CODE
# ============================================================================
alias cc='claude' # interactive session
alias cch='claude -p --model haiku' # piped haiku (cheap/fast)
alias ccs='claude -p --model sonnet' # piped sonnet (balanced)
alias cco='claude -p --model opus' # piped opus (heavy)
alias ccr='claude --resume' # resume last conversation
alias ccl='claude --resume --latest' # resume latest conversation
# ============================================================================
# ANTHROPIC API (curl one-liners)
# ============================================================================
alias akey='echo $ANTHROPIC_API_KEY' # print current key
alias amod='curl -s https://api.anthropic.com/v1/models -H "x-api-key: $ANTHROPIC_API_KEY" -H "anthropic-version: 2023-06-01" | jq .data[].id'
# ============================================================================
# LOCAL MODELS (ollama)
# ============================================================================
alias ol='ollama'
alias olr='ollama run'
alias oll='ollama list'
alias olp='ollama pull'
alias ols='ollama serve'
# ============================================================================
# FUNCTIONS
# ============================================================================
# ask -- one-shot question to claude (stdin or arg)
ask() {
if [ -n "$1" ]; then
echo "$*" | claude -p --model sonnet
else
claude -p --model sonnet
fi
}
# explain -- pipe code/text and get an explanation
explain() {
claude -p --model sonnet <<EOF
Explain the following concisely. No preamble.
$(cat)
EOF
}
# review -- pipe a diff or file for code review
review() {
claude -p --model sonnet <<EOF
Review this code. Be direct, flag bugs and security issues, skip praise.
$(cat)
EOF
}
# summarize -- pipe text for a summary
summarize() {
claude -p --model haiku <<EOF
Summarize the following in 3-5 bullet points. No preamble.
$(cat)
EOF
}
# translate -- translate text to a target language
# usage: echo "hello" | translate japanese
translate() {
local lang="${1:-english}"
claude -p --model haiku <<EOF
Translate the following to $lang. Output only the translation.
$(cat)
EOF
}
# commit-msg -- generate a commit message from staged diff
commit-msg() {
git diff --cached | claude -p --model haiku <<EOF
Write a concise git commit message for this diff. One line, imperative mood, under 72 chars. Output only the message.
$(cat)
EOF
}
# refactor -- pipe code, get a refactored version
refactor() {
claude -p --model sonnet <<EOF
Refactor this code for clarity and correctness. Output only the code, no markdown fences.
$(cat)
EOF
}