Token导航 LogoToken导航TokenDH.com
Claude Code Cheat Sheet logo
开发工具未说明官方级别未说明来源级核验

Claude Code Cheat Sheet

MCP Server

Anthropic推出的智能编码命令行工具,提供交互式编程辅助、自动化代码修改和项目工作流管理功能。

工具数

0

提示词数

0

GitHub Stars

6

资源数

0
编程辅助工作流自动化Claude命令行工具ClaudeVS Code

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

jmutai

提供方

jmutai

最后核验

2026/5/17 20:23

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

Claude代码备忘单-命令、快捷方式、提示和工作流模式

![Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview) ![Last Updated](#) ![License](LICENSE)

完整的参考文献 克劳德代码Anthropic的代理编码CLI。每个命令、键盘快捷键、CLI标志、配置选项和工作流模式都在一个地方。在Claude Code的最新版本上进行了测试和验证。

带有截图和扩展示例的整篇文章: computingforgeks.com/claude编码壳

______________________________________________________________________

目录

______________________________________________________________________

安装

在macOS、Linux或Windows(WSL)上安装Claude Code:

curl -fsSL https://claude.ai/install.sh | bash

在macOS上通过Homebrew:

brew install --cask claude-code

在Windows(PowerShell)上:

irm https://claude.ai/install.ps1 | iex

验证和身份验证:

claude --version
claude auth login

______________________________________________________________________

键盘快捷键

这些在交互式Claude Code终端中工作。

基本快捷方式

快捷方式操作
Ctrl+C取消当前生成或输入
Ctrl+D退出克劳德代码
Ctrl+L清除终端屏幕
Ctrl+R反向搜索命令历史记录
Esc + Esc倒退到上一个检查点(撤消)
Shift+Tab循环权限模式(默认/计划/自动)
Ctrl+G在外部编辑器(vim等)中打开输入
Ctrl+O切换详细输出
Ctrl+T切换任务列表
Ctrl+F杀死所有后台特工(按两次)

输入和编辑

快捷方式操作
\ + Enter新行(多行输入)-适用于macOS、Linux和Windows
Option+Enter (Mac)/ Alt+Enter (Linux/Win)新行(平台默认)
Shift+Enter新品(iTerm2、WezTerm、Ghostty、Kitty、Windows终端)
Ctrl+K删除到行尾
Ctrl+U删除整行
Ctrl+Y粘贴已删除的文本
Alt+B / Alt+F将光标前后移动一个单词
Cmd+V (Mac)/ Ctrl+V (Linux/Win)从剪贴板粘贴图像
Up/Down浏览命令历史记录

型号和模式切换

快捷方式操作
Option+P (Mac)/ Alt+P (Linux/Win)交换机型号(Sonnet/Opus/Haiku)
Option+T (Mac)/ Alt+T (Linux/Win)切换扩展思维
Shift+Tab / Alt+M循环许可模式
?显示所有可用快捷方式

快速前缀

前缀动作
/打开斜线命令菜单
!直接运行bash命令
@自动完成文件路径提及

______________________________________________________________________

斜杠命令

会话和上下文管理

命令它做什么
/clear擦除对话历史记录和自由上下文窗口
/compact [focus]将对话总结为自由语境,可选择关注特定主题
/cost显示当前会话的令牌使用情况和API成本
/context可视化什么在消耗你的上下文窗口
/resume选择并继续上一个会话
/rename [name]为当前会话命名,以便以后轻松恢复
/rewind倒退到上一个检查点
/diff查看所有更改的交互式差异
/copy将上次响应复制到剪贴板
/export [file]将对话导出为文本文件

配置和型号

命令它做什么
/model [name]切换模式(十四行诗、小品、俳句)
/effort [level]设定推理努力(低、中、高、最大)
/config打开设置界面
/permissions查看和管理工具权限
/mcp管理MCP服务器连接
/terminal-setup为您的shell配置终端键绑定
/theme更改颜色主题
/vim切换vim键绑定模式

项目和代码工具

命令它做什么
/init初始化项目,使用项目上下文生成CLAUDE.md
/memory查看和编辑CLAUDE.md文件和自动内存
/security-review扫描待定更改以查找安全漏洞
/simplify审查更改的代码是否存在质量问题,并提出改进建议
/pr-comments [PR]获取并处理GitHub PR评论
/add-dir [path]将另一个目录添加到工作上下文中
/plan进入计划模式,进行更改前进行只读探索
/batch [task]在5-30个并行git工作树上运行大规模更改
/debug [description]排除当前会话中的问题

系统和帐户

命令它做什么
/help显示所有可用命令
/doctor诊断安装、设置、身份验证和MCP问题
/insights生成会话分析报告
/status显示版本、型号和帐户信息
/login / /logout登录或退出
/bug提交带有会话日志的错误报告
/stats查看使用模式、每日记录和会话历史
/usage显示计划使用情况和费率限制
/release-notes查看当前版本的更新日志
/loop [interval] [prompt]按定期计划运行提示或命令
/voice切换按键通话语音听写(按住空格键)
/schedule创建、更新、列出或运行计划的远程代理(cron任务)
/fast切换快速模式(相同型号,更快输出)
/hooks查看和管理已配置的挂钩
/desktop将当前会话切换到桌面应用程序
/teleport将web/iOS会话拉入您的终端

______________________________________________________________________

CLI标志

开始会话

# Start interactive session
claude

# Start with initial prompt
claude "refactor the auth module"

# Continue most recent session
claude -c

# Resume specific session by name
claude -r "auth-refactor"

# Name a session for later
claude -n "feature-payments"

# Run in isolated git worktree
claude -w feature-branch

# Run in worktree with tmux panes
claude -w feature-branch --tmux

# Resume session linked to a GitHub PR
claude --from-pr 42

# Fork a session (new ID, keeps context)
claude -c --fork-session

# Enable auto mode (AI decides permissions)
claude --permission-mode auto

# Bare mode (skip hooks, plugins, auto-memory)
claude --bare

打印模式(非交互式/管道)

-p flag以非交互方式运行Claude Code。它处理提示并退出。这是将Claude Code集成到脚本、CI/CD管道和Unix管道中的关键:

# Simple query
claude -p "explain this error in server.log"

# Pipe input
cat error.log | claude -p "what caused this crash?"

# Git diff review
git diff main | claude -p "review for security issues"

# JSON output for scripting
claude -p "list all TODO comments" --output-format json

# Structured output with schema validation
claude -p "extract function names from auth.py" \
  --output-format json \
  --json-schema '{"type":"object","properties":{"functions":{"type":"array","items":{"type":"string"}}}}'

# Auto-approve tools (careful with this)
claude -p "run tests and fix failures" --allowedTools "Bash,Read,Edit"

# Set spending limit
claude -p "refactor the API layer" --max-budget-usd 5.00

# Limit turns
claude -p "fix the bug" --max-turns 3

# Fallback model when primary is overloaded
claude -p "review this code" --fallback-model haiku

# Restrict available tools
claude -p "analyze this" --tools "Read,Grep,Glob"

# Block specific tools (deny list)
claude -p "refactor auth module" --disallowedTools "Bash(rm:*),Bash(sudo:*)"

# Override system prompt entirely
claude -p "review this code" --system-prompt "You are a security auditor. Focus only on vulnerabilities."

# Append to default system prompt
claude -p "explain this function" --append-system-prompt "Always include time complexity analysis."

# Load MCP servers from external config file
claude -p "check open issues" --mcp-config ./ci-mcp.json

# Disable session persistence (ephemeral, for CI/CD)
claude -p "run lint check" --no-session-persistence

# Debug mode (logs API calls, tool usage, timings)
claude -p "fix the build" --debug

# Debug with category filter
claude -p "fix the build" --debug "api,hooks"

# Write debug output to a file
claude -p "fix the build" --debug-file /tmp/claude-debug.log

# Select a specific agent
claude -p "review auth.py" --agent code-reviewer

# Enable Chrome debugging integration
claude --chrome

模型和努力标志

# Use specific model
claude --model opus
claude --model sonnet
claude --model haiku

# Set reasoning effort
claude --effort high    # More thorough (costs more)
claude --effort low     # Faster, cheaper

# Custom system prompt
claude --append-system-prompt "Always use TypeScript. Never use any."

# Load system prompt from file
claude --append-system-prompt-file ./coding-rules.txt

______________________________________________________________________

CLAUDE.md-项目说明

CLAUDE.md是在每个项目的基础上定制CLAUDE代码行为的最重要的文件。它在每个会话开始时自动加载。

文件位置和范围

位置范围是否与团队共享?
./CLAUDE.md仅此项目是(提交到git)
./.claude/CLAUDE.md仅此项目是(提交到git)
~/.claude/CLAUDE.md所有项目否(个人)
.claude/rules/*.md路径特定规则是(提交到git)

CLAUDE.md示例

# My Project

## Build and Test
- Run tests: `npm test`
- Build: `npm run build`
- Lint: `npm run lint`

## Code Style
- Use TypeScript strict mode
- Prefer functional components in React
- All API responses must include error handling
- Never commit .env files

## Architecture
- Backend: Express.js + PostgreSQL
- Frontend: React + TailwindCSS
- Auth: JWT tokens stored in httpOnly cookies

See @README.md for project overview.
See @package.json for available scripts.

@filename 语法从其他文件导入内容。克劳德会自动阅读它们。

路径特定规则

仅适用于某些文件的规则。创建 .claude/rules/api.md:

---
paths:
  - "src/api/**/*.ts"
---

# API Rules
- All endpoints must validate input with Zod
- Return proper HTTP status codes
- Include rate limiting on public endpoints

为具有以下条件的任何项目自动生成CLAUDE.md /init.

______________________________________________________________________

权限模式

Claude Code在运行命令或编辑文件之前会请求权限。通过以下方式在模式之间切换 Shift+Tab:

模式行为用例
默认首次使用每个工具的提示正常的互动工作
计划只读,无需编辑,无需命令安全探索和规划
接受编辑自动批准文件编辑,提示命令受信任的编辑会话
别问除非事先批准,否则自动拒绝严格控制
自动AI分类器决定每次工具调用的允许/拒绝具有明确CLAUDE.md规则的受信任项目
绕过权限跳过所有提示(危险)仅限容器/沙盒

预先批准特定工具

通过CLI:

# Allow git commands and file reads without prompting
claude --allowedTools "Read,Bash(git *)"

# Block dangerous tools explicitly
claude --disallowedTools "Bash(rm:*),Bash(sudo:*),Bash(chmod:*)"

# Combine both: allow some, block others
claude --allowedTools "Bash(git:*),Read,Edit" --disallowedTools "Bash(rm -rf:*)"

或在 .claude/settings.json:

{
  "permissions": {
    "allow": [
      "Read",
      "Bash(git *)",
      "Bash(npm run *)",
      "Bash(docker compose *)"
    ],
    "deny": [
      "Bash(rm -rf *)"
    ]
  }
}

______________________________________________________________________

模型和努力水平

型号最适合速度
十四行诗 (Claude Sonnet 4.6)日常编码、编辑、重构、测试快速
作品 (Claude Opus 4.6)复杂的架构、调试、多文件更改速度较慢
俳句 (克劳德·海库4.5)简单任务,快速提问最快

在会话中期切换型号 /model opusOption+P (Mac)/ Alt+P (Linux/Windows)。

努力程度控制着克劳德运用的推理程度:

级别用例
/effort low简单的问题,快速查找
/effort medium默认、平衡速度和质量
/effort high复杂的调试、架构决策
/effort max最难的问题(仅限Opus,无限思维预算)

______________________________________________________________________

MCP服务器-扩展克劳德代码

MCP(模型上下文协议) 允许Claude Code连接到外部工具和数据源。在中配置服务器 .mcp.json 在项目根或 ~/.claude/.mcp.json 对于所有项目。

GitHub和PostgreSQL服务器的示例配置:

{
  "mcpServers": {
    "github": {
      "type": "stdio",
      "command": "npx",
      "args": ["@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_TOKEN"
      }
    },
    "postgres": {
      "type": "stdio",
      "command": "npx",
      "args": ["@modelcontextprotocol/server-postgres"],
      "env": {
        "DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb"
      }
    }
  }
}

管理MCP连接 /mcp 在交互式会话中,或在CLI上传递配置文件:

# Load MCP servers from an external config
claude --mcp-config ./team-mcp.json

# Load multiple configs
claude --mcp-config ./github-mcp.json ./db-mcp.json

# Ignore all other MCP sources, only use this config
claude --mcp-config ./ci-mcp.json --strict-mcp-config

--mcp-config 标志在CI/CD中很有用,因为您需要跨运行进行一致的MCP服务器配置。 --strict-mcp-config 确保只加载指定的服务器,忽略任何来自 .mcp.json 或用户设置。

______________________________________________________________________

自定义技能-你自己的杀戮命令

技能是可重复使用的提示,显示为斜线命令。创建它们 .claude/skills/ (项目)或 ~/.claude/skills/ (个人)。

示例:创建部署技能:

mkdir -p .claude/skills/deploy

创建 .claude/skills/deploy/SKILL.md:

---
name: deploy
description: Deploy the application to production
argument-hint: "[environment]"
user-invocable: true
---

Deploy the application to the $0 environment (default: staging).

Steps:
1. Run the test suite
2. Build the production bundle
3. Deploy using the deploy script
4. Verify the deployment health check

现在使用它: /deploy production

______________________________________________________________________

自定义子代理

子代理是Claude可以委派任务的专用AI代理。在以下位置创建它们 .claude/agents/:

mkdir -p .claude/agents/code-reviewer

创建 .claude/agents/code-reviewer/AGENT.md:

---
name: code-reviewer
description: Expert code reviewer. Use proactively after code changes.
tools: Read, Grep, Glob, Bash
model: sonnet
---

You are a senior code reviewer. When reviewing code:
- Check for security vulnerabilities (SQL injection, XSS, etc.)
- Verify error handling is complete
- Flag any hardcoded secrets or credentials
- Suggest performance improvements
- Check for proper input validation

Claude会自动将代码审查任务委托给此代理,或直接使用 @code-reviewer check my latest changes.

从CLI中,为整个会话选择一个代理:

# Use a named agent from .claude/agents/
claude --agent code-reviewer

# In print mode (CI/CD)
claude -p "review the latest commit" --agent code-reviewer

# Define agents inline (no files needed)
claude --agents '{"qa": {"description": "QA tester", "prompt": "You are a QA engineer. Write test cases for every change."}}'

______________________________________________________________________

Hooks-自动化触发器

Hooks会自动运行shell命令以响应Claude Code事件。在中配置 .claude/settings.json:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "npx prettier --write $(jq -r '.tool_input.file_path')"
          }
        ]
      }
    ],
    "Notification": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "osascript -e 'display notification \"Claude needs input\" with title \"Claude Code\"'"
          }
        ]
      }
    ]
  }
}

常见挂钩事件: SessionStart, PreToolUse, PostToolUse, Stop, Notification, UserPromptSubmit.

______________________________________________________________________

上下文窗口管理

Claude Code有一个有限的上下文窗口。管理好它是富有成效的会议和碰壁之间的区别。

关键命令

命令何时使用
/compact在任务中期总结对话以释放空间
/compact Focus on auth module总结,但保持具体背景不变
/clear完成无关任务之间的重置
/context看看是什么在消耗你的上下文

长时间会话的提示

  • 使用 /clear 在不相关的任务之间。不要把旧的背景带入新的工作中
  • /compact 当你注意到速度减慢时,主动出击
  • 使用子代理进行详细操作(测试运行、日志分析)。他们的输出保持在子代理环境中
  • 将详细说明转移到技能上,而不是每次都打字
  • 将CLAUDE.md保持在200行以下。将详细信息移动到单独的文件并导入 @filename

______________________________________________________________________

Git工作树-并行工作

同时处理多个任务,而不会发生分支切换冲突:

# Start Claude in a new worktree
claude -w feature-auth

# Batch changes across many files in parallel
/batch migrate all components from class-based to functional

-w flag创建了一个独立的git工作树。更改发生在工作树中,不会影响您的主工作目录。代理完成后,将工作树分支合并回去。

______________________________________________________________________

设置文件参考

文件范围
.claude/settings.json项目(通过git共享)
.claude/settings.local.json项目(匿名、个人)
~/.claude/settings.json所有项目(个人)

常用设置:

{
  "model": "sonnet",
  "effortLevel": "medium",
  "defaultMode": "default",
  "autoMemoryEnabled": true,
  "permissions": {
    "allow": ["Read", "Bash(git *)"],
    "deny": ["Bash(rm -rf *)"]
  }
}

______________________________________________________________________

环境变量

变量目的
ANTHROPIC_MODEL默认模型(例如。, opus)
ANTHROPIC_API_KEY用于直接访问API的API密钥
CLAUDE_CODE_EFFORT_LEVEL默认努力(低/中/高/最大)
CLAUDE_CODE_DISABLE_AUTO_MEMORY设置为 1 禁用自动记忆
CLAUDE_CODE_DISABLE_1M_CONTEXT设置为 1 禁用1M令牌上下文
MAX_THINKING_TOKENS自定义思维预算(默认值不同)
HTTPS_PROXY企业网络的HTTP代理

______________________________________________________________________

文件结构参考

# User-level (personal, all projects)
~/.claude/
  settings.json          # Global settings
  keybindings.json       # Custom keyboard shortcuts
  CLAUDE.md              # Personal instructions
  rules/                 # Personal rules
  agents/                # Personal subagents
  skills/                # Personal skills
  .mcp.json              # Global MCP servers

# Project-level (shared with team)
.claude/
  settings.json          # Project settings (git tracked)
  settings.local.json    # Local overrides (gitignored)
  CLAUDE.md              # Project instructions
  rules/                 # Path-specific rules
  agents/                # Project subagents
  skills/                # Project skills
.mcp.json                # Project MCP servers
CLAUDE.md                # Project instructions (alternative location)

______________________________________________________________________

实用的工作流程技巧

正确启动每个项目

# In your project root
claude
/init

这将扫描您的项目,并生成一个包含构建命令、测试指令和代码约定的CLAUDE.md。查看并编辑它。此文件决定了未来的每一次交互。

建造前计划

Shift+Tab 在要求克劳德进行更改之前进入计划模式。在计划模式下,克劳德会阅读和分析,但无法编辑任何内容。一旦你批准了计划,切换回默认模式并说“执行计划”。

立即撤销错误

Esc + Esc 打开倒带菜单。选择“还原代码和对话”以撤消代码更改和导致更改的对话。比...更快 git stash 用于快速实验。

管道一切

# Analyze logs
tail -500 /var/log/app.log | claude -p "find the root cause of errors"

# Review a PR
gh pr diff 42 | claude -p "security review this PR"

# Generate commit message
git diff --staged | claude -p "write a conventional commit message" --model haiku

# Translate
cat README.md | claude -p "translate to Japanese" > README.ja.md

# Docker container analysis
docker ps --format json | claude -p "which containers are using the most resources?"

# Kubernetes pod debugging
kubectl logs deployment/api --tail=200 | claude -p "why are requests failing?"

# Database structure review
pg_dump --schema-only mydb | claude -p "suggest index improvements"

# Summarize recent commits
git log --oneline -20 | claude -p "write release notes from these commits"

# Find config issues
cat /etc/nginx/nginx.conf | claude -p "check for misconfigurations"

附带问题/btw

需要在不干扰当前任务的情况下提出问题吗?使用 /btw:

/btw what was the name of that config file we edited earlier?

响应是短暂的(不保存到上下文中),低成本(使用缓存),并且不使用任何工具。

成本控制

  • 使用 /cost 随时检查支出
  • 大多数工作使用Sonnet,Opus仅用于复杂问题
  • 使用 /effort low 用于简单任务
  • /compact 减少上下文大小(每个请求的令牌更少)
  • 在提示中要具体。模糊的请求会导致更多的来回
  • 使用 --max-budget-usd 5.00 在CI/CD中防止成本失控

______________________________________________________________________

提示提示-获得更好的结果

Claude Code输出的质量在很大程度上取决于你如何提示它。这些模式始终如一地产生更好的结果。

要具体,不要含糊

不良提示良好提示
“修复bug”“当电子邮件包含加号时,登录端点返回500,修复src/auth/login.ts中的输入验证”
“让它更快”“/api/users端点在10k行上占用3s,添加数据库索引和分页”
“编写测试”“为src/presing.ts中的calculateDiscount函数编写单元测试,涵盖边缘情况:零价格、负数量、过期优惠券”
“清理代码”“将src/api/orders.ts和src/api/returns.ts中的重复验证逻辑提取到共享验证器中”

首先使用计划模式

对于复杂任务,切换到计划模式(Shift+Tab)并要求Claude在编码前进行探索:

# In plan mode:
"I need to add OAuth2 login with Google. Look at the existing auth flow
in src/auth/ and propose where to add the Google provider without
breaking the current email/password login."

查看计划,然后切换回默认模式并说“执行计划”。

给出验证目标

告诉克劳德如何验证自己的工作:

"Add rate limiting to the /api/auth endpoints. After implementing,
run npm test to make sure nothing breaks, and verify the rate limiter
works by checking the middleware is registered in the Express app."

使用@file引用作为上下文

将Claude指向特定文件,而不是进行搜索:

"look at @src/db/schema.ts and @src/api/users.ts - the User model
has a new 'role' field in the schema but the API doesn't expose it.
Add the role field to the GET /users/:id response."

课程早点纠正

如果你看到克劳德走错了方向,按 Ctrl+C 停止并重定向。不要等到它完成了一个大的错误更改。如果它已经进行了错误的更改,请按 Esc + Esc 倒带。

将大型任务分解为步骤

与其“构建用户管理系统”,不如将其拆分:

  1. 使用id、电子邮件、姓名、角色、created_at创建用户数据库架构
  2. “为具有输入验证的用户添加CRUD API终结点”
  3. “为用户端点编写测试”
  4. “添加基于角色的访问控制中间件”

每一步在进入下一步之前都会经过验证。这避免了在糟糕的基础上浪费代币。

______________________________________________________________________

代币保存策略

发送给克劳德的每条消息都包含完整的对话内容。更大的上下文意味着更高的成本和更慢的响应。

环境卫生

策略方法节省
任务之间清晰/clear 切换到无关工作时影响最大,重置为零
主动压缩/compact Focus on the auth module changes保持相关上下文,降低噪音
检查上下文使用情况/context 查看是什么在消耗空间识别膨胀源
使用@文件提及@src/auth.ts 而不是“查找身份验证文件”避免探索性文件读取
使用子代理委派详细任务(测试运行、日志分析)输出保留在子代理上下文中

模型选择

任务模型努力
简单的编辑、重命名、格式化Sonnet/effort low
标准编码、测试、重构Sonnet/effort medium
复杂的调试、架构Opus/effort high
快速提问俳句(通过 /btw)

CLAUDE.md优化

  • 将主CLAUDE.md保持在200行以下。它加载在每条消息上
  • 将详细说明转化为技能。它们仅在调用时加载
  • 使用 @file 导入大型参考文档,而不是粘贴内容
  • 将路径特定规则放入 .claude/rules/。它们仅在Claude触摸匹配文件时加载

MCP和工具优化

  • 使用禁用未使用的MCP服务器 /mcp每个服务器都将工具定义添加到上下文中
  • 使用CLI工具(gh, aws, gcloud)当单个命令工作时,使用MCP
  • ENABLE_TOOL_SEARCH=auto:5 当工具定义超过上下文的5%时,自动推迟工具定义

CI/CD预算控制

# Hard spending limit
claude -p "fix failing tests" --max-budget-usd 2.00

# Limit agentic turns
claude -p "review this file" --max-turns 3

# Use cheapest model for simple CI tasks
claude -p "check for linting errors" --model haiku

______________________________________________________________________

诊断

--debug-详细日志记录

当您需要确切了解Claude Code正在做什么时(API调用、工具调用、计时):

# Full debug output to stderr
claude --debug

# Filter to specific categories
claude --debug "api,hooks"

# Write debug logs to a file (keeps terminal clean)
claude --debug-file /tmp/claude-debug.log

当MCP服务器未连接、挂钩未启动或API调用以静默方式失败时很有用。

/医生-健康检查

/doctor 当事情不正常时。它检查:

  • Claude代码版本和自动更新程序状态
  • 身份验证状态和令牌有效性
  • API连接
  • 设置文件语法和冲突
  • MCP服务器运行状况
  • 权限配置

/见解-会话分析

/insights 在长时间的会议后,获得一份分析报告,内容包括:

  • 按类别划分的代币使用情况
  • 会话中最昂贵的操作
  • 使用Claude代码的模式
  • 提高效率的建议
  • 等待时间与积极工作时间

使用此功能可以识别浪费代币的习惯并调整您的工作流程。

______________________________________________________________________

IDE集成

Claude Code与VS Code和JetBrains IDE集成,用于内联差异、上下文共享和并排对话。

VS代码

  • 从VS Code市场安装“Claude Code”扩展
  • 打开命令选项板(Cmd+Shift+P 在Mac上/ Ctrl+Shift+P 在Linux/Windows上)并搜索“克劳德代码”
  • 也适用于光标编辑器

JetBrains(IntelliJ、PyCharm、WebStorm等)

  • 从JetBrains市场安装“Claude Code”
  • 适用于所有JetBrains IDE
  • 支持交互式差异和上下文共享

使用IDE自动检测启动Claude:

claude --ide

______________________________________________________________________

自动模式

自动模式使用AI分类器来决定每个工具调用是否需要您的批准。它不是在每个命令上都提示,而是允许安全操作(读取、git状态、测试运行)并自动阻止有风险的操作(强制推送、rm-rf、生产部署)。启用它 --permission-mode auto 或按 Shift+Tab 骑自行车去。

检查分类器规则:

# View current auto-mode config
claude auto-mode config

# View default allow/deny rules
claude auto-mode defaults

# Get AI feedback on your custom rules
claude auto-mode critique

在中自定义规则 .claude/settings.json~/.claude/settings.json 在...之下 autoMode 钥匙与 allow, soft_deny,以及 environment 阵列。

______________________________________________________________________

自动化脚本

链式多 claude -p 在bash脚本中调用可重复工作流:

#!/bin/bash
# Automated PR review pipeline
git diff HEAD~1 > /tmp/diff.txt
cat /tmp/diff.txt | claude -p "review for security issues" --model sonnet > security_review.md
cat /tmp/diff.txt | claude -p "check for performance regressions" --model sonnet > perf_review.md
cat /tmp/diff.txt | claude -p "write a one-paragraph summary" --model haiku > summary.md

批量处理多个文件:

#!/bin/bash
# Generate docstrings for all Python files missing them
for f in $(grep -rL '"""' src/*.py); do
  claude -p "add docstrings to functions missing them in $f" \
    --allowedTools "Read,Edit" --max-turns 3
done

从git标签生成更改日志:

git log v1.0.0..v2.0.0 --oneline | \
  claude -p "create a changelog grouped by feature, fix, and chore" \
  --output-format text > CHANGELOG.md

______________________________________________________________________

/循环-重复任务

/loop slash命令在会话中以重复的间隔运行提示符或另一个slash命令:

# Check deploy status every 5 minutes
/loop 5m check if the deploy on staging is complete

# Run tests every 10 minutes (default interval)
/loop /test

# Custom interval with a slash command
/loop 2m /security-review

循环在后台运行,直到您停止它或结束会话。每次迭代都有自己的上下文,因此长时间运行的循环不会使对话膨胀。

______________________________________________________________________

快速参考卡

您每天将使用的20个命令和快捷键:

行动如何
开始新会话claude
继续上次会话claude -c
初始化项目/init
切换到计划模式Shift+Tab
交换机型号/model opusOption+P / Alt+P
撤消更改Esc + Esc
自由上下文空间/compact
重新开始/clear
检查成本/cost
审查变更/diff
安全扫描/security-review
命名会话/rename my-feature
恢复会话/resumeclaude -r
提及一个文件@path/to/file
直接运行bash!ls -la
多行输入\ + Enter
取消生成Ctrl+C
退出Ctrl+D
非交互式claude -p "query"
显示所有命令/help

______________________________________________________________________

子命令参考

子命令它做什么
claude agents列出已配置的代理及其描述
claude auth管理身份验证(登录、注销、令牌信息)
claude auto-mode config打印有效的自动模式分类器规则
claude auto-mode defaults显示默认允许/拒绝规则
claude auto-mode critique获取有关自定义自动模式规则的AI反馈
claude doctor自动更新程序、身份验证、MCP、设置的健康检查
claude install [target]安装特定版本(稳定、最新或版本号)
claude mcp从CLI配置和管理MCP服务器
claude plugins管理Claude代码插件
claude setup-token设置长期身份验证令牌(需要订阅)
claude update检查并安装更新

______________________________________________________________________

相关资源

______________________________________________________________________

贡献

发现缺少的命令或过时的标志?打开一个问题或提交PR。欢迎所有投稿。

许可证

该项目根据MIT许可证获得许可。看 许可证 了解详情。

目录标签

目录标签

编程辅助工作流自动化Claude命令行工具本地部署代码重构AI开发工具

支持客户端

ClaudeVS Code

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

token

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明token部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP