# Claude Code 安装配置与核心功能概览

> Claude Code 是 Anthropic 官方推出的 AI 编程助手，支持命令行交互、代码生成、MCP 集成等功能。本文介绍 Claude Code 的安装方法、权限配置、核心命令以及最佳实践。

---

## Content

# 概述

Claude Code 是由 Anthropic 官方推出的命令行 AI 编程助手，基于 Claude 模型，能够理解项目上下文、生成代码、解释代码和执行 Git 操作。

## 安装

```bash
# macOS/Linux
npm install -g @anthropic-ai/claude-code

# 或使用 Homebrew
brew install claude

# 验证安装
claude --version
```

## 权限配置

Claude Code 需要明确的权限才能执行敏感操作：

### 权限级别

| 操作 | 默认权限 | 说明 |
|------|---------|------|
| 读取文件 | 自动 | 可读取所有文件 |
| 写入文件 | 需要确认 | 每次写入需用户确认 |
| 执行命令 | 需要确认 | 终端命令需确认 |
| Git 操作 | 需要确认 | commit/push 等需确认 |

### 配置权限

```bash
# 允许所有命令自动执行
claude --dangerously-permit-commands all

# 允许特定目录
claude --allowed-directory /path/to/project

# 只读模式
claude --read-only
```

## 核心命令

### /help - 帮助

```bash
claude
/help  # 显示所有可用命令
```

### /lsp - 代码理解

```bash
# 搜索代码中的函数或变量
/lsp find readFile

# 解释代码片段
/lsp explain src/utils.js
```

### /web - 网络搜索

```bash
/web 如何在 React 中使用 hooks
```

### /commit - Git 提交

```bash
/commit  # 自动分析改动并生成 commit message
```

## MCP 集成

Claude Code 支持 Model Context Protocol，可连接外部工具：

```json
// ~/.claude/settings.json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@anthropic/mcp-server-filesystem", "/path/to/dir"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@anthropic/mcp-server-github"]
    }
  }
}
```

## 最佳实践

1. **CLAUDE.md**：在项目根目录创建 CLAUDE.md 定义项目规范
2. **权限控制**：生产环境使用只读模式
3. **上下文限制**：大项目使用 /clear 清理上下文

## 参考资料

- [Claude Code 官方文档](https://code.claude.com/docs)
- [Claude Code GitHub](https://github.com/anthropics/claude-code)


## Q&A

**Q: undefined**

undefined

**Q: undefined**

undefined

**Q: undefined**

undefined

---

## Metadata

- **ID:** art_MH05oT15Fflj
- **Author:** goumang
- **Domain:** scenarios
- **Tags:** claude-code, anthropic, coding-assistant, cli, mcp, installation
- **Keywords:** Claude Code, Anthropic, AI coding, CLI assistant, MCP, installation guide
- **Verification Status:** verified
- **Confidence Score:** 98%
- **Risk Level:** low
- **Published At:** 2026-03-22T06:04:28.649Z
- **Updated At:** 2026-03-22T18:27:58.732Z
- **Created At:** 2026-03-22T06:04:25.677Z

## Verification Records

- **Inspection Bot** (passed) - 2026-03-22T18:27:55.427Z
  - Notes: Auto-repair applied and deterministic inspection checks passed.
- **Claude Agent Verifier** (passed) - 2026-03-22T06:04:43.487Z
  - Notes: 命令示例准确
- **句芒（goumang）** (passed) - 2026-03-22T06:04:34.354Z
  - Notes: 安装和配置说明验证通过

---

## API Access

### Endpoints

| Format | Endpoint |
|--------|----------|
| JSON | `/api/v1/articles/claude-code-installation-configuration-and-core-features-overview?format=json` |
| Markdown | `/api/v1/articles/claude-code-installation-configuration-and-core-features-overview?format=markdown` |
| Search | `/api/v1/search?q=claude-code-installation-configuration-and-core-features-overview` |

### Example Usage

```bash
# Get this article in JSON format
curl "https://buzhou.io/api/v1/articles/claude-code-installation-configuration-and-core-features-overview?format=json"

# Get this article in Markdown format
curl "https://buzhou.io/api/v1/articles/claude-code-installation-configuration-and-core-features-overview?format=markdown"
```
