Claude Code: Master Configuration for Performance

Le brief IA que les pros lisent chaque soir
Les 7 actus IA du jour, décryptées en 5 min. Gratuit.
Inclus dès l'inscription : notre sélection des meilleurs guides & comparatifs IA.
Choisis ton rythme
Gratuit · Pas de spam · Désabonnement en 1 clic
Introduction to Claude Code: Surpassing the Limits of Default Configuration
For many users of Claude Code, the first day of use often boils down to a quick installation, followed by a few prompt tests, and then a gradual abandonment of configuration tweaks. However, this minimalist approach often leads to sessions where past decisions are forgotten, permissions are constantly requested, and lengthy tasks end with context warnings, forcing users to restart conversations.
These limitations are not inherent to the Claude Code model itself, but rather to the default configuration. While Claude Code comes with reasonable initial settings, there is a notable difference between these settings and optimal performance. This difference primarily lies in a few configuration files that beginners often overlook. This guide aims to bridge that gap by detailing the configurations, permissions, hooks, and command habits that transform a basic installation into a robust tool for sustained agentic work, relying on the current documentation from Anthropic.
Optimal Installation of Claude Code
Claude Code installs as a standalone command-line interface (CLI). The recommended installation path is the native installer, although using npm remains a viable alternative:
Installation on macOS, Linux, or WSL
curl -fsSL https://claude.ai/install.sh | bash
Installation via Windows PowerShell
irm https://claude.ai/install.ps1 | iex
Installation via npm
npm install -g @anthropic-ai/claude-code
Once installed, it is crucial to navigate to a specific project directory before launching Claude Code for the first time. This is more important than it seems because Claude Code limits its project memory and settings to the directory from which it is launched. Starting from a personal folder or the desktop means it will never capture the right context for the ongoing project.
cd your-project-directory
During the first run, you will be guided through the authentication process, which can be done via an OAuth login with a Claude subscription (Pro, Max, or Team) or an API key linked to a Console account. Outside of the terminal, Claude Code is also accessible via a VS Code extension, a JetBrains plugin, a desktop application, and a web version on claude.ai for sessions you wish to resume from a browser. All these environments share the same settings and project files, so no configuration is lost when transitioning between these tools.
Crucial Configuration Files
Claude Code reads its configuration from two locations: the .claude/ directory of your project and a global ~/.claude/ directory that applies to all projects on your machine. Understanding what is located where is essential for the tool to function effectively or not, according to Anthropic's documentation on the .claude directory structure.
The CLAUDE.md file serves as the project's memory, containing instructions that Claude reads at the beginning of each session in this repository. It can include architecture notes, build and test commands, coding style rules, and anything else that would need to be re-explained in each session. By running /init in a new project, Claude Code will analyze the codebase and generate an initial CLAUDE.md that you can refine with /memory. It is advisable to keep it concise, under 2,500 tokens, and to move any lengthy or specific content into .claude/rules/*.md files, which can be loaded only when Claude touches corresponding files.
The settings.json file, located at .claude/settings.json for project-level configuration or ~/.claude/settings.json for personal default values, is where permissions, hooks, environment variables, and model default values actually reside. This is the file that most beginners never open, and it is directly responsible for two of the most common complaints regarding the tool: constant permission interruptions and Claude opting for a more expensive model than necessary.
Automatic memory is a newer and subtle feature: Claude can write and read its own working notes during a session without you having to directly manage a file, enabled with the autoMemoryEnabled setting or the CLAUDE_CODE_DISABLE_AUTO_MEMORY environment variable if you prefer to keep memory entirely manual and auditable via CLAUDE.md only.
The practical rule that connects these elements, repeated in Anthropic's documentation and independent analyses of the configuration system, is as follows: stable rules belong in CLAUDE.md, as instructions buried only in conversation history are lost the moment a long session triggers automatic compression. If a rule needs to survive beyond today’s session, write it down.
Configuring Permissions and Hooks
Claude Code operates in one of three permission modes, cycled with Shift+Tab:
- Default, which asks before each potentially risky tool call.
- Auto-Accept Edits, which allows file modifications without asking while keeping other tools under control.
- Plan Mode, which is read-only — no modifications, no shell commands — until you approve a plan. Plan Mode is worth using by default for your first sessions in an unknown codebase, as it forces Claude to propose before acting.
Beyond interactive modes, settings.json allows you to write real permission rules, so you are not manually approving the same safe command fifty times per session:
"permissions": {
"Bash(npm test:*)",
"Bash(npm run lint:*)",
"Bash(git push:*)",
"Bash(rm -rf /*)"
}
What this does: anything matching allow executes without prompt, anything matching deny is blocked unconditionally, and anything not listed returns to asking you directly. This order of deny first is important: a deny rule always takes precedence, even if a broader allow rule would otherwise cover it, allowing for fairly broad read and test execution access without opening the door to destructive commands.
Hooks go a bit further than permission rules, as a rule can only allow or block a call, while a hook can actually execute something in response to a call. A PostToolUse hook that automatically reformats every file that Claude edits is one of the most recommended starting points:
"PostToolUse": [
{
"matcher": "Write|Edit",
"type": "command",
"command": "npx prettier --write \"$CLAUDE_TOOL_INPUT_FILE_PATH\""
}
]
What this does: every time Claude writes or edits a file, this hook then triggers and runs Prettier against exactly the file that changed, using the path that Claude Code passes via the environment variable $CLAUDE_TOOL_INPUT_FILE_PATH. You stop manually reformatting after each change, and your style rules apply consistently whether Claude wrote the file or you did.
A PreToolUse hook can go further and actually block a dangerous command before it executes, which is a stronger guarantee than a permission rule alone, as it can inspect the exact text of the command rather than just matching a pattern:
#!/usr/bin/env python3
# .claude/hooks/block-dangerous-bash.py
import json, re, sys
DANGEROUS_PATTERNS = [
r'\brm\s+.*-[a-z]*r[a-z]*f',
r'git\s+push\s+--force.*main'
]
input_data = json.load(sys.stdin)
if input_data.get('tool_name') == 'Bash':
command = input_data.get('tool_input', {}).get('command', '')
for pattern in DANGEROUS_PATTERNS:
if re.search(pattern, command, re.IGNORECASE):
print("BLOCKED: matches a dangerous command pattern", file=sys.stderr)
What this does: Claude Code sends the details of the tool call to this script as JSON on stdin before the command executes. If the bash tool is about to execute something matching a forced recursive deletion, a sudo rm, a world-writable chmod, or a forced git push to main, the script prints a reason and exits with code 2, which Claude Code's hook system treats as a strict block — stopping the command before it executes. Save it in settings.json under PreToolUse with a Bash matcher, and it becomes a permanent safety net rather than something you have to remember to check manually.
Commands to Master First
Claude Code comes with over sixty built-in commands to date, and trying to memorize them all on the first day is a waste of time. The table below covers those that actually change the performance of a session, organized by their function, drawn directly from the official command reference of Claude Code.
/init: Scans your codebase and generates a starting CLAUDE.md./edit CLAUDE.md: Opens CLAUDE.md for direct editing./start: Begins a new conversation while retaining project memory./compact [focus]: Summarizes the conversation history to free up context; accepts instructions on what to preserve./usage: Shows the current usage of the context window./plan: Activates Plan Mode; Claude proposes before acting, nothing executes until you approve./diff: Opens an interactive diff of every change made during this session./code-review [--fix]: Checks the current diff for fixable bugs; --fix applies the results./security-review: Checks the current diff specifically for security vulnerabilities./resume [session]: Resumes a previous conversation by name or ID./branch [name](alias/fork): Forks the current conversation into a new session./rollback: Restores the code and/or conversation to an earlier checkpoint./cost: Changes the active model during the session without losing context./depth: Sets the reasoning depth (low to max) to match the complexity of the task./tokens: Shows token usage and spending for API key users./agents: Manages sub-agents — view, create, or invoke specialized agents./permissions: Manages permission rules interactively./hooks: Manages hooks interactively./check: Checks your installation for configuration issues.
A useful habit for a beginner: first build your comfort with /compact, /plan, and /diff, as these three commands alone resolve the majority of initial frustrations — sessions degrading due to context clutter, modifications going further than intended, and not knowing exactly what has been done.
Brief IA — L'actualité IA en français
L'essentiel de l'actualité de l'intelligence artificielle, décrypté et expliqué chaque jour.