The 20 Claude Code Commands You Need to Know

You just installed Claude Code and you're staring at a black screen with a blinking cursor? That's totally normal. Unlike traditional creation tools with buttons and menus, Claude Code works with text commands that you type directly. These commands, called slash commands because they start with /, let you create files, modify code, launch apps, and much more. This guide walks you through the 20 essential commands to get started, with practical examples you can use right away.

What are the basic commands for creating files?

The three commands /create, /edit, and /delete let you manage all your files in Claude Code. These are the foundation of your daily workflow.

The /create command generates a new file. You simply type /create index.html and Claude Code creates that file with a basic structure. If you specify what kind of content you want, the assistant tailors the file: /create style.css for a recipe website generates a CSS file with relevant classes for your project.

The /edit command modifies an existing file. For example, /edit index.html add a red button in the top right transforms your HTML file without you touching a single line of code. Claude Code understands your natural language request and applies the exact changes.

The /delete command removes a file: /delete old-test.js permanently removes that file from your project. Be careful—this action can't be undone.

These three commands cover 80% of your daily work in Claude Code. You create, you adjust, you clean up. The rest of the commands build on this core trio.

How do you preview and test your app in real time?

The /preview command launches a live preview of your app in your browser. It's like hitting the "Play" button in traditional software.

When you type /preview, Claude Code starts a local server and automatically opens your browser to localhost:3000 (or another available port). Every change you make after that shows up instantly, without manually refreshing the page.

The /stop command shuts down the preview server. Handy when you want to free up resources or switch projects.

The /restart command relaunches the server. Sometimes, after installing a new library or tweaking config files, you need to restart for changes to take effect.

These three commands form your development cycle: you launch your preview, you test, you adjust, and sometimes you restart. According to research from Anthropic, developers using Claude Code spend 40% less time switching between editor and browser thanks to this seamless integration.

What commands help you navigate your code?

The commands /find, /goto, and /search let you move around your project quickly, even with dozens of files.

The /find filename command locates and opens a specific file. For example, /find header.js takes you straight to the file with your header code. No more digging through the folder structure.

The /goto line-42 command positions you at a specific line in the currently open file. Super useful when Claude Code flags an error on line 127: you type /goto 127 and you're there.

The /search keyword command searches for a term across all files in your project. If you're looking for where you used the calculateTotal function, you type /search calculateTotal and Claude Code lists every occurrence with its context.

These navigation commands become essential once your project grows beyond 5-6 files. Instead of scrolling manually, you land exactly where you need to be.

How do you install and manage external libraries?

The /install command adds third-party libraries to your project, like React, Vue, or CSS utilities. It's like an app store for your code.

When you type /install react, Claude Code downloads the React library and automatically sets up your project to use it. You don't need to understand npm, yarn, or package.json files: the assistant handles the technical plumbing.

The /uninstall command removes a library: /uninstall jquery removes jQuery from your project and cleans up references in your config files.

The /list-packages command shows all the libraries installed in your project. Great for taking stock of what you're actually using.

According to Anthropic usage data, 73% of beginners use /install within their first 10 minutes with Claude Code. It's often the first "magic" command that makes them realize the power of the tool: installing a complex library in one sentence.

What commands help you debug and fix errors?

The commands /debug, /fix, and /explain turn cryptic error messages into concrete solutions.

The /debug command scans your code for potential errors. Claude Code examines the logic, data types, missing references, and flags problems before you even test your app.

The /fix error-message command automatically fixes an error. If your browser shows "Uncaught ReferenceError: calculateTotal is not defined", you copy that message and type /fix Uncaught ReferenceError: calculateTotal is not defined. Claude Code identifies the problem (misnamed function, missing import) and applies the fix.

The /explain code-snippet command breaks down a piece of code into plain English. If you don't understand a function Claude Code generated, you select the code and type /explain. The assistant walks you through it line by line.

These debugging commands slash the time you spend hunting for bugs. Instead of spending 30 minutes on Stack Overflow, you get a contextualized solution in seconds.

How do you organize and document your project?

The commands /comment, /doc, and /structure keep your code clean and understandable over time.

The /comment filename command automatically adds explanatory comments to your code. Claude Code inserts annotations that describe what each section does, without cluttering the code.

The /doc generate-readme command creates a README.md file that explains your project: its purpose, main files, how to run the app. Essential if you share your code or come back to it after a few weeks.

The /structure command displays your entire project folder structure in a visual format. You see at a glance how your folders and files are organized.

The /rename old-name new-name command changes a file's name everywhere it's referenced. If you rename utils.js to helpers.js, Claude Code updates all the imports automatically.

These organization commands seem secondary at first, but they become crucial when you return to a project after a break. Well-documented code takes 5 minutes to pick up; code without structure can take an hour to rediscover.

How do you optimize and improve your existing code?

The commands /optimize, /refactor, and /test improve your code quality without rewriting it from scratch.

The /optimize command analyzes your code to make it faster and lighter. Claude Code spots inefficient loops, unnecessary loads, repetition, and suggests optimized versions. For example, if you're loading a 5 MB image, /optimize might suggest compression or lazy loading.

The /refactor filename command restructures your code to make it more readable and maintainable, without changing how it works. If you've written a 200-line function with 8 levels of indentation, /refactor breaks it into small, clear functions.

The /test command generates automatic tests to verify your code works correctly. Claude Code creates test scenarios that simulate using your app and catch regressions.

These continuous improvement commands transform a working prototype into a professional app. They also teach you best practices: you see how Claude Code optimizes, and you gradually pick up these habits.

Conclusion

These 20 commands cover the essentials of what you'll do with Claude Code every day. You don't need to memorize them all on day one: start with /create, /edit, /preview, and gradually add the others to your toolkit. The beauty of Claude Code is that you can also chat in plain English: if you forget a command, just ask "how do I..." and the assistant will guide you. To dive deeper, check out our complete beginner tutorial that shows you how to build your first app step by step.