Boost Your Productivity 10× with Claude Code Slash Commands – Complete Guide
This tutorial walks through Claude Code’s built‑in slash commands, explaining each command’s purpose, when to use it, and providing concrete examples and demo prompts so developers can manage sessions, control context, run background tasks, and streamline AI‑assisted coding efficiently.
Session Management Commands
/clear removes the current conversation so a new task starts without residual context. The cleared session can be restored later with /resume.
/compact summarizes earlier dialogue to free context space. Claude Code’s context window is limited; when usage approaches the limit the model’s attention drifts and answer quality degrades. Running /compact after each logical milestone (e.g., after debugging a bug) lets you control which information is retained. You can add a directive to keep specific details, for example:
/compact 重点保留 API 接口的设计决策和参数定义/resume restores a cleared or paused conversation. After a break or after using /clear, you can select a recent session from the selector or specify its name/ID, e.g., /resume 昨天的重构任务.
/branch and /fork create a new branch from the current conversation, allowing exploration of an alternative direction without affecting the original flow. Return to the original branch with /resume. Example:
/branch 试试用 Redis 替代内存缓存的方案/rewind rolls back the conversation and code to a previously saved checkpoint. Claude automatically saves a checkpoint before each execution, so you can revert if a change goes wrong.
/recap generates a one‑sentence summary of the current session, useful for quickly recalling where you left off.
/btw inserts a side question without polluting the main context, acting like a temporary pop‑up window.
/copy copies the latest Claude reply (or a specific numbered reply) to the clipboard, with a selector for code blocks. Adding a number copies that reply, e.g., /copy 2 copies the second‑most recent reply.
/export exports the entire conversation as a plain‑text file. Adding a filename saves directly, e.g., /export 开发记录.txt.
/exit exits the Claude Code session (Ctrl+C twice also works). If background tasks or sub‑agents are running, Claude asks whether to terminate them.
Information & Diagnostics
/usage shows token usage and estimated cost for the current session, helping avoid unexpected charges.
/context visualizes current context consumption. Adding all expands detailed information for each component. /context all /diff opens an interactive diff viewer to see exactly what Claude changed in the codebase. It displays all uncommitted changes and allows navigation between the overall git diff and Claude’s per‑round modifications.
/status displays version, model, account, and connection status without waiting for the current reply to finish.
/help lists all available commands with brief descriptions.
/insights generates an analysis report of your Claude Code usage patterns, project directories, interaction modes, and recurring issues.
Model & Mode Control
/plan enters planning mode, prompting Claude to produce an execution plan before coding. Example:
/plan 重构整个项目,增加用户系统和 JWT 认证/goal sets a completion condition so Claude works autonomously until the condition is met. The condition must be verifiable from the dialogue (e.g., test suite passes). You can also add a circuit‑breaker limit to prevent infinite loops. Example with a limit of 20 rounds:
/goal 把所有 API 调用迁移到 v2 格式,直到测试通过,如果 20 轮还没搞定就停下来Typical verifiable conditions include:
npm test exits with code 0 and git status shows no uncommitted changes.
No TODO comments remain in src/ (Claude can grep and display the result).
Invalid examples such as “code quality must be good” are not usable because the evaluation model cannot assess subjectivity.
/model switches the underlying AI model; a selector UI appears after the command.
/effort adjusts the model’s reasoning depth from low to max (five levels). Use higher effort for complex tasks.
/fast toggles fast‑response mode, increasing speed by roughly 2.5× while keeping quality unchanged; token price is higher.
Configuration & Extensions
/config opens the settings UI to adjust theme, model, output style, and other preferences.
/mcp , /skills , and /plugin manage MCP server connections, custom Skills, and plugins that extend Claude’s capabilities. MCP enables AI to interact with external tools (e.g., databases, browsers). Skills are reusable custom commands, and plugins bundle multiple skills, themes, and hooks.
Code Review
/review runs an automated review of the current branch’s Pull Request, launching parallel sub‑agents to detect bugs and logic errors. You can specify a PR number, e.g., /review 42.
/simplify analyzes recent changes for code reuse, quality, and performance, then automatically applies fixes. You can focus the simplification, for example on memory efficiency:
/simplify 重点关注内存效率Sub‑Agents & Parallelism
/agents shows and configures sub‑agents; most users rely on automatic handling.
/tasks lists currently running background tasks and lets you inspect each sub‑agent’s progress.
/background moves the whole session to the background, freeing the terminal. You can add a final instruction before detaching, e.g.:
/background 编写单元测试并运行,执行失败则自动修复/loop sets a periodic execution interval for a command, useful for monitoring deployments or logs. Example checking deployment status every 5 minutes:
/loop 5m 检查项目前后端的部署状态https://github.com/liyupi/ai-guide
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
IT Services Circle
Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
