Aller au contenu principal
claude-code-commandes-slash-guide-developpeurs

Claude code: 10 essential commands for beginners

Back to blog
Artificial Intelligence
Nicolas
9 min read
claude-code-commandes-slash-guide-developpeurs

You’ve just launched Claude Code for the very first time. The terminal is waiting for your command. So now you’re wondering: where do you start? The answer: Claude slash commands. These shortcuts turn a simple AI agent into a genuine development partner. Once mastered, they’ll cut your configuration time by 40% and streamline every step of your AI developer workflow.

Claude Code is Anthropic’s CLI tool that understands your code, edits your files, and executes shell commands.

But its real power lies in its native and custom Claude Code commands, which automate repetitive tasks and preserve the context of your sessions.

Here are the 10 commands that will change the way you code.

The Native Slash Commands: Your Survival Kit

Type / then Tab in Claude Code: about fifteen commands are shown. Five of these cover 95% of your daily needs.

/init: The Starting Point Of Every Project

This command automatically generates a CLAUDE.md file at the root of your project. This file acts as persistent memory: it stores your team conventions, repo structure, and critical dependencies. Claude Code reads it at each session and tailors its answers accordingly.

When to use it? As soon as you open a new project or join a team. Only one run needed.

/init

Claude analyzes your repo, detects the main language, the frameworks in use, and suggests a pre-filled CLAUDE.md. All you have to do is tweak it.

/review: Instant Code Review

No more hours spent reviewing code before a merge. /review analyzes the current diff or a specific file and flags issues: potential bugs, convention violations, possible optimizations.

When to use it? Before each pull request, after major refactoring, or when you inherit some obscure legacy code.

/review src/auth/login.ts

Claude Code won’t replace a human review, but it will catch 80% of obvious mistakes that fatigue might let slip through.

/compact: Save Your Context In Long Sessions

Debugging sessions can last for hours. The problem? The conversation context blows up, and Claude loses track. /compact compresses the history while preserving the essentials: decisions made, files changed, bugs fixed.

When to use it? As soon as you feel the answers get less relevant or the session starts slowing down. In general, every 30-45 minutes of focused work.

/compact

/clear: Start From Scratch

Sometimes the accumulated context gets in the way. You switch topics—from a frontend bug to a database migration, for example. /clear wipes the history and frees up memory.

When to use it? When you’re switching to a radically different task or when Claude seems “stuck” in a faulty line of reasoning.

/clear

/help: The Command 78% Of Beginners Use First

It’s only logical: /help shows the full list of commands, their keyboard shortcuts, and examples of usage. This is your built-in documentation.

/help

Quick tip: The /cost and /doctor commands round out this kit. The first displays your real-time token consumption. The second diagnoses installation issues—handy if Claude refuses to authenticate or access certain files.

The Custom Command System: Your Personalized Toolbox

Native commands don’t cover every use case. Want to automate React component creation? Generate unit tests according to your team’s standards? Custom commands are built for this.

Where To Store Them?

You have two options:

  • .claude/commands/ at your project root for repo-specific commands
  • ~/.claude/commands/ in your home directory for global commands, reusable anywhere

The name of the Markdown file becomes the command name. A refactor.md file in .claude/commands/ runs as /project:refactor.

Anatomy Of A Custom Command

---
name: fix-lint
description: Fixes ESLint errors in the current file
allowed-tools: Edit, Bash(npm run lint:fix *)
---
## Context
The project uses ESLint with the Airbnb config.

## Task
Analyze linting errors and fix them automatically.
Target file: $ARGUMENTS

The $ARGUMENTS variable captures what you pass after the command. Example: /project:fix-lint src/utils/helpers.js passes the file path to the command.

Practical Example: Generate A New Component

Create a file .claude/commands/component.md:

---
name: component
description: Generates a TypeScript React component with tests
allowed-tools: Edit, Bash(mkdir *)
---
## Task
Create a new React component in src/components/$ARGUMENTS/
- Main file: index.tsx
- Styles file: styles.module.css
- Test file: $ARGUMENTS.test.tsx

Use project conventions (hooks, no classes).

Usage: /project:component UserProfile. Claude creates all three files, respects your project conventions, and saves you 10 minutes.

Over 57 ready-to-use commands are available on the official GitHub repo, plenty to inspire your own automations.

CLAUDE.md: The Invisible Command That Changes Everything

This file isn’t a command in the strict sense. But its impact surpasses all the others. CLAUDE.md is read automatically at every session start. It contains:

  • Project description (tech stack, architecture)
  • Code conventions (naming, folder structure)
  • Frequent commands (npm scripts, make commands)
  • Traps to avoid (broken dependencies, files to leave untouched)

Without this file, Claude Code offers only generic responses. With it, every suggestion is context-aware for your project.

If you use another solution like Cursor AI, this is where the difference lies: Claude Code bets on persistent project memory rather than IDE integration.

A well-written CLAUDE.md is like automatic onboarding for your AI assistant—it understands your project in 2 seconds instead of 20 questions.

Concrete Use Cases: From Terminal To Production

Automated Pull Request Review

You get a PR with 400 lines changed. Instead of reading everything, you run:

git diff main...feature-branch | claude "/review this diff, focus on security and performance"

Claude returns a structured report: potential vulnerabilities, N+1 queries, unsanitized variables. You save 30 minutes and don’t miss key issues.

Fixing A GitHub Bug With Context

A user opens an issue: “500 error on /api/users when email contains a +”. You copy the issue URL and ask:

claude "Analyze this GitHub issue and suggest a fix: [URL]"

Claude grabs the context, locates the responsible file, and suggests a patch. If you’ve configured allowed-tools: Bash(git commit *) in a custom command, it can even create the commit directly. For even greater automation, creating AI agents with Make.com lets you orchestrate these workflows at scale.

Automatic Linting On Pre-Commit

Combine a custom command with a Git hook:

# .git/hooks/pre-commit
claude "/project:fix-lint $(git diff --cached --name-only)"

Each commit triggers an automatic lint fix. No more linting errors slipping through reviews.

Why Claude Code Stands Out From The Competition

Compared with alternatives like Antigravity or GitHub Copilot CLI, Claude Code offers unique flexibility. Custom Markdown commands are version-controlled with Git, easily shared with teammates, and endlessly extensible.

Cursor bets on VSCode integration; Claude Code is agnostic—it works in any terminal, on any project.

The 2025 updates introduce Skills (Beta) and subagent support for parallel task execution.

A single command can now trigger multiple agents working on different files in parallel. The AI developer workflow has never been so smooth.

Key point: Claude Code’s real strength isn’t in any single command, but in the combination of CLAUDE.md + custom commands + native commands. This ecosystem is what turns a tool into a true development partner.

Take Action

Run /help right now. Explore the available commands. Create your first file in .claude/commands/—even something simple like a commit message template. Then, set up your CLAUDE.md with your project’s specifics.

In one hour, you’ll have a setup that saves you time every day. And in a week, you’ll wonder how you ever coded without it.

FAQ

How do I install Claude Code on my machine?

Claude Code is installed via npm with npm install -g @anthropic-ai/claude-code. You’ll need an Anthropic API key configured in your environment variables. The /doctor command checks that everything is properly installed.

Do custom commands work with all languages?

Yes. Commands are written in Markdown and can target any language. It’s the prompt content and allowed tools (Edit, Bash) that determine what Claude can do, not your project’s language.

What’s the difference between /compact and /clear?

/compact compresses your history, preserving essential information—for long sessions. /clear wipes everything and starts fresh. Use compact to continue the same thread, clear when you’re fully changing context.

Can I share my custom commands with my team?

Absolutely. Files in .claude/commands/ are versioned with your Git repo. Each team member who clones the project automatically gets the same commands. That’s a major advantage over IDE extensions.

Is the CLAUDE.md file required?

No, but it’s highly recommended. Without it, Claude Code works with generic responses. With it, every suggestion is tailored to your specific project—conventions, structure, dependencies.

How much does it cost to use Claude Code?

Claude Code uses the Anthropic API, billed per tokens consumed. The /cost command shows your real-time usage. A typical development session costs between $0.10 and $2 depending on intensity.

Can I restrict the actions Claude can perform?

Yes. The allowed-tools field in custom commands limits available tools. You can allow only Edit (file modification), or add Bash with specific patterns like Bash(git diff *).

How do I debug a custom command that doesn’t work?

First, check your YAML frontmatter syntax (the three dashes and fields). Then, test the command with a simple argument. The /help command lets you confirm your custom command is detected in the list.

Can Claude Code run dangerous shell commands?

By default, Claude asks for confirmation before running any Bash commands. You can allow safe patterns in allowed-tools for trusted commands, but destructive actions always require explicit approval.

Is there a size limit for the CLAUDE.md file?

No strict limit, but an overly long file uses up unnecessary context. Aim for 200–500 lines max. Focus on information Claude can’t deduce automatically: team conventions, specific architecture, known pitfalls.

Related Articles

Ready to scale your business?

Anthem Creation supports you in your AI transformation

Disponibilité : 1 nouveau projet pour Avril/Mai
Book a discovery call
Une question ?
✉️

Encore quelques questions ?

Laissez-moi votre email pour qu'on puisse continuer cette conversation. Promis, je garde ça précieusement (et je ne vous bombarderai pas de newsletters).

  • 💬 Accès illimité au chatbot
  • 🚀 Des réponses plus poussées
  • 🔐 Vos données restent entre nous
Cette réponse vous a-t-elle aidé ? Merci !