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
Native Installer (Recommended)
For macOS, Linux, and WSL:
curl -fsSL https://claude.ai/install.sh | bashHomebrew (macOS)
brew install --cask claude-codeNPM
Requires Node.js 18+:
npm install -g @anthropic-ai/claude-codeBasic Usage
Start Claude Code in any project directory:
claudeAuthentication
The assistant will need to be authenticated within the REPL to work with your project.
/loginCommands & Shortcuts
Built-in Commands
| Command | Description |
|---|---|
/help | List all available commands |
/init | Initialize project with CLAUDE.md |
/login | Authenticate with Anthropic |
/logout | Sign out of current session |
/clear | Reset conversation history |
/compact | Compress conversation context |
/config | Open configuration panel |
/context | Visualize current context usage |
/cost | Show token usage for session |
/doctor | Check installation health |
/memory | Edit CLAUDE.md files |
/permissions | Manage tool permissions |
/mcp | Manage MCP server connections |
/ide | Manage IDE integrations |
/review | Start interactive code review |
/vim | Toggle vim mode for input |
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Escape | Interrupt current generation |
Ctrl+C | Cancel current operation |
Up/Down | Navigate 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-namedescription: 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
| Option | Value | Effect |
|---|---|---|
name | string | Skill identifier |
description | string | Used for contextual auto-discovery |
user-invocable | boolean | Shows in / menu when true |
disable-model-invocation | boolean | Prevents automatic invocation when true |
allowed-tools | list | Restricts available tools |
model | string | Specifies model (e.g., claude-3-5-haiku-20241022) |
argument-hint | string | Shows argument placeholder (e.g., [message]) |
Skill Invocation Methods
Skills can be invoked in three ways:
- Manual: User types
/skill-name - Programmatic: Claude calls it via the
Skilltool - 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: commitdescription: Smart git commit with conventional commits format, diff analysisuser-invocable: trueallowed-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 changes2. If no staged changes, exit with a message3. 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 improvements4. 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 changes7. Create the commit (never include AI attribution lines)
## Commit Message Formattype(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
| Event | When it Runs | Can Block |
|---|---|---|
PreToolUse | Before tool execution | Yes |
PostToolUse | After tool completion | No |
UserPromptSubmit | When user submits prompt | Yes |
Stop | When agent finishes | No |
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 normally2: 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
| Location | Scope | Version Control |
|---|---|---|
.mcp.json | Project | Yes (shared) |
.claude/settings.local.json | Project | No (gitignored) |
~/.claude/settings.json | User | No |
Adding MCP Servers
Via CLI:
claude mcp add <name> <command> [args...]claude mcp add github npx -y @modelcontextprotocol/server-githubVia 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"] } }}Recommended Servers
| Server | Purpose |
|---|---|
@modelcontextprotocol/server-github | GitHub integration |
@modelcontextprotocol/server-filesystem | Enhanced file operations |
@upstash/context7-mcp | Up-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
| Category | Examples | Default |
|---|---|---|
| Read-only | Read, Grep, Glob | Allowed |
| Write operations | Edit, Write | Ask |
| Shell commands | Bash | Ask |
| Network | WebFetch, MCP tools | Ask |
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
- Review CLAUDE.md files - Ensure no sensitive data in project memory files
- Use hooks for validation - Block dangerous operations programmatically
- Restrict shell access - Limit Bash permissions in production-adjacent environments
- Audit MCP servers - Only use trusted external integrations
- 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):
- CLI flags (runtime)
- Environment variables
.claude/settings.local.json(project, gitignored).claude/settings.json(project, committed)~/.claude/settings.json(user, global)
Key Configuration Options
{ "model": "claude-sonnet-4-20250514", "permissions": { "allow": [], "deny": [] }, "hooks": {}, "mcpServers": {}}Environment Variables
| Variable | Purpose |
|---|---|
ANTHROPIC_API_KEY | API authentication |
CLAUDE_MODEL | Default model selection |
Access Settings
/config- Open configuration panel in REPLclaude 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:
## 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 middlewareExample Workflow: Code Review Preparation
Create a custom workflow for preparing code for team review:
# 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 needsAutomated 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:
# Single prompt executionclaude -p "Analyze the codebase and list potential security issues"
# With specific permission modeclaude --permission-mode acceptEdits -p "Fix all TypeScript errors"
# Output as JSONclaude -p "List all TODO comments" --output-format jsonUse 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