Linux command
claude 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Start an interactive session
claude
Start with an initial prompt
claude "[prompt]"
Run a one-off command
claude -p "[prompt]"
Continue the most recent
claude -c
Resume a specific session
claude -r "[session_id]" "[prompt]"
Pipe input
cat [file.txt] | claude -p "[analyze this code]"
Output response as JSON
claude -p "[prompt]" --output-format json
Specify a different model
claude --model [opus]
说明
Claude Code is Anthropic's official command-line interface for interacting with Claude AI. It provides an agentic coding assistant that can read, write, and execute code directly in your development environment. The tool operates in two main modes: interactive mode for extended sessions with ongoing dialogue, and print mode (-p) for scripted automation and one-off commands. Claude can navigate codebases, edit files, run shell commands, and perform complex multi-step development tasks. Claude Code integrates with your terminal environment, understanding project context through file access and command execution. It maintains conversation history across sessions, allowing you to resume previous discussions. The tool supports piping input from other commands and outputting structured JSON for integration with other tools. Special syntax includes @ for file references and ! for direct shell command execution. The CLI supports MCP (Model Context Protocol) servers for extending capabilities and can connect to IDEs and Chrome for enhanced integration.
参数
- -p, --print
- Print mode: process prompt and exit without interactive session.
- -c, --continue
- Continue the most recent conversation.
- -r _ID_, --resume _ID_
- Resume a specific conversation by session ID or name.
- -v, --version
- Display version information.
- --model _MODEL_
- Specify the Claude model to use (aliases: sonnet, opus, haiku, or full model name).
- --max-turns _N_
- Maximum number of agentic turns in non-interactive mode.
- --max-budget-usd _AMOUNT_
- Maximum dollar amount for API calls (print mode only).
- --output-format _FORMAT_
- Output format: text, json, or stream-json.
- --input-format _FORMAT_
- Input format for print mode.
- --tools _TOOLS_
- Restrict available built-in tools (e.g., "Bash,Edit,Read").
- --allowedTools _TOOLS_
- Tools that execute without prompting.
- --disallowedTools _TOOLS_
- Tools removed from context.
- --permission-mode _MODE_
- Begin in specified permission mode (e.g., plan).
- --system-prompt _PROMPT_
- Replace the entire default system prompt.
- --append-system-prompt _PROMPT_
- Append additional instructions to the default prompt.
- --add-dir _PATHS_
- Add additional working directories.
- --mcp-config _FILE_
- Load MCP servers from JSON configuration file.
- --chrome
- Enable Chrome browser integration.
- --ide
- Auto-connect to IDE on startup.
- --remote
- Create web session on claude.ai.
- --teleport
- Resume web session in local terminal.
- --verbose
- Enable verbose logging output.
- --debug _FILTER_
- Enable debug mode with optional filtering.
- --dangerously-skip-permissions
- Skip permission prompts (use with caution in trusted environments).
FAQ
What is the claude command used for?
Claude Code is Anthropic's official command-line interface for interacting with Claude AI. It provides an agentic coding assistant that can read, write, and execute code directly in your development environment. The tool operates in two main modes: interactive mode for extended sessions with ongoing dialogue, and print mode (-p) for scripted automation and one-off commands. Claude can navigate codebases, edit files, run shell commands, and perform complex multi-step development tasks. Claude Code integrates with your terminal environment, understanding project context through file access and command execution. It maintains conversation history across sessions, allowing you to resume previous discussions. The tool supports piping input from other commands and outputting structured JSON for integration with other tools. Special syntax includes @ for file references and ! for direct shell command execution. The CLI supports MCP (Model Context Protocol) servers for extending capabilities and can connect to IDEs and Chrome for enhanced integration.
How do I run a basic claude example?
Run `claude` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -p, --print do in claude?
Print mode: process prompt and exit without interactive session.