added more concepts
This commit is contained in:
@@ -0,0 +1,229 @@
|
||||
# CLI Startup Flags Best Practice
|
||||
|
||||

|
||||
|
||||
Complete reference of all available command-line flags, subcommands, and environment variables when launching Claude Code from the terminal.
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td><a href="../">← Back to Claude Code Best Practice</a></td>
|
||||
<td align="right"><img src="../!/claude-jumping.svg" alt="Claude" width="60" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
1. [Session Management](#session-management)
|
||||
2. [Model & Configuration](#model--configuration)
|
||||
3. [Permissions & Security](#permissions--security)
|
||||
4. [Output & Format](#output--format)
|
||||
5. [System Prompt](#system-prompt)
|
||||
6. [Agent & Subagent](#agent--subagent)
|
||||
7. [MCP & Plugins](#mcp--plugins)
|
||||
8. [Directory & Workspace](#directory--workspace)
|
||||
9. [Budget & Limits](#budget--limits)
|
||||
10. [Integration](#integration)
|
||||
11. [Initialization & Maintenance](#initialization--maintenance)
|
||||
12. [Debug & Diagnostics](#debug--diagnostics)
|
||||
13. [Settings Override](#settings-override)
|
||||
14. [Version & Help](#version--help)
|
||||
15. [Subcommands](#subcommands)
|
||||
16. [Environment Variables](#environment-variables)
|
||||
|
||||
---
|
||||
|
||||
## Session Management
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--continue` | `-c` | Continue the most recent conversation in the current directory |
|
||||
| `--resume` | `-r` | Resume a specific session by ID or name, or show interactive picker |
|
||||
| `--from-pr <NUMBER\|URL>` | | Resume sessions linked to a specific GitHub PR |
|
||||
| `--fork-session` | | Create a new session ID when resuming (use with `--resume` or `--continue`) |
|
||||
| `--session-id <UUID>` | | Use a specific session ID (must be valid UUID) |
|
||||
| `--no-session-persistence` | | Disable session persistence (print mode only) |
|
||||
| `--remote` | | Create a new web session on claude.ai |
|
||||
| `--teleport` | | Resume a web session in your local terminal |
|
||||
|
||||
---
|
||||
|
||||
## Model & Configuration
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--model <NAME>` | | Set model with alias (`sonnet`, `opus`, `haiku`) or full model ID |
|
||||
| `--fallback-model <NAME>` | | Auto-fallback model when default is overloaded (print mode only) |
|
||||
| `--betas <LIST>` | | Beta headers to include in API requests (API key users only) |
|
||||
|
||||
---
|
||||
|
||||
## Permissions & Security
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--dangerously-skip-permissions` | | Skip ALL permission prompts. Use with extreme caution |
|
||||
| `--allow-dangerously-skip-permissions` | | Enable permission bypassing as an option without activating it |
|
||||
| `--permission-mode <MODE>` | | Begin in specified permission mode: `default`, `plan`, `acceptEdits`, `bypassPermissions` |
|
||||
| `--allowedTools <TOOLS>` | | Tools that execute without prompting (permission rule syntax) |
|
||||
| `--disallowedTools <TOOLS>` | | Tools removed from model context entirely |
|
||||
| `--tools <TOOLS>` | | Restrict which built-in tools Claude can use (use `""` to disable all) |
|
||||
| `--permission-prompt-tool <TOOL>` | | Specify MCP tool to handle permission prompts in non-interactive mode |
|
||||
|
||||
---
|
||||
|
||||
## Output & Format
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--print` | `-p` | Print response without interactive mode (headless/SDK mode) |
|
||||
| `--output-format <FORMAT>` | | Output format: `text`, `json`, `stream-json` |
|
||||
| `--input-format <FORMAT>` | | Input format: `text`, `stream-json` |
|
||||
| `--json-schema <SCHEMA>` | | Get validated JSON matching schema (print mode only) |
|
||||
| `--include-partial-messages` | | Include partial streaming events (requires `--print` and `--output-format=stream-json`) |
|
||||
| `--verbose` | | Enable verbose logging with full turn-by-turn output |
|
||||
|
||||
---
|
||||
|
||||
## System Prompt
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--system-prompt <TEXT>` | | Replace entire system prompt with custom text |
|
||||
| `--system-prompt-file <PATH>` | | Load system prompt from file, replacing default (print mode only) |
|
||||
| `--append-system-prompt <TEXT>` | | Append custom text to default system prompt |
|
||||
| `--append-system-prompt-file <PATH>` | | Append file contents to default prompt (print mode only) |
|
||||
|
||||
---
|
||||
|
||||
## Agent & Subagent
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--agent <NAME>` | | Specify an agent for the current session |
|
||||
| `--agents <JSON>` | | Define custom subagents dynamically via JSON |
|
||||
| `--teammate-mode <MODE>` | | Set agent team display: `auto`, `in-process`, `tmux` |
|
||||
|
||||
---
|
||||
|
||||
## MCP & Plugins
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--mcp-config <PATH\|JSON>` | | Load MCP servers from JSON file or string |
|
||||
| `--strict-mcp-config` | | Only use MCP servers from `--mcp-config`, ignore all others |
|
||||
| `--plugin-dir <PATH>` | | Load plugins from directory for this session only (repeatable) |
|
||||
|
||||
---
|
||||
|
||||
## Directory & Workspace
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--add-dir <PATH>` | | Add additional working directories for Claude to access |
|
||||
| `--worktree` | `-w` | Start Claude in an isolated git worktree (branched from HEAD) |
|
||||
|
||||
---
|
||||
|
||||
## Budget & Limits
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--max-budget-usd <AMOUNT>` | | Maximum dollar amount for API calls before stopping (print mode only) |
|
||||
| `--max-turns <NUMBER>` | | Limit number of agentic turns (print mode only) |
|
||||
|
||||
---
|
||||
|
||||
## Integration
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--chrome` | | Enable Chrome browser integration for web automation |
|
||||
| `--no-chrome` | | Disable Chrome browser integration for this session |
|
||||
| `--ide` | | Automatically connect to IDE on startup if exactly one valid IDE available |
|
||||
|
||||
---
|
||||
|
||||
## Initialization & Maintenance
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--init` | | Run initialization hooks and start interactive mode |
|
||||
| `--init-only` | | Run initialization hooks and exit (no interactive session) |
|
||||
| `--maintenance` | | Run maintenance hooks and exit |
|
||||
|
||||
---
|
||||
|
||||
## Debug & Diagnostics
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--debug <CATEGORIES>` | | Enable debug mode with optional category filtering (e.g., `"api,hooks"`) |
|
||||
|
||||
---
|
||||
|
||||
## Settings Override
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--settings <PATH\|JSON>` | | Path to settings JSON file or JSON string to load |
|
||||
| `--setting-sources <LIST>` | | Comma-separated list of sources to load: `user`, `project`, `local` |
|
||||
| `--disable-slash-commands` | | Disable all skills and slash commands for this session |
|
||||
|
||||
---
|
||||
|
||||
## Version & Help
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--version` | `-v` | Output the version number |
|
||||
| `--help` | `-h` | Show help information |
|
||||
|
||||
---
|
||||
|
||||
## Subcommands
|
||||
|
||||
These are not flags but top-level subcommands run as `claude <subcommand>`:
|
||||
|
||||
| Subcommand | Description |
|
||||
|------------|-------------|
|
||||
| `claude` | Start interactive REPL |
|
||||
| `claude "query"` | Start REPL with initial prompt |
|
||||
| `claude update` | Update to latest version |
|
||||
| `claude mcp` | Configure MCP servers (`add`, `remove`, `list`, `get`, `enable`) |
|
||||
| `claude doctor` | Run diagnostics from the command line |
|
||||
|
||||
---
|
||||
|
||||
## Environment Variables
|
||||
|
||||
These environment variables modify Claude Code behavior at startup:
|
||||
|
||||
| Variable | Description |
|
||||
|----------|-------------|
|
||||
| `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` | Enable experimental agent teams |
|
||||
| `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1` | Disable experimental beta features |
|
||||
| `CLAUDE_CODE_TMPDIR` | Override temp directory for internal files |
|
||||
| `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` | Disable background task functionality |
|
||||
| `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` | Enable additional directory CLAUDE.md loading |
|
||||
| `DISABLE_AUTOUPDATER=1` | Disable auto-updates |
|
||||
| `MAX_THINKING_TOKENS` | Limit thinking token budget (set to `0` to disable) |
|
||||
| `CLAUDE_CODE_EFFORT_LEVEL` | Control thinking depth: `low`, `medium`, `high` |
|
||||
| `USE_BUILTIN_RIPGREP=0` | Use system ripgrep instead of built-in (Alpine Linux) |
|
||||
| `CLAUDE_CODE_ENABLE_TASKS=false` | Disable new task management system, revert to old todos |
|
||||
| `CLAUDE_CODE_SHELL` | Override automatic shell detection |
|
||||
| `CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS` | Override default file read token limit |
|
||||
| `CLAUDE_CODE_EXIT_AFTER_STOP_DELAY` | Auto-exit SDK mode after idle duration (ms) |
|
||||
| `CLAUDE_CODE_SIMPLE` | Enable simple mode (Bash + Edit tools only) |
|
||||
| `CLAUDE_BASH_NO_LOGIN=1` | Skip login shell for BashTool |
|
||||
|
||||
---
|
||||
|
||||
## Sources
|
||||
|
||||
- [Claude Code CLI Reference](https://code.claude.com/docs/en/cli-reference)
|
||||
- [Claude Code Headless Mode](https://code.claude.com/docs/en/headless)
|
||||
- [Claude Code Setup](https://code.claude.com/docs/en/setup)
|
||||
- [Claude Code CHANGELOG](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md)
|
||||
- [Claude Code Common Workflows](https://code.claude.com/docs/en/common-workflows)
|
||||
@@ -0,0 +1,119 @@
|
||||
# MCP Servers Best Practice
|
||||
|
||||
<br>
|
||||
[](../.mcp.json)
|
||||
|
||||
MCP (Model Context Protocol) servers extend Claude Code with connections to external tools, databases, and APIs. This guide covers recommended servers for daily use and configuration best practices.
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td><a href="../">← Back to Claude Code Best Practice</a></td>
|
||||
<td align="right"><img src="../!/claude-jumping.svg" alt="Claude" width="60" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
---
|
||||
|
||||
## MCP Servers for Daily Use
|
||||
|
||||
> *"Went overboard with 15 MCP servers thinking more = better. Ended up using only 4 daily."* — [r/mcp](https://reddit.com/r/mcp/comments/1mj0fxs/) (682 upvotes)
|
||||
|
||||
| MCP Server | What It Does | Resources |
|
||||
|------------|-------------|-----------|
|
||||
| [**Context7**](https://github.com/upstash/context7) | Fetches up-to-date library docs into context. Prevents hallucinated APIs from outdated training data | [Reddit: "by far the best MCP for coding"](https://reddit.com/r/mcp/comments/1qarjqm/) · [npm](https://www.npmjs.com/package/@upstash/context7-mcp) |
|
||||
| [**Playwright**](https://github.com/microsoft/playwright-mcp) | Browser automation — implement, test, and verify UI features autonomously. Screenshots, navigation, form testing | [Reddit: essential for frontend](https://reddit.com/r/mcp/comments/1m59pk0/) · [Docs](https://playwright.dev/) |
|
||||
| [**Claude in Chrome**](https://github.com/nicobailon/claude-code-in-chrome-mcp) | Connects Claude to your real Chrome browser — inspect console, network, DOM. Debug what users actually see | [Reddit: "game changer" for debugging](https://reddit.com/r/mcp/comments/1qarjqm/5_mcps_that_have_genuinely_made_me_10x_faster/nza0i7t/) · [Comparison Report](../reports/claude-in-chrome-v-chrome-devtools-mcp.md) |
|
||||
| [**DeepWiki**](https://github.com/devanshusemwal/deepwiki-mcp) | Fetches structured wiki-style documentation for any GitHub repo — architecture, API surface, relationships | [Reddit: "put it behind a gateway with Context7"](https://reddit.com/r/mcp/comments/1qarjqm/) |
|
||||
| [**Excalidraw**](https://github.com/antonpk1/excalidraw-mcp-app) | Generate architecture diagrams, flowcharts, and system designs as hand-drawn Excalidraw sketches from prompts | [GitHub](https://github.com/antonpk1/excalidraw-mcp-app) |
|
||||
|
||||
Research (Context7/DeepWiki) -> Debug (Playwright/Chrome) -> Document (Excalidraw)
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
MCP servers are configured in `.mcp.json` at the project root (project-scoped) or in `~/.claude.json` (user-scoped).
|
||||
|
||||
### Server Types
|
||||
|
||||
| Type | Transport | Example |
|
||||
|------|-----------|---------|
|
||||
| **stdio** | Spawns a local process | `npx`, `python`, binary |
|
||||
| **http** | Connects to a remote URL | HTTP/SSE endpoint |
|
||||
|
||||
### Example `.mcp.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
},
|
||||
"playwright": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@playwright/mcp"]
|
||||
},
|
||||
"deepwiki": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "deepwiki-mcp"]
|
||||
},
|
||||
"remote-api": {
|
||||
"type": "http",
|
||||
"url": "https://mcp.example.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Settings for MCP Servers
|
||||
|
||||
These settings in `.claude/settings.json` control MCP server approval:
|
||||
|
||||
| Key | Type | Description |
|
||||
|-----|------|-------------|
|
||||
| `enableAllProjectMcpServers` | boolean | Auto-approve all `.mcp.json` servers without prompting |
|
||||
| `enabledMcpjsonServers` | array | Allowlist of specific server names to auto-approve |
|
||||
| `disabledMcpjsonServers` | array | Blocklist of specific server names to reject |
|
||||
|
||||
### Permission Rules for MCP Tools
|
||||
|
||||
MCP tools follow the `mcp__<server>__<tool>` naming convention in permission rules:
|
||||
|
||||
```json
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"mcp__*",
|
||||
"mcp__context7__*",
|
||||
"mcp__playwright__browser_snapshot"
|
||||
],
|
||||
"deny": [
|
||||
"mcp__dangerous-server__*"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## MCP Scopes
|
||||
|
||||
MCP servers can be defined at three levels:
|
||||
|
||||
| Scope | Location | Purpose |
|
||||
|-------|----------|---------|
|
||||
| **Project** | `.mcp.json` (repo root) | Team-shared servers, committed to git |
|
||||
| **User** | `~/.claude.json` (`mcpServers` key) | Personal servers across all projects |
|
||||
| **Subagent** | Agent frontmatter (`mcpServers` field) | Servers scoped to a specific subagent |
|
||||
|
||||
Precedence: Subagent > Project > User
|
||||
|
||||
---
|
||||
|
||||
## Sources
|
||||
|
||||
- [MCP Servers — Claude Code Docs](https://code.claude.com/docs/en/mcp)
|
||||
- [Model Context Protocol Specification](https://modelcontextprotocol.io/)
|
||||
- [5 MCPs that have genuinely made me 10x faster — r/mcp](https://reddit.com/r/mcp/comments/1qarjqm/)
|
||||
- [MCP Server Overload Discussion — r/mcp](https://reddit.com/r/mcp/comments/1mj0fxs/)
|
||||
Reference in New Issue
Block a user