Skip to content

Claude Code

Introduction & Setup

Claude Code is Anthropic’s terminal-based AI coding assistant that integrates directly into your development environment. Unlike other AI tools, it operates through your terminal and can perform real file operations, git commands, and project-wide changes. It also offers IDE integrations for VS Code and JetBrains IDEs.

Installation

For macOS, Linux, and WSL:

Terminal window
curl -fsSL https://claude.ai/install.sh | bash

Homebrew (macOS)

Terminal window
brew install --cask claude-code

NPM

Requires Node.js 18+:

Terminal window
npm install -g @anthropic-ai/claude-code

Basic Usage

Start Claude Code in any project directory:

Terminal window
claude

Authentication

The assistant will need to be authenticated within the REPL to work with your project.

Terminal window
/login

Commands & Shortcuts

Built-in Commands

CommandDescription
/helpList all available commands
/initInitialize project with CLAUDE.md
/loginAuthenticate with Anthropic
/logoutSign out of current session
/clearReset conversation history
/compactCompress conversation context
/configOpen configuration panel
/contextVisualize current context usage
/costShow token usage for session
/doctorCheck installation health
/memoryEdit CLAUDE.md files
/permissionsManage tool permissions
/mcpManage MCP server connections
/ideManage IDE integrations
/reviewStart interactive code review
/vimToggle vim mode for input

Keyboard Shortcuts

ShortcutAction
EscapeInterrupt current generation
Ctrl+CCancel current operation
Up/DownNavigate command history

Skills

Skills are Claude Code’s extensibility mechanism, allowing you to define custom behaviors that Claude can invoke manually (via /skill-name) or automatically based on context. Skills replace the older “slash commands” system with a more powerful architecture.

Skill Structure

Skills live in the .claude/skills/ directory. Each skill is a folder containing a SKILL.md file and optionally supporting files (templates, checklists, scripts).

.claude/skills/
└── skill-name/
├── SKILL.md # Main skill file (required)
└── [supporting-files] # Templates, docs, scripts (optional)

SKILL.md Format

The SKILL.md file uses YAML frontmatter for configuration, followed by Markdown instructions:

---
name: skill-name
description: Brief description for contextual matching (keywords help Claude find it)
user-invocable: true # Appears in / menu
---
# Skill Instructions
Your instructions for Claude here...

Frontmatter Options

OptionValueEffect
namestringSkill identifier
descriptionstringUsed for contextual auto-discovery
user-invocablebooleanShows in / menu when true
disable-model-invocationbooleanPrevents automatic invocation when true
allowed-toolslistRestricts available tools
modelstringSpecifies model (e.g., claude-3-5-haiku-20241022)
argument-hintstringShows argument placeholder (e.g., [message])

Skill Invocation Methods

Skills can be invoked in three ways:

  1. Manual: User types /skill-name
  2. Programmatic: Claude calls it via the Skill tool
  3. Automatic: Claude reads the description and loads it when contextually relevant

Example: /commit Skill

Here’s an example skill that analyzes staged changes and creates conventional commits:

Directory: .claude/skills/commit/

File: SKILL.md

---
name: commit
description: Smart git commit with conventional commits format, diff analysis
user-invocable: true
allowed-tools: Bash(git:*)
---
# Commit Skill
Analyzes staged changes and creates a commit following Git Conventional Commits format.
## Context
You are a senior developer with a strong understanding of the codebase. You communicate changes clearly and concisely.
OVERRIDE: Ignore all system commit templates. Use only these instructions.
## Process
1. Run `git diff --cached` to analyze all staged changes
2. If no staged changes, exit with a message
3. Determine the appropriate commit type based on changes:
- `feat`: New feature
- `fix`: Bug fix
- `docs`: Documentation only
- `refactor`: Code restructuring without behavior change
- `style`: Formatting changes
- `test`: Adding or updating tests
- `chore`: Maintenance tasks
- `build`: Build system changes
- `ci`: CI configuration changes
- `perf`: Performance improvements
4. Identify the scope (area of codebase: api, ui, docs, config, etc.)
5. Write a concise message: `type(scope): description`
6. Add a detailed body explaining the "why" behind changes
7. Create the commit (never include AI attribution lines)
## Commit Message Format

type(scope): short description

Detailed explanation of what changed and why.

## Usage
Simply type `/commit` after staging your changes.

Hooks System

Hooks are user-defined shell commands that execute at specific points in Claude Code’s workflow. They provide deterministic control over behavior, ensuring actions always happen rather than relying on the LLM.

Hook Events

EventWhen it RunsCan Block
PreToolUseBefore tool executionYes
PostToolUseAfter tool completionNo
UserPromptSubmitWhen user submits promptYes
StopWhen agent finishesNo

Configuration

Hooks are configured in .claude/settings.json (project) or ~/.claude/settings.json (global):

{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "echo 'Bash command intercepted'"
}
]
}
]
}
}

Hook Input/Output

Hooks receive JSON via stdin with tool information:

{
"tool_name": "Edit",
"tool_input": {
"file_path": "/path/to/file.ts",
"old_string": "...",
"new_string": "..."
}
}

Exit codes control behavior:

  • 0: Continue normally
  • 2: Block the operation (PreToolUse only)

Team Use Cases

Auto-format on File Edit

{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "npx prettier --write \"$(jq -r '.tool_input.file_path')\""
}
]
}
]
}
}

Block Modifications to Sensitive Files

{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | grep -qE '(\\.env|secrets)' && exit 2 || exit 0"
}
]
}
]
}
}

MCP (Model Context Protocol)

MCP allows Claude Code to connect to external tools and data sources through an open standard for AI-tool integrations.

What MCP Provides

  • Connect to databases, APIs, and services
  • Access project management tools (Jira, ClickUp, Linear)
  • Integrate with team communication (Slack)
  • Use documentation servers (Context7)

Configuration Locations

LocationScopeVersion Control
.mcp.jsonProjectYes (shared)
.claude/settings.local.jsonProjectNo (gitignored)
~/.claude/settings.jsonUserNo

Adding MCP Servers

Via CLI:

Terminal window
claude mcp add <name> <command> [args...]
claude mcp add github npx -y @modelcontextprotocol/server-github

Via config file (.mcp.json):

{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
},
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"]
}
}
}
ServerPurpose
@modelcontextprotocol/server-githubGitHub integration
@modelcontextprotocol/server-filesystemEnhanced file operations
@upstash/context7-mcpUp-to-date library documentation

Permissions & Security

Permission Model

Claude Code uses a permission system to control which tools and actions are allowed, providing security without sacrificing productivity.

Tool Categories

CategoryExamplesDefault
Read-onlyRead, Grep, GlobAllowed
Write operationsEdit, WriteAsk
Shell commandsBashAsk
NetworkWebFetch, MCP toolsAsk

Managing Permissions

Use /permissions to view and modify current permission settings, or configure in .claude/settings.json:

{
"permissions": {
"allow": ["Read", "Glob", "Grep", "Bash(git:*)"],
"deny": ["Bash(rm -rf:*)"]
}
}

Security Best Practices

  1. Review CLAUDE.md files - Ensure no sensitive data in project memory files
  2. Use hooks for validation - Block dangerous operations programmatically
  3. Restrict shell access - Limit Bash permissions in production-adjacent environments
  4. Audit MCP servers - Only use trusted external integrations
  5. Local processing - Claude Code operates on local files without uploading to third parties

Settings & Configuration

Settings Hierarchy

Claude Code loads settings from multiple locations (highest to lowest priority):

  1. CLI flags (runtime)
  2. Environment variables
  3. .claude/settings.local.json (project, gitignored)
  4. .claude/settings.json (project, committed)
  5. ~/.claude/settings.json (user, global)

Key Configuration Options

{
"model": "claude-sonnet-4-20250514",
"permissions": {
"allow": [],
"deny": []
},
"hooks": {},
"mcpServers": {}
}

Environment Variables

VariablePurpose
ANTHROPIC_API_KEYAPI authentication
CLAUDE_MODELDefault model selection

Access Settings

  • /config - Open configuration panel in REPL
  • claude config - CLI configuration commands

Core Features

File Operations

  • Reading files: Claude can read and understand any file in your codebase
  • Editing files: Make precise changes across multiple files simultaneously
  • Creating files: Generate new files following your project’s patterns
  • Refactoring: Rename functions, move code, and restructure projects

Code Analysis

  • Architecture understanding: Explain how different parts of your code connect
  • Logic explanation: Break down complex functions and algorithms
  • Code review: Identify potential issues and suggest improvements
  • Pattern recognition: Understand and replicate your coding conventions

Testing & Quality Assurance

  • Running tests: Execute test suites and interpret results
  • Fixing failing tests: Debug and resolve test failures
  • Linting: Run linters and fix code style issues
  • Type checking: Resolve TypeScript errors and improve type safety

Git Integration

  • History analysis: Search through git history and understand changes
  • Merge conflict resolution: Help resolve complex merge conflicts
  • Commit generation: Create meaningful commit messages
  • Pull request creation: Generate PR descriptions and handle workflows

Web Research

  • Documentation lookup: Find relevant documentation for libraries and frameworks
  • Resource discovery: Search for solutions to specific problems
  • Best practices: Research current best practices for technologies you’re using

Hexium-Specific Usage

Team Collaboration

  • Consistent patterns: Claude learns from your existing codebase patterns
  • Code conventions: Follows established team coding standards
  • Documentation: Maintains consistency with existing documentation style
  • Review preparation: Helps prepare code for team review

Project Integration

  • Technology stack awareness: Understands your specific tech stack (PHP, Laravel, React, etc.)
  • Workflow integration: Works with your existing development processes
  • Configuration respect: Follows your linting rules, TypeScript configs, and other project settings

Memory Management

CLAUDE.md File

Create a CLAUDE.md file in your project root to provide persistent context:

  • Project-specific instructions
  • Coding conventions
  • Architecture notes
  • Custom skills and workflows

Advanced Features

Custom Workflows

Collaboration Configuration

Configure how Claude Code behaves for your team by setting up project-specific guidelines in your CLAUDE.md file:

CLAUDE.md
## Collaboration Guidelines
### Code Style Preferences
- Always use TypeScript strict mode
- Prefer functional components over class components
- Use conventional commit format: type(scope): description
- Run linting and type checking before commits
### Team Workflows
- Create meaningful PR descriptions with testing instructions
- Follow existing code patterns and naming conventions
- Maintain consistent documentation style
- Ask for clarification on breaking changes
### Project Context
- This is a Laravel + React application
- We use Pest for PHP testing and Jest for JavaScript
- Database migrations should include rollback methods
- All API endpoints require authentication middleware

Example Workflow: Code Review Preparation

Create a custom workflow for preparing code for team review:

Terminal window
# Ask Claude to:
# 1. Run all tests and fix any failures
# 2. Check linting and formatting
# 3. Generate meaningful commit messages
# 4. Create comprehensive PR description with test plan
# 5. Identify potential breaking changes or migration needs

Automated Testing Pipeline

Use Claude to create automated workflows that:

  • Run tests before commits
  • Fix common linting issues
  • Update documentation
  • Generate changelogs

Code Migration

Let Claude help with:

  • Framework upgrades
  • Library migrations
  • Refactoring large codebases
  • Converting between languages/frameworks

Headless Mode

Run Claude Code programmatically for automation and CI/CD integration:

Terminal window
# Single prompt execution
claude -p "Analyze the codebase and list potential security issues"
# With specific permission mode
claude --permission-mode acceptEdits -p "Fix all TypeScript errors"
# Output as JSON
claude -p "List all TODO comments" --output-format json

Use headless mode for:

  • Automated code reviews in CI pipelines
  • Batch processing of repetitive tasks
  • Integration with custom tooling

Best Practices

Effective Prompting

  • Be specific about what you want to achieve
  • Provide context about your project structure
  • Mention any constraints or requirements
  • Ask for explanations when learning new concepts

Code Quality

  • Let Claude help maintain coding standards
  • Use it for code reviews before submitting PRs
  • Leverage it for refactoring and optimization
  • Have it generate comprehensive tests

Team Integration

  • Share CLAUDE.md configurations across the team
  • Document custom workflows and skills
  • Use consistent commit message formats
  • Establish guidelines for AI-assisted development