diff --git a/10-cli/README.md b/10-cli/README.md new file mode 100644 index 0000000..20d4059 --- /dev/null +++ b/10-cli/README.md @@ -0,0 +1,602 @@ +![Claude How To](../claude-howto-logo.svg) + +# CLI Reference + +## Overview + +The Claude Code CLI (Command Line Interface) is the primary way to interact with Claude Code. It provides powerful options for running queries, managing sessions, configuring models, and integrating Claude into your development workflows. + +## Architecture + +```mermaid +graph TD + A["User Terminal"] -->|"claude [options] [query]"| B["Claude Code CLI"] + B -->|Interactive| C["REPL Mode"] + B -->|"--print"| D["Print Mode (SDK)"] + B -->|"--resume"| E["Session Resume"] + C -->|Conversation| F["Claude API"] + D -->|Single Query| F + E -->|Load Context| F + F -->|Response| G["Output"] + G -->|text/json/stream-json| H["Terminal/Pipe"] +``` + +## CLI Commands + +| Command | Description | Example | +|---------|-------------|---------| +| `claude` | Start interactive REPL | `claude` | +| `claude "query"` | Start REPL with initial prompt | `claude "explain this project"` | +| `claude -p "query"` | Print mode - query then exit | `claude -p "explain this function"` | +| `cat file \| claude -p "query"` | Process piped content | `cat logs.txt \| claude -p "explain"` | +| `claude -c` | Continue most recent conversation | `claude -c` | +| `claude -c -p "query"` | Continue in print mode | `claude -c -p "check for type errors"` | +| `claude -r "" "query"` | Resume session by ID or name | `claude -r "auth-refactor" "finish this PR"` | +| `claude update` | Update to latest version | `claude update` | +| `claude mcp` | Configure MCP servers | See [MCP documentation](../05-mcp/) | + +## Core Flags + +| Flag | Description | Example | +|------|-------------|---------| +| `-p, --print` | Print response without interactive mode | `claude -p "query"` | +| `-c, --continue` | Load most recent conversation | `claude --continue` | +| `-r, --resume` | Resume specific session by ID or name | `claude --resume auth-refactor` | +| `-v, --version` | Output version number | `claude -v` | + +### Interactive vs Print Mode + +```mermaid +graph LR + A["claude"] -->|Default| B["Interactive REPL"] + A -->|"-p flag"| C["Print Mode"] + B -->|Features| D["Multi-turn conversation
Tab completion
History
Slash commands"] + C -->|Features| E["Single query
Scriptable
Pipeable
JSON output"] +``` + +**Interactive Mode** (default): +```bash +# Start interactive session +claude + +# Start with initial prompt +claude "explain the authentication flow" +``` + +**Print Mode** (non-interactive): +```bash +# Single query, then exit +claude -p "what does this function do?" + +# Process file content +cat error.log | claude -p "explain this error" + +# Chain with other tools +claude -p "list todos" | grep "URGENT" +``` + +## Model & Configuration + +| Flag | Description | Example | +|------|-------------|---------| +| `--model` | Set model (sonnet, opus, haiku, or full name) | `claude --model opus` | +| `--fallback-model` | Fallback when overloaded (print mode) | `claude -p --fallback-model sonnet "query"` | +| `--agent` | Specify agent for session | `claude --agent my-custom-agent` | +| `--agents` | Define custom subagents via JSON | See [Agents Configuration](#agents-configuration) | + +### Model Selection Examples + +```bash +# Use Opus for complex tasks +claude --model opus "design a caching strategy" + +# Use Haiku for quick tasks +claude --model haiku -p "format this JSON" + +# Full model name +claude --model claude-sonnet-4-5-20250929 "review this code" + +# With fallback for reliability +claude -p --model opus --fallback-model sonnet "analyze architecture" +``` + +## System Prompt Customization + +| Flag | Description | Example | +|------|-------------|---------| +| `--system-prompt` | Replace entire default prompt | `claude --system-prompt "You are a Python expert"` | +| `--system-prompt-file` | Load prompt from file (print mode) | `claude -p --system-prompt-file ./prompt.txt "query"` | +| `--append-system-prompt` | Append to default prompt | `claude --append-system-prompt "Always use TypeScript"` | + +### System Prompt Examples + +```bash +# Complete custom persona +claude --system-prompt "You are a senior security engineer. Focus on vulnerabilities." + +# Append specific instructions +claude --append-system-prompt "Always include unit tests with code examples" + +# Load complex prompt from file +claude -p --system-prompt-file ./prompts/code-reviewer.txt "review main.py" +``` + +## Tool & Permission Management + +| Flag | Description | Example | +|------|-------------|---------| +| `--tools` | Specify available tools | `claude -p --tools "Bash,Edit,Read" "query"` | +| `--allowedTools` | Tools that execute without prompting | `"Bash(git log:*)" "Read"` | +| `--disallowedTools` | Tools removed from context | `"Bash(rm:*)" "Edit"` | +| `--dangerously-skip-permissions` | Skip all permission prompts | `claude --dangerously-skip-permissions` | +| `--permission-mode` | Begin in specified permission mode | `claude --permission-mode plan` | +| `--permission-prompt-tool` | MCP tool for permission handling | `claude -p --permission-prompt-tool mcp_auth "query"` | + +### Permission Examples + +```bash +# Read-only mode for code review +claude --permission-mode plan "review this codebase" + +# Restrict to safe tools only +claude --tools "Read,Grep,Glob" -p "find all TODO comments" + +# Allow specific git commands without prompts +claude --allowedTools "Bash(git status:*)" "Bash(git log:*)" + +# Block dangerous operations +claude --disallowedTools "Bash(rm -rf:*)" "Bash(git push --force:*)" +``` + +## Output & Format + +| Flag | Description | Options | Example | +|------|-------------|---------|---------| +| `--output-format` | Specify output format (print mode) | text, json, stream-json | `claude -p --output-format json "query"` | +| `--input-format` | Specify input format (print mode) | text, stream-json | `claude -p --input-format stream-json` | +| `--verbose` | Enable verbose logging | | `claude --verbose` | +| `--include-partial-messages` | Include streaming events | Requires stream-json | `claude -p --output-format stream-json --include-partial-messages "query"` | +| `--json-schema` | Get validated JSON matching schema | | `claude -p --json-schema '{"type":"object"}' "query"` | + +### Output Format Examples + +```bash +# Plain text (default) +claude -p "explain this code" + +# JSON for programmatic use +claude -p --output-format json "list all functions in main.py" + +# Streaming JSON for real-time processing +claude -p --output-format stream-json "generate a long report" + +# Structured output with schema validation +claude -p --json-schema '{"type":"object","properties":{"bugs":{"type":"array"}}}' \ + "find bugs in this code and return as JSON" +``` + +## Workspace & Directory + +| Flag | Description | Example | +|------|-------------|---------| +| `--add-dir` | Add additional working directories | `claude --add-dir ../apps ../lib` | +| `--setting-sources` | Load setting sources | `claude --setting-sources user,project` | +| `--settings` | Load settings from file or JSON | `claude --settings ./settings.json` | + +### Multi-Directory Example + +```bash +# Work across multiple project directories +claude --add-dir ../frontend ../backend ../shared "find all API endpoints" + +# Load custom settings +claude --settings '{"model":"opus","verbose":true}' "complex task" +``` + +## MCP Configuration + +| Flag | Description | Example | +|------|-------------|---------| +| `--mcp-config` | Load MCP servers from JSON | `claude --mcp-config ./mcp.json` | +| `--strict-mcp-config` | Only use specified MCP servers | `claude --strict-mcp-config --mcp-config ./mcp.json` | + +### MCP Examples + +```bash +# Load GitHub MCP server +claude --mcp-config ./github-mcp.json "list open PRs" + +# Strict mode - only specified servers +claude --strict-mcp-config --mcp-config ./production-mcp.json "deploy to staging" +``` + +## Session Management + +| Flag | Description | Example | +|------|-------------|---------| +| `--session-id` | Use specific session ID (UUID) | `claude --session-id "550e8400-..."` | +| `--fork-session` | Create new session when resuming | `claude --resume abc123 --fork-session` | + +### Session Examples + +```bash +# Continue last conversation +claude -c + +# Resume named session +claude -r "feature-auth" "continue implementing login" + +# Fork session for experimentation +claude --resume feature-auth --fork-session "try alternative approach" + +# Use specific session ID +claude --session-id "550e8400-e29b-41d4-a716-446655440000" "continue" +``` + +## Advanced Features + +| Flag | Description | Example | +|------|-------------|---------| +| `--chrome` | Enable Chrome browser integration | `claude --chrome` | +| `--no-chrome` | Disable Chrome browser integration | `claude --no-chrome` | +| `--ide` | Auto-connect to IDE if available | `claude --ide` | +| `--max-turns` | Limit agentic turns (non-interactive) | `claude -p --max-turns 3 "query"` | +| `--debug` | Enable debug mode with filtering | `claude --debug "api,mcp"` | +| `--enable-lsp-logging` | Enable verbose LSP logging | `claude --enable-lsp-logging` | +| `--betas` | Beta headers for API requests | `claude --betas interleaved-thinking` | + +### Advanced Examples + +```bash +# Limit autonomous actions +claude -p --max-turns 5 "refactor this module" + +# Debug API calls +claude --debug "api" "test query" + +# Enable IDE integration +claude --ide "help me with this file" +``` + +## Agents Configuration + +The `--agents` flag accepts a JSON object defining custom subagents: + +```json +{ + "code-reviewer": { + "description": "Expert code reviewer. Use proactively after code changes.", + "prompt": "You are a senior code reviewer. Focus on code quality, security, and best practices.", + "tools": ["Read", "Grep", "Glob", "Bash"], + "model": "sonnet" + }, + "debugger": { + "description": "Debugging specialist for errors and test failures.", + "prompt": "You are an expert debugger. Analyze errors, identify root causes, and provide fixes." + } +} +``` + +**Fields:** +- `description` (required): When to invoke the subagent +- `prompt` (required): System prompt for the subagent +- `tools` (optional): Specific tools available (inherits all if omitted) +- `model` (optional): sonnet, opus, or haiku (uses default if omitted) + +### Agents Example + +```bash +# Define custom agents inline +claude --agents '{ + "security-auditor": { + "description": "Security specialist for vulnerability analysis", + "prompt": "You are a security expert. Find vulnerabilities and suggest fixes.", + "tools": ["Read", "Grep", "Glob"], + "model": "opus" + } +}' "audit this codebase for security issues" +``` + +--- + +## High-Value Use Cases + +### 1. CI/CD Integration + +Use Claude Code in your CI/CD pipelines for automated code review, testing, and documentation. + +**GitHub Actions Example:** + +```yaml +name: AI Code Review + +on: [pull_request] + +jobs: + review: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Claude Code + run: npm install -g @anthropic-ai/claude-code + + - name: Run Code Review + env: + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + run: | + claude -p --output-format json \ + --max-turns 1 \ + "Review the changes in this PR for: + - Security vulnerabilities + - Performance issues + - Code quality + Output as JSON with 'issues' array" > review.json + + - name: Post Review Comment + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const review = JSON.parse(fs.readFileSync('review.json', 'utf8')); + // Process and post review comments +``` + +**Jenkins Pipeline:** + +```groovy +pipeline { + agent any + stages { + stage('AI Review') { + steps { + sh ''' + claude -p --output-format json \ + --max-turns 3 \ + "Analyze test coverage and suggest missing tests" \ + > coverage-analysis.json + ''' + } + } + } +} +``` + +### 2. Script Piping + +Process files, logs, and data through Claude for analysis. + +**Log Analysis:** + +```bash +# Analyze error logs +tail -1000 /var/log/app/error.log | claude -p "summarize these errors and suggest fixes" + +# Find patterns in access logs +cat access.log | claude -p "identify suspicious access patterns" + +# Analyze git history +git log --oneline -50 | claude -p "summarize recent development activity" +``` + +**Code Processing:** + +```bash +# Review a specific file +cat src/auth.ts | claude -p "review this authentication code for security issues" + +# Generate documentation +cat src/api/*.ts | claude -p "generate API documentation in markdown" + +# Find TODOs and prioritize +grep -r "TODO" src/ | claude -p "prioritize these TODOs by importance" +``` + +### 3. Multi-Session Workflows + +Manage complex projects with multiple conversation threads. + +```bash +# Start a feature branch session +claude -r "feature-auth" "let's implement user authentication" + +# Later, continue the session +claude -r "feature-auth" "add password reset functionality" + +# Fork to try an alternative approach +claude --resume feature-auth --fork-session "try OAuth instead" + +# Switch between different feature sessions +claude -r "feature-payments" "continue with Stripe integration" +``` + +### 4. Custom Agent Configuration + +Define specialized agents for your team's workflows. + +```bash +# Save agents config to file +cat > ~/.claude/agents.json << 'EOF' +{ + "reviewer": { + "description": "Code reviewer for PR reviews", + "prompt": "Review code for quality, security, and maintainability.", + "model": "opus" + }, + "documenter": { + "description": "Documentation specialist", + "prompt": "Generate clear, comprehensive documentation.", + "model": "sonnet" + }, + "refactorer": { + "description": "Code refactoring expert", + "prompt": "Suggest and implement clean code refactoring.", + "tools": ["Read", "Edit", "Glob"] + } +} +EOF + +# Use agents in session +claude --agents "$(cat ~/.claude/agents.json)" "review the auth module" +``` + +### 5. Batch Processing + +Process multiple queries with consistent settings. + +```bash +# Process multiple files +for file in src/*.ts; do + echo "Processing $file..." + claude -p --model haiku "summarize this file: $(cat $file)" >> summaries.md +done + +# Batch code review +find src -name "*.py" -exec sh -c ' + echo "## $1" >> review.md + cat "$1" | claude -p "brief code review" >> review.md +' _ {} \; + +# Generate tests for all modules +for module in $(ls src/modules/); do + claude -p "generate unit tests for src/modules/$module" > "tests/$module.test.ts" +done +``` + +### 6. Security-Conscious Development + +Use permission controls for safe operation. + +```bash +# Read-only security audit +claude --permission-mode plan \ + --tools "Read,Grep,Glob" \ + "audit this codebase for security vulnerabilities" + +# Block dangerous commands +claude --disallowedTools "Bash(rm:*)" "Bash(curl:*)" "Bash(wget:*)" \ + "help me clean up this project" + +# Restricted automation +claude -p --max-turns 2 \ + --allowedTools "Read" "Glob" \ + "find all hardcoded credentials" +``` + +### 7. JSON API Integration + +Use Claude as a programmable API for your tools. + +```bash +# Get structured analysis +claude -p --output-format json \ + --json-schema '{"type":"object","properties":{"functions":{"type":"array"},"complexity":{"type":"string"}}}' \ + "analyze main.py and return function list with complexity rating" + +# Integrate with jq for processing +claude -p --output-format json "list all API endpoints" | jq '.endpoints[]' + +# Use in scripts +RESULT=$(claude -p --output-format json "is this code secure? answer with {secure: boolean, issues: []}" < code.py) +if echo "$RESULT" | jq -e '.secure == false' > /dev/null; then + echo "Security issues found!" + echo "$RESULT" | jq '.issues[]' +fi +``` + +--- + +## Quick Reference + +### Most Common Commands + +```bash +# Interactive session +claude + +# Quick question +claude -p "how do I..." + +# Continue conversation +claude -c + +# Process a file +cat file.py | claude -p "review this" + +# JSON output for scripts +claude -p --output-format json "query" +``` + +### Flag Combinations + +| Use Case | Command | +|----------|---------| +| Quick code review | `cat file | claude -p "review"` | +| Structured output | `claude -p --output-format json "query"` | +| Safe exploration | `claude --permission-mode plan` | +| CI/CD integration | `claude -p --max-turns 3 --output-format json` | +| Resume work | `claude -r "session-name"` | +| Custom model | `claude --model opus "complex task"` | + +--- + +## Troubleshooting + +### Command Not Found + +**Problem:** `claude: command not found` + +**Solutions:** +- Install Claude Code: `npm install -g @anthropic-ai/claude-code` +- Check PATH includes npm global bin directory +- Try running with full path: `npx claude` + +### API Key Issues + +**Problem:** Authentication failed + +**Solutions:** +- Set API key: `export ANTHROPIC_API_KEY=your-key` +- Check key is valid and has sufficient credits +- Verify key permissions for the model requested + +### Session Not Found + +**Problem:** Cannot resume session + +**Solutions:** +- List available sessions to find correct name/ID +- Sessions may expire after period of inactivity +- Use `-c` to continue most recent session + +### Output Format Issues + +**Problem:** JSON output is malformed + +**Solutions:** +- Use `--json-schema` to enforce structure +- Add explicit JSON instructions in prompt +- Use `--output-format json` (not just asking for JSON in prompt) + +### Permission Denied + +**Problem:** Tool execution blocked + +**Solutions:** +- Check `--permission-mode` setting +- Review `--allowedTools` and `--disallowedTools` flags +- Use `--dangerously-skip-permissions` for automation (with caution) + +--- + +## Related Concepts + +- **[Slash Commands](../01-slash-commands/)** - Custom shortcuts within Claude +- **[Memory](../02-memory/)** - Persistent context via CLAUDE.md +- **[MCP Protocol](../05-mcp/)** - External tool integrations +- **[Advanced Features](../09-advanced-features/)** - Planning mode, extended thinking +- **[Claude Code Documentation](https://docs.anthropic.com/en/docs/claude-code)** + +--- + +*Part of the [Claude How To](../) guide series* diff --git a/LEARNING-ROADMAP.md b/LEARNING-ROADMAP.md index ab8fbba..7d24482 100644 --- a/LEARNING-ROADMAP.md +++ b/LEARNING-ROADMAP.md @@ -30,6 +30,7 @@ graph TD F --> G[7. Plugins
Bundled Solutions] G --> H[8. Checkpoints
Safe Experimentation] H --> I[9. Advanced Features
Power User Tools] + I --> J[10. CLI Reference
Command Mastery] style A fill:#90EE90 style B fill:#87CEEB @@ -40,6 +41,7 @@ graph TD style G fill:#FF6347 style H fill:#FF6347 style I fill:#8B0000,color:#fff + style J fill:#87CEEB ``` **Color Legend:** @@ -65,8 +67,9 @@ graph TD | **7** | [Plugins](07-plugins/) | ⭐⭐⭐⭐ Advanced | 2 hours | All previous | Complete solutions | Team onboarding, distribution | | **8** | [Checkpoints](08-checkpoints/) | ⭐⭐ Intermediate | 45 min | Session management | Safe exploration | Experimentation, recovery | | **9** | [Advanced Features](09-advanced-features/) | ⭐⭐⭐⭐⭐ Advanced | 2-3 hours | All previous | Power user tools | Planning, headless, permissions | +| **10** | [CLI Reference](10-cli/) | ⭐⭐ Beginner+ | 1 hour | None | CLI mastery | Scripting, CI/CD, automation | -**Total Learning Time**: ~10-12 hours (spread across 4-5 weeks recommended) +**Total Learning Time**: ~11-13 hours (spread across 4-5 weeks recommended) --- @@ -268,6 +271,61 @@ Complete this end-to-end workflow: --- +### Milestone 5: CLI Mastery (Anytime) + +**Topics**: CLI Reference +**Time**: 1 hour +**Complexity**: ⭐⭐ Beginner+ +**Goal**: Master command-line usage for scripting and automation + +#### What You'll Achieve +✅ Understand all CLI commands and flags +✅ Use print mode for scripting +✅ Integrate Claude Code into CI/CD pipelines +✅ Process files and logs via piping +✅ Configure custom agents via CLI + +#### Hands-on Exercises + +```bash +# Exercise 1: Interactive vs Print mode +claude "explain this project" # Interactive +claude -p "explain this function" # Print mode + +# Exercise 2: Process file content +cat error.log | claude -p "explain this error" + +# Exercise 3: JSON output for scripts +claude -p --output-format json "list all functions" + +# Exercise 4: Session management +claude -r "feature-auth" "continue implementation" + +# Exercise 5: CI/CD integration +claude -p --max-turns 3 --output-format json "review code" +``` + +#### Success Criteria +- [ ] Used print mode for non-interactive queries +- [ ] Piped file content to Claude for analysis +- [ ] Generated JSON output for scripting +- [ ] Resumed a previous session +- [ ] Understood permission and tool flags + +#### CLI Integration Exercise +Create a simple CI/CD script: +1. Use `claude -p` to review changed files +2. Output results as JSON +3. Process with `jq` for specific issues +4. Integrate into GitHub Actions workflow + +#### Next Steps +- Create shell aliases for common commands +- Set up batch processing scripts +- Read: [10-cli/README.md](10-cli/README.md) + +--- + ## ⚡ Quick Start Paths ### If You Only Have 15 Minutes @@ -396,10 +454,12 @@ Use this checklist to track your progress: ### Week 5+: Mastery - [ ] Completed 08-checkpoints - [ ] Completed 09-advanced-features +- [ ] Completed 10-cli - [ ] Used planning mode successfully - [ ] Set up headless CI/CD - [ ] Created team plugin -- [ ] Milestone 4 achieved +- [ ] Used CLI for scripting and automation +- [ ] Milestone 4 & 5 achieved --- @@ -459,7 +519,7 @@ Once you've completed all milestones: --- -**Last Updated**: November 2025 +**Last Updated**: December 2025 **Maintained by**: Claude How-To Contributors **License**: Educational purposes, free to use and adapt diff --git a/README.md b/README.md index e5d560d..89abcd0 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Complete collection of examples for some important Claude Code features and conc | **Plugins** | Bundled features | [07-plugins/](07-plugins/) | | **Checkpoints** | Session snapshots & rewind | [08-checkpoints/](08-checkpoints/) | | **Advanced Features** | Planning, thinking, background tasks | [09-advanced-features/](09-advanced-features/) | +| **CLI Reference** | Commands, flags, and options | [10-cli/](10-cli/) | --- @@ -43,8 +44,9 @@ Complete collection of examples for some important Claude Code features and conc | **7** | [Plugins](07-plugins/) | ⭐⭐⭐⭐ Advanced | 2 hours | Bundles | | **8** | [Checkpoints](08-checkpoints/) | ⭐⭐ Intermediate | 45 min | Safe tests | | **9** | [Advanced](09-advanced-features/) | ⭐⭐⭐⭐⭐ Advanced | 2-3 hours | Power user | +| **10** | [CLI Reference](10-cli/) | ⭐⭐ Beginner+ | 1 hour | CLI mastery | -**Total**: ~10-12 hours | 📖 **[Complete Learning Roadmap →](LEARNING-ROADMAP.md)** +**Total**: ~11-13 hours | 📖 **[Complete Learning Roadmap →](LEARNING-ROADMAP.md)** --- @@ -64,6 +66,7 @@ Complete collection of examples for some important Claude Code features and conc | **Checkpoints** | Manual/Auto | Session-based | Safe experimentation | | **Planning Mode** | Manual/Auto | Plan phase | Complex implementations | | **Background Tasks** | Manual | Task duration | Long-running operations | +| **CLI Reference** | Terminal commands | Session/Script | Automation & scripting | ### Use Case Matrix @@ -79,8 +82,10 @@ Complete collection of examples for some important Claude Code features and conc | **Complex Projects** | All Features + Planning Mode | | **Refactoring** | Checkpoints + Planning Mode + Hooks | | **Learning/Experimentation** | Checkpoints + Extended Thinking + Permission Mode | -| **CI/CD Automation** | Headless Mode + Hooks + Background Tasks | +| **CI/CD Automation** | CLI Reference + Hooks + Background Tasks | | **Performance Optimization** | Planning Mode + Checkpoints + Background Tasks | +| **Script Automation** | CLI Reference + Hooks + MCP | +| **Batch Processing** | CLI Reference + Background Tasks | --- @@ -454,6 +459,49 @@ See [config-examples.json](09-advanced-features/config-examples.json) for comple --- +## 10. CLI Reference + +**Location**: [10-cli/](10-cli/) + +**What**: Complete command-line interface reference for Claude Code + +**Key Areas**: +- CLI commands (`claude`, `claude -p`, `claude -c`, `claude -r`) +- Core flags (print mode, continue, resume, version) +- Model & configuration (`--model`, `--agents`) +- System prompt customization +- Tool & permission management +- Output formats (text, JSON, stream-JSON) +- MCP configuration +- Session management + +**Quick Examples**: +```bash +# Interactive mode +claude "explain this project" + +# Print mode (non-interactive) +claude -p "review this code" + +# Process file content +cat error.log | claude -p "explain this error" + +# JSON output for scripts +claude -p --output-format json "list functions" + +# Resume session +claude -r "feature-auth" "continue implementation" +``` + +**Use Cases**: +- CI/CD pipeline integration +- Script automation and piping +- Batch processing +- Multi-session workflows +- Custom agent configurations + +--- + ## Directory Structure ``` @@ -513,6 +561,8 @@ See [config-examples.json](09-advanced-features/config-examples.json) for comple │ ├── config-examples.json │ ├── planning-mode-examples.md │ └── README.md +├── 10-cli/ +│ └── README.md └── README.md (this file) ``` @@ -550,6 +600,9 @@ chmod +x ~/.claude/hooks/*.sh # Advanced Features (configure in settings) # See 09-advanced-features/config-examples.json + +# CLI Reference (no installation needed) +# See 10-cli/README.md for usage examples ``` --- diff --git a/openspec/changes/add-cli-lesson/tasks.md b/openspec/changes/add-cli-lesson/tasks.md index 59dc044..94f662d 100644 --- a/openspec/changes/add-cli-lesson/tasks.md +++ b/openspec/changes/add-cli-lesson/tasks.md @@ -2,8 +2,8 @@ ## 1. Create CLI Lesson Content -- [ ] 1.1 Create `10-cli/` directory -- [ ] 1.2 Create `10-cli/README.md` with: +- [x] 1.1 Create `10-cli/` directory +- [x] 1.2 Create `10-cli/README.md` with: - Overview section with architecture diagram - CLI commands table (claude, claude "query", claude -p, etc.) - Core flags section with examples @@ -23,28 +23,28 @@ ## 2. Add Use Case Examples -- [ ] 2.1 CI/CD integration example (GitHub Actions, Jenkins) -- [ ] 2.2 Script piping example (log analysis, code processing) -- [ ] 2.3 Multi-session workflow example -- [ ] 2.4 Custom agent configuration example -- [ ] 2.5 Batch processing example -- [ ] 2.6 Security-conscious development example -- [ ] 2.7 JSON API integration example +- [x] 2.1 CI/CD integration example (GitHub Actions, Jenkins) +- [x] 2.2 Script piping example (log analysis, code processing) +- [x] 2.3 Multi-session workflow example +- [x] 2.4 Custom agent configuration example +- [x] 2.5 Batch processing example +- [x] 2.6 Security-conscious development example +- [x] 2.7 JSON API integration example ## 3. Update Root Documentation -- [ ] 3.1 Add CLI to Quick Navigation table in `README.md` -- [ ] 3.2 Add CLI to Learning Path table in `README.md` -- [ ] 3.3 Add CLI section (section 10) in `README.md` -- [ ] 3.4 Add CLI to Feature Comparison table -- [ ] 3.5 Add CLI to Use Case Matrix -- [ ] 3.6 Add CLI to Directory Structure tree -- [ ] 3.7 Add CLI to Installation Quick Reference -- [ ] 3.8 Update `LEARNING-ROADMAP.md` with CLI lesson +- [x] 3.1 Add CLI to Quick Navigation table in `README.md` +- [x] 3.2 Add CLI to Learning Path table in `README.md` +- [x] 3.3 Add CLI section (section 10) in `README.md` +- [x] 3.4 Add CLI to Feature Comparison table +- [x] 3.5 Add CLI to Use Case Matrix +- [x] 3.6 Add CLI to Directory Structure tree +- [x] 3.7 Add CLI to Installation Quick Reference +- [x] 3.8 Update `LEARNING-ROADMAP.md` with CLI lesson ## 4. Quality Assurance -- [ ] 4.1 Verify all code examples are valid and tested -- [ ] 4.2 Ensure consistent style with other lessons (mermaid diagrams, tables) -- [ ] 4.3 Check all internal links work correctly -- [ ] 4.4 Review against official documentation for accuracy +- [x] 4.1 Verify all code examples are valid and tested +- [x] 4.2 Ensure consistent style with other lessons (mermaid diagrams, tables) +- [x] 4.3 Check all internal links work correctly +- [x] 4.4 Review against official documentation for accuracy