CLI Flags & Commands — Claude Cert Academy

CLI Flags & Commands

Claude Code is invoked as `claude` from the terminal. Flags control authentication, execution mode, output, and debugging. Most flags are composable — combine them as needed.

Auth & Config

# Auth & config examples
export ANTHROPIC_API_KEY=sk-ant-...
claude --model claude-sonnet-4-6 "summarize this codebase"
claude --add-dir /tmp/scratch --add-dir /data "analyze both dirs"
CLAUDE_HOME=/opt/claude-config claude "use custom home"

Execution Mode

# Mode examples
claude -p "list all TODO comments in src/" > todos.txt
echo "fix the bug in auth.ts" | claude -p
claude --plan "refactor the payments module"
# Dangerous: only in isolated CI
claude --dangerously-skip-permissions -p "run the test suite"

I/O

# I/O examples
cat error.log | claude -p "what caused this error?"
claude -p "explain this code" < src/main.py
claude -p "generate a test" > test_generated.py

# Exit code usage in scripts
if claude -p "check for security issues in auth.ts" > report.txt; then
  echo "Scan complete"
else
  echo "Claude failed with exit $?"
fi

Debug

# Debug examples
claude --debug "why is this function slow?"
claude --version
# => claude 1.2.3

Continue to Claude Cert Academy