# Claude Code CLI Guide Claude Code is Anthropic's agentic coding tool. It reads your codebase, edits files, runs commands, and integrates with dev tools. Available as a terminal CLI, VS Code/Cursor extension, desktop app, and in-browser. **Official docs:** https://code.claude.com/docs/en/overview **CLI reference:** https://code.claude.com/docs/en/cli-reference --- ## Installation ```bash # macOS / Linux / WSL (recommended — auto-updates) curl -fsSL https://claude.ai/install.sh | bash # Homebrew (does NOT auto-update) brew install --cask claude-code # npm (global) npm install -g @anthropic-ai/claude-code ``` **Installed on:** Tabitha, Hunter's machine, Ozymandias --- ## Authentication ```bash claude auth login # Sign in with Claude subscription (claude.ai) claude auth login --console # Sign in with Anthropic Console (API billing) claude auth status # Check current auth state (JSON) claude auth status --text # Human-readable claude auth logout ``` --- ## Core CLI Commands ```bash claude # Start interactive session claude "query" # Start session with initial prompt claude -p "query" # One-shot query, then exit (SDK mode) cat file.ts | claude -p "explain" # Pipe content in claude -c # Continue most recent conversation claude -c -p "query" # Continue + one-shot claude -r "session-name" "query" # Resume session by ID or name claude update # Update to latest version ``` --- ## Key Flags | Flag | Description | |------|-------------| | `--model ` | Specify model (e.g. `claude-opus-4-5`, `claude-sonnet-4-6`) | | `--add-dir ` | Add directory to allowed paths | | `--permission-mode` | Set permission mode (`auto`, `default`, `manual`) | | `--output-format` | `text` (default), `json`, `stream-json` | | `--max-turns ` | Limit agentic loop turns | | `--no-update-notifier` | Suppress update messages | | `--mcp-config ` | Load MCP config from file | | `--settings ` | Load settings from JSON file | --- ## In-Session Slash Commands ``` /help Show available commands /status Show auth, model, context info /model Switch model mid-session /clear Clear conversation history /compact Summarize conversation to save context /memory Show loaded memory files (CLAUDE.md etc.) /tools List available tools /reasoning Toggle extended thinking on/off /cost Show token usage for session /quit Exit ``` --- ## MCP Servers (Tabitha — User Scope) Configured in `~/.claude.json`. All available in every Claude Code session on Tabitha: ```bash claude mcp list # Show all MCPs claude mcp add --scope user -e KEY=val -- name npx -y pkg # Add one claude mcp remove --scope user name # Remove one ``` | MCP | What it gives Claude | |-----|---------------------| | `github` | GitHub API (silmaai PAT) | | `postgres` | SQL → silma DB | | `memory` | Knowledge graph (`memory/knowledge-graph.json`) | | `redis` | Redis client | | `qdrant` | Vector search on `silma` collection | | `elasticsearch` | Full-text search | | `minio` | S3-compatible object storage | | `playwright` | Headless browser automation | | `kubernetes` | `kubectl` via MCP | | `google-workspace` | Gmail, Drive, Docs, Sheets, Calendar | > ⚠️ postgres, redis, qdrant, elasticsearch, minio require k8s port-forward active. --- ## CLAUDE.md (Project Memory) Claude Code automatically loads `CLAUDE.md` from the project root and parent directories. This is how you give Claude project-specific instructions that persist across sessions. Create one at the project root: ```bash echo "# Project Instructions\nAlways use TypeScript strict mode." > CLAUDE.md ``` On Tabitha, Silma's workspace CLAUDE.md equivalent is `AGENTS.md`. --- ## Using Local LLMs with Claude Code Claude Code supports OpenAI-compatible third-party providers. Point it at the local llama.cpp server: ```bash # Set provider to local llama.cpp (Gemma models on Tabitha) export ANTHROPIC_BASE_URL=http://localhost:8080/v1 export ANTHROPIC_API_KEY=local # required but ignored by llama.cpp claude --model gemma-4-e4b ``` See `tools/local-llm.llm.md` for full local LLM details. --- ## Environment in This Workspace | Detail | Value | |--------|-------| | **Workspace** | `/Users/Tabitha/.openclaw/workspace/` | | **OCPlatform channel** | webchat (main session) | | **Model** | `anthropic/claude-sonnet-4-6` (check `/status`) | | **Agent YAML** | `AGENTS.md` at workspace root | | **Memory** | `memory/YYYY-MM-DD.md` (daily) + `MEMORY.md` (long-term) | --- ## Tips for This Environment - `Glob` and `Grep` built-in tools are **not available** in OCPlatform sessions — use `Bash` with `find`/`grep` instead - For cross-machine work, use the kittens WebSocket bridge (see `tools/tailscale.llm.md`) - Run `source credentials/secrets.env` inside Bash tool calls to load credentials - k8s MCPs require port-forward — run `bash k8s/silma-ai/scripts/port-forward.sh` first