How I use Claude Code (+ my best tips)
安装 Claude Code 插件
@文件 /命令
/clear 清除上下文
使用 claude --dangerously-skip-permissions 自动通过权限请求
/install-github-app 自动审查PR,下面这个提示词可以简化审查的行为
# claude-code-review.yml
direct_prompt: |
Please review this pull request and look for bugs and security issues. Only report on bugs and potential vulnerabilities you find. Be concise.
Shift+Enter 不适用于换行。只需执行 /terminal-setup,能够解决这个问题。
在正常情况下拖拽文件会像在 Cursor 或 VS Code 中那样在新标签页中打开。在拖拽时按住 Shift 键可以正确地在 Claude 中引用它们
从剪贴板粘贴图片无法使用 Command+V,应使用 Control+V
使用 ESC 键来停止 Claude
CLAUDE.md 文件,其中包含一些项目概述和一些它应该知道的关键命令
可以在项目目录中的 .claude/settings.json 文件中创建自己的钩子,或使用交互式 /hooks 命令,通过菜单界面来配置钩子
{
# 比如 PreToolUse(工具执行前)、PostToolUse(工具完成后)、Notification(Claude 发送通知时)和 Stop(Claude 完成响应时)。
"hooks": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "prettier --write \\"$CLAUDE_FILE_PATHS\\""
}
]
},
{
"matcher": "Edit",
"hooks": [
{
"type": "command",
"command": "if [[ \\"$CLAUDE_FILE_PATHS\\" =~ \\\\.(ts|tsx)$ ]]; then npx tsc --noEmit --skipLibCheck \\"$CLAUDE_FILE_PATHS\\" || echo '⚠️ TypeScript errors detected - please review'; fi"
}
]
}
]
}
要添加命令,只需创建一个 .claude/commands 文件夹,将命令名称作为带 .md 扩展名的文件添加进去。你只需用自然语言编写这些内容,并可以使用 $ARGUMENTS 字符串将参数放入提示中。
# .claude/hooks/test.md
Please create comprehensive tests for: $ARGUMENTS
Test requirements:
- Use Jest and React Testing Library
- Place tests in __tests__ directory
- Mock Firebase/Firestore dependencies
- Test all major functionality
- Include edge cases and error scenarios
- Test MobX observable state changes
- Verify computed values update correctly
- Test user interactions
- Ensure proper cleanup in afterEach
- Aim for high code coverage
可以使用 # 符号来超级快速地添加记忆