Skip to main content

12 - Claude Code CLI: Essential Commands and Configuration

Claude Code CLI: Comandi Essenziali e Configurazione Claude Code non è solo un assistente AI: è un terminale potenziato che si integra nel workflow...

What do you think about this article?

At a Glance

Claude Code CLI: Comandi Essenziali e Configurazione Claude Code non è solo un assistente AI: è un terminale potenziato che si integra nel workflow...

Claude Code CLI: Essential Commands and Configuration

Claude Code is not just an AI assistant: it is a supercharged terminal that integrates into the developer's daily workflow. From the command line, you can manage files, run builds, launch tests, analyze code, and orchestrate complex tasks, all through a conversational interface that understands your project's context.

In this twelfth article in the series, we will explore in depth the Command Line Interface of Claude Code: installation methods on every platform, keyboard shortcuts that speed up your work, slash commands for agent control, the four-level configuration hierarchy, permission templates for security, and headless mode for CI/CD automation.

What You Will Learn

  • Install Claude Code on macOS, Linux, Windows, and WSL
  • Master keyboard shortcuts to speed up your workflow
  • Use all available slash commands
  • Understand the 4-level configuration hierarchy
  • Configure permission templates for different security scenarios
  • Run Claude Code in headless mode for CI/CD pipelines
  • Troubleshoot common installation and configuration issues
  • Optimize the CLI experience for daily work

Complete Series Overview

#ArticleFocus
1Claude as Technical PartnerSetup and first steps
2Context and Project SetupCLAUDE.md and configuration
3Ideation and RequirementsMVP and user personas
4Backend and Frontend ArchitectureSpring Boot and Angular
5Code StructureOrganization and conventions
6Advanced Prompt EngineeringAdvanced techniques
7Testing and QualityStrategies and test generation
8Professional DocumentationREADME, API, ADR
9Deploy and DevOpsDocker, CI/CD, monitoring
10Evolution and MaintenanceRefactoring and scalability
11Real Project IntegrationClaude Code in production
12Claude Code CLI (you are here)Commands and configuration
13Agent SkillsModular capabilities
14Specialized SubagentsRole-specific agents
15Hooks and AutomationEvent-driven workflows
16Ralph Wiggum MethodAutonomous iterative dev
17BMAD MethodAI-driven agile
18Multi-Agent OrchestrationAgent pipelines
19Claude CoworkAI for knowledge workers
20Security and PrivacyBest practices
21Monitoring and ProductivityMetrics and dashboards

1. Installing Claude Code

Claude Code supports multiple platforms and installation methods. The choice of method depends on the operating system and personal preferences. All methods install the same claude binary which is added to the system PATH.

Prerequisites

Before proceeding with the installation, make sure you meet the following requirements on your system:

System Requirements

RequirementMinimum VersionNotes
Node.js 18.0+ Required for the JavaScript runtime
npm 9.0+ Included with Node.js
Git 2.30+ For repository operations
Operating System macOS 12+, Ubuntu 20.04+, Windows 10+ (WSL2) Native support for Linux and macOS, WSL for Windows
Anthropic Account Pro, Max, or Team plan Required for API authentication

Method 1: Installation via npm (Recommended)

The most universal method is global installation via npm. It works on all platforms where Node.js is available and ensures simple updates.

Global installation with npm
# Global installation
npm install -g @anthropic-ai/claude-code

# Verify installation
claude --version

# First launch and authentication
claude

# Update to the latest version
npm update -g @anthropic-ai/claude-code

Method 2: Installation via curl (macOS and Linux)

For those who prefer to avoid npm, a direct installation script is available that downloads the precompiled binary. This method is particularly useful in environments without Node.js preinstalled.

Installation with curl
# macOS and Linux
curl -fsSL https://cli.anthropic.com/install.sh | sh

# Verify that the binary is in the PATH
which claude
# Expected output: /usr/local/bin/claude

# First run
claude

Method 3: Installation via Homebrew (macOS)

macOS users who use Homebrew as their package manager can install Claude Code through the official tap. This method integrates Claude Code into Homebrew's centralized package management.

Installation with Homebrew
# Add the official Anthropic tap
brew tap anthropics/claude-code

# Installation
brew install claude-code

# Update
brew upgrade claude-code

# Verify version
claude --version

Method 4: Installation on Windows (PowerShell + WSL)

On Windows, Claude Code requires WSL2 (Windows Subsystem for Linux) to work properly. The installation can be performed directly from Windows PowerShell or from within the WSL terminal.

Installation on Windows with WSL
# Step 1: Install WSL2 (if not already installed)
wsl --install

# Step 2: Open the WSL terminal (Ubuntu)
wsl

# Step 3: Install Node.js in WSL
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

# Step 4: Install Claude Code
npm install -g @anthropic-ai/claude-code

# Step 5: Verify
claude --version

# Alternative: Direct installation from PowerShell
# (Requires Node.js installed on Windows)
npm install -g @anthropic-ai/claude-code

Note on Windows Compatibility

Claude Code on Windows works best with WSL2 because many development tools (Git, compilers, build tools) are natively supported on Linux. If you work with projects that require Unix-like tools, WSL2 is strongly recommended. The native PowerShell experience is supported but may have limitations with certain system commands.

Authentication

After installation, the first launch of claude starts the authentication flow. Claude Code supports two main authentication methods.

Authentication Methods

MethodUseConfiguration
Anthropic Console Individual Pro/Max accounts Automatic browser login on first launch
API Key Team, Enterprise, CI/CD accounts Environment variable ANTHROPIC_API_KEY
AWS Bedrock Enterprise on AWS infrastructure AWS credentials configuration
Google Vertex AI Enterprise on GCP infrastructure Google Cloud credentials configuration
API Key Configuration
# Method 1: Environment variable (current session)
export ANTHROPIC_API_KEY="sk-ant-api03-xxxxx"

# Method 2: .env file in the project root
echo 'ANTHROPIC_API_KEY=sk-ant-api03-xxxxx' >> .env

# Method 3: Permanent configuration in .bashrc or .zshrc
echo 'export ANTHROPIC_API_KEY="sk-ant-api03-xxxxx"' >> ~/.zshrc
source ~/.zshrc

# Verify authentication
claude --print-auth-status

2. Keyboard Shortcuts

Keyboard shortcuts are essential for efficient use of Claude Code. Knowing them allows you to quickly switch between operating modes, manage context, and control the execution flow without interrupting your work rhythm.

Complete Shortcuts Table

ShortcutActionDetailed Description
! Bash Mode Activates direct Bash mode. Type ! followed by the command to execute it in the terminal without Claude interpreting it as a prompt. Example: !npm test directly runs the tests.
@ Mention File/Folder Mentions a file or folder to add them to the current context. Supports Tab autocompletion. Example: @src/app/services/ loads the entire folder into the context.
Esc Interrupt Interrupts Claude's current operation. Useful when a generation is going in the wrong direction or taking too long.
Esc + Esc Rewind Menu Double pressing Escape opens the rewind menu that allows you to go back to a previous state of the conversation, undoing Claude's last actions.
Ctrl+R Full Output Shows the complete output of the last executed command, including parts that may have been truncated for brevity.
Shift+Tab Auto-Accept (YOLO Mode) Activates automatic acceptance mode for subsequent operations. Claude will execute actions without asking for confirmation. Use with caution in production environments.
Shift+Tab+Tab Plan Mode Activates planning mode. Claude analyzes the task, creates a structured plan, and presents it for approval before executing any action.
Ctrl+C Cancel Input Cancels the text typed in the current input without interrupting the Claude Code session.
Ctrl+D Exit Closes the current Claude Code session while saving the conversation history.
Tab Autocompletion Autocompletes file names, folders, and slash commands in the input prompt.

YOLO Mode: Usage and Precautions

YOLO mode (You Only Live Once) activated with Shift+Tab is a powerful but dangerous tool. When active, Claude executes all operations - including file modifications, command execution, and package installation - without asking the user for confirmation.

When to Use YOLO Mode

  • Rapid prototyping: When you are exploring ideas in a dedicated branch
  • Automated refactoring: When you have already validated the plan and want fast execution
  • Boilerplate generation: When Claude needs to create many similar files
  • Sandbox environments: When working in Docker containers or disposable VMs

When NOT to Use YOLO Mode

  • Production: Never on main/master branches or production environments
  • Destructive operations: When the task could involve file deletion
  • System commands: When Claude might execute commands with sudo
  • Sensitive data: When the context contains credentials or confidential data

Plan Mode: Structured Planning

Plan mode (Shift+Tab+Tab) is the opposite of YOLO mode. It forces Claude to create a detailed plan before executing any action. The plan includes:

  • Analysis of the requested task and identification of involved files
  • Ordered sequence of operations to execute
  • Potential risks and dependencies between operations
  • Estimate of the number of files to modify
  • Explicit request for approval before execution
Example of Plan Mode in action
# Activate Plan Mode with Shift+Tab+Tab, then type the prompt:
> Add email validation to the registration form

# Claude responds with a plan:
# Execution Plan:
# 1. Read src/app/auth/register.component.ts
# 2. Read src/app/auth/register.component.html
# 3. Add email validator to the FormGroup
# 4. Add error message in the template
# 5. Add tests for email validation
# 6. Update the validation service
#
# Files involved: 4
# Operations: 6
#
# Proceed? [y/n]

3. Slash Commands

Slash commands are special commands that control Claude Code's behavior. They are typed directly in the prompt preceded by the / character. Each command has a specific function for managing the session, context, and configuration.

Complete Slash Commands Table

CommandDescriptionUsage Example
/add-dir Adds a directory to the current working context /add-dir ../shared-libs to include shared libraries
/agents Shows and manages available subagents in the .claude/agents/ directory /agents to list all configured subagents
/clear Clears the current conversation history, freeing up context /clear after completing a task to start fresh
/config Opens and modifies Claude Code configuration files /config to view and modify settings
/help Shows the complete guide of available commands /help for quick reference
/mcp Manages configured MCP (Model Context Protocol) servers /mcp to see the status of connected servers
/model Changes the AI model used in the current session /model claude-sonnet-4-20250514 to switch to Sonnet
/permissions Views and modifies permissions granted to Claude Code /permissions to review what Claude can do
/rewind Goes back to a previous state of the conversation /rewind to undo the last actions
/status Shows the current session status, context, and token usage /status to check how many tokens have been used

Advanced Use of Slash Commands

Slash commands can be combined in logical sequences to manage complex work sessions. Here are some advanced usage patterns.

Advanced slash command usage patterns
# Pattern 1: Context reset for a new task
/clear
/add-dir ./src/features/new-feature
Implement the UserProfile component following existing patterns

# Pattern 2: Status check before critical operations
/status
/permissions
Execute the refactoring of the payment module

# Pattern 3: Model switch for specific tasks
/model claude-sonnet-4-20250514    # For quick and frequent tasks
Generate boilerplate tests for all services
/model claude-opus-4-20250514      # For complex tasks
Analyze the architecture and propose improvements

# Pattern 4: Debug MCP connections
/mcp
# Verify that the required servers are connected
# before executing tasks that require them

Custom Slash Commands

In addition to built-in commands, Claude Code supports the creation of custom commands through Markdown files in the .claude/commands/ directory. Each .md file becomes a slash command that can be invoked in the session.

.claude/commands/review.md - Custom command for code review
# Complete Code Review

Perform a thorough code review of the modified files.

## Checklist
1. Verify the logical correctness of the code
2. Check naming conventions and consistency
3. Identify potential bugs or edge cases
4. Verify error handling
5. Check test coverage
6. Evaluate performance and scalability

## Output
Produce a structured report with:
- **Severity**: Critical / Major / Minor / Suggestion
- **File and line**: Precise reference
- **Issue**: Clear description
- **Solution**: Proposed fix with code
.claude/commands/deploy-check.md - Pre-deploy verification
# Pre-Deploy Verification

Before proceeding with the deploy, check:

1. Run `npm run build` and verify there are no errors
2. Run `npm test` and verify all tests pass
3. Check that no console.log statements remain in the code
4. Verify that environment variables are configured
5. Check that the .env.production file is up to date
6. Verify the version in package.json

Report the status of each point with a checkmark.

Once created, custom commands are invoked with /review or /deploy-check directly in the Claude Code prompt.

4. Configuration Hierarchy

Claude Code uses a four-level hierarchical configuration system, where each level can override the settings of the level below it. This architecture allows for granular configurations ranging from corporate policies down to the personal preferences of individual developers.

Configuration Hierarchy (from highest to lowest)

LevelFile PathScopePriority
Enterprise /etc/claude-code/managed-settings.json Entire organization Highest (cannot be overridden)
Project Local .claude/settings.local.json Individual developer in the project High
Project Shared .claude/settings.json All developers on the project Medium
User Global ~/.claude/settings.json All of the user's projects Base

Level 1: Enterprise (Highest Priority)

The Enterprise configuration is managed by the system administrator and is located at /etc/claude-code/managed-settings.json. Settings defined at this level cannot be overridden by any other level. It is the ideal mechanism for enforcing corporate security policies.

/etc/claude-code/managed-settings.json - Enterprise Configuration
{
  "permissions": {
    "deny": [
      "Bash(rm -rf /*)",
      "Bash(sudo *)",
      "Bash(chmod 777 *)",
      "Write(~/.ssh/*)",
      "Write(~/.aws/*)"
    ]
  },
  "security": {
    "max_file_size_bytes": 10485760,
    "blocked_domains": ["*.internal.company.com"],
    "require_approval_for_network": true
  },
  "model": {
    "default": "claude-sonnet-4-20250514",
    "allowed": ["claude-sonnet-4-20250514", "claude-opus-4-20250514"]
  }
}

Level 2: Project Local (settings.local.json)

The .claude/settings.local.json file is specific to the individual developer in the context of a project. This file should not be committed to the repository (it should be added to .gitignore) because it contains personal preferences.

.claude/settings.local.json - Personal project preferences
{
  "permissions": {
    "allow": [
      "Bash(npm run test:watch)",
      "Bash(npm run dev)",
      "Bash(docker compose up -d)"
    ]
  },
  "preferences": {
    "model": "claude-opus-4-20250514",
    "theme": "dark",
    "auto_approve_reads": true
  }
}

Level 3: Project Shared (settings.json)

The .claude/settings.json file is committed to the repository and shares the project's configurations with the entire team. This is where the rules and permissions that all developers must follow go.

.claude/settings.json - Shared project configuration
{
  "permissions": {
    "allow": [
      "Bash(npm run *)",
      "Bash(mvn *)",
      "Bash(gradle *)",
      "Bash(git status)",
      "Bash(git diff *)",
      "Bash(git log *)",
      "Read(*)",
      "Write(src/**/*)"
    ],
    "deny": [
      "Bash(git push --force *)",
      "Bash(git reset --hard *)",
      "Bash(rm -rf *)",
      "Write(.env*)",
      "Write(**/credentials*)",
      "Write(**/secrets*)"
    ]
  },
  "context": {
    "include_patterns": ["src/**/*.ts", "src/**/*.html", "src/**/*.css"],
    "exclude_patterns": ["node_modules/**", "dist/**", ".angular/**"]
  }
}

Level 4: User Global

The ~/.claude/settings.json file in the user's home directory contains global preferences that apply to all projects. It is the level with the lowest priority and is overridden by any project configuration.

~/.claude/settings.json - User global preferences
{
  "permissions": {
    "allow": [
      "Bash(ls *)",
      "Bash(cat *)",
      "Bash(which *)",
      "Bash(node --version)",
      "Read(*)"
    ]
  },
  "preferences": {
    "model": "claude-sonnet-4-20250514",
    "auto_approve_reads": true,
    "verbose_output": false,
    "language": "it"
  }
}

Conflict Resolution

When the same setting is defined at multiple levels, the level with the higher priority prevails. In the case of lists (such as allow and deny), deny entries from higher levels always prevail over allow entries from lower levels. This ensures that corporate security policies cannot be bypassed.

5. Permission Templates for Security

Permissions control which actions Claude Code can perform without asking for confirmation. Correct permission configuration balances productivity and security. Here are two ready-to-use templates for common scenarios.

Template 1: Basic Security (Standard Development)

This template is ideal for everyday development on projects where you want Claude to have autonomy over common development commands, but with protection on sensitive files and destructive operations.

Basic Security Template - .claude/settings.json
{
  "permissions": {
    "allow": [
      "Bash(npm run *)",
      "Bash(npm test *)",
      "Bash(npm install *)",
      "Bash(npx *)",
      "Bash(git status)",
      "Bash(git diff *)",
      "Bash(git log *)",
      "Bash(git branch *)",
      "Bash(git checkout *)",
      "Bash(git add *)",
      "Bash(git commit *)",
      "Bash(tsc *)",
      "Bash(ng *)",
      "Bash(mvn *)",
      "Bash(gradle *)",
      "Bash(python -m pytest *)",
      "Bash(docker compose *)",
      "Bash(curl *)",
      "Read(*)",
      "Write(src/**/*)",
      "Write(tests/**/*)",
      "Write(docs/**/*)"
    ],
    "deny": [
      "Write(.env*)",
      "Write(**/*.pem)",
      "Write(**/*.key)",
      "Write(**/credentials*)",
      "Write(**/secrets*)",
      "Write(~/.ssh/*)",
      "Write(~/.aws/*)",
      "Bash(rm -rf *)",
      "Bash(sudo *)",
      "Bash(chmod 777 *)",
      "Bash(git push --force *)",
      "Bash(git reset --hard *)"
    ]
  }
}

Template 2: Strict Security (Critical Environments)

This template requires explicit approval for all write operations and denies any network access. It is ideal for environments with sensitive data, strict compliance, or production projects.

Strict Security Template - .claude/settings.json
{
  "permissions": {
    "allow": [
      "Read(src/**/*)",
      "Read(tests/**/*)",
      "Read(docs/**/*)",
      "Bash(git status)",
      "Bash(git diff *)",
      "Bash(git log *)"
    ],
    "deny": [
      "Write(*)",
      "Bash(npm install *)",
      "Bash(npx *)",
      "Bash(curl *)",
      "Bash(wget *)",
      "Bash(ssh *)",
      "Bash(scp *)",
      "Bash(nc *)",
      "Bash(git push *)",
      "Bash(git commit *)",
      "Bash(docker *)",
      "Bash(sudo *)",
      "Bash(rm *)",
      "Bash(mv *)",
      "Bash(cp *)"
    ]
  },
  "security": {
    "require_approval_for_all_writes": true,
    "require_approval_for_network": true,
    "audit_log": true,
    "max_file_modifications_per_session": 10
  }
}

Template Comparison

AspectBasic SecurityStrict Security
File reading Automatic on all files Automatic only on src/tests/docs
File writing Automatic on src, test, docs Requires approval for every file
Build commands Automatic (npm, mvn, gradle) Denied - read only
Git commands Read + commit/checkout Read only (status, diff, log)
Network access curl allowed, no ssh/scp Completely denied
Sensitive files Blocked (.env, .pem, .key) Blocked (all files for writing)
Ideal use Everyday development Audit, compliance, production

6. Headless Mode

Headless mode allows running Claude Code in a non-interactive way, ideal for integration into CI/CD pipelines, automation scripts, and batch processes. In this mode, Claude receives a prompt, executes it, and returns the result in structured JSON format.

Basic Syntax

Headless execution from the terminal
# Basic syntax
claude --print "Analyze the code in src/ and report issues" --output-format json

# With iteration limit
claude --print "Run tests and fix failures" \
  --output-format json \
  --max-iterations 10

# With specific model
claude --print "Generate API documentation" \
  --output-format json \
  --model claude-sonnet-4-20250514

# With explicit permissions
claude --print "Format all TypeScript files" \
  --output-format json \
  --allowedTools "Bash(npx prettier --write src/**/*.ts)" \
  --allowedTools "Read(*)"

Main Headless Mode Flags

Headless Mode Flags

FlagDescriptionDefault Value
--print The prompt to execute in non-interactive mode Required
--output-format Output format (json, text, stream-json) text
--max-iterations Maximum number of iterations (tool use cycles) Unlimited
--model AI model to use From configuration
--allowedTools Tools allowed for execution (repeatable) From configuration
--verbose Detailed output with debug logs false

GitHub Actions Integration

A powerful use case for headless mode is integration with CI/CD pipelines. Here is a complete example of a GitHub Actions workflow that uses Claude Code for automatic code review on every Pull Request.

.github/workflows/claude-review.yml
name: Claude Code Review

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install Claude Code
        run: npm install -g @anthropic-ai/claude-code

      - name: Run Code Review
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
        run: |
          DIFF=$(git diff origin/main...HEAD)
          claude --print "Analyze the following diff and provide a code review:
          $DIFF

          Output format:
          - Severity: Critical/Major/Minor
          - File and line
          - Issue
          - Proposed solution" \
            --output-format json \
            --max-iterations 5 > review.json

      - name: Post Review Comment
        uses: actions/github-script@v7
        with:
          script: |
            const fs = require('fs');
            const review = JSON.parse(fs.readFileSync('review.json', 'utf8'));
            await github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              body: review.result
            });

Local Automation Script

scripts/auto-fix.sh - Automatic fix script
#!/bin/bash
# Script for automatic lint error fixing

echo "=== Claude Code Auto-Fix ==="
echo "Analyzing lint errors..."

# Run lint and capture errors
LINT_OUTPUT=$(npm run lint 2>&1 || true)

if [ -z "$LINT_OUTPUT" ]; then
  echo "No errors found!"
  exit 0
fi

echo "Errors found. Starting Claude Code for correction..."

claude --print "Fix the following lint errors:
$LINT_OUTPUT

Rules:
- Fix only the reported errors
- Do not modify the code logic
- Maintain the existing style" \
  --output-format json \
  --max-iterations 15 \
  --allowedTools "Read(src/**/*)" \
  --allowedTools "Write(src/**/*)" \
  --allowedTools "Bash(npm run lint)"

echo "Fix completed. Final verification..."
npm run lint

7. Common Errors and Troubleshooting

Even with correct configuration, it is possible to encounter errors while using Claude Code. Here are the most common problems and their solutions.

Common Problems and Solutions

ProblemCauseSolution
Command not found: claude Binary not in PATH Check npm list -g and add the global npm path to PATH
Authentication failed Invalid or expired API key Re-run claude for the login flow or verify the ANTHROPIC_API_KEY variable
Permission denied Action blocked by configuration Check /permissions and add the necessary rule in settings
Context too large Too many files in context Use /clear and reload only the necessary files with @
Rate limit exceeded Too many requests in a short time Wait a few minutes, consider upgrading the plan
ENOENT .claude/settings.json Missing configuration file Create the .claude/ directory and the settings.json file with content {}
Model not available Model not included in the plan Use /model to switch to a model available in the current plan
WSL network error DNS not configured in WSL Configure /etc/resolv.conf with nameserver 8.8.8.8 in WSL

Advanced Debugging

Diagnostic commands
# Check the installed version
claude --version

# Check authentication status
claude --print-auth-status

# Start in verbose debug mode
claude --verbose

# Check the active configuration
claude --print "Show the active configuration" --output-format json

# Complete configuration reset
rm -rf ~/.claude/settings.json
claude  # Recreates the default configuration

# Verify API connectivity
curl -s https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2024-01-01" \
  -H "content-type: application/json" \
  -d '{"model":"claude-sonnet-4-20250514","max_tokens":10,"messages":[{"role":"user","content":"test"}]}'

8. Daily Workflow with the CLI

The true power of the Claude Code CLI emerges when you integrate it into your daily development workflow. Here is a typical day for a developer who uses Claude Code as a constant work companion.

Morning Routine

Starting the day with Claude Code
# 1. Enter the project directory
cd ~/projects/my-app

# 2. Launch Claude Code
claude

# 3. Check the repository status
> !git status
> !git log --oneline -5

# 4. Load the context for the current task
> @src/features/user-profile/
> I'm working on the user-profile feature.
> What has been done so far and what remains to be implemented?

# 5. Activate Plan Mode for the first task
> [Shift+Tab+Tab] Implement the profile form validation

Development Flow

Typical development cycle
# Feature implementation
> Implement the EditProfile component with a reactive form
> Use Angular validators for email, phone, and name
> Follow existing patterns in src/features/auth/

# Testing
> Generate unit tests for EditProfileComponent
> Cover the cases: valid form, invalid email, submit and cancel

# Code review
> /review   # Use the custom command created earlier

# Commit
> !git add -A
> !git commit -m "feat(user-profile): add edit profile form with validation"

# Move to the next task
> /clear
> @src/features/notifications/
> Implement the push notification system

Productivity Patterns

Best Practices for Daily Use

  • Use /clear between different tasks: Keeps the context clean and responses accurate
  • Mention specific files with @: Reduces noise in the context and improves quality
  • Plan Mode for complex tasks: Avoids surprises on multi-file operations
  • YOLO Mode for boilerplate: Speeds up generation of repetitive files
  • Custom commands for recurring tasks: Standardizes review, deploy check, test
  • Bash mode (!) for quick commands: No need to leave Claude for a git status
  • Rewind (Esc+Esc) when needed: Don't hesitate to go back if the direction is wrong
  • Check /status periodically: Monitor token usage to avoid limits

9. Advanced Configuration

Beyond the basic templates, Claude Code offers advanced configuration options for specific scenarios such as monorepos, distributed teams, and multi-project environments.

Monorepo Configuration

In a monorepo with multiple packages, the configuration must handle different contexts for each sub-project while maintaining common rules.

.claude/settings.json for monorepo
{
  "permissions": {
    "allow": [
      "Read(*)",
      "Write(packages/*/src/**/*)",
      "Write(packages/*/tests/**/*)",
      "Bash(npm run -w packages/* *)",
      "Bash(npx turbo run *)",
      "Bash(git *)"
    ],
    "deny": [
      "Write(packages/*/node_modules/**)",
      "Write(packages/*/.env*)",
      "Bash(rm -rf *)",
      "Bash(sudo *)"
    ]
  },
  "context": {
    "include_patterns": [
      "packages/*/src/**/*.ts",
      "packages/*/package.json",
      "turbo.json",
      "package.json"
    ],
    "exclude_patterns": [
      "**/node_modules/**",
      "**/dist/**",
      "**/.turbo/**"
    ]
  }
}

Environment Variables for Configuration

Supported Environment Variables

VariableDescriptionExample
ANTHROPIC_API_KEY API key for authentication sk-ant-api03-xxxxx
CLAUDE_CODE_MODEL Default model claude-sonnet-4-20250514
CLAUDE_CODE_MAX_TOKENS Token limit per response 16384
CLAUDE_CODE_CONFIG_DIR Custom configuration directory /custom/path/.claude
CLAUDE_CODE_VERBOSE Enables verbose output true

Conclusion

Claude Code CLI is much more than a simple wrapper around an AI model. It is a complete conversational development environment that integrates into the terminal and transforms the way we interact with code. The combination of keyboard shortcuts, slash commands, hierarchical configuration, and headless mode creates a flexible ecosystem that adapts to any workflow and security level.

Key Takeaways

  • Flexible installation: npm, curl, Homebrew, or WSL - choose the method best suited to your environment
  • Essential shortcuts: ! for Bash, @ for files, Esc+Esc for rewind, Shift+Tab for YOLO
  • Slash commands for control: /clear, /model, /status, /permissions to manage the session
  • 4-level hierarchy: Enterprise > Project Local > Project Shared > User Global
  • Permission templates: Basic Security for development, Strict Security for production
  • Headless mode: CI/CD automation with structured JSON output
  • Custom commands: Create your own slash commands to standardize the team's workflow

In the next article we will explore Agent Skills: modular capabilities that extend Claude Code's functionality with specialized competencies for documents, data analysis, web development, and much more. We will discover how to create custom skills and integrate them into the daily workflow.

Try These Tools

Free developer tools related to this topic.

Commenti

Caricamento commenti...

Sign in to comment

Discuss this article in the community

Join the Telegram group to discuss with other developers, ask questions and share your experiences.

Did you like this article?

Explore other content on the blog or discover my projects