If you've been using Claude Code just to type out requirements, you're missing out on a suite of terminal commands that can drastically improve your AI coding workflow. Many developers use Claude Code for months without realizing these hidden commands, leading to low efficiency and avoidable mistakes — like AI messing up core code, conversations going off-track, or not knowing how to undo broken changes. Let's break down 12 practical terminal commands for Claude Code, categorized into three tiers for beginners, regular developers, and advanced users.
Tier 1: Beginner-Friendly Commands (Daily Development Essentials)
These commands are zero-friction and essential for everyday coding tasks.
1. /init — Project Initialization Wizard
Kickstart new projects with this command. It automatically identifies your tech stack and directory structure, then generates a CLAUDE.md file to store project context. For a full Claude Code installation and setup guide, check out the first article in our series.
/init
Use it as the first command for any new project to set a solid foundation.
2. /help — Official Command Reference
Forgot how a command works? /help pulls up the official documentation instantly.
/help [command]
Replace [command] with the command you need help with (e.g., /help /diff).
3. /clear — Reset Conversation
Wipe current session history and reset the chat state. Perfect for switching projects or requirements without opening a new window.
/clear
4. /ls — List Project Directory
Get a full overview of your project's file structure without manually navigating folders. Helps AI and you stay oriented.
/ls
Tier 2: Must-Know Commands for Avoiding Pitfalls (Development Staples)
These commands tackle common pain points like tracking code changes, undoing mistakes, and keeping conversations focused.
5. /diff — Track Code Changes
See exactly what files and lines AI modified. Verify changes before saving to prevent unexpected edits to core code. This is especially useful when building real projects with Claude Code.
/diff
6. /undo — Undo Last Changes
Rescue your project from broken edits. This command undoes all recent file changes made by AI.
/undo
7. /compact — Streamline Context
Prevent AI from going off-topic by trimming irrelevant conversation history. Keeps discussions focused on core requirements.
/compact
8. /mode — Switch Interaction Modes
Toggle between plan (planning), edit (coding), and ask (Q&A) modes. Use /mode ask for a read-only Q&A mode to avoid accidental code changes.
/mode ask
Tier 3: Advanced Commands for Power Users (Critical Scenario Savers)
These lesser-known commands solve niche but crucial problems like protecting files and resetting project states.
9. /exclude — Lock Critical Files/Directories
Prevent AI from modifying sensitive files (e.g., core configs or dependencies). Specify paths to lock. For more on securing your workspace, read our MCP server configuration guide.
/exclude path/to/file-or-directory
10. /reset — Full Project Reset
Go beyond /clear — this command resets both conversation history and temporary project states. Ideal for completely fresh project starts.
/reset
11. /cat — View File Contents
Quickly inspect a file's full content by specifying its path — no need to open it manually.
/cat path/to/file
12. /reload — Sync Manual File Changes
If you edit files outside Claude Code, /reload ensures AI uses the latest versions.
/reload
Why These Commands Matter
These 12 commands cover every stage of development: project setup, daily coding, debugging, and risk management. They eliminate guesswork, prevent costly mistakes, and keep your workflow efficient. Whether you're a beginner or an expert, integrating these commands into your Claude Code routine will save time and headaches. For a deeper dive, check out our top Claude Code commands guide and the advanced Claude Code features article.
Save this guide and refer back to it whenever you need to streamline your AI coding process!
Frequently Asked Questions
Q: What is the difference between /clear and /reset in Claude Code?
/clear only resets the current conversation history while keeping the project context intact. /reset goes further by resetting both conversation history and temporary project states, making it ideal for starting completely fresh on a project without restarting the terminal.
Q: Can I use Claude Code commands like /undo and /diff on any operating system?
Yes, all Claude Code commands work identically across Windows (PowerShell), macOS (Terminal), and Linux. Commands like /diff and /undo operate on the project files regardless of your operating system.
Q: How do I protect important files from accidental AI modifications?
Use the /exclude command followed by the file or directory path to lock critical files. You can also use /mode ask for a read-only Q&A session to prevent any accidental modifications while discussing your code.