.claude/commands/code-review.md
--- description: Review the current diff for correctness, security, and maintainability issues argument-hint: [target] allowed-tools: Read, Grep, Glob, Bash(git diff *) --- # code-review Review the current changes. Focus on correctness bugs, regressions, missing tests, security risks, and unnecessary complexity. Return findings first, ordered by severity. ## Project Context - Project type: Next.js - Tech stack: Next.js, TypeScript, React, CSS modules - Validation: npm test, npm run lint, npm run build ## Output Summarize what you checked, what changed, and which validation commands passed or still need to run.
使用 Claude Code Custom Commands Generator 生成可复用的 markdown 命令,把 code review、PRD、refactor、test、security、changelog、commit message 等重复提示词变成 slash command。
Custom Commands 与 Skills
旧版 .claude/commands markdown 文件仍然可用,但 Claude Code 现在更推荐用 skills 承载更复杂的可复用工作流。小型提示词仍适合用 custom command 快速落地。
Claude Code 官方引用
官方 slash commands 和 skills 文档覆盖文件位置、frontmatter、参数、bash 执行、文件引用、命名空间,以及从 custom commands 迁移到 skills 的路径。
常见错误
避免提示词过空、allowed-tools 权限过宽、本地绝对路径、读取 unstaged diff 却假设 staged files,以及命令名与内置命令冲突。
常见问题
哪个文件名会变成 slash command?
对于旧版 custom commands,markdown 文件名去掉 .md 后就是命令名。
Custom command 能运行 shell 命令吗?
可以,但工具权限应该尽量窄,并在提交到团队仓库前审查。
什么时候应该改用 skill?
当工作流需要支持文件、长说明、自动触发或跨项目共享时,用 skill 更合适。