Tutorial
如何安装 Claude 代码并运行您的第一个 AI 任务
在任何平台上安装 Claude 代码, 并在10分钟内执行您的第一个自主编码任务 。 本指南涵盖安装,设置,以及您的第一个真正的提示.
Claude Code是Anthropic的代理编码工具. 它运行在您的终端,读取您的整个工程,编辑文件,运行命令,并重排结果. 这个指南让你在十分钟内 从零到第一次有成果的会议.
如何安装 克劳德代码?
Claude Code在macOS,Linux或WSL上通过单一命令安装. 在视窗上,使用PowerShell.
macOS / Linux / WSL
curl -fsSL https://claude.ai/install.sh | bash视窗电源 贝壳
irm https://claude.ai/install.ps1 | iex替代方法
| 方法 | 命令 |
|---|---|
| 自制软件 (macOS) | 酿造安装克劳德代码 |
| npm(任何平台) | npm 安装 -g @ harmic-ai/ claude- code |
| VS 代码扩展 | 搜索 VS 中的" Claude 代码" 代码市场 |
| 喷气管插件 | 在 JetBrains 市场搜索"克劳德代码" |
验证安装 :
claude --version
# Claude Code 2.x.x如何开始你的第一次会话?
导航到任何项目目录并输入`claude'。 Claude Code读取您的工程结构并自动构建上下文. 你不需要配置什么开始.
cd your-project
claude你会看到一个可以输入自然语言指令的提示. Claude Code理解你的计划 因为它读取了你的文件 不是因为你解释.
什么是好的第一提示吗?
从帮助你了解克洛德密码能做什么的任务开始. 这促使第一届会议顺利进行:
# Understand the project
> "What does this project do? Give me a high-level overview."
# Find issues
> "Are there any obvious bugs or code smells in this codebase?"
# Take action
> "Write tests for the auth module, run them, and fix any failures"
# Multi-step task
> "Add input validation to the user registration form,
write unit tests, and commit with a descriptive message"Claude Code 与其他 AI 工具有何不同?
| 能力 | 克劳德·科德 | 基于聊天的工具 |
|---|---|---|
| 文件访问 | 读取项目中的任何文件 | 仅您粘贴的内容 |
| 执行 | 在终端中运行命令 | 没有执行 |
| 重复 | 修正自己的错误 | 您复制- 粘贴修正 |
| 图形 | 创建承诺、 分支、 公关 | 没有 git 整合 |
| 内存 | CLAUDE.md 在各个会期内坚持不懈 | 没有记忆 |
如何设置 CLAUDE.md 以获得更好的结果?
在项目根目录创建 CLAUDE.md 文件。克劳德·科德在每次训练开始时都会阅读它。它告诉代理您的项目约定、技术堆栈和规则。
# Create CLAUDE.md automatically
claude /init
# Or write one manually
cat > CLAUDE.md << 'EOF'
# Project Context
Next.js 14 app with TypeScript and Tailwind CSS.
## Commands
- npm run dev — start dev server
- npm run test — run tests
## Conventions
- Use server components by default
- Never use `any` in TypeScript
EOF查看我们有关 CLAUDE.md 高级配置最佳实践的详细指南。